/* Sandstone (default) */

:root,
[data-theme="sandstone"] {
    --color-bg: #f5f0e8;
    --color-surface: #ffffff;
    --color-header: #3b2f1e;
    --color-header-text: #fdf6ec;
    --color-accent: #d4790e;
    --color-accent-soft: rgba(212, 121, 14, 0.12);
    --color-text: #2c2416;
    --color-text-muted: #5e5347;
    --color-link: #9a4d00;
    --color-border: #d9d0c3;
    --color-triassic: #e04040;
    --color-jurassic: #22b855;
    --color-cretaceous: #3388dd;
    --color-badge-locked: #e0d8ce;
    --color-badge-unlocked: #f59e0b;
    --color-badge-bg: #fff6e0;
    --color-footer-link: #f0c97a;
    --color-loading-bg: rgba(59, 47, 30, 0.92);
    --color-card: #faf7f2;
    --color-card-hover: #f5f0e8;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --transition: 0.2s ease;
}

/* Glacier */

[data-theme="glacier"] {
    --color-bg: #e4f0fa;
    --color-surface: #f4f9ff;
    --color-header: #1a3d5c;
    --color-header-text: #dceefa;
    --color-accent: #2e9eee;
    --color-accent-soft: rgba(46, 158, 238, 0.12);
    --color-text: #142838;
    --color-text-muted: #3b6a8a;
    --color-link: #1470b8;
    --color-border: #b8d4ef;
    --color-triassic: #e05050;
    --color-jurassic: #30c070;
    --color-cretaceous: #3890e0;
    --color-badge-locked: #a8c8e0;
    --color-badge-unlocked: #2e9eee;
    --color-badge-bg: #e0f0ff;
    --color-footer-link: #8ec6e8;
    --color-loading-bg: rgba(30, 58, 82, 0.92);
    --color-card: #eef5fb;
    --color-card-hover: #e4eef6;
}

/* Jungle */

[data-theme="jungle"] {
    --color-bg: #e0f2dc;
    --color-surface: #f0faf0;
    --color-header: #163016;
    --color-header-text: #d8f0d4;
    --color-accent: #20a050;
    --color-accent-soft: rgba(32, 160, 80, 0.12);
    --color-text: #142814;
    --color-text-muted: #336e33;
    --color-link: #14703c;
    --color-border: #a8d4a0;
    --color-triassic: #e04840;
    --color-jurassic: #20a050;
    --color-cretaceous: #3080c0;
    --color-badge-locked: #a0c898;
    --color-badge-unlocked: #20a050;
    --color-badge-bg: #d8f5d0;
    --color-footer-link: #8ad4a0;
    --color-loading-bg: rgba(26, 58, 26, 0.92);
    --color-card: #edf5eb;
    --color-card-hover: #e2eee0;
}

/* Campfire */

[data-theme="campfire"] {
    --color-bg: #1c1408;
    --color-surface: #2a1e10;
    --color-header: #342414;
    --color-header-text: #ffe8c8;
    --color-accent: #ffaa22;
    --color-accent-soft: rgba(255, 170, 34, 0.2);
    --color-text: #ffe8d0;
    --color-text-muted: #d4a870;
    --color-link: #ffbb44;
    --color-border: #5a3c18;
    --color-triassic: #ff5544;
    --color-jurassic: #44ee66;
    --color-cretaceous: #44bbff;
    --color-badge-locked: #6a4c28;
    --color-badge-unlocked: #ffaa22;
    --color-badge-bg: #3e2c14;
    --color-footer-link: #e0a84c;
    --color-loading-bg: rgba(30, 22, 16, 0.95);
    --color-card: #2e2218;
    --color-card-hover: #38291e;
}

/* Deep Sea */

