/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --green-500: #22c55e;
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-700: #15803d;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --card-bg: #ffffff;
    --body-bg: #f9fafb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
}

body {
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--gray-900);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Page Sections ── */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Navigation Bar ── */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    height: 64px;
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--gray-900);
    text-decoration: none;
    letter-spacing: -0.3px;
}

.navbar-brand .header-icon {
    width: 32px;
    height: 32px;
    font-size: 15px;
    border-radius: 8px;
}

.navbar-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
}

.navbar-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    text-decoration: none;
    color: var(--gray-500);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 8px 14px;
    border-radius: var(--radius-xs);
    transition: all 0.15s ease;
}

.nav-link:hover {
    color: var(--gray-900);
    background: var(--gray-100);
}

.nav-link.active {
    color: var(--green-500);
    background: var(--green-50);
}

.navbar-auth {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-signin {
    background-color: var(--gray-900);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-xs);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s ease;
}

.btn-signin:hover {
    background-color: #1e293b;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.nav-user .username {
    font-weight: 600;
    color: var(--gray-900);
}

.level-badge {
    background: var(--green-50);
    color: var(--green-700);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--green-100);
}

.btn-ghost {
    background: none;
    border: 1px solid var(--gray-200);
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    color: var(--gray-500);
    transition: all 0.15s;
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* ── Page Wrapper ── */
.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

/* ── Header ── */
.header {
    margin-bottom: 24px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
}

.header-icon {
    width: 44px;
    height: 44px;
    background: var(--green-500);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.header h1 {
    font-family: 'Fraunces', serif;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--gray-900);
}

.header-sub {
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 18px 20px;
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--gray-400);
    font-weight: 500;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.stat-card-label svg {
    opacity: 0.5;
}

.stat-card-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card-value.green {
    color: var(--green-500);
}

.stat-card-value.orange {
    color: #f97316;
}

.stat-card-value.dark {
    color: var(--gray-900);
}

.stat-card-sub {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ── Bottom Grid ── */
.bottom-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 18px;
    align-items: start;
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 26px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.card-subtitle {
    font-size: 0.82rem;
    color: var(--gray-400);
    margin-bottom: 20px;
}

/* ── Inputs ── */
.input-group {
    margin-bottom: 14px;
}

.input-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.input-label svg {
    color: var(--gray-500);
}

.input-field {
    width: 100%;
    padding: 10px 13px;
    background: var(--gray-100);
    border: 1.5px solid transparent;
    border-radius: var(--radius-xs);
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--gray-700);
    outline: none;
    transition: all 0.15s;
}

.input-field::placeholder {
    color: var(--gray-400);
}

.input-field:focus {
    border-color: var(--green-500);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.transport-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
    display: block;
}

/* ── Mode Grid ── */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 6px;
    background: var(--gray-100);
    border: 1.5px solid transparent;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.mode-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.mode-btn.active {
    background: var(--green-50);
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.mode-emoji {
    font-size: 1.2rem;
    line-height: 1;
}

.mode-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gray-500);
}

.mode-btn.active .mode-name {
    color: var(--green-700);
}

/* ── Add Button ── */
.btn-add {
    width: 100%;
    padding: 12px;
    background: var(--gray-900);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    transition: background 0.15s, transform 0.1s;
}

.btn-add:hover {
    background: #1e293b;
}

.btn-add:active {
    transform: scale(0.98);
}

.btn-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Comparison Card ── */
.comparison-card {
    margin-top: 18px;
    padding: 18px;
    background: var(--green-50);
    border: 1px solid var(--green-100);
    border-radius: var(--radius-sm);
    display: none;
}

.comparison-card.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.comparison-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--green-700);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.comparison-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}

.comparison-item {
    text-align: center;
}

.comp-label {
    display: block;
    font-size: 0.72rem;
    color: var(--gray-500);
    margin-bottom: 2px;
}

.comp-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--green-500);
}

.comp-car {
    color: var(--gray-400);
}

.comparison-vs {
    color: var(--gray-400);
    font-size: 0.8rem;
    font-weight: 600;
}

