/* ============================================
   CSS VARIABLES — nature palette
   ============================================ */
:root {
    --green-dark:   #2d5a3d;
    --green-mid:    #4a7c59;
    --green-light:  #7ab893;
    --green-bright: #34d058;
    --brown-dark:   #6b5a3e;
    --brown-mid:    #8b6f47;
    --cream:        #f5f0e8;
    --cream-dark:   #ede5d4;
    --text-dark:    #2c2416;
    --text-mid:     #5a4a32;
    --text-light:   #8b7a60;
    --red:          #d44;
    --red-bg:       #fef2f2;
    --red-border:   #fca5a5;
    --orange:       #e8a96c;
    --orange-bg:    #fff8ef;
    --yellow:       #f5d76e;
    --amber:        #f59e0b;
    --amber-bg:     #fffbeb;
    --amber-border: #fbbf24;
    --shadow:       0 4px 24px rgba(45, 90, 61, 0.14);
    --radius:       18px;
    --explorer-amber:  #e8a020;
    --explorer-tan:    #c4956a;
    --explorer-cream:  #fdf6e3;
    --explorer-terra:  #c1643c;
    --explorer-forest: #1a3a2a;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--cream);
    color: var(--text-dark);
    min-height: 100vh;
    max-width: 500px;
    margin: 0 auto;
}

.hidden { display: none !important; }

/* ============================================
   AUTH SCREENS
   ============================================ */
.auth-screen {
    min-height: 100vh;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-logo {
    font-size: 38px;
    font-weight: 900;
    color: var(--green-dark);
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.auth-tagline {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 32px;
    text-align: center;
}

.auth-card {
    background: white;
    border-radius: var(--radius);
    padding: 28px 22px;
    width: 100%;
    box-shadow: var(--shadow);
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--green-dark);
    margin-bottom: 20px;
    text-align: center;
}

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--cream-dark);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-dark);
    background: var(--cream);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.form-input:focus { outline: none; border-color: var(--green-mid); }

.password-wrapper { position: relative; }

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    font-weight: 600;
}

.consent-group { margin: 20px 0 16px; }

.consent-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-mid);
    line-height: 1.4;
}

.consent-item input[type="checkbox"] {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--green-mid);
}

.consent-item a { color: var(--green-mid); text-decoration: underline; }

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--green-dark);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s;
}

.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { opacity: 0.85; }

.btn-secondary {
    width: 100%;
    padding: 14px;
    background: var(--cream);
    color: var(--green-dark);
    border: 2px solid var(--green-mid);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-text {
    background: none;
    border: none;
    color: var(--green-mid);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
}

/* FIX 7: Prominent login buttons */
.btn-parent-login {
    display: block;
    width: 100%;
    max-width: 400px;
    padding: 14px;
    margin-top: 20px;
    background: transparent;
    color: var(--green-dark);
    border: 2px solid var(--green-mid);
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.btn-parent-login:active { background: #e8f5ec; }

.btn-kid-switch {
    display: block;
    width: 100%;
    padding: 14px;
    background: transparent;
    color: var(--green-dark);
    border: 2px solid var(--green-mid);
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.btn-kid-switch:active { background: #e8f5ec; }

.auth-section-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--green-mid);
    margin-bottom: 16px;
    text-align: center;
}

.gate-modal-branded { padding: 28px 22px 24px; }
.gate-logo { font-size: 36px; text-align: center; margin-bottom: 10px; }
.gate-modal-branded h3 { text-align: center; font-size: 20px; font-weight: 800; color: var(--green-dark); margin-bottom: 6px; }
.gate-modal-branded p { text-align: center; font-size: 14px; color: var(--text-mid); line-height: 1.5; margin-bottom: 16px; }

.reward-card-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--cream); }
.reward-card-row:last-of-type { border-bottom: none; }
.reward-card-info { flex: 1; font-size: 13px; color: var(--text-mid); }
.reward-card-icon-btn { background: none; border: none; font-size: 16px; cursor: pointer; padding: 4px; color: var(--text-light); -webkit-tap-highlight-color: transparent; }
.reward-card-icon-btn:active { opacity: 0.6; }

.reward-edit-form { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--cream); }
.reward-edit-form input { padding: 8px 10px; border: 2px solid var(--cream-dark); border-radius: 10px; font-size: 14px; font-family: inherit; }
.reward-edit-form input:focus { outline: none; border-color: var(--green-mid); }
.reward-edit-actions { display: flex; gap: 6px; }
.reward-edit-actions button { padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; border: none; }

.voice-saved-indicator { position: absolute; top: 12px; right: 16px; font-size: 12px; font-weight: 700; color: var(--green-mid); opacity: 0; transition: opacity 0.3s; }
.voice-saved-indicator.show { opacity: 1; }