[data-theme="deep_sea"] {
    --color-bg: #081620;
    --color-surface: #0e2436;
    --color-header: #061420;
    --color-header-text: #88d0f8;
    --color-accent: #00ccff;
    --color-accent-soft: rgba(0, 204, 255, 0.18);
    --color-text: #d0eeff;
    --color-text-muted: #8ccce8;
    --color-link: #22ddff;
    --color-border: #1a3a58;
    --color-triassic: #ff5555;
    --color-jurassic: #33ff88;
    --color-cretaceous: #33bbff;
    --color-badge-locked: #204060;
    --color-badge-unlocked: #00ccff;
    --color-badge-bg: #122840;
    --color-footer-link: #60c0e0;
    --color-loading-bg: rgba(12, 26, 36, 0.95);
    --color-card: #16303f;
    --color-card-hover: #1a3848;
}

/* Volcano */

[data-theme="volcano"] {
    --color-bg: #140808;
    --color-surface: #241010;
    --color-header: #2c0a0a;
    --color-header-text: #ffe0d0;
    --color-accent: #ff4422;
    --color-accent-soft: rgba(255, 68, 34, 0.22);
    --color-text: #ffd8c8;
    --color-text-muted: #e08870;
    --color-link: #ff6644;
    --color-border: #5c2020;
    --color-triassic: #ff3322;
    --color-jurassic: #44dd66;
    --color-cretaceous: #44aaff;
    --color-badge-locked: #5c2828;
    --color-badge-unlocked: #ff6644;
    --color-badge-bg: #3c1414;
    --color-footer-link: #f0a080;
    --color-loading-bg: rgba(26, 14, 14, 0.95);
    --color-card: #301818;
    --color-card-hover: #3a1e1e;
}

/* Welcome overlay */

#welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--color-bg);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
#welcome-overlay.leaving {
    opacity: 0;
    transform: scale(1.04);
    pointer-events: none;
}
#welcome-overlay.gone { display: none; }

.welcome-card {
    max-width: 540px;
    width: 100%;
    text-align: center;
    margin: auto 0;
}

.welcome-dino {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 0.3rem;
    animation: dinoWalk 1.2s ease infinite alternate;
}

.welcome-title {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    color: var(--color-accent);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.welcome-subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.welcome-body {
    text-align: left;
    margin-bottom: 1.5rem;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.welcome-feature {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.8rem;
    background: var(--color-card, var(--color-surface));
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.3;
    color: var(--color-text);
}
.wf-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.welcome-btn {
    display: inline-block;
    padding: 0.85rem 2.5rem;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    margin-bottom: 1.2rem;
}
.welcome-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}
.welcome-btn:active {
    transform: translateY(0);
}

.welcome-share {
    text-align: center;
    margin-bottom: 1rem;
}
.welcome-share p {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 0.4rem;
}
.welcome-share-btn {
    display: inline-block;
    padding: 0.55rem 1.5rem;
    background: var(--color-card, var(--color-surface));
    border: 2px solid var(--color-accent);
    border-radius: 30px;
    color: var(--color-accent);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}
.welcome-share-btn:hover {
    background: var(--color-accent);
    color: #fff;
}

.welcome-privacy {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    padding: 0.7rem 1rem;
    background: var(--color-card, var(--color-surface));
    border-radius: 10px;
    margin-bottom: 1rem;
    text-align: left;
}
.welcome-privacy strong {
    color: var(--color-text);
}
.privacy-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}
.privacy-list li {
    padding: 0.2rem 0;
    font-size: 0.75rem;
    line-height: 1.45;
}
.privacy-list li strong {
    color: var(--color-text);
}