.comparison-savings {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.saving-badge {
    background: var(--card-bg);
    border: 1px solid var(--green-100);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* ── Ecosystem Panel ── */
.tree-panel {
    min-height: 520px;
    display: flex;
    flex-direction: column;
}

.tree-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.tree-panel-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.tree-panel-sub {
    font-size: 0.82rem;
    color: var(--gray-400);
    margin-bottom: 18px;
}

.eco-scene-container {
    width: 100%;
    height: 300px;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    margin-bottom: 18px;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    user-select: none;
    box-shadow: inset 0 -30px 60px rgba(0, 0, 0, 0.08);
}

.eco-sky {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 230px;
    background: linear-gradient(180deg, #e2e8f0 0%, #f1f5f9 100%);
    transition: background 1.5s ease;
    z-index: 1;
}

.sun {
    position: absolute;
    top: 22px;
    right: 28px;
    width: 44px;
    height: 44px;
    background: radial-gradient(circle, #fde68a 30%, #fbbf24 100%);
    border-radius: 50%;
    box-shadow: 0 0 30px 8px rgba(251, 191, 36, 0.5), 0 0 60px 20px rgba(251, 191, 36, 0.2);
    opacity: 0;
    transition: all 1.5s ease;
    animation: sunPulse 4s ease-in-out infinite;
}

@keyframes sunPulse {

    0%,
    100% {
        box-shadow: 0 0 30px 8px rgba(251, 191, 36, 0.5), 0 0 60px 20px rgba(251, 191, 36, 0.2);
    }

    50% {
        box-shadow: 0 0 40px 12px rgba(251, 191, 36, 0.6), 0 0 80px 30px rgba(251, 191, 36, 0.25);
    }
}

.cloud {
    position: absolute;
    font-size: 28px;
    opacity: 0;
    transition: opacity 1.5s ease;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
}

.cloud-1 {
    top: 18px;
    left: 12%;
    font-size: 32px;
    animation: cloudDrift1 25s linear infinite;
}

.cloud-2 {
    top: 50px;
    left: 55%;
    font-size: 22px;
    animation: cloudDrift2 35s linear infinite;
}

@keyframes cloudDrift1 {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(120px);
    }
}

@keyframes cloudDrift2 {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100px);
    }
}

.bird {
    position: absolute;
    font-size: 18px;
    opacity: 0;
    transition: all 1.5s ease;
    pointer-events: none;
}

.bird-1 {
    top: 30px;
    left: 20%;
    animation: birdFly1 8s ease-in-out infinite;
}

.bird-2 {
    top: 55px;
    left: 38%;
    font-size: 14px;
    animation: birdFly2 12s ease-in-out infinite;
}

.bird-3 {
    top: 40px;
    left: 65%;
    font-size: 16px;
    opacity: 0;
    animation: birdFly3 10s ease-in-out infinite;
}

@keyframes birdFly1 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(30px, -8px);
    }

    50% {
        transform: translate(60px, 3px);
    }

    75% {
        transform: translate(30px, -5px);
    }
}

@keyframes birdFly2 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    33% {
        transform: translate(-20px, -6px);
    }

    66% {
        transform: translate(-40px, 4px);
    }
}

@keyframes birdFly3 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(25px, -10px);
    }
}

.eco-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75px;
    background: #d6cfc4;
    transition: background 1.5s ease;
    z-index: 2;
}

.river {
    position: absolute;
    bottom: 6px;
    left: -10%;
    right: -10%;
    height: 12px;
    background: linear-gradient(90deg, #60a5fa, #38bdf8, #60a5fa);
    background-size: 200% 100%;
    border-radius: 50%;
    opacity: 0;
    transform: scaleY(0);
    transition: all 1.5s ease;
    animation: riverFlow 3s linear infinite;
}

@keyframes riverFlow {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 200% 50%;
    }
}

.flower-patch {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    z-index: 3;
    pointer-events: none;
}