.quest-active-banner {
    background: linear-gradient(135deg, var(--green-dark), #1e3d29);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    box-shadow: var(--shadow);
}

.quest-active-dot { width: 10px; height: 10px; background: #4caf50; border-radius: 50%; animation: pulse 1.5s ease-in-out infinite; flex-shrink: 0; }
.quest-active-info { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quest-active-avatar { font-size: 20px; }
.quest-active-name { font-size: 14px; font-weight: 700; }
.quest-active-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; }
.quest-active-timer { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* FIX 5: Remote end quest button */
.btn-end-quest-remote {
    padding: 6px 12px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 8px;
    color: white;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

.battery-friendly { font-size: 11px; opacity: 0.6; margin-top: 4px; }

.auth-footer { margin-top: 20px; text-align: center; font-size: 14px; color: var(--text-light); }
.auth-footer a, .auth-footer button { color: var(--green-mid); font-weight: 600; text-decoration: none; background: none; border: none; cursor: pointer; font-size: 14px; }

.auth-error { background: var(--red-bg); border: 1px solid var(--red-border); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--red); margin-bottom: 16px; display: none; }
.auth-error.show { display: block; }

.verify-screen { text-align: center; padding-top: 80px; }
.verify-screen .auth-logo { margin-bottom: 24px; }
.verify-msg { font-size: 16px; color: var(--text-mid); line-height: 1.6; margin-bottom: 24px; }

/* ============================================
   PROFILE PICKER
   ============================================ */
.profile-picker { min-height: 100vh; padding: 40px 24px; text-align: center; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.profile-picker h2 { font-size: 24px; font-weight: 800; color: var(--green-dark); margin-bottom: 8px; }
.profile-picker .subtitle { font-size: 14px; color: var(--text-light); margin-bottom: 32px; }

.avatar-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-bottom: 32px; }
.avatar-circle { width: 90px; height: 90px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 40px; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; }
.avatar-circle:active { transform: scale(0.93); }
.avatar-name { font-size: 14px; font-weight: 700; color: var(--text-dark); margin-top: 6px; }
.avatar-item { display: flex; flex-direction: column; align-items: center; }

/* PIN */
.pin-screen { min-height: 100vh; padding: 60px 24px; text-align: center; }
.pin-avatar { width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 36px; margin: 0 auto 12px; box-shadow: var(--shadow); }
.pin-name { font-size: 20px; font-weight: 800; color: var(--green-dark); margin-bottom: 24px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 28px; }
.pin-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--green-mid); background: transparent; transition: background 0.15s; }
.pin-dot.filled { background: var(--green-mid); }
.pin-dot.wrong { border-color: var(--red); background: var(--red); }
.pin-keypad { display: grid; grid-template-columns: repeat(3, 70px); justify-content: center; gap: 12px; }
.pin-key { width: 70px; height: 56px; border-radius: 14px; border: 2px solid var(--cream-dark); background: white; font-size: 24px; font-weight: 700; color: var(--text-dark); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.1s; }
.pin-key:active { background: var(--cream-dark); }
.pin-key.backspace { font-size: 18px; color: var(--text-light); }
.pin-lockout { font-size: 15px; color: var(--red); font-weight: 600; margin-top: 20px; }

/* ============================================
   ONBOARDING
   ============================================ */
.onboarding-screen { min-height: 100vh; padding: 40px 24px; display: flex; flex-direction: column; }
.onboarding-step { display: none; flex-direction: column; flex: 1; }
.onboarding-step.active { display: flex; }
.onboarding-step h1 { font-size: 30px; font-weight: 900; color: var(--green-dark); text-align: center; margin-bottom: 8px; }
.onboarding-step h2 { font-size: 22px; font-weight: 800; color: var(--green-dark); margin-bottom: 16px; }
.onboarding-step .subtitle { font-size: 15px; color: var(--text-mid); text-align: center; margin-bottom: 32px; line-height: 1.5; }
.color-picker { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.color-option { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: border-color 0.15s, transform 0.1s; }
.color-option:active { transform: scale(0.9); }
.color-option.selected { border-color: var(--text-dark); }
.emoji-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 16px; }
.emoji-option { font-size: 28px; text-align: center; padding: 6px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; background: white; transition: border-color 0.15s; }
.emoji-option.selected { border-color: var(--green-mid); background: #e8f5ec; }
.onboarding-dots { display: flex; justify-content: center; gap: 8px; margin: 24px 0 16px; }
.onboarding-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cream-dark); }
.onboarding-dot.active { background: var(--green-mid); }

/* ============================================
   NAVIGATION BAR
   ============================================ */
.nav { display: none !important; background: var(--green-dark); padding: 10px 14px; gap: 8px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(0,0,0,0.2); }
.nav.parent-visible { display: flex !important; }
body.kid-mode .nav,
body.kid-mode #main-nav { display: none !important; visibility: hidden !important; height: 0 !important; overflow: hidden !important; }
.nav-btn { flex: 1; padding: 10px 8px; border: 2px solid transparent; border-radius: 10px; background: transparent; color: rgba(255,255,255,0.55); font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; -webkit-tap-highlight-color: transparent; position: relative; }
.nav-btn.active { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.35); color: white; }
.nav-badge { position: absolute; top: 4px; right: 8px; width: 8px; height: 8px; background: #ff5252; border-radius: 50%; }

/* ============================================
   TIME FILTER TABS — FEATURE 1: playful pills
   ============================================ */
.time-filter { display: flex; gap: 6px; margin-bottom: 14px; }
.time-filter-btn {
    flex: 1;
    padding: 8px 6px;
    border: 2px solid var(--cream-dark);
    border-radius: 20px;
    background: white;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}
.time-filter-btn.active {
    border-color: var(--green-bright);
    background: #e8f5ec;
    color: var(--green-dark);
}
.filter-period-label { font-size: 11px; color: var(--text-light); text-align: center; margin-bottom: 14px; }

/* ============================================
   KID MODE — FEATURE 1: Colorful overhaul
   ============================================ */
#kid-mode {
    padding: 20px 16px 60px;
    position: relative;
    overflow: hidden;
}

/* FEATURE 1: Background nature emojis */
.kid-bg-emojis {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}
.kid-bg-emojis span {
    position: absolute;
    font-size: 24px;
    opacity: 0.06;
}
#kid-mode > * { position: relative; z-index: 1; }

/* Kid sub-tabs */
.kid-tabs {
    display: flex;
    gap: 3px;
    margin-bottom: 16px;
    background: var(--cream-dark);
    border-radius: 12px;
    padding: 3px;
}
.kid-tab {
    flex: 1;
    padding: 8px 2px;
    border-radius: 10px;
    border: none;
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
    position: relative;
}
.kid-tab.active {
    background: white;
    color: var(--green-dark);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.kid-tab-panel { display: none; }
.kid-tab-panel.active { display: block; }

/* FEATURE 1: Vibrant rank header */
.rank-header {
    background: linear-gradient(135deg, #1a4d2e, #2d8a4e, #34d058);
    border-radius: var(--radius);
    padding: 18px 22px;
    color: white;
    text-align: center;
    margin-bottom: 16px;
    box-shadow: 0 6px 28px rgba(45, 90, 61, 0.35);
    position: relative;
}

/* FEATURE 2: Child avatar row */
.rank-avatar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    position: absolute;
    top: 14px;
    left: 16px;
}
.rank-child-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid rgba(255,255,255,0.4);
}
.rank-child-name {
    font-size: 16px;
    font-weight: 700;
}