.welcome-parents {
    margin-bottom: 1rem;
    text-align: left;
}
.welcome-parents summary {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
    padding: 0.6rem 0.9rem;
    background: var(--color-card, var(--color-surface));
    border-radius: 10px;
    transition: all 0.2s ease;
    list-style: none;
}
.welcome-parents summary::-webkit-details-marker { display: none; }
.welcome-parents summary::after {
    content: '\25B6';
    font-size: 0.55rem;
    margin-left: auto;
    transition: transform 0.2s ease;
    color: var(--color-text-muted);
}
.welcome-parents[open] summary::after {
    transform: rotate(90deg);
}
.welcome-parents summary:hover {
    background: var(--color-accent);
    color: #fff;
}
.welcome-parents summary:hover::after { color: #fff; }
.parents-summary-icon { font-size: 1rem; }
.parents-content {
    padding: 0.8rem;
    margin-top: 0.5rem;
    background: var(--color-card, var(--color-surface));
    border-radius: 12px;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--color-text-muted);
}
.parents-content strong { color: var(--color-text); }
.parents-content a { color: var(--color-accent); font-weight: 600; }
.parents-intro {
    margin-bottom: 0.7rem;
}
.parents-tip-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
}
.parents-tip {
    display: flex;
    gap: 0.6rem;
    padding: 0.6rem 0.7rem;
    background: var(--color-surface);
    border-radius: 10px;
    border: 1px solid var(--color-border);
}
.parents-tip-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 0.1rem;
}
.parents-tip-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.parents-tip-body > strong {
    font-size: 0.8rem;
}
.parents-tip-body > span {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}
.parents-tip-steps {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin-top: 0.2rem;
    font-size: 0.68rem;
    color: var(--color-text-muted);
}
.parents-sources {
    padding: 0.55rem 0.7rem;
    background: var(--color-surface);
    border-radius: 10px;
    border: 1px solid var(--color-border);
}
.parents-sources > strong {
    display: block;
    font-size: 0.75rem;
    margin-bottom: 0.35rem;
}
.parents-source-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.parents-source-list a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.6rem;
    background: var(--color-card, var(--color-surface));
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    transition: all 0.15s ease;
}
.parents-source-list a:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.welcome-disclaimer {
    font-size: 0.62rem;
    color: var(--color-text-muted);
    opacity: 0.6;
    text-align: center;
    line-height: 1.4;
    margin-bottom: 0.6rem;
}
.welcome-footer {
    font-size: 0.68rem;
    color: var(--color-text-muted);
}
.welcome-footer a {
    color: var(--color-text-muted);
    font-weight: 600;
}
.welcome-footer a:hover { color: var(--color-accent); }
.welcome-footer .dot { margin: 0 0.25rem; opacity: 0.35; }

@media (max-width: 480px) {
    .welcome-title { font-size: 2rem; }
    .welcome-dino { font-size: 3rem; }
    .welcome-btn { padding: 0.7rem 2rem; font-size: 1rem; }
    .welcome-feature { font-size: 0.82rem; padding: 0.45rem 0.6rem; }
}

/* Reset */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Accessibility — skip link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-accent);
    color: #fff;
    padding: 0.5rem 1rem;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    z-index: 10001;
    transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }

/* Accessibility — screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Accessibility — focus indicators */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Accessibility — reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

body {
    display: flex;
    flex-direction: column;
}

/* Header */

#app-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem 1rem;
    background: var(--color-header);
    color: var(--color-header-text);
    flex-shrink: 0;
    z-index: 1000;
    flex-wrap: wrap;
}

.header-brand h1 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1;
}
.header-brand .tagline {
    font-size: 0.65rem;
    opacity: 0.6;
    display: block;
    letter-spacing: 0.02em;
}

.header-search {
    flex: 1;
    min-width: 160px;
    max-width: 320px;
}
.header-search input {
    width: 100%;
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-header-text);
    outline: none;
    transition: background var(--transition);
}
.header-search input::placeholder { color: rgba(255, 255, 255, 0.4); }
.header-search input:focus { background: rgba(255, 255, 255, 0.22); }

.header-filters {
    display: flex;
    gap: 0.25rem;
}

.filter-btn {
    padding: 0.45rem 0.75rem;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: transparent;
    color: var(--color-header-text);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.filter-btn:hover { background: rgba(255, 255, 255, 0.1); }
.filter-btn.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
    font-weight: 700;
}
.filter-btn.triassic.active  { background: var(--color-triassic); border-color: var(--color-triassic); }
.filter-btn.jurassic.active  { background: var(--color-jurassic); border-color: var(--color-jurassic); }
.filter-btn.cretaceous.active { background: var(--color-cretaceous); border-color: var(--color-cretaceous); }

/* Layout */

#app-main {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

#map {
    flex: 1;
    z-index: 1;
}

/* Stats Panel */

#stats-panel {
    width: 280px;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    overflow-y: auto;
    z-index: 500;
    flex-shrink: 0;
}