.flower {
    position: absolute;
    bottom: 18px;
    font-size: 14px;
    animation: flowerSway 3s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes flowerSway {

    0%,
    100% {
        transform: rotate(-3deg);
    }

    50% {
        transform: rotate(3deg);
    }
}

.tree-base {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 230px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 3;
}

.trunk {
    position: absolute;
    bottom: 0;
    width: 22px;
    height: 0;
    background: linear-gradient(90deg, #5c2d0e 0%, #8b5e3c 40%, #7c3f1a 60%, #5c2d0e 100%);
    border-radius: 6px 6px 4px 4px;
    transition: height 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.15);
}

.branch {
    position: absolute;
    background: linear-gradient(90deg, #7c3f1a, #8b5e3c);
    border-radius: 3px;
    transition: all 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    height: 6px;
}

.branch-left {
    top: 25%;
    right: 100%;
    width: 0;
    transform: rotate(-25deg);
    transform-origin: right center;
}

.branch-right {
    top: 45%;
    left: 100%;
    width: 0;
    transform: rotate(20deg);
    transform-origin: left center;
}

.leaves-wrap {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    transition: bottom 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.leaf-circle {
    border-radius: 50%;
    background: var(--green-500);
    transition: all 1s ease;
    position: absolute;
}

.leaf-circle.sway {
    animation: leafSway 4s ease-in-out infinite;
}

@keyframes leafSway {

    0%,
    100% {
        transform: translateX(0) rotate(0);
    }

    25% {
        transform: translateX(-3px) rotate(-1deg);
    }

    75% {
        transform: translateX(3px) rotate(1deg);
    }
}

.animal {
    position: absolute;
    opacity: 0;
    transition: all 1.5s ease;
    z-index: 4;
    pointer-events: none;
}

.deer {
    bottom: 28px;
    right: 12%;
    font-size: 24px;
    animation: animalBob 4s ease-in-out infinite;
}

.rabbit {
    bottom: 25px;
    right: 28%;
    font-size: 18px;
    animation: animalBob 3s ease-in-out infinite 0.5s;
}

.butterfly {
    bottom: 80px;
    left: 22%;
    font-size: 16px;
    animation: butterflyFloat 6s ease-in-out infinite;
}

.frog {
    bottom: 8px;
    left: 42%;
    font-size: 14px;
    animation: animalBob 2.5s ease-in-out infinite 1s;
}

.squirrel {
    bottom: 50px;
    left: 55%;
    font-size: 16px;
    animation: animalBob 3.5s ease-in-out infinite 0.3s;
}

.hedgehog {
    bottom: 22px;
    left: 10%;
    font-size: 16px;
    animation: animalBob 5s ease-in-out infinite 0.7s;
}

@keyframes animalBob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

@keyframes butterflyFloat {

    0%,
    100% {
        transform: translate(0, 0) rotate(0);
    }

    25% {
        transform: translate(15px, -12px) rotate(5deg);
    }

    50% {
        transform: translate(30px, -5px) rotate(-3deg);
    }

    75% {
        transform: translate(15px, -15px) rotate(4deg);
    }
}

.particle-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.leaf-particle {
    position: absolute;
    font-size: 12px;
    opacity: 0;
    animation: leafFall 4s ease-in-out forwards;
}

@keyframes leafFall {
    0% {
        opacity: 0.8;
        transform: translate(0, 0) rotate(0deg);
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 0;
        transform: translate(30px, 200px) rotate(360deg);
    }
}

.eco-bubble {
    position: absolute;
    background: var(--card-bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--gray-700);
    z-index: 10;
    box-shadow: var(--shadow-md);
    max-width: 220px;
    animation: bubbleIn 0.3s ease;
    pointer-events: none;
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.co2-display {
    text-align: center;
    margin-top: auto;
}

.co2-value {
    font-family: 'Fraunces', serif;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--green-500);
    line-height: 1;
}

.co2-label {
    font-size: 0.82rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.milestone-section {
    margin-top: 20px;
    border-top: 1px solid var(--gray-100);
    padding-top: 16px;
}

.milestone-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--gray-700);
    font-weight: 500;
    margin-bottom: 8px;
}

.milestone-row span:last-child {
    font-weight: 700;
}

.progress-bar-bg {
    width: 100%;
    height: 7px;
    background: var(--gray-200);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--green-500);
    border-radius: 999px;
    width: 0%;
    transition: width 0.8s ease;
}

.milestone-to-go {
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ── Journeys List ── */
.journey-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-xs);
    margin-bottom: 8px;
    border: 1px solid var(--gray-100);
    transition: background 0.15s;
}

.journey-item:hover {
    background: var(--green-50);
}

.journey-mode-icon {
    font-size: 1.4rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: 10px;
    flex-shrink: 0;
}

.journey-details {
    flex: 1;
    min-width: 0;
}

.journey-details h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.journey-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.journey-meta span {
    white-space: nowrap;
}

.journey-xp {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--green-500);
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-400);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.9rem;
}

.loading {
    text-align: center;
    padding: 48px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--green-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Pagination ── */
.btn-sm {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: 1px solid var(--gray-200);
    background: var(--card-bg);
    color: var(--gray-500);
    transition: all 0.15s;
}

.btn-sm:hover {
    background: var(--gray-100);
}

.btn-sm.btn-primary {
    background: var(--green-500);
    color: white;
    border-color: var(--green-500);
}

/* ── Leaderboard ── */
.leaderboard-card {
    padding: 0;
    overflow: hidden;
}

.leaderboard-tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.tab-btn {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2.5px solid transparent;
    transition: all 0.15s ease;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--gray-900);
    background: var(--gray-100);
}