.rank-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.8px; opacity: 0.65; margin-bottom: 4px; }
.rank-name { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.rank-pts { font-size: 15px; opacity: 0.9; margin-top: 3px; font-weight: 700; }
.rank-bar-bg { background: rgba(255,255,255,0.18); border-radius: 20px; height: 7px; margin-top: 14px; overflow: hidden; }
.rank-bar-fill { background: var(--yellow); height: 100%; border-radius: 20px; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.rank-next { font-size: 11px; opacity: 0.6; margin-top: 6px; }
.rank-reward { font-size: 13px; margin-top: 6px; font-weight: 600; color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.15); padding: 4px 12px; border-radius: 12px; display: inline-block; }
.rank-streak { font-size: 14px; margin-top: 8px; opacity: 1; font-weight: 700; color: #ffb74d; }
.rank-timer { font-size: 20px; font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; }
.parent-gate-btn { position: absolute; top: 12px; right: 14px; background: none; border: none; color: white; font-size: 18px; cursor: pointer; padding: 4px; text-shadow: 0 1px 4px rgba(0,0,0,0.4); }

/* FEATURE 1: Quest card with yellow accent */
.quest-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--yellow);
}
.quest-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.quest-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-light); font-weight: 700; }
.quest-season { font-size: 11px; color: var(--green-mid); font-weight: 600; }
.quest-text { font-size: 16px; font-weight: 700; color: var(--green-dark); line-height: 1.4; margin-bottom: 12px; }
.quest-progress-bar { background: var(--cream-dark); border-radius: 20px; height: 8px; overflow: hidden; margin-bottom: 6px; }
.quest-progress-fill { background: linear-gradient(90deg, var(--green-mid), var(--green-bright)); height: 100%; border-radius: 20px; transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.quest-progress-text { font-size: 12px; color: var(--text-light); font-weight: 600; }

/* Session controls */
.session-controls { display: flex; gap: 10px; margin-bottom: 16px; }

/* FEATURE 1: Vibrant Start Quest button */
.btn-start-quest {
    flex: 1;
    padding: 14px;
    background: linear-gradient(135deg, #34d058, #2d8a4e);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-end-quest {
    flex: 1;
    padding: 14px;
    background: var(--brown-mid);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* SOS Button — FEATURE 1: slightly larger */
.sos-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--red);
    color: white;
    border: 3px solid white;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(204,0,0,0.4);
    z-index: 90;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* FEATURE 1: Free Roam camera — larger, warm gradient, pulse */
.camera-area { display: flex; flex-direction: column; align-items: center; padding: 16px 0 24px; }
.camera-prompt { font-size: 19px; font-weight: 700; color: var(--green-dark); text-align: center; margin-bottom: 28px; line-height: 1.4; }

.camera-btn {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(145deg, #2d8a4e, #4caf50);
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(45, 90, 61, 0.5), 0 2px 8px rgba(45,90,61,0.2);
    transition: transform 0.12s, box-shadow 0.12s;
    color: white;
    gap: 10px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
    animation: cameraPulse 2.5s ease-in-out infinite;
}

@keyframes cameraPulse {
    0%, 100% { box-shadow: 0 10px 40px rgba(45, 90, 61, 0.5); }
    50% { box-shadow: 0 10px 50px rgba(52, 208, 88, 0.5), 0 0 20px rgba(52, 208, 88, 0.2); }
}

.camera-btn:disabled { opacity: 0.35; cursor: not-allowed; animation: none; }
.camera-btn:active:not(:disabled) { transform: scale(0.94); box-shadow: 0 4px 18px rgba(45, 90, 61, 0.35); }
.camera-btn svg { width: 52px; height: 52px; }
.camera-btn-label { font-size: 14px; font-weight: 700; text-align: center; line-height: 1.3; }
.pending-badge { position: absolute; top: 8px; right: 8px; background: var(--orange); color: white; font-size: 11px; font-weight: 700; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
#photo-input { display: none; }

/* ============================================
   FIX 10: NATURE NINJA SPY THEME
   ============================================ */
/* FIX 8: Explorer theme — warm Indiana Jones adventure vibe */
.explorer-tabs {
    background: var(--explorer-cream);
    border-radius: 12px;
    border: 1px solid var(--explorer-tan);
    gap: 0;
    padding: 4px;
}
.explorer-tabs .kid-tab {
    color: #5c3d1e;
    font-size: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    min-height: 44px;
    padding: 10px 2px;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}
.explorer-tabs .kid-tab.active {
    background: transparent;
    color: var(--explorer-amber);
    border-bottom-color: var(--explorer-amber);
    box-shadow: none;
    font-weight: 800;
}

.explorer-quest {
    background: var(--explorer-cream);
    border: none;
    border-left: 4px solid var(--explorer-amber);
}
.explorer-quest .explorer-label {
    color: var(--explorer-amber);
    letter-spacing: 2px;
    font-size: 10px;
}
.explorer-quest .quest-season {
    color: var(--explorer-tan);
}
.explorer-quest .quest-text {
    color: var(--explorer-forest);
}
.explorer-quest .quest-progress-bar {
    background: var(--explorer-tan);
    opacity: 0.3;
}
.explorer-quest .quest-progress-fill {
    background: linear-gradient(90deg, var(--explorer-amber), var(--explorer-terra));
    opacity: 1;
}
.explorer-quest .quest-progress-text {
    color: var(--explorer-tan);
}

.explorer-prompt {
    color: var(--explorer-forest);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
}

.explorer-camera-btn {
    background: linear-gradient(145deg, var(--explorer-amber), var(--explorer-terra));
    box-shadow: 0 10px 40px rgba(232, 160, 32, 0.4), 0 0 20px rgba(193, 100, 60, 0.15);
    border: 3px solid rgba(255,255,255,0.3);
}
.explorer-camera-btn .explore-icon {
    width: 56px;
    height: 56px;
    color: white;
}
.explorer-camera-btn .explorer-label-text {
    font-size: 15px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: white;
    font-weight: 800;
}

@keyframes cameraPulse {
    0%, 100% { box-shadow: 0 10px 40px rgba(232, 160, 32, 0.4), 0 0 20px rgba(193,100,60,0.15); }
    50% { box-shadow: 0 10px 50px rgba(232, 160, 32, 0.55), 0 0 30px rgba(193,100,60,0.25); }
}

/* FIX 5: Explorer color overhaul — remove all green from kid dashboard */
#kid-mode { background: var(--explorer-cream); }
#kid-mode .rank-header {
    background: linear-gradient(135deg, #3d2008, #5c3d1e, #e8a020);
    box-shadow: 0 6px 28px rgba(92, 61, 30, 0.35);
}
#kid-mode .time-filter-btn.active {
    border-color: var(--explorer-amber);
    background: #fdf0d5;
    color: #5c3d1e;
}
#kid-mode .rank-bar-fill,
#kid-mode .quest-progress-fill {
    background: linear-gradient(90deg, var(--explorer-amber), var(--explorer-terra));
}
#kid-mode .rank-bar-bg,
#kid-mode .quest-progress-bar {
    background: rgba(92, 61, 30, 0.15);
}
#kid-mode .points-badge {
    background: linear-gradient(90deg, var(--explorer-amber), var(--explorer-terra));
}
#kid-mode .btn-primary {
    background: var(--explorer-amber);
}
#kid-mode .btn-start-quest {
    background: var(--explorer-amber);
    color: white;
}
#kid-mode .again-btn {
    background: #5c3d1e;
}

/* ============================================
   FIX 9: SCANNER LOADING ANIMATION
   ============================================ */
.loading-state { display: none; text-align: center; padding: 60px 20px; }
.loading-state.show { display: block; }