#stats-toggle {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 600;
    width: 32px;
    height: 32px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    color: var(--color-text-muted);
    transition: all var(--transition);
}
#stats-toggle:hover { background: var(--color-card); }
#stats-panel.collapsed #stats-toggle svg { transform: rotate(180deg); }

#stats-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.panel-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}
.site-counter {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* Stat cards */

.stat-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.7rem;
    background: var(--color-card);
    border-radius: var(--radius);
    transition: background var(--transition);
}
.stat-card:hover { background: var(--color-card-hover); }

.stat-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
}
.stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-accent);
    line-height: 1.1;
}
.stat-label {
    font-size: 0.68rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Period breakdown */

.period-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 0.7rem;
    background: var(--color-card);
    border-radius: var(--radius);
}

.period-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
}

.period-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.period-dot.triassic { background: var(--color-triassic); }
.period-dot.jurassic { background: var(--color-jurassic); }
.period-dot.cretaceous { background: var(--color-cretaceous); }

.period-name {
    flex: 1;
    font-weight: 500;
}

.period-count {
    font-weight: 700;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* Map legend */

.map-legend {
    padding: 0.5rem 0.7rem;
    background: var(--color-card);
    border-radius: var(--radius);
}
.map-legend h3 {
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}
.legend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    padding: 0.15rem 0;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #fff;
}
.legend-podcast {
    background: #ffcc00;
    border-color: #ff6600;
    box-shadow: 0 0 6px rgba(255, 200, 0, 0.6);
}

/* Badges */

#badges-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

#badges-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.badge-card {
    padding: 0.55rem 0.4rem;
    border-radius: var(--radius);
    text-align: center;
    background: var(--color-card);
    border: 2px solid var(--color-badge-locked);
    opacity: 0.4;
    transition: all 0.3s ease;
    position: relative;
}
.badge-card.unlocked {
    border-color: var(--color-badge-unlocked);
    opacity: 1;
    background: var(--color-badge-bg);
}
.badge-card.unlocked .badge-icon {
    animation: badgePop 0.4s ease;
}

.badge-icon {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 0.1rem;
}
.badge-name {
    font-size: 0.65rem;
    font-weight: 700;
    display: block;
    line-height: 1.2;
}
.badge-tier {
    font-size: 0.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-top: 0.05rem;
}

.badge-progress {
    margin-top: 0.3rem;
    height: 3px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}
.badge-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}
.badge-pct {
    font-size: 0.5rem;
    color: var(--color-text-muted);
    display: block;
    margin-top: 0.1rem;
}

@keyframes badgePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Badge toast notifications */

.badge-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    background: var(--color-surface);
    border: 2px solid #999;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
    pointer-events: none;
    white-space: nowrap;
}
.badge-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.badge-toast.hide {
    transform: translateX(-50%) translateY(120%);
    opacity: 0;
}
.badge-toast-icon {
    font-size: 1.6rem;
    animation: badgePop 0.4s ease 0.3s both;
}
.badge-toast-body {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}
.badge-toast-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}
.badge-toast-name {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--color-text);
}
.badge-toast-tier {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: capitalize;
}

/* Guided Tours */

#tours-section h3 {
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}
#tours-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.tour-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
    min-height: 36px;
}
.tour-item:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
}
.tour-item-icon { font-size: 1.1rem; flex-shrink: 0; }
.tour-item-info { display: flex; flex-direction: column; }
.tour-item-name { font-size: 0.72rem; font-weight: 700; color: var(--color-text); }
.tour-item-desc { font-size: 0.62rem; color: var(--color-text-muted); }

/* Tour panel overlay on map */
.tour-panel {
    position: absolute;
    top: 0.8rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    width: calc(100% - 2rem);
}
.tour-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}
.tour-step {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent);
}
.tour-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.tour-close:hover { color: var(--color-text); }
.tour-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 0.2rem;
}
.tour-text {
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--color-text-muted);
    margin-bottom: 0.4rem;
}
.tour-nav {
    display: flex;
    gap: 0.3rem;
    justify-content: flex-end;
}
.tour-nav-btn {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 32px;
    transition: all var(--transition);
}
.tour-nav-btn:hover { border-color: var(--color-accent); }
.tour-nav-primary {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}
.tour-nav-primary:hover { opacity: 0.9; }