.tab-btn.active {
    color: var(--green-500);
    border-bottom-color: var(--green-500);
    background: var(--card-bg);
}

.leaderboard-period {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.period-btn {
    padding: 5px 14px;
    border-radius: 999px;
    border: 1px solid var(--gray-200);
    background: var(--card-bg);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.period-btn:hover {
    background: var(--gray-100);
}

.period-btn.active {
    background: var(--gray-900);
    color: white;
    border-color: var(--gray-900);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table thead th {
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
}

.leaderboard-table tbody td {
    padding: 14px 20px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--gray-100);
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: none;
}

.leaderboard-table tbody tr:hover {
    background: var(--gray-50);
}

.leaderboard-table tbody tr.current-user {
    background: var(--green-50);
}

.leaderboard-table tbody tr.current-user:hover {
    background: #e6fced;
}

.rank-medal {
    font-size: 1.1rem;
}

/* ── Auth Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.show {
    display: flex;
}

.modal-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(12px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-brand {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 8px;
}

.modal-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.88rem;
    margin-bottom: 24px;
}

.auth-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.auth-form {
    display: flex;
    flex-direction: column;
}

.modal-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.modal-footer a {
    color: var(--green-500);
    font-weight: 600;
    text-decoration: none;
}

.modal-footer a:hover {
    text-decoration: underline;
}

/* ── Toasts ── */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--gray-900);
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 340px;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ── Shake animation for tree ── */
.eco-scene-container.shake {
    animation: treeShake 0.5s ease;
}

@keyframes treeShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    50% {
        transform: translateX(3px);
    }

    75% {
        transform: translateX(-2px);
    }
}

/* ── Leaflet Map ── */
.map-container {
    position: relative;
    height: 220px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 14px;
    border: 1px solid var(--gray-200);
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.leaflet-container {
    font-family: 'DM Sans', system-ui !important;
}

.map-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-ctrl-btn {
    width: 32px;
    height: 32px;
    background: var(--card-bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xs);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}

.map-ctrl-btn:hover {
    background: var(--gray-50);
    color: var(--green-500);
}

.route-info-overlay {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 500;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xs);
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--green-700);
    box-shadow: var(--shadow-sm);
}

.route-info-sep {
    color: var(--gray-300);
    margin: 0 6px;
}

/* ── Search Dropdown ── */
.search-input-wrap {
    position: relative;
}

.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xs);
    z-index: 600;
    max-height: 180px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.search-dropdown.show {
    display: block;
}

.search-dropdown-item {
    padding: 10px 13px;
    font-size: 0.82rem;
    color: var(--gray-700);
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.1s;
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover,
.search-dropdown-item:active {
    background: var(--green-50);
}

.input-hint {
    font-weight: 400;
    color: var(--green-500);
    font-size: 0.75rem;
    margin-left: 4px;
}

/* ── Custom Leaflet Markers ── */
.marker-pin {
    width: 24px;
    height: 24px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.marker-pin.origin {
    background: var(--gray-900);
    border: 2px solid #fff;
}

.marker-pin.dest {
    background: var(--green-500);
    border: 2px solid #fff;
}

.marker-pin span {
    transform: rotate(45deg);
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

/* ── Mobile Bottom Nav ── */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--card-bg);
    border-top: 1px solid var(--gray-200);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}

.bnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--gray-400);
    font-family: inherit;
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
    transition: color 0.2s;
}

.bnav-btn.active {
    color: var(--green-500);
}

.bnav-btn svg {
    transition: all 0.2s;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .mobile-bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .navbar-links {
        display: none;
    }
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px 14px;
    }

    .stat-card-value {
        font-size: 1.4rem;
    }

    .header h1 {
        font-size: 1.35rem;
    }

    .page-wrapper {
        padding: 16px 12px 48px;
    }

    .navbar {
        padding: 0 12px;
    }

    .mode-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .mode-btn {
        padding: 8px 4px;
    }

    .card {
        padding: 18px 14px;
    }

    .map-container {
        height: 200px;
        margin-left: -14px;
        margin-right: -14px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .eco-scene-container {
        height: 240px;
    }

    /* Toast at top on mobile */
    #toastContainer {
        bottom: auto;
        top: 72px;
        right: 12px;
        left: 12px;
    }

    .toast {
        max-width: 100%;
    }

    .leaderboard-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 12px 10px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
}