.scanner-anim {
    width: 140px;
    height: 140px;
    margin: 0 auto 24px;
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    background: var(--explorer-cream);
    border: 2px solid var(--explorer-amber);
    box-shadow: 0 4px 20px rgba(232, 160, 32, 0.15);
}
.scanner-page {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.scanner-page svg { width: 90px; height: 90px; }
.draw-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawBotanical 3s ease-in-out infinite;
}
@keyframes drawBotanical {
    0% { stroke-dashoffset: 200; opacity: 0.3; }
    50% { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 200; opacity: 0.3; }
}
.scanner-bar {
    position: absolute;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(180deg, transparent, rgba(232,160,32,0.5), transparent);
    box-shadow: 0 0 12px rgba(232,160,32,0.4);
    animation: scanSweep 2.5s ease-in-out infinite;
}
@keyframes scanSweep {
    0% { top: 0; }
    50% { top: calc(100% - 6px); }
    100% { top: 0; }
}

.loading-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--explorer-forest);
}

/* ============================================
   DISCOVERY RESULT CARD — FIX 2 reordered
   ============================================ */
.discovery-card { display: none; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 24px; }
.discovery-card.show { display: block; }
.discovery-photo { width: 100%; height: 230px; object-fit: cover; display: block; }
.discovery-body { padding: 20px; }