/* Species Index */

#species-index-section {
    margin-bottom: 0;
}
#species-index-section > summary {
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0.3rem 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
#species-index-section > summary::-webkit-details-marker { display: none; }
#species-index-section > summary::before {
    content: '\25B6';
    font-size: 0.5rem;
    transition: transform 0.2s ease;
    color: var(--color-text-muted);
}
#species-index-section[open] > summary::before {
    transform: rotate(90deg);
}
.si-count-badge {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--color-text-muted);
}
#species-index-search {
    width: 100%;
    padding: 0.35rem 0.6rem;
    margin: 0.3rem 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.72rem;
}
#species-index-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.species-index-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.2rem 0.4rem;
    padding: 0.3rem 0.4rem;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
    min-height: 32px;
}
.species-index-item:hover {
    background: var(--color-card);
    border-color: var(--color-border);
}
.si-name {
    font-style: italic;
    font-weight: 700;
    font-size: 0.72rem;
    color: var(--color-text);
}
.si-count {
    font-size: 0.6rem;
    color: var(--color-text-muted);
}
.si-pron {
    font-size: 0.6rem;
    color: var(--color-text-muted);
    font-style: normal;
}
.si-more {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    text-align: center;
    padding: 0.3rem;
}

/* Quick actions + continent jumps */

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.action-btn {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.action-btn:hover {
    background: var(--color-card);
    border-color: var(--color-accent);
    color: var(--color-text);
}
.action-accent {
    background: var(--color-accent);
    color: #1a1a1a;
    border-color: var(--color-accent);
}
.action-accent:hover {
    opacity: 0.9;
    color: #1a1a1a;
}
.action-podcast {
    background: #ffcc00;
    color: #333;
    border-color: #ffaa00;
    font-weight: 700;
}
.action-podcast:hover {
    background: #ffdd33;
    color: #333;
}

.continent-jumps h3 {
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}
.continent-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.3rem;
}
.continent-btn {
    padding: 0.45rem 0.3rem;
    min-height: 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.continent-btn:hover {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

/* Progress actions */

#progress-actions {
    display: flex;
    gap: 0.3rem;
}

/* Panel footer */

.panel-footer {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    text-align: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
}
.panel-footer a { color: var(--color-text-muted); font-weight: 600; }
.panel-footer a:hover { color: var(--color-accent); }
.panel-footer .dot { margin: 0 0.25rem; opacity: 0.4; }
.panel-footer .support-link { color: var(--color-accent); font-weight: 700; }

/* Map popups */

.leaflet-popup-content {
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 10px 14px !important;
}

.popup-image-wrap {
    margin: -10px -14px 0.5rem -14px;
    max-height: 140px;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    background: #f0ebe3;
    text-align: center;
}
.popup-image-loading {
    padding: 1rem;
    font-size: 0.72rem;
    color: #aaa;
    font-style: italic;
}
.popup-hero-img {
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    display: block;
}

.site-popup {
    min-width: 240px;
    max-width: 300px;
    font-size: 0.82rem;
    line-height: 1.45;
}
.site-popup h3 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    color: #2c2416;
}
.site-popup .period-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fff;
    margin-bottom: 0.5rem;
}
.period-tag.triassic  { background: #e04040; }
.period-tag.jurassic  { background: #22b855; }
.period-tag.cretaceous { background: #3388dd; }

.site-popup .detail-row {
    margin: 0.2rem 0;
    font-size: 0.82rem;
}
.site-popup .detail-label {
    font-weight: 700;
    color: #666;
    margin-right: 0.25rem;
}

.popup-world {
    margin: 0.5rem 0;
    padding: 0.45rem 0.6rem;
    background: #f0ebe3;
    border-left: 3px solid #d4a84c;
    border-radius: 0 6px 6px 0;
    font-size: 0.78rem;
    color: #5a4a30;
    line-height: 1.4;
}

.popup-fact {
    margin: 0.5rem 0;
    padding: 0.45rem 0.6rem;
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
    border-radius: 0 6px 6px 0;
    font-size: 0.78rem;
    color: #2e5a2e;
    line-height: 1.4;
}

.popup-species-header {
    font-size: 0.78rem;
    font-weight: 700;
    color: #555;
    margin-top: 0.4rem;
}

.site-popup .species-list {
    margin: 0.25rem 0 0.2rem 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.site-popup .species-list li {
    font-size: 0.78rem;
    line-height: 1.3;
}
.site-popup .species-list li .species-podcast-dot,
.site-popup .species-list li .species-diet {
    font-style: normal;
    font-size: 0.7rem;
    cursor: default;
}
.site-popup .species-list li .species-name {
    font-style: italic;
    font-weight: 600;
}
.species-pron {
    font-style: normal;
    font-size: 0.65rem;
    color: #888;
    font-weight: 400;
}
.species-size {
    display: block;
    font-style: normal;
    font-size: 0.65rem;
    color: #777;
    margin-top: 0.05rem;
}
.site-popup .species-list .more-species {
    font-style: normal;
    color: #999;
    font-size: 0.72rem;
}

.wiki-extract-text {
    margin: 0.4rem 0;
    padding: 0.5rem 0.6rem;
    background: #faf6f0;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #444;
}

.popup-links {
    margin-top: 0.4rem;
}
.popup-wiki-link {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1a73e8;
}

.site-popup .visited-tag {
    display: inline-block;
    margin: 0.4rem 0.3rem 0.2rem 0;
    padding: 0.2rem 0.6rem;
    background: #e040fb;
    color: #fff;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 700;
}

/* Timeline in popups */

.timeline-bar {
    position: relative;
    height: 18px;
    background: #e8e0d4;
    border-radius: 9px;
    margin: 0.4rem 0 0.15rem;
    overflow: hidden;
}
.timeline-period {
    position: absolute;
    top: 0;
    height: 100%;
    opacity: 0.35;
    display: flex;
    align-items: center;
    justify-content: center;
}
.timeline-period-label {
    font-size: 0.55rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}
.timeline-marker {
    position: absolute;
    top: 2px;
    height: calc(100% - 4px);
    background: var(--color-text);
    border-radius: 6px;
    opacity: 0.8;
    min-width: 4px;
}
.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.55rem;
    color: #999;
}
.timeline-age {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 0.2rem;
}

/* Geology info in popups */

.geology-info {
    margin: 0.3rem 0;
    padding: 0.4rem 0.5rem;
    background: #f0ebe3;
    border-radius: 8px;
    border-left: 3px solid #8d6e4c;
}
.geology-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: #6b5340;
    margin-bottom: 0.15rem;
}
.geology-name {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #444;
}
.geology-lith {
    display: block;
    font-size: 0.65rem;
    color: #777;
    font-style: italic;
}
.geology-period {
    display: inline-block;
    font-size: 0.6rem;
    color: #999;
    margin-top: 0.1rem;
}
#geology-toggle.active {
    background: #8d6e4c;
    color: #fff;
    border-color: #8d6e4c;
}

/* Addon panels */
.addon-panel { margin-bottom: 0.5rem; }

/* Food web in popups */

.foodweb {
    margin: 0.4rem 0;
    padding: 0.45rem 0.5rem;
    background: #f5f0e8;
    border-radius: 8px;
}
.foodweb-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 0.3rem;
}
.foodweb-grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.foodweb-group {
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.6);
}
.foodweb-icon { font-size: 0.85rem; flex-shrink: 0; }
.foodweb-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #444;
    white-space: nowrap;
}
.foodweb-names {
    font-size: 0.62rem;
    font-style: italic;
    color: #777;
    margin-left: 0.2rem;
}
.foodweb-narrative {
    margin-top: 0.3rem;
    font-size: 0.68rem;
    line-height: 1.4;
    color: #666;
    font-style: italic;
}

.podcast-embed {
    margin-top: 0.6rem;
    border-top: 1px solid #eee;
    padding-top: 0.5rem;
}
.podcast-embed-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.35rem;
}
.podcast-embed iframe {
    border-radius: 8px;
    max-width: 100%;
}
/* Expedition Log in popups */

.expedition-log-section {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
}
.elog-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 0.25rem;
}
.elog-icon { font-size: 0.9rem; }
.elog-input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: inherit;
    line-height: 1.4;
    resize: vertical;
    min-height: 40px;
    color: #333;
    background: #faf8f5;
}
.elog-input:focus {
    border-color: var(--color-accent);
    outline: none;
}
.elog-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}
.elog-save {
    padding: 0.25rem 0.6rem;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 28px;
}
.elog-save:hover { opacity: 0.9; }
.elog-saved-date {
    font-size: 0.6rem;
    color: #999;
}

.podcast-play-btn {
    margin-top: 0.3rem;
    width: 100%;
}

/* Podcast star markers on map */

.podcast-star {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ffaa00;
    text-shadow: 0 0 6px rgba(255, 140, 0, 0.8), 0 0 12px rgba(255, 170, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
    line-height: 1;
    -webkit-text-stroke: 0.5px #c77700;
}
.podcast-star.visited {
    color: #e040fb;
    text-shadow: 0 0 4px rgba(224, 64, 251, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
}
.legend-star {
    font-size: 0.9rem;
    color: #ffcc00;
    margin-right: 0.1rem;
}

/* Quiz panel */

.quiz-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 900;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: calc(100% - 2rem);
}
.quiz-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.quiz-progress {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}
.quiz-score {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--color-accent);
}
.quiz-prompt {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.6rem;
    line-height: 1.5;
}
.quiz-clues {
    margin-top: 0.3rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-text-muted);
}
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.quiz-option {
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-card);
    color: var(--color-text);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    min-height: 36px;
}
.quiz-option:hover:not(:disabled) {
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
}
.quiz-option:disabled { cursor: default; opacity: 0.8; }
.quiz-correct {
    background: #4caf50 !important;
    color: #fff !important;
    border-color: #4caf50 !important;
}
.quiz-wrong {
    background: #ef5350 !important;
    color: #fff !important;
    border-color: #ef5350 !important;
}
.quiz-results {
    text-align: center;
}
.quiz-results-score {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-accent);
    margin-bottom: 0.2rem;
}
.quiz-results-msg {
    font-size: 0.85rem;
    color: var(--color-text);
    margin-bottom: 0.8rem;
}
.quiz-results-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