.discovery-top-row { margin-bottom: 12px; }
.discovery-badges-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.points-badge { display: inline-flex; align-items: center; gap: 5px; background: linear-gradient(90deg, #4caf50, #43a047); color: white; font-size: 13px; font-weight: 700; padding: 5px 13px; border-radius: 20px; }
.scavenger-badge { display: inline-flex; align-items: center; gap: 5px; background: linear-gradient(90deg, #f5a623, #e8891d); color: white; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px; }
.discovery-name { font-size: 24px; font-weight: 800; color: var(--green-dark); line-height: 1.2; }
.discovery-lesson { font-size: 15px; line-height: 1.7; color: var(--text-mid); margin-bottom: 14px; }

/* Wow Fact */
.wow-fact-box { background: linear-gradient(135deg, #fef9e7, #fdf2d5); border: 2px solid var(--yellow); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.wow-fact-label { font-size: 12px; font-weight: 800; color: #d4a017; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.wow-fact-text { font-size: 17px; font-weight: 700; color: #8b6914; line-height: 1.45; }

/* FIX 2: Friendly safety note — warm amber */
.safety-inline-warning {
    margin-bottom: 14px;
    padding: 0;
}
.safety-inline-warning .safety-warning-text {
    font-size: 14px;
    color: #b91c1c;
    line-height: 1.5;
    font-weight: 600;
}
.safety-inline-warning .safety-warning-text::before {
    content: '\1F6A9 WARNING: ';
    font-weight: 800;
}

/* FEATURE 3+4: Rarity stamps */
.rarity-stamp {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transform: rotate(-2deg);
}
.rarity-stamp-inline { transform: none; }
.rarity-common { background: #9ca3af; color: white; }
.rarity-uncommon { background: #22c55e; color: white; }
.rarity-rare { background: #3b82f6; color: white; }
.rarity-epic { background: #8b5cf6; color: white; }
.rarity-legendary { background: linear-gradient(135deg, #f59e0b, #d97706); color: #1a1a1a; animation: legendaryShimmer 2s ease-in-out infinite; }
@keyframes legendaryShimmer { 0%, 100% { box-shadow: 0 0 4px rgba(245, 158, 11, 0.4); } 50% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.8); } }

.wiki-img { width: 100%; height: 170px; object-fit: cover; border-radius: 12px; margin-bottom: 14px; display: block; }

/* Voice */
.voice-controls { display: flex; gap: 8px; margin-top: 10px; margin-bottom: 10px; }
.voice-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--cream); border: 2px solid var(--green-mid); border-radius: 12px; padding: 8px 14px; font-size: 13px; font-weight: 700; color: var(--green-dark); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.15s; }
.voice-btn:active { background: var(--cream-dark); }

.card-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-share, .btn-report { padding: 8px 14px; border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer; border: 2px solid var(--cream-dark); background: white; color: var(--text-light); -webkit-tap-highlight-color: transparent; }
.btn-thumb { background: none; border: 2px solid var(--cream-dark); border-radius: 10px; font-size: 22px; cursor: pointer; padding: 4px 10px; opacity: 0.5; -webkit-tap-highlight-color: transparent; transition: opacity 0.15s; }
.btn-thumb.active-up, .btn-thumb.active-down { opacity: 1; border-color: var(--green-mid); }
.grid-card-actions { display: flex; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--cream); align-items: center; }
.btn-report-grid { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--cream-dark); background: white; font-size: 11px; font-weight: 600; cursor: pointer; color: var(--text-light); -webkit-tap-highlight-color: transparent; }
.again-btn { width: 100%; padding: 15px; background: var(--green-dark); color: white; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 18px; -webkit-tap-highlight-color: transparent; }

/* Error / Duplicate */
.error-card { display: none; background: var(--orange-bg); border: 2px solid var(--orange); border-radius: var(--radius); padding: 28px 20px; text-align: center; margin-bottom: 24px; }
.error-card.show { display: block; }
.error-emoji { font-size: 44px; margin-bottom: 14px; }
.error-msg { font-size: 16px; font-weight: 500; color: var(--brown-dark); line-height: 1.5; }
.try-again-btn { margin-top: 18px; padding: 12px 28px; background: var(--brown-mid); color: white; border: none; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer; }
.duplicate-card { display: none; background: #f0f9ff; border: 2px solid #7dd3fc; border-radius: var(--radius); padding: 28px 20px; text-align: center; margin-bottom: 24px; }
.duplicate-card.show { display: block; }

/* Session summary */
.session-summary { display: none; background: white; border-radius: var(--radius); padding: 28px 22px; box-shadow: var(--shadow); text-align: center; margin-bottom: 24px; }
.session-summary.show { display: block; }
.session-summary h3 { font-size: 22px; font-weight: 800; color: var(--green-dark); margin-bottom: 20px; }
.summary-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.summary-stat-value { font-size: 28px; font-weight: 800; color: var(--green-dark); }
.summary-stat-label { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }

/* ============================================
   FEATURE 3: FIELD JOURNAL — scrapbook style
   ============================================ */
#tab-journal { background: #faf6ee; border-radius: 14px; padding: 16px; margin: -16px; margin-top: 0; }

.journal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px dashed var(--cream-dark);
}
.journal-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.journal-child-name { font-size: 18px; font-weight: 800; color: var(--green-dark); }
.journal-tagline { font-size: 12px; color: var(--text-light); }
.journal-total { font-size: 13px; font-weight: 700; color: var(--green-mid); margin-left: auto; }

.journal-filters { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.journal-filter-btn { padding: 5px 10px; border-radius: 16px; border: 2px solid var(--cream-dark); background: white; font-size: 11px; font-weight: 700; color: var(--text-light); cursor: pointer; }
.journal-filter-btn.active { border-color: var(--green-mid); background: #e8f5ec; color: var(--green-dark); }

.journal-sort { display: flex; gap: 6px; margin-bottom: 16px; }
.journal-sort-btn { padding: 4px 12px; border-radius: 10px; border: none; background: var(--cream-dark); font-size: 11px; font-weight: 700; color: var(--text-light); cursor: pointer; }
.journal-sort-btn.active { background: var(--green-dark); color: white; }

.journal-entries { display: flex; flex-direction: column; gap: 12px; }

.journal-card {
    background: white;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    gap: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.15s;
    position: relative;
}
.journal-card:active { transform: scale(0.98); }

.journal-card-photo { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }

.journal-card-stamp {
    position: absolute;
    top: 8px;
    right: 8px;
}
.journal-card-stamp .rarity-stamp { transform: rotate(8deg); font-size: 10px; padding: 2px 8px; }

.journal-card-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.journal-card-name { font-size: 15px; font-weight: 700; color: #5c3d1e; margin-bottom: 4px; }
.journal-card-pts { font-size: 12px; font-weight: 700; color: var(--explorer-amber); }
.journal-card-date { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.journal-delete-btn { position: absolute; top: 6px; right: 6px; background: rgba(255,255,255,0.9); border: none; border-radius: 50%; width: 28px; height: 28px; font-size: 14px; cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center; opacity: 0.5; -webkit-tap-highlight-color: transparent; }
.journal-delete-btn:active { opacity: 1; }

/* ============================================
   FIX 6: Kid discovery feed (week/month)
   ============================================ */
.kid-feed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kid-feed-card { background: white; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s; }
.kid-feed-card:active { transform: scale(0.97); }
.kid-feed-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.kid-feed-info { padding: 8px 10px 10px; }
.kid-feed-name { font-size: 13px; font-weight: 700; color: var(--green-dark); margin-bottom: 4px; }
.kid-feed-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kid-feed-pts { font-size: 11px; font-weight: 700; color: var(--green-mid); }

/* ============================================
   SCAVENGER HUNT
   ============================================ */
.scavenger-header { text-align: center; margin-bottom: 16px; }
.scavenger-header h3 { font-size: 20px; font-weight: 800; color: var(--green-dark); }
.scavenger-header .state-name { font-size: 13px; color: var(--text-light); font-weight: 600; }
.scavenger-progress { background: var(--cream-dark); border-radius: 20px; height: 10px; margin: 12px 0 8px; overflow: hidden; }
.scavenger-progress-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--green-mid), var(--green-light)); transition: width 0.5s; }
.scavenger-count { font-size: 13px; color: var(--text-light); font-weight: 600; text-align: center; margin-bottom: 16px; }
.scavenger-list { display: flex; flex-direction: column; gap: 8px; }
.scavenger-item { background: white; border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.scavenger-item.found { background: #e8f5ec; border: 2px solid var(--green-light); }
.scavenger-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--cream-dark); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.scavenger-item.found .scavenger-icon { background: var(--green-mid); }
.scavenger-item-info { flex: 1; }
.scavenger-item-name { font-size: 14px; font-weight: 700; color: var(--text-dark); }
.scavenger-item-desc { font-size: 12px; color: var(--text-light); line-height: 1.3; margin-top: 2px; }
.difficulty-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 8px; text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
.difficulty-badge.easy { background: #dcfce7; color: #166534; }
.difficulty-badge.medium { background: #fef9c3; color: #854d0e; }
.difficulty-badge.hard { background: #fee2e2; color: #991b1b; }
.scavenger-photo-slot { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }

/* ============================================
   CHAT / MESSAGES — FIX 10: bottom fix + photo
   ============================================ */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 200px); max-height: 500px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.chat-bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; word-wrap: break-word; }
.chat-bubble.from-kid { align-self: flex-end; background: var(--green-mid); color: white; border-bottom-right-radius: 4px; }
.chat-bubble.from-parent { align-self: flex-start; background: white; color: var(--text-dark); border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.chat-time { font-size: 10px; color: var(--text-light); margin-top: 2px; padding: 0 4px; }
.chat-time.right { text-align: right; }

/* FIX 10: Input pinned to bottom */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--cream-dark);
    position: sticky;
    bottom: 0;
    background: var(--cream);
    z-index: 5;
}
.chat-input { flex: 1; padding: 10px 14px; border: 2px solid var(--cream-dark); border-radius: 20px; font-size: 14px; font-family: inherit; background: white; }
.chat-input:focus { outline: none; border-color: var(--green-mid); }
.chat-send { width: 42px; height: 42px; border-radius: 50%; background: var(--green-dark); color: white; border: none; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* FIX 10: Photo button in chat */
.chat-photo-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--cream-dark); border: none; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* FIX 10: Photo preview */
.chat-photo-preview { padding: 8px; background: var(--cream-dark); border-radius: 12px; margin-bottom: 8px; position: relative; display: inline-block; }
.chat-photo-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }
.chat-preview-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,0.5); color: white; border: none; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* Photo messages */
.chat-photo-msg { max-width: 200px; cursor: pointer; }
.chat-photo-msg img { width: 100%; border-radius: 12px; display: block; }

.quick-replies { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.quick-reply-btn { padding: 6px 12px; border-radius: 16px; border: 2px solid var(--cream-dark); background: white; font-size: 12px; font-weight: 600; color: var(--text-mid); cursor: pointer; transition: all 0.2s; }
.quick-reply-btn:active { background: var(--cream-dark); }
.quick-reply-btn.sent { background: var(--green-mid); color: white; border-color: var(--green-mid); }

/* ============================================
   KID SETTINGS TAB — FIX 3
   ============================================ */
.kid-settings-section { margin-bottom: 24px; }
.kid-settings-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-light); font-weight: 700; margin-bottom: 12px; }
.settings-card { background: white; border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--cream); }
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 14px; color: var(--text-dark); font-weight: 600; }
.settings-row-value { font-size: 14px; color: var(--text-light); }
.stat-tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.stat-tappable:active { background: var(--cream); border-radius: 8px; }

/* FIX 3: Stat photo grid */
.stat-photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-photo-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* Badges */
.badges-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-item { background: white; border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; }
.badge-item.locked { opacity: 0.4; filter: grayscale(1); }
.badge-icon { font-size: 28px; margin-bottom: 4px; }
.badge-name { font-size: 11px; font-weight: 700; color: var(--text-dark); line-height: 1.2; }

/* FIX 3: Badge detail modal */
.badge-detail-box { text-align: center; }
.badge-detail-icon { font-size: 64px; margin-bottom: 8px; }
.badge-challenge-card { background: var(--amber-bg); border: 2px solid var(--amber-border); border-radius: 12px; padding: 14px; font-size: 14px; color: #92400e; line-height: 1.5; font-weight: 600; margin-top: 8px; }

/* ============================================
   FEATURE 5: Photo Gallery
   ============================================ */
.kid-photo-gallery { margin-top: 16px; }
.gallery-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.gallery-header h4 { font-size: 16px; font-weight: 800; color: var(--green-dark); }
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; }
.btn-gallery-toggle { width: 100%; padding: 10px; margin-top: 16px; background: white; border: 2px solid var(--cream-dark); border-radius: 12px; font-size: 14px; font-weight: 700; color: var(--text-mid); cursor: pointer; }

/* Fullscreen photo viewer */
.fullscreen-photo { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 500; align-items: center; justify-content: center; flex-direction: column; }
.fullscreen-photo.show { display: flex; }
.fullscreen-photo img { max-width: 100%; max-height: 80vh; object-fit: contain; touch-action: pinch-zoom; }
.fullscreen-photo-actions { display: flex; gap: 12px; margin-top: 16px; }
.btn-share-fullscreen, .btn-close-fullscreen { padding: 10px 24px; border-radius: 12px; font-size: 14px; font-weight: 700; cursor: pointer; border: none; }
.btn-share-fullscreen { background: var(--green-mid); color: white; }
.btn-close-fullscreen { background: rgba(255,255,255,0.2); color: white; }

/* ============================================
   PARENT DASHBOARD
   ============================================ */
#parent-mode { display: none; padding: 20px 16px 60px; }
.parent-tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--cream-dark); border-radius: 12px; padding: 3px; }
.parent-tab { flex: 1; padding: 8px 4px; border-radius: 10px; border: none; background: transparent; font-size: 11px; font-weight: 700; color: var(--text-light); cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent; transition: all 0.15s; position: relative; }
.parent-tab.active { background: white; color: var(--green-dark); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.parent-tab-panel { display: none; }
.parent-tab-panel.active { display: block; }

.child-filter { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.child-filter-btn { padding: 6px 14px; border-radius: 20px; border: 2px solid var(--cream-dark); background: white; font-size: 12px; font-weight: 700; color: var(--text-light); cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.child-filter-btn.active { border-color: var(--green-mid); background: #e8f5ec; color: var(--green-dark); }

.stats-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-card { background: white; border-radius: 14px; padding: 12px 10px; box-shadow: var(--shadow); text-align: center; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--green-dark); line-height: 1.1; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-light); font-weight: 700; margin-top: 3px; }
.stats-bar-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }

.reward-summary { background: white; border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 14px; font-size: 13px; color: var(--text-mid); line-height: 1.6; }
.reward-line { display: flex; align-items: center; gap: 6px; padding: 3px 0; }

.warning-banner { background: #fef3cd; border: 2px solid #ffc107; border-radius: 12px; padding: 12px 16px; font-size: 13px; color: #856404; font-weight: 600; margin-bottom: 14px; display: none; line-height: 1.4; }
.warning-banner.show { display: block; }
.warning-banner.orange { background: #fff3cd; border-color: var(--orange); color: #8a5600; }

.map-section { margin-bottom: 22px; }
.section-heading { font-size: 11px; text-transform: uppercase; letter-spacing: 1.8px; color: var(--text-light); font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.live-dot { width: 7px; height: 7px; background: #4caf50; border-radius: 50%; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.8); } }

#discovery-map { width: 100%; height: 280px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--cream-dark); position: relative; z-index: 0; isolation: isolate; }
.map-empty { display: flex; align-items: center; justify-content: center; height: 100%; text-align: center; padding: 24px; color: var(--text-light); font-size: 14px; line-height: 1.6; }

.leaflet-popup-content { margin: 10px 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.map-popup-img { width: 120px; height: 80px; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 6px; }
.map-popup-name { font-size: 14px; font-weight: 700; color: var(--green-dark); }
.map-popup-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* Photo Grid */
.grid-section { margin-bottom: 24px; }
.grid-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.btn-manage { padding: 6px 14px; border-radius: 10px; border: 2px solid var(--cream-dark); background: white; font-size: 12px; font-weight: 700; color: var(--text-light); cursor: pointer; }
.photo-grid { columns: 2; column-gap: 10px; }
.grid-card { background: white; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 10px; break-inside: avoid; cursor: pointer; transition: transform 0.15s; position: relative; }
.grid-card:active { transform: scale(0.97); }
.grid-card.selected { border: 3px solid var(--green-mid); }
.grid-checkbox { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid white; background: rgba(0,0,0,0.3); display: none; align-items: center; justify-content: center; color: white; font-size: 14px; font-weight: 700; z-index: 2; }
.grid-card.select-mode .grid-checkbox { display: flex; }
.grid-card.selected .grid-checkbox { background: var(--green-mid); border-color: var(--green-mid); }
.grid-photo { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.grid-body { padding: 10px 12px 12px; }
.grid-name { font-size: 14px; font-weight: 700; color: var(--green-dark); line-height: 1.2; margin-bottom: 4px; }
.grid-meta { display: flex; justify-content: space-between; align-items: center; }
.grid-pts { font-size: 11px; font-weight: 700; color: var(--green-mid); background: #e8f5ec; padding: 2px 8px; border-radius: 10px; }
.grid-time { font-size: 10px; color: var(--text-light); }

/* FIX 9: Thumbs up/down rating */
.thumbs-rating { display: flex; gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--cream); align-items: center; }
.thumb-btn { background: none; border: none; font-size: 20px; cursor: pointer; padding: 2px 4px; opacity: 0.4; -webkit-tap-highlight-color: transparent; transition: opacity 0.15s; }
.thumb-btn.active-up { opacity: 1; }
.thumb-btn.active-down { opacity: 1; }
.point-edit-btn { background: none; border: none; font-size: 14px; cursor: pointer; margin-left: auto; color: var(--text-light); }

/* FIX 9: Point editor */
.point-editor { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 6px; background: var(--cream); border-radius: 10px; }
.point-editor button { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--cream-dark); background: white; font-size: 13px; font-weight: 700; cursor: pointer; }
.point-editor-value { font-size: 16px; font-weight: 800; color: var(--green-dark); min-width: 40px; text-align: center; }
.point-save-btn { background: var(--green-dark) !important; color: white !important; border: none !important; }

.correction-field { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px; background: #fef3c7; border-radius: 10px; flex-wrap: wrap; width: 100%; box-sizing: border-box; }
.correction-input { flex: 1; min-width: 120px; padding: 6px 10px; border-radius: 8px; border: 1px solid #d4a017; font-size: 13px; font-weight: 500; outline: none; box-sizing: border-box; }
.correction-input:focus { border-color: var(--green-mid); }
.correction-submit { padding: 5px 10px; border-radius: 8px; border: none; background: var(--green-dark); color: white; font-size: 12px; font-weight: 700; cursor: pointer; }
.correction-skip { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--cream-dark); background: white; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-light); }

.load-more-btn { display: block; width: 100%; padding: 12px; background: white; border: 2px solid var(--cream-dark); border-radius: 12px; font-size: 14px; font-weight: 700; color: var(--text-light); cursor: pointer; margin-top: 10px; }

/* Selection bar */
.selection-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 500px; background: var(--green-dark); color: white; padding: 14px 20px; display: none; align-items: center; justify-content: space-between; z-index: 150; box-shadow: 0 -4px 20px rgba(0,0,0,0.2); }
.selection-bar.show { display: flex; }
.selection-count { font-size: 14px; font-weight: 700; }
.selection-actions { display: flex; gap: 8px; }
.btn-delete-selected { padding: 8px 16px; background: var(--red); color: white; border: none; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn-cancel-select { padding: 8px 16px; background: rgba(255,255,255,0.2); color: white; border: none; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; }

/* ============================================
   FIX 8: Expanded card overlay redesign
   ============================================ */
.card-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; align-items: center; justify-content: center; padding: 20px; }
.card-overlay.show { display: flex; }
.card-expanded { background: white; border-radius: var(--radius); overflow: hidden; max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(0,0,0,0.3); animation: popIn 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes popIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.expanded-photo { width: 100%; height: 280px; object-fit: cover; display: block; touch-action: pinch-zoom; }
.expanded-body { padding: 18px 20px 22px; }
.expanded-name { font-size: 22px; font-weight: 800; color: var(--green-dark); margin-bottom: 6px; }
.expanded-badges-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.expanded-pts { font-size: 13px; font-weight: 700; color: var(--green-mid); background: #e8f5ec; padding: 3px 10px; border-radius: 10px; display: inline-block; }
.expanded-what { font-size: 15px; line-height: 1.7; color: var(--text-mid); margin-bottom: 12px; }
.expanded-wow-box { background: linear-gradient(135deg, #fef9e7, #fdf2d5); border: 2px solid var(--yellow); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.expanded-time { font-size: 12px; color: var(--text-light); }
.expanded-location { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.expanded-close { display: block; width: 100%; padding: 14px; margin-top: 10px; background: var(--cream); border: none; border-radius: 12px; font-size: 15px; font-weight: 700; color: var(--text-mid); cursor: pointer; }

/* FIX 8: Dinner Table Questions */
.dinner-questions-section { margin-top: 16px; padding-top: 16px; border-top: 2px dashed var(--cream-dark); }
.dinner-questions-title { font-size: 16px; font-weight: 800; color: var(--green-dark); margin-bottom: 12px; }
.dinner-question-card { background: var(--cream); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font-size: 14px; color: var(--text-dark); line-height: 1.5; font-weight: 500; cursor: pointer; transition: background 0.15s; }
.dinner-question-card:active { background: var(--cream-dark); }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-feed { text-align: center; padding: 56px 24px; color: var(--text-light); }
.empty-emoji { font-size: 52px; margin-bottom: 16px; }
.empty-text { font-size: 16px; line-height: 1.6; }

/* ============================================
   PARENT SETTINGS
   ============================================ */
.settings-section { margin-bottom: 28px; }
.settings-section h3 { font-size: 16px; font-weight: 800; color: var(--green-dark); margin-bottom: 12px; }
.settings-panel { background: white; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.reward-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.reward-row input { flex: 1; padding: 8px 10px; border: 2px solid var(--cream-dark); border-radius: 10px; font-size: 14px; font-family: inherit; }
.reward-row input:focus { outline: none; border-color: var(--green-mid); }
.btn-add-reward { padding: 8px 16px; border-radius: 10px; border: 2px dashed var(--cream-dark); background: transparent; font-size: 13px; font-weight: 700; color: var(--text-light); cursor: pointer; width: 100%; margin-top: 8px; }
.voice-setting { margin-bottom: 14px; }
.voice-setting label { display: block; font-size: 12px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.voice-setting select, .voice-setting input[type="range"] { width: 100%; padding: 8px; border-radius: 10px; border: 2px solid var(--cream-dark); font-family: inherit; font-size: 14px; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; }
.range-value { font-size: 13px; font-weight: 700; color: var(--text-mid); width: 36px; text-align: right; }
.session-limit-select { width: 100%; padding: 10px; border: 2px solid var(--cream-dark); border-radius: 10px; font-size: 14px; font-family: inherit; background: white; }
#geofence-map { width: 100%; height: 250px; border-radius: 14px; overflow: hidden; margin-top: 10px; position: relative; z-index: 0; isolation: isolate; }

/* FIX 12: Toggle switch for Free Roam */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--cream-dark); border-radius: 24px; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--green-mid); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ============================================
   CHILD MANAGEMENT
   ============================================ */
.child-cards { display: flex; flex-direction: column; gap: 10px; }
.child-card { background: white; border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.child-card-avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.child-card-info { flex: 1; }
.child-card-name { font-size: 16px; font-weight: 700; color: var(--text-dark); }
.child-card-meta { font-size: 12px; color: var(--text-light); }
.child-card-streak { font-size: 13px; font-weight: 700; color: var(--green-dark); }

/* ============================================
   SOS OVERLAYS
   ============================================ */
.sos-overlay { display: none; position: fixed; inset: 0; z-index: 400; background: rgba(200, 0, 0, 0.95); align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 40px 24px; }
.sos-overlay.show { display: flex; }
.sos-overlay h2 { font-size: 32px; font-weight: 900; color: white; margin-bottom: 12px; }
.sos-overlay p { font-size: 16px; color: rgba(255,255,255,0.9); line-height: 1.6; margin-bottom: 8px; }
.sos-overlay a { color: white; font-weight: 700; text-decoration: underline; }
.sos-resolve-btn { margin-top: 24px; padding: 16px 48px; background: white; color: var(--red); border: none; border-radius: 14px; font-size: 18px; font-weight: 800; cursor: pointer; }

.sos-confirm { display: none; position: fixed; inset: 0; z-index: 350; background: rgba(200, 0, 0, 0.92); align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 40px 24px; }
.sos-confirm.show { display: flex; }
.sos-confirm h2 { color: white; font-size: 24px; margin-bottom: 16px; }
.sos-countdown { font-size: 60px; font-weight: 900; color: white; margin-bottom: 24px; }
.sos-cancel-btn { padding: 16px 48px; background: rgba(255,255,255,0.2); color: white; border: 2px solid white; border-radius: 14px; font-size: 18px; font-weight: 700; cursor: pointer; }

/* ============================================
   MODALS
   ============================================ */
.report-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 250; align-items: center; justify-content: center; padding: 20px; }
.report-modal.show { display: flex; }
.report-content { background: white; border-radius: var(--radius); padding: 24px 20px; width: 100%; max-width: 400px; box-shadow: 0 16px 48px rgba(0,0,0,0.3); }
.report-content h3 { font-size: 18px; font-weight: 800; color: var(--green-dark); margin-bottom: 16px; }
.report-option { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--cream); cursor: pointer; }
.report-option input[type="radio"] { accent-color: var(--green-mid); }
.report-option label { font-size: 14px; cursor: pointer; }
.report-text-field { width: 100%; padding: 10px; border: 2px solid var(--cream-dark); border-radius: 10px; font-size: 14px; font-family: inherit; margin-top: 10px; display: none; }
.report-actions { display: flex; gap: 8px; margin-top: 16px; }
.report-actions button { flex: 1; }

.weekly-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 260; align-items: center; justify-content: center; padding: 20px; }
.weekly-modal.show { display: flex; }
.weekly-content { background: linear-gradient(180deg, #1e3d29, var(--green-dark)); border-radius: var(--radius); padding: 32px 22px; width: 100%; max-width: 420px; color: white; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.4); max-height: 90vh; overflow-y: auto; }
.weekly-content h2 { font-size: 24px; font-weight: 900; margin-bottom: 4px; }
.weekly-subtitle { font-size: 13px; opacity: 0.7; margin-bottom: 24px; }
.weekly-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.weekly-stat { background: rgba(255,255,255,0.1); border-radius: 14px; padding: 14px; }
.weekly-stat-value { font-size: 28px; font-weight: 800; }
.weekly-stat-label { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.weekly-highlight { background: rgba(255,255,255,0.12); border-radius: 14px; padding: 16px; margin-bottom: 24px; text-align: left; }
.weekly-highlight-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.6; margin-bottom: 8px; }
.weekly-highlight-photo { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; }
.weekly-highlight-name { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.weekly-highlight-fact { font-size: 14px; opacity: 0.85; line-height: 1.5; }
.weekly-close-btn { padding: 14px 32px; background: white; color: var(--green-dark); border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; }

.delete-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 270; align-items: center; justify-content: center; padding: 20px; }
.delete-modal.show { display: flex; }
.delete-content { background: white; border-radius: var(--radius); padding: 28px 22px; width: 100%; max-width: 400px; text-align: center; }
.delete-content h3 { font-size: 20px; font-weight: 800; color: var(--red); margin-bottom: 12px; }
.delete-content p { font-size: 14px; color: var(--text-mid); line-height: 1.5; margin-bottom: 16px; }
.delete-confirm-input { width: 100%; padding: 12px; border: 2px solid var(--red-border); border-radius: 10px; font-size: 16px; text-align: center; font-family: inherit; margin-bottom: 16px; }
.btn-delete-account { width: 100%; padding: 14px; background: var(--red); color: white; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; }
.btn-delete-account:disabled { opacity: 0.4; }

/* ============================================
   FEATURE 1: UPGRADE / SUBSCRIPTION UI
   ============================================ */
.upgrade-card { padding: 4px 0; }
.upgrade-title { font-size: 18px; font-weight: 800; color: var(--green-dark); margin-bottom: 12px; }
.upgrade-features { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--text-mid); font-weight: 500; }
.upgrade-features div { padding: 4px 0; }
.upgrade-plans { display: flex; gap: 8px; }
.btn-upgrade { flex: 1; padding: 14px 12px; border-radius: 12px; border: 2px solid var(--green-mid); background: white; font-size: 16px; font-weight: 700; color: var(--green-dark); cursor: pointer; text-align: center; }
.btn-upgrade-best { background: var(--green-dark); color: white; border-color: var(--green-dark); }
.upgrade-save { display: block; font-size: 11px; font-weight: 600; opacity: 0.8; margin-top: 2px; }
.lock-badge { font-size: 14px; margin-left: 4px; opacity: 0.5; }

/* ============================================
   CELEBRATIONS
   ============================================ */
.celebration-overlay { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(30, 61, 41, 0.92); align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 40px 24px; }
.celebration-overlay.show { display: flex; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.celebration-rank { font-size: 42px; font-weight: 900; color: white; margin-bottom: 8px; animation: bounceIn 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes bounceIn { 0% { opacity: 0; transform: scale(0.3); } 60% { transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
.celebration-msg { font-size: 18px; color: rgba(255,255,255,0.85); line-height: 1.5; max-width: 280px; }
.celebration-stars { font-size: 48px; margin-bottom: 16px; animation: bounceIn 0.5s cubic-bezier(0.22, 1, 0.36, 1); }

.confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 301; overflow: hidden; }
.confetti-piece { position: absolute; width: 10px; height: 10px; top: -10px; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }
.confetti-piece:nth-child(odd) { border-radius: 50%; }
.confetti-piece:nth-child(even) { border-radius: 2px; }

/* FEATURE 4: Rarity celebration */
.rarity-celebration { display: none; position: fixed; inset: 0; z-index: 310; align-items: center; justify-content: center; pointer-events: none; }
.rarity-celebration.show { display: flex; animation: rarityFlash 0.8s ease-out; }
.rarity-cel-epic { background: rgba(139, 92, 246, 0.85); }
.rarity-cel-legendary { background: rgba(245, 158, 11, 0.85); }
.rarity-cel-text { font-size: 48px; font-weight: 900; color: white; text-transform: uppercase; letter-spacing: 3px; animation: bounceIn 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes rarityFlash { 0% { opacity: 1; } 100% { opacity: 0; } }

.badge-celebration { display: none; position: fixed; inset: 0; z-index: 310; background: rgba(30, 61, 41, 0.92); align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 40px 24px; }
.badge-celebration.show { display: flex; animation: fadeIn 0.3s ease-out; }
.badge-celebration .badge-big-icon { font-size: 72px; margin-bottom: 16px; animation: bounceIn 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.badge-celebration h2 { font-size: 28px; font-weight: 900; color: white; margin-bottom: 8px; }
.badge-celebration p { font-size: 16px; color: rgba(255,255,255,0.8); line-height: 1.5; }

/* ============================================
   GENERIC MODALS
   ============================================ */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 280; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal-box { background: white; border-radius: var(--radius); padding: 24px 20px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 16px 48px rgba(0,0,0,0.3); }
.modal-box h3 { font-size: 18px; font-weight: 800; color: var(--text-dark); margin-bottom: 10px; }
.modal-box p { font-size: 14px; color: var(--text-mid); line-height: 1.5; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn-modal-cancel { background: var(--cream); border: none; color: var(--text-mid); }
.btn-modal-confirm { background: var(--red); border: none; color: white; }

.parent-gate-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 280; align-items: center; justify-content: center; padding: 20px; }
.parent-gate-modal.show { display: flex; }