/* Now Playing — compact sidebar section */

.now-playing {
    background: var(--color-card);
    border: 1px solid #ffcc00;
    border-radius: var(--radius);
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.5rem;
}
.now-playing-header {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.25rem;
}
.now-playing-icon {
    font-size: 0.85rem;
}
.now-playing-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.now-playing-close {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.now-playing-close:hover {
    color: var(--color-text);
}
.now-playing-embed {
    overflow: hidden;
    border-radius: var(--radius-sm);
}
.now-playing-embed iframe {
    display: block;
    width: 100%;
    height: 200px;
    border: none;
    border-radius: var(--radius-sm);
}

/* Marker cluster overrides */

.marker-cluster {
    border-radius: 50%;
}

.cluster-triassic {
    background: rgba(192, 57, 43, 0.25);
}
.cluster-triassic div {
    background: var(--color-triassic);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    margin: 5px;
}

.cluster-jurassic {
    background: rgba(39, 174, 96, 0.25);
}
.cluster-jurassic div {
    background: var(--color-jurassic);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    margin: 5px;
}

.cluster-cretaceous {
    background: rgba(36, 113, 163, 0.25);
}
.cluster-cretaceous div {
    background: var(--color-cretaceous);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    margin: 5px;
}

.cluster-mixed {
    background: rgba(150, 130, 100, 0.25);
}
.cluster-mixed div {
    background: #6b5b45;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
    margin: 5px;
}

/* Loading overlay */

#loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-loading-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}
#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.loading-content {
    text-align: center;
    color: #fff;
}
.loading-dino {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: dinoWalk 1s ease infinite alternate;
}
@keyframes dinoWalk {
    0% { transform: translateX(-8px) scaleX(1); }
    100% { transform: translateX(8px) scaleX(-1); }
}
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    margin: 0 auto 0.8rem;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content p {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Theme Picker */

.header-lang select {
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-header-text);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
    cursor: pointer;
    outline: none;
    transition: background var(--transition);
}
.header-lang select:hover,
.header-lang select:focus { background: rgba(255, 255, 255, 0.22); }
.header-lang select option { color: #333; background: #fff; }

.header-theme { position: relative; }

#theme-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: var(--color-header-text);
    width: 32px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
#theme-toggle:hover { background: rgba(255, 255, 255, 0.12); }

#theme-picker {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: all 0.2s ease;
    z-index: 1100;
}
#theme-picker.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#theme-picker-list {
    display: flex;
    gap: 0.35rem;
}

.theme-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
}
.theme-swatch:hover { transform: scale(1.2); }
.theme-swatch.active {
    border-color: var(--color-text);
    box-shadow: 0 0 0 2px var(--color-surface);
}

/* Footer */

#app-footer {
    padding: 0.4rem 1rem;
    background: var(--color-header);
    color: var(--color-header-text);
    font-size: 0.7rem;
    text-align: center;
    flex-shrink: 0;
    z-index: 1000;
    opacity: 0.85;
}
#app-footer a { color: var(--color-footer-link); }
#app-footer .dot { margin: 0 0.3rem; opacity: 0.3; }
.footer-creed {
    display: block;
    text-align: center;
    margin-top: 0.3rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    opacity: 0.7;
}

/* Mobile floating journal button + backdrop */

.mobile-journal-btn {
    display: none;
    position: absolute;
    bottom: 1.2rem;
    right: 1rem;
    z-index: 800;
    width: 48px;
    height: 48px;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.mobile-journal-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.mobile-journal-btn:active { transform: scale(0.95); }

.mobile-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 499;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.mobile-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive — tablet */

@media (max-width: 768px) {
    #app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        padding: 0.35rem 0.6rem;
    }
    .header-brand { display: flex; align-items: baseline; gap: 0.5rem; }
    .header-brand h1 { font-size: 1.1rem; }
    .header-brand .tagline { display: none; }
    .header-search { max-width: none; }
    .header-filters { justify-content: center; }

    #stats-panel {
        position: absolute;
        top: 0;
        right: 0;
        height: 100%;
        width: 300px;
        max-width: 85vw;
        box-shadow: var(--shadow-lg);
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    #stats-panel.open { transform: translateX(0); }
    #stats-toggle { display: flex; }

    .mobile-journal-btn { display: flex; }
    .mobile-backdrop { display: block; }
}

/* Responsive — phone */

@media (max-width: 480px) {
    #app-header {
        gap: 0.25rem;
        padding: 0.3rem 0.5rem;
    }
    .header-brand h1 { font-size: 1rem; }
    .header-search input { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
    .header-filters { gap: 0.15rem; }
    .filter-btn { padding: 0.22rem 0.45rem; font-size: 0.68rem; }
    .header-theme { position: absolute; top: 0.3rem; right: 0.5rem; }

    #stats-panel { width: 100%; max-width: none; }

    .stat-cards { gap: 0.35rem; }
    .stat-card { padding: 0.5rem; }
    .stat-icon { font-size: 1.2rem; }
    .stat-value { font-size: 1.1rem; }

    .mobile-journal-btn {
        bottom: 0.8rem;
        right: 0.6rem;
        width: 44px;
        height: 44px;
    }

    #app-footer { font-size: 0.6rem; padding: 0.3rem 0.5rem; }
    #app-footer .dot { margin: 0 0.15rem; }

    .leaflet-popup-content { margin: 8px 10px !important; max-height: 55vh; }
    .leaflet-popup { max-width: calc(100vw - 30px) !important; }
}

/* Keyboard-safe: shrink header when search focused on mobile */
@media (max-width: 768px) {
    #search-input:focus ~ .header-filters,
    #app-header:has(#search-input:focus) .header-filters {
        display: none;
    }
    #app-header:has(#search-input:focus) .header-theme {
        display: none;
    }
}
