/* ============================================================
   Wonders of Océania — Design system
   ============================================================ */

:root {
    /* Marque — lagon */
    --lagoon-50:  #f0fdfa;
    --lagoon-100: #ccf4ee;
    --lagoon-200: #99e6dd;
    --lagoon-500: #0d9488;
    --lagoon-600: #0f766e;
    --lagoon-700: #115e59;
    --sand-500:   #d97706;
    --sand-600:   #b45309;

    /* Neutres */
    --gray-0:   #ffffff;
    --gray-50:  #f7f9fb;
    --gray-100: #eef2f6;
    --gray-200: #e3e8ef;
    --gray-300: #cfd8e3;
    --gray-400: #9aa7b8;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;

    /* Rôles */
    --primary: var(--lagoon-600);
    --primary-hover: var(--lagoon-700);
    --secondary: var(--sand-500);
    --bg: var(--gray-50);
    --surface: var(--gray-0);
    --surface-2: var(--gray-100);
    --border: var(--gray-200);
    --text: var(--gray-900);
    --text-soft: var(--gray-500);

    /* Forme */
    --r-xs: 8px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-full: 999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .09), 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, .09), 0 2px 6px rgba(15, 23, 42, .05);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, .16), 0 4px 12px rgba(15, 23, 42, .08);

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --animate-duration: 0.5s;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --surface: #131c2b;
        --surface-2: #1c2739;
        --border: #263247;
        --text: #e8edf4;
        --text-soft: #9aa7b8;
        --primary: #2dd4bf;
        --primary-hover: #5eead4;
        --secondary: #fbbf24;
        --shadow-md: 0 6px 16px rgba(0, 0, 0, .4);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
}

body {
    display: flex;
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.01em; }

/* ---------- SIDEBAR ---------- */
#sidebar {
    width: 400px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

/* ---------- HEADER / MARQUE ---------- */
.header {
    padding: calc(1rem + var(--safe-top)) 1.1rem 0.9rem;
    background:
        radial-gradient(120% 120% at 12% -10%, rgba(255, 255, 255, .16), transparent 55%),
        linear-gradient(158deg, var(--lagoon-600) 0%, var(--lagoon-700) 100%);
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.header::after {
    content: '';
    position: absolute;
    top: calc(var(--safe-top) - 6px);
    right: -14px;
    width: 132px;
    height: 100px;
    background: url("../images/sp-roussette.png") no-repeat right top;
    background-size: contain;
    opacity: 0.12;
    transform: rotate(-6deg);
    pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .22);
    flex-shrink: 0;
}
.brand-text { flex: 1; min-width: 0; }
.brand-text h1 {
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.015em;
}
.brand-text p { font-size: 0.73rem; opacity: 0.82; margin-top: 2px; }

.help-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s var(--ease-spring), background 0.2s;
}
.help-btn:hover { background: rgba(255, 255, 255, 0.28); }
.help-btn:active { transform: scale(0.85); }

.gps-status-card {
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--r-sm);
    padding: 0.45rem 0.65rem;
    margin-top: 0.85rem;
    font-size: 0.72rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.gps-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f87171;
    display: inline-block;
    margin-right: 5px;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, .25);
}
.gps-active { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .3); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: 0.45; } }

.btn-group { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.action-btn {
    flex: 1;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: white;
    border-radius: var(--r-xs);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}
.action-btn:hover { background: rgba(255, 255, 255, 0.24); }
#engage-btn { transition: background 0.2s ease; }

.engage-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.45rem;
    padding: 0.4rem 0.55rem;
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--r-xs);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.92);
}
.engage-row select {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
    padding: 0.2rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
}
.engage-row select option { color: #0f172a; }
.engage-mini {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
}
.engage-mini:hover { background: rgba(255, 255, 255, 0.3); }
.engage-mini.off { border-color: rgba(255, 200, 200, 0.6); }

.user-card {
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, .14);
    padding: 0.6rem 0.75rem;
    border-radius: var(--r-sm);
    margin-top: 0.6rem;
}
.user-card .row {
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 700;
}
.progress-bar {
    background: rgba(0, 0, 0, 0.22);
    height: 7px;
    border-radius: var(--r-full);
    overflow: hidden;
    margin-top: 0.45rem;
}
.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: var(--r-full);
    background-image: linear-gradient(110deg, var(--secondary), #fbbf24 45%, var(--secondary));
    background-size: 200% 100%;
    animation: shimmer 2.8s linear infinite;
    transition: width 0.55s var(--ease-out);
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.user-card .sub { font-size: 0.68rem; opacity: 0.82; margin-top: 0.3rem; text-align: right; }

/* ---------- ONGLETS ---------- */
.tabs {
    display: flex;
    gap: 0.15rem;
    padding: 0 0.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: 0 0 auto;
    position: relative;
    padding: 0.85rem 0.7rem;
    border: none;
    background: none;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-soft);
    white-space: nowrap;
    transition: color 0.2s ease;
}
.tab-btn::after {
    content: '';
    position: absolute;
    left: 50%;
    right: 50%;
    bottom: -1px;
    height: 2.5px;
    border-radius: 3px 3px 0 0;
    background: var(--primary);
    transition: left 0.28s var(--ease-out), right 0.28s var(--ease-out);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after { left: 0.35rem; right: 0.35rem; }

/* ---------- CONTENU ---------- */
.tab-content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.9rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.content-panel { display: none; }
.content-panel.active { display: block; animation: fadeInUp 0.35s var(--ease-out) both; }

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.7rem;
    color: var(--text);
}

/* ---------- CARTES ---------- */
.site-card {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 0.95rem;
    margin-bottom: 0.7rem;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: transform 0.16s var(--ease-out), box-shadow 0.2s ease, border-color 0.2s ease;
}
.site-card.clickable { cursor: pointer; }
.site-card h3 { color: var(--text); font-size: 0.95rem; font-weight: 650; }
.site-card .meta { font-size: 0.75rem; color: var(--text-soft); margin-top: 0.15rem; }
.site-card .body { font-size: 0.83rem; color: var(--text-soft); margin-top: 0.4rem; }
.site-card .pts { font-weight: 700; font-size: 0.82rem; color: var(--secondary); white-space: nowrap; }

@media (hover: hover) {
    .site-card.clickable:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
        border-color: var(--lagoon-200);
    }
}
.site-card:active { transform: scale(0.995); }

/* ---------- CHAMPS & FILTRES ---------- */
.search-input,
.filter-row select {
    width: 100%;
    padding: 0.62rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input { margin-bottom: 0.6rem; }
.search-input:focus,
.filter-row select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--lagoon-100);
}

.filter-row { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; }
.filter-row select { flex: 1; min-width: 0; cursor: pointer; -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    padding-right: 1.8rem;
}

.chip-row { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.chip {
    padding: 0.4rem 0.8rem;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-soft);
    cursor: pointer;
    transition: all 0.16s var(--ease-out);
}
.chip:hover { border-color: var(--gray-300); color: var(--text); }
.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.chip:active { transform: scale(0.94); }

.empty-note {
    text-align: center;
    color: var(--text-soft);
    font-size: 0.86rem;
    padding: 1.4rem 1rem 2rem;
}
.empty-note::before {
    content: '';
    display: block;
    height: 90px;
    margin-bottom: 0.5rem;
    background: url("../images/sp-cagou.png") no-repeat center / contain;
    opacity: 0.85;
}

/* ---------- BOUTONS D'ACTION ---------- */
.btn-row { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
.photo-btn, .route-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    border-radius: var(--r-sm);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: transform 0.12s var(--ease-spring), filter 0.15s ease, background 0.2s ease;
}
.route-btn { background: var(--primary); color: #fff; }
.route-btn:hover { background: var(--primary-hover); }
.photo-btn { background: var(--lagoon-50); color: var(--lagoon-700); box-shadow: inset 0 0 0 1px var(--lagoon-100); }
.photo-btn:hover:not(:disabled) { background: var(--lagoon-100); }
.photo-btn:disabled { background: var(--surface-2); color: var(--text-soft); cursor: not-allowed; box-shadow: inset 0 0 0 1px var(--border); }
.route-btn:active, .photo-btn:active:not(:disabled), .action-btn:active { transform: scale(0.95); filter: brightness(0.96); }

@media (prefers-color-scheme: dark) {
    .photo-btn { background: rgba(45, 212, 191, .12); color: var(--primary-hover); box-shadow: inset 0 0 0 1px rgba(45, 212, 191, .22); }
}

/* ---------- QUIZ ---------- */
.quiz-category {
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}
.quiz-option {
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.8rem;
    margin-top: 0.45rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 0.83rem;
    transition: transform 0.1s var(--ease-spring), border-color 0.15s, background 0.15s;
}
.quiz-option:not(:disabled):hover { border-color: var(--primary); background: var(--lagoon-50); }
.quiz-option:active:not(:disabled) { transform: scale(0.985); }
.quiz-option.correct { background: #dcfce7 !important; border-color: #22c55e !important; color: #14532d !important; }
.quiz-option.wrong { background: #fee2e2 !important; border-color: #ef4444 !important; color: #7f1d1d !important; }

.quiz-head {
    position: sticky;
    top: -0.9rem;
    background: var(--surface);
    padding: 0.6rem 0 0.7rem;
    margin-bottom: 0.3rem;
    z-index: 5;
}
.quiz-progress-bar {
    height: 8px;
    background: var(--surface-2);
    border-radius: var(--r-full);
    overflow: hidden;
}
#quiz-progress-fill {
    height: 100%;
    width: 0;
    border-radius: var(--r-full);
    background: linear-gradient(90deg, var(--lagoon-500), var(--lagoon-600));
    transition: width 0.5s var(--ease-spring);
}
.quiz-head p { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.4rem; }
.quiz-head b { color: var(--text); }

.quiz-result {
    text-align: center;
    padding: 1.5rem 1rem;
    border: 1px solid var(--lagoon-200);
    border-radius: var(--r-lg);
    background: var(--lagoon-50);
    margin-bottom: 1rem;
}
.quiz-result .big { font-size: 2.8rem; }
.quiz-result h3 { color: var(--lagoon-700); font-size: 1.1rem; margin: 0.35rem 0; }
.quiz-result p { font-size: 0.85rem; color: var(--text-soft); }
.quiz-result button {
    margin-top: 1rem;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--secondary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
@media (prefers-color-scheme: dark) {
    .quiz-result { background: rgba(45, 212, 191, .08); }
    .quiz-result h3 { color: var(--primary-hover); }
    .quiz-option.correct { background: rgba(34, 197, 94, .18) !important; color: #bbf7d0 !important; }
    .quiz-option.wrong { background: rgba(239, 68, 68, .18) !important; color: #fecaca !important; }
}

/* ---------- CHRONOLOGIE ---------- */
.timeline {
    position: relative;
    padding-left: 1.3rem;
    border-left: 2px solid var(--lagoon-200);
    margin: 0.4rem 0.2rem;
}
.timeline-item { position: relative; margin-bottom: 1.1rem; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.66rem;
    top: 0.2rem;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--secondary);
    border: 2.5px solid var(--surface);
    box-shadow: 0 0 0 1px var(--lagoon-200);
}
.timeline-date { font-weight: 700; font-size: 0.82rem; color: var(--primary); }
.timeline-item p { font-size: 0.83rem; margin-top: 0.2rem; color: var(--text-soft); }

/* ---------- PASSEPORT ---------- */
.stamps-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
.stamp-card {
    border: 1.5px dashed var(--gray-300);
    border-radius: var(--r-md);
    padding: 0.7rem;
    text-align: center;
    background: var(--surface);
    opacity: 0.75;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.stamp-card > div:first-child { font-size: 1.2rem; }
.stamp-card .name {
    font-size: 0.75rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.1rem;
}
.stamp-card .p { font-size: 0.65rem; color: var(--text-soft); margin-top: 0.1rem; }
.stamp-card .p.win { color: var(--secondary); font-weight: 700; }
.stamp-card.unlocked {
    border-style: solid;
    border-color: var(--secondary);
    background: linear-gradient(180deg, #fffbeb, var(--surface));
    opacity: 1;
}
@media (prefers-color-scheme: dark) {
    .stamp-card.unlocked { background: rgba(217, 119, 6, .1); }
}
@media (hover: hover) {
    .stamp-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
}
.stamp-photo { width: 100%; height: 74px; object-fit: cover; border-radius: var(--r-xs); margin-top: 0.35rem; }

/* ---------- MARQUEURS CARTE ---------- */
#map { flex: 1; height: 100%; width: 100%; z-index: 1; background: #dfe7ea; }

.custom-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    border: 2px solid white;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s var(--ease-spring);
    animation: markerDrop 0.45s var(--ease-spring) both;
}
.custom-pin > span { font-size: 13px; line-height: 1; }
.leaflet-marker-icon:hover .custom-pin { transform: scale(1.16); z-index: 5; }

@keyframes markerDrop {
    0%   { transform: translateY(-22px) scale(0.6); opacity: 0; }
    70%  { transform: translateY(3px) scale(1.04); opacity: 1; }
    100% { transform: translateY(0) scale(1); }
}

.user-position-pin {
    background: #2563eb;
    border: 3px solid white;
    animation: pulse-user 1.6s infinite;
}
@keyframes pulse-user {
    0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.55); }
    70%  { box-shadow: 0 0 0 14px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.pin-blue { background-color: #2563eb; }
.pin-green { background-color: #16a34a; }
.pin-red { background-color: #dc2626; }
.pin-red { animation: markerDrop 0.45s var(--ease-spring) both, pulse-red 1s ease-in-out infinite 0.5s; }
@keyframes pulse-red {
    0%, 100% { box-shadow: 0 3px 8px rgba(0, 0, 0, .35), 0 0 0 0 rgba(220, 38, 38, .5); }
    50% { box-shadow: 0 3px 8px rgba(0, 0, 0, .35), 0 0 0 10px rgba(220, 38, 38, 0); }
}

.leaflet-popup-content-wrapper { border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.leaflet-popup-content { margin: 0.85rem 1rem; font-size: 0.82rem; }
.popup-btn {
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    border: none;
    border-radius: var(--r-xs);
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
}
.popup-btn.primary { background: var(--primary); color: #fff; }
.popup-btn.ghost { background: var(--surface-2); color: var(--text); }

@keyframes dashMove { to { stroke-dashoffset: -100; } }
.leaflet-overlay-pane path[stroke-dasharray] { animation: dashMove 3s linear infinite; }

/* ---------- ANIMATIONS PARTAGÉES ---------- */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn {
    0% { opacity: 0; transform: scale(0.85); }
    60% { opacity: 1; transform: scale(1.03); }
    100% { transform: scale(1); }
}
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.content-panel.active .site-card,
.content-panel.active .timeline-item,
.content-panel.active .stamp-card { animation: fadeInUp 0.4s var(--ease-out) both; }
.content-panel.active .site-card:nth-child(1) { animation-delay: .02s; }
.content-panel.active .site-card:nth-child(2) { animation-delay: .06s; }
.content-panel.active .site-card:nth-child(3) { animation-delay: .10s; }
.content-panel.active .site-card:nth-child(4) { animation-delay: .14s; }
.content-panel.active .site-card:nth-child(5) { animation-delay: .18s; }
.content-panel.active .site-card:nth-child(n+6) { animation-delay: .22s; }

.route-btn, .photo-btn, .action-btn, .quiz-option, .tab-btn, .chip, .onb-btn {
    transition: transform 0.12s var(--ease-spring), filter 0.15s ease, background 0.2s ease;
}

/* ---------- TOASTS ---------- */
#toast-container {
    position: fixed;
    top: calc(var(--safe-top) + 14px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 6000;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: min(92vw, 400px);
    pointer-events: none;
}
.toast {
    background: var(--surface);
    color: var(--text);
    padding: 0.8rem 0.95rem;
    border-radius: var(--r-md);
    font-size: 0.83rem;
    line-height: 1.4;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}
.toast::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--primary);
}
.toast.success::before { background: #22c55e; }
.toast.error::before { background: #ef4444; }
.toast.info::before { background: var(--secondary); }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast b { font-weight: 700; }

/* ---------- OVERLAYS ---------- */
#onboarding {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(9, 15, 26, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#onboarding.visible { opacity: 1; pointer-events: auto; }

.onb-card {
    background: var(--surface);
    color: var(--text);
    border-radius: var(--r-lg);
    width: min(100%, 400px);
    max-height: 90dvh;
    overflow-y: auto;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: translateY(24px) scale(0.95);
    transition: transform 0.4s var(--ease-spring);
    position: relative;
}
#onboarding.visible .onb-card { transform: translateY(0) scale(1); }

.onb-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.8);
    background: rgba(15, 23, 42, 0.4);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: transform 0.15s var(--ease-spring), background 0.15s;
}
.onb-close:hover { background: rgba(15, 23, 42, 0.65); }
.onb-close:active { transform: scale(0.86); }

.onb-hero {
    position: relative;
    aspect-ratio: 400 / 168;
    max-height: 190px;
    background: var(--lagoon-100);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    overflow: hidden;
}
.onb-hero #onb-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}
.onb-mascot {
    position: absolute;
    right: 4px;
    bottom: 2px;
    height: 46%;
    width: auto;
    filter: drop-shadow(-2px 3px 4px rgba(0, 0, 0, 0.22));
    pointer-events: none;
}
.onb-hero img.swap { animation: heroSwap 0.4s var(--ease-out) both; }
@keyframes heroSwap {
    from { opacity: 0; transform: scale(1.04); }
    to   { opacity: 1; transform: scale(1); }
}
.onb-body { padding: 0 1.5rem 1.4rem; }
.onb-emoji {
    width: 56px;
    height: 56px;
    margin: -28px auto 0.7rem;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    background: var(--surface);
    border: 3px solid var(--surface);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
}
.onb-emoji.pop { animation: onbBadge 0.5s var(--ease-spring) both; }
@keyframes onbBadge {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.12); opacity: 1; }
    100% { transform: scale(1); }
}
.onb-card h2 { color: var(--text); font-size: 1.25rem; margin-bottom: 0.45rem; }
.onb-card p { font-size: 0.9rem; color: var(--text-soft); line-height: 1.55; }

.onb-dots { display: flex; gap: 0.4rem; justify-content: center; margin: 1.2rem 0; }
.onb-dot { width: 7px; height: 7px; border-radius: var(--r-full); background: var(--gray-300); transition: all 0.25s var(--ease-out); }
.onb-dot.active { background: var(--primary); width: 22px; }

.onb-actions { display: flex; gap: 0.6rem; }
.onb-btn {
    flex: 1;
    padding: 0.82rem;
    border-radius: var(--r-sm);
    border: none;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}
.onb-btn:active { transform: scale(0.96); }
.onb-btn.primary { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }
.onb-btn.primary:hover { background: var(--primary-hover); }
.onb-btn.ghost { background: var(--surface-2); color: var(--text-soft); }
.onb-skip {
    margin-top: 0.85rem;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
}

/* Détail plein écran */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 5200;
    background: rgba(9, 15, 26, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.overlay.visible { opacity: 1; pointer-events: auto; }

.detail-card {
    background: var(--surface);
    color: var(--text);
    width: min(100%, 540px);
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding-bottom: calc(1.1rem + var(--safe-bottom));
    box-shadow: var(--shadow-lg);
    transform: translateY(28px);
    transition: transform 0.32s var(--ease-spring);
    position: relative;
}
.overlay.visible .detail-card { transform: translateY(0); }
@media (min-width: 620px) {
    .overlay { align-items: center; }
    .detail-card { border-radius: var(--r-lg); padding-bottom: 1.1rem; max-height: 88dvh; }
}

/* Bouton fermer : toujours visible, fixé à l'écran (ne défile jamais) */
.overlay-close {
    position: fixed;
    top: calc(var(--safe-top) + 12px);
    right: 12px;
    z-index: 5300;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: rgba(15, 23, 42, 0.6);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: var(--shadow-md);
    transition: transform 0.15s var(--ease-spring), background 0.15s ease;
}
.overlay-close:hover { background: rgba(15, 23, 42, 0.82); }
.overlay-close:active { transform: scale(0.86); }
@media (min-width: 620px) {
    /* grand écran : bouton accroché au coin haut-droit de la fiche centrée */
    .overlay-close {
        top: max(calc(6dvh - 6px), 14px);
        right: max(calc(50vw - 270px - 6px), 14px);
    }
}
#detail-map { width: 100%; height: 210px; background: var(--surface-2); }
#detail-map.detail-map-inline {
    border-radius: var(--r-md);
    overflow: hidden;
    margin: 1rem 0 0.2rem;
    border: 1px solid var(--border);
    height: 180px;
}
.detail-hero { width: 100%; height: 220px; object-fit: cover; display: block; background: var(--surface-2); }

.detail-hero-wrap { position: relative; margin: 0; }
.detail-hero-wrap.failed { display: none; }
.detail-hero-wrap figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.9rem 0.7rem 0.4rem;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.92);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}
.detail-hero-wrap figcaption a { color: #fff; text-decoration: underline; }

.credits-list h2 { margin-bottom: 0.5rem; }
.credits-list ul { list-style: none; margin: 0.8rem 0; }
.credits-list li {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-soft);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.credits-list a { color: var(--primary); font-weight: 600; }

.onb-credits {
    display: block;
    margin: 0.35rem auto 0;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 0.72rem;
    text-decoration: underline;
    cursor: pointer;
}
.detail-inner { padding: 1.1rem 1.2rem; }
.detail-inner h2 { color: var(--text); font-size: 1.2rem; margin-bottom: 0.15rem; }
.detail-region { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 0.6rem; }
.detail-badge {
    display: inline-block;
    background: var(--lagoon-50);
    color: var(--lagoon-700);
    border: 1px solid var(--lagoon-100);
    border-radius: var(--r-full);
    padding: 0.18rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 700;
    margin: 0 0.35rem 0.7rem 0;
}
.detail-badge.ok { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.detail-desc { font-size: 0.92rem; line-height: 1.6; color: var(--text); margin-bottom: 1rem; }
.detail-meta { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.8rem; }

.detail-sec { margin: 1.1rem 0 0; }
.detail-sec h3 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
    margin-bottom: 0.5rem;
}
.detail-voir { list-style: none; display: grid; gap: 0.4rem; }
.detail-voir li {
    position: relative;
    padding-left: 1.15rem;
    font-size: 0.87rem;
    line-height: 1.45;
    color: var(--text);
}
.detail-voir li::before { content: '▸'; position: absolute; left: 0; color: var(--primary); font-size: 0.8rem; }

.detail-facts {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.fact {
    display: flex;
    gap: 0.55rem;
    padding: 0.6rem 0.75rem;
    background: var(--surface-2);
    align-items: baseline;
    font-size: 0.85rem;
}
.fact + .fact { border-top: 1px solid var(--border); }
.fact .fi { flex-shrink: 0; }
.fact .fk {
    flex-shrink: 0;
    width: 74px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-soft);
    line-height: 1.5;
}
.fact .fv { color: var(--text); line-height: 1.5; }
@media (max-width: 400px) {
    .fact { flex-wrap: wrap; }
    .fact .fk { width: auto; flex-basis: calc(100% - 1.5rem); }
    .fact .fv { flex-basis: 100%; padding-left: 1.5rem; }
}

.detail-tip {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--lagoon-700);
    background: var(--lagoon-50);
    border-radius: var(--r-sm);
    padding: 0.65rem 0.8rem;
    margin-top: 1rem;
}
.detail-tip.fun {
    color: var(--sand-600);
    background: #fff7ed;
    border: 1px solid #fed7aa;
}
@media (prefers-color-scheme: dark) {
    .detail-tip { background: rgba(45, 212, 191, 0.1); color: var(--primary-hover); }
    .detail-tip.fun { background: rgba(217, 119, 6, 0.12); color: #fbbf24; border-color: rgba(217, 119, 6, 0.3); }
}

/* --- Bouton "Fiche détaillée" sur les cartes --- */
.detail-btn {
    width: 100%;
    margin-top: 0.7rem;
    padding: 0.6rem;
    border: 1px solid var(--lagoon-200);
    border-radius: var(--r-sm);
    background: var(--lagoon-50);
    color: var(--lagoon-700);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s var(--ease-spring);
}
.detail-btn:hover { background: var(--lagoon-100); }
.detail-btn:active { transform: scale(0.98); }
@media (prefers-color-scheme: dark) {
    .detail-btn { background: rgba(45, 212, 191, 0.1); color: var(--primary-hover); border-color: rgba(45, 212, 191, 0.25); }
}

/* --- "Toute l'histoire" --- */
.story-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.4rem 0 1rem;
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--lagoon-200);
    border-radius: var(--r-md);
    background: linear-gradient(180deg, var(--lagoon-50), var(--surface));
    color: var(--lagoon-700);
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.story-toggle:hover { box-shadow: var(--shadow-sm); }
.story-toggle .st-meta {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-soft);
}
.story-toggle .st-chev { transition: transform 0.25s var(--ease-out); font-size: 0.85rem; }
.story-toggle.open .st-chev { transform: rotate(180deg); }
.story-toggle.open { border-color: var(--lagoon-500); }
@media (prefers-color-scheme: dark) {
    .story-toggle {
        background: linear-gradient(180deg, rgba(45, 212, 191, 0.12), var(--surface));
        color: var(--primary-hover);
        border-color: rgba(45, 212, 191, 0.25);
    }
}

.detail-story { margin-bottom: 0.5rem; }
.detail-story p {
    font-size: 0.9rem;
    line-height: 1.68;
    color: var(--text);
    margin-bottom: 0.85rem;
}
.detail-story .story-sub {
    font-size: 0.98rem;
    font-weight: 750;
    color: var(--primary);
    margin: 1.3rem 0 0.5rem;
    line-height: 1.3;
}
.detail-story .story-sub:first-child { margin-top: 0.2rem; }
.detail-story .story-h {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
    margin: 1.6rem 0 0.6rem;
}

.story-timeline { list-style: none; position: relative; padding-left: 1.1rem; }
.story-timeline::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--lagoon-200);
}
.story-timeline li { position: relative; margin-bottom: 0.7rem; }
.story-timeline li::before {
    content: '';
    position: absolute;
    left: -1.1rem;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--secondary);
    box-shadow: 0 0 0 3px var(--surface);
}
.st-date {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.01em;
}
.st-txt { font-size: 0.85rem; color: var(--text-soft); line-height: 1.4; }

.story-figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0 0.4rem;
}
.fig {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.6rem 0.5rem;
    text-align: center;
}
.fig-v { display: block; font-size: 1rem; font-weight: 800; color: var(--primary); }
.fig-l { display: block; font-size: 0.68rem; color: var(--text-soft); line-height: 1.3; margin-top: 0.15rem; }
@media (prefers-color-scheme: dark) {
    .detail-badge { background: rgba(45, 212, 191, .1); color: var(--primary-hover); border-color: rgba(45, 212, 191, .2); }
}

/* ---------- BASCULE MOBILE + BANNIÈRE ITINÉRAIRE ---------- */
#view-toggle {
    display: none;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: calc(var(--safe-top) + 12px);
    z-index: 1500;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.65rem 1.2rem;
    border-radius: var(--r-full);
    font-size: 0.83rem;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring);
}
#view-toggle:active { transform: translateX(-50%) scale(0.93); }

#route-banner {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(18px + var(--safe-bottom));
    z-index: 1400;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    padding: 0.6rem 0.85rem;
    display: none;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    max-width: 92vw;
}
#route-banner.visible { display: flex; animation: bannerIn 0.32s var(--ease-out) both; }
#route-banner b { color: var(--primary); }
#route-banner button {
    border: none;
    background: var(--surface-2);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text);
}

.sheet-handle { display: none; }

/* ========================================================
   JEUX
   ======================================================== */
.games-summary { font-size: 0.8rem; color: var(--text-soft); margin: -0.3rem 0 0.9rem; }

.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }

.game-tile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: left;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition: transform 0.16s var(--ease-out), box-shadow 0.2s ease, border-color 0.2s ease;
}
.game-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--lagoon-200); }
.game-tile:active { transform: scale(0.98); }
.gt-emoji { font-size: 1.7rem; }
.gt-nom { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.gt-check { color: #16a34a; }
.gt-desc { font-size: 0.76rem; color: var(--text-soft); line-height: 1.35; }
.gt-best { font-size: 0.72rem; font-weight: 700; color: var(--secondary); margin-top: 0.3rem; }
.gt-best.muted { color: var(--gray-400); font-weight: 600; }

/* ---- L'Île du jour : tuile mise en avant dans le hub ---- */
.daily-tile {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
    padding: 1rem 1.05rem;
    border: 1px solid var(--lagoon-300);
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--lagoon-600), var(--lagoon-800));
    color: #fff;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.16s var(--ease-out), box-shadow 0.2s ease;
}
.daily-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.daily-tile:active { transform: scale(0.985); }
.daily-tile.todo { animation: dt-glow 2.4s ease-in-out infinite; }
@keyframes dt-glow { 0%,100% { box-shadow: var(--shadow-md); } 50% { box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.25), var(--shadow-md); } }
@media (prefers-reduced-motion: reduce) { .daily-tile.todo { animation: none; } }
.dt-badge { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; opacity: 0.9; }
.dt-title { font-weight: 800; font-size: 1.05rem; }
.dt-num { opacity: 0.7; font-weight: 700; }
.dt-desc { font-size: 0.78rem; line-height: 1.4; opacity: 0.92; }
.dt-foot { display: flex; justify-content: space-between; gap: 0.6rem; margin-top: 0.35rem; font-size: 0.74rem; font-weight: 700; }
.dt-state { opacity: 0.9; font-weight: 600; }

/* ---- L'Île du jour : plateau de jeu ---- */
.idj-head h3 { font-size: 1.1rem; color: var(--primary); }
.idj-num { color: var(--text-soft); font-weight: 700; }
.idj-streak { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--text-soft); margin: 0.5rem 0 0.9rem; }
.idj-streak b { color: var(--secondary); font-size: 0.95rem; }
.idj-rows { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.9rem; }
.idj-row {
    display: grid;
    grid-template-columns: 1fr auto auto 64px auto;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 0.84rem;
    animation: popIn 0.25s var(--ease-spring) both;
}
.idj-row.empty { opacity: 0.4; color: var(--text-soft); }
.idj-row.ok { border-color: #16a34a; background: rgba(22, 163, 74, 0.12); font-weight: 700; }
.idj-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idj-dist { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.idj-arrow { font-size: 1rem; }
.idj-bar { height: 7px; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.idj-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f59e0b, #16a34a); }
.idj-pct { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-soft); }
.idj-form { display: flex; flex-direction: column; gap: 0.5rem; }
.idj-form input {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
}
.idj-form input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.idj-result { text-align: center; animation: popIn 0.35s var(--ease-spring) both; }
.idj-reveal { padding: 0.9rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); margin-bottom: 0.7rem; }
.idj-reveal b { font-size: 1rem; color: var(--primary); }
.idj-reg { font-size: 0.74rem; color: var(--text-soft); margin-left: 0.35rem; }
.idj-reveal p { font-size: 0.82rem; color: var(--text-soft); line-height: 1.45; margin-top: 0.35rem; }
.idj-verdict { font-size: 0.86rem; margin-bottom: 0.7rem; }
.idj-next { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.7rem; }
.idj-next b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- Lagon Match (type Candy Crush) ---- */
.lagon-tile {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
    padding: 1rem 1.05rem;
    border: 1px solid #f0b357;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #f59e0b, #b45309);
    color: #fff;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.16s var(--ease-out), box-shadow 0.2s ease;
}
.lagon-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lagon-tile:active { transform: scale(0.985); }

.lm-map-head h3 { font-size: 1.1rem; color: var(--primary); }
.lm-lives { font-size: 0.85rem; margin: 0.5rem 0 0.9rem; color: var(--text-soft); }
.lm-regen { font-size: 0.78rem; }
.lm-regen b { color: var(--text); font-variant-numeric: tabular-nums; }
.lm-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
.lm-lvl {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    transition: transform 0.14s var(--ease-out), border-color 0.2s;
}
.lm-lvl:not(.locked):hover { transform: translateY(-2px); border-color: var(--primary); }
.lm-lvl.cleared { background: rgba(245, 158, 11, 0.12); border-color: #f59e0b; }
.lm-lvl.locked { opacity: 0.45; cursor: not-allowed; }
.lm-lvl-n { font-weight: 800; font-size: 1.15rem; color: var(--text); }
.lm-lvl-stars { font-size: 0.7rem; color: #f59e0b; letter-spacing: 1px; }

.lm-hud { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.lm-moves { font-weight: 800; font-size: 0.95rem; color: var(--text); }
.lm-head { font-size: 0.85rem; color: var(--text-soft); margin-bottom: 0.6rem; }
.lm-head b { color: var(--text); }
.lm-goal { height: 8px; border-radius: 999px; background: var(--gray-200); overflow: hidden; margin: 0.35rem 0 0.2rem; }
.lm-goal > span { display: block; height: 100%; background: linear-gradient(90deg, #fbbf24, #f59e0b); border-radius: 999px; transition: width 0.25s ease; }
.lm-stars-hint { font-size: 0.68rem; }
.lm-board {
    display: grid;
    gap: 3px;
    background: var(--lagoon-50);
    padding: 4px;
    border-radius: var(--r-sm);
    touch-action: manipulation;
}
.lm-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.1rem, 6vw, 1.7rem);
    line-height: 1;
    border: none;
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease;
}
.lm-cell.sel { background: var(--lagoon-200); transform: scale(1.12); box-shadow: 0 0 0 2px var(--primary); }
.lm-cell.pop { animation: lm-pop 0.22s ease both; }
@keyframes lm-pop { 0% { transform: scale(1); } 55% { transform: scale(1.35); } 100% { transform: scale(0.2); opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .lm-cell.pop { animation: none; opacity: 0.25; } }

.game-back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.2rem 0;
    margin-bottom: 0.6rem;
}

.game-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.4rem; }
.game-head h3 { color: var(--text); font-size: 1.05rem; }
.game-stat { font-size: 0.82rem; font-weight: 700; color: var(--text-soft); white-space: nowrap; }
.game-hint { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 0.9rem; }

.game-cta {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 0.7rem;
}
.game-cta:hover { background: var(--primary-hover); }
.game-skip {
    width: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-soft);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 0.5rem;
}

/* Écran de fin */
.game-over { text-align: center; padding: 1.4rem 0.5rem 0.5rem; animation: popIn 0.4s var(--ease-spring) both; }
.go-emoji { font-size: 3rem; }
.game-over h3 { color: var(--primary); font-size: 1.15rem; margin: 0.4rem 0; }
.game-over p { font-size: 0.88rem; color: var(--text-soft); margin-bottom: 0.6rem; }
.go-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; }
.go-actions .game-cta, .go-actions .game-skip { margin-top: 0; }

/* Mémo Nature */
.memory-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.mem-card {
    aspect-ratio: 3 / 4;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    perspective: 700px;
}
.mem-card .mc-inner {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    transition: transform 0.4s var(--ease-out);
    transform-style: preserve-3d;
}
.mem-card.up .mc-inner { transform: rotateY(180deg); }
.mc-back, .mc-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.mc-back { background: linear-gradient(150deg, var(--lagoon-500), var(--lagoon-700)); font-size: 1.5rem; }
.mc-face {
    background: var(--surface);
    border: 2px solid var(--lagoon-200);
    transform: rotateY(180deg);
    padding: 0.2rem;
    gap: 0.2rem;
}
.mc-face b { font-size: 1.6rem; }
.mc-face small { font-size: 0.6rem; line-height: 1.1; text-align: center; color: var(--text-soft); }
.mem-card.done .mc-face { border-color: #22c55e; background: #dcfce7; }
@media (prefers-color-scheme: dark) {
    .mc-face { background: var(--surface-2); }
    .mem-card.done .mc-face { background: rgba(34, 197, 94, 0.18); }
}

/* Quiz Éclair */
.flash-bar-wrap { height: 8px; background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; margin-bottom: 0.3rem; }
#flash-bar { height: 100%; background: var(--primary); border-radius: var(--r-full); transition: width 1s linear; }
.flash-time { text-align: right; font-size: 0.8rem; font-weight: 800; color: var(--text-soft); margin-bottom: 0.6rem; }
.flash-time.low { color: #ef4444; }
.flash-q { font-size: 0.95rem; color: var(--text); margin: 0.3rem 0 0.5rem; line-height: 1.35; }
#game-stage .quiz-option { margin-top: 0.45rem; }
.game-skip#flash-skip { margin-top: 0.7rem; }

/* L'Histoire en ordre */
.order-slots { list-style: none; counter-reset: slot; display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.9rem; }
.order-slots li {
    counter-increment: slot;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border: 1px dashed var(--gray-300);
    border-radius: var(--r-sm);
    font-size: 0.8rem;
    color: var(--text);
    background: var(--surface);
}
.order-slots li::before { content: counter(slot); font-weight: 800; color: var(--primary); flex-shrink: 0; }
.order-slots li.filled { border-style: solid; border-color: var(--lagoon-200); background: var(--lagoon-50); }
.order-slots li em { color: var(--text-soft); font-style: normal; }
.order-pool { display: flex; flex-direction: column; gap: 0.4rem; }
.order-chip {
    text-align: left;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: transform 0.12s var(--ease-spring), border-color 0.15s;
}
.order-chip:hover { border-color: var(--primary); }
.order-chip:active { transform: scale(0.98); }
.order-actions { display: flex; flex-direction: column; gap: 0.4rem; }
.order-result { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.4rem; }
.order-result li { font-size: 0.8rem; padding: 0.5rem 0.6rem; border-radius: var(--r-sm); line-height: 1.4; }
.order-result li.ok { background: #dcfce7; color: #14532d; }
.order-result li.ko { background: #fee2e2; color: #7f1d1d; }
@media (prefers-color-scheme: dark) {
    .order-result li.ok { background: rgba(34, 197, 94, 0.18); color: #bbf7d0; }
    .order-result li.ko { background: rgba(239, 68, 68, 0.18); color: #fecaca; }
    .order-slots li.filled { background: rgba(45, 212, 191, 0.1); }
}

/* Devine le lieu */
.guess-clue {
    font-size: 0.92rem;
    font-style: italic;
    color: var(--text);
    background: var(--surface-2);
    border-left: 3px solid var(--secondary);
    padding: 0.7rem 0.8rem;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    margin-bottom: 0.5rem;
    line-height: 1.45;
}

/* Pendu */
.pendu-word { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; margin: 1rem 0; }
.pendu-word span {
    width: 26px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 3px solid var(--primary);
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}
.pendu-keys { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.35rem; margin-top: 0.5rem; }
.pk {
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.1s var(--ease-spring), background 0.15s;
}
.pk:hover:not(:disabled) { background: var(--lagoon-50); border-color: var(--primary); }
.pk:active:not(:disabled) { transform: scale(0.9); }
.pk:disabled { opacity: 0.35; cursor: default; }
.pendu-msg { text-align: center; font-size: 1rem; font-weight: 700; margin: 0.8rem 0; }
.pendu-msg.win { color: #16a34a; }
.pendu-msg.lose { color: #ef4444; }

/* ========================================================
   LES LIVRES DE CAGO
   ======================================================== */
.cago-intro { font-size: 0.85rem; color: var(--text-soft); line-height: 1.5; margin-bottom: 0.7rem; }
#cago-link-btn { margin: 0 0 1rem; }

.cago-books { display: flex; flex-direction: column; gap: 1rem; }

.cago-book {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.cago-book.unlocked { border-color: var(--lagoon-200); box-shadow: var(--shadow-sm); }

.cago-cover-wrap { position: relative; line-height: 0; }
.cago-cover {
    display: block;
    width: 100%;
    aspect-ratio: 900 / 640;
    max-height: 208px;
    object-fit: cover;
    object-position: center 22%;
    transition: filter 0.35s ease;
}
.cago-book.locked .cago-cover { filter: none; }
.cago-lock {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 0.2rem 0.55rem;
    border-radius: var(--r-full);
    background: rgba(15, 23, 42, 0.62);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    backdrop-filter: blur(3px);
}
.cago-lock.soon { top: auto; bottom: 10px; left: 10px; background: rgba(217, 119, 6, 0.9); }

.cago-shop {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px dashed var(--border);
}
.cago-prix { font-size: 1.05rem; font-weight: 800; color: var(--text); }
.cago-buy {
    margin-left: auto;
    padding: 0.5rem 0.9rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--secondary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, transform 0.12s var(--ease-spring);
}
.cago-buy:hover { filter: brightness(1.05); }
.cago-buy:active { transform: scale(0.96); }
.cago-buy.soon { background: var(--surface-2); color: var(--text-soft); box-shadow: inset 0 0 0 1px var(--border); }

.cago-info { min-width: 0; padding: 0.9rem 1rem 1rem; }
.cago-num { font-size: 0.72rem; font-weight: 800; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.cago-info h3 { font-size: 0.98rem; color: var(--text); margin: 0.15rem 0 0.35rem; line-height: 1.25; }
.cago-resume { font-size: 0.82rem; color: var(--text-soft); line-height: 1.5; }
.cago-theme { font-size: 0.76rem; color: var(--primary); font-weight: 600; margin-top: 0.4rem; }

.cago-hint {
    font-size: 0.78rem;
    color: var(--text-soft);
    background: var(--surface-2);
    border-radius: var(--r-xs);
    padding: 0.5rem 0.6rem;
    margin-top: 0.5rem;
    line-height: 1.45;
}
.cago-badge {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--lagoon-700);
    background: var(--lagoon-50);
    border-radius: var(--r-xs);
    padding: 0.5rem 0.6rem;
    margin-top: 0.5rem;
    line-height: 1.4;
}
@media (prefers-color-scheme: dark) {
    .cago-badge { background: rgba(45, 212, 191, 0.12); color: var(--primary-hover); }
}

.cago-go {
    margin-top: 0.6rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--lagoon-200);
    border-radius: var(--r-sm);
    background: var(--lagoon-50);
    color: var(--lagoon-700);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s var(--ease-spring);
}
.cago-go:hover { background: var(--lagoon-100); }
.cago-go:active { transform: scale(0.97); }
@media (prefers-color-scheme: dark) {
    .cago-go { background: rgba(45, 212, 191, 0.1); color: var(--primary-hover); border-color: rgba(45, 212, 191, 0.25); }
}

/* Illustrations d'espèces (Animaux.png) */
.site-card.has-thumb { display: flex; gap: 0.8rem; align-items: flex-start; }
.sp-thumb {
    width: 78px;
    height: 78px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    padding: 3px;
}
.sp-body { min-width: 0; }
.sp-hero {
    background: linear-gradient(170deg, var(--lagoon-50), var(--surface-2));
    text-align: center;
    padding: 0.8rem;
}
.sp-hero img { max-height: 210px; max-width: 90%; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18)); }

/* ========================================================
   MODE ENFANT
   ======================================================== */
#kid-btn.on {
    background: #fff;
    color: var(--lagoon-700);
    border-color: #fff;
}
body.kid-mode {
    --r-md: 18px;
    --r-sm: 14px;
}
body.kid-mode .tab-content { font-size: 1.02rem; }
body.kid-mode .site-card h3 { font-size: 1.05rem; }
body.kid-mode .site-card .body { font-size: 0.95rem; color: var(--text); }
body.kid-mode .route-btn,
body.kid-mode .photo-btn,
body.kid-mode .detail-btn { padding: 0.85rem; font-size: 0.92rem; }
body.kid-mode .filter-row,
body.kid-mode #search-bar { display: none; }

.detail-inner.kid { text-align: center; padding: 1.1rem 1.1rem 1.4rem; }
.detail-inner.kid h2 { font-size: 1.35rem; }
.kid-say {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    text-align: left;
    background: var(--lagoon-50);
    border: 1px solid var(--lagoon-100);
    border-radius: var(--r-md);
    padding: 0.9rem;
    margin: 0.8rem 0 1rem;
}
.kid-cago { width: 66px; flex-shrink: 0; }
.kid-say p { font-size: 1.02rem; line-height: 1.6; color: var(--text); }
.kid-btns .route-btn, .kid-btns .photo-btn { padding: 0.95rem; font-size: 1rem; }
.kid-grown {
    margin-top: 1rem;
    background: none;
    border: none;
    color: var(--text-soft);
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
}
@media (prefers-color-scheme: dark) {
    .kid-say { background: rgba(45, 212, 191, 0.1); border-color: rgba(45, 212, 191, 0.2); }
}

/* ========================================================
   QUÊTES
   ======================================================== */
.quests-label { font-size: 0.78rem; font-weight: 700; color: var(--text-soft); margin-bottom: 0.5rem; }
.quests-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 0.3rem;
    scrollbar-width: none;
}
.quests-strip::-webkit-scrollbar { display: none; }
.quest-chip {
    flex: 0 0 auto;
    width: 132px;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: left;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.12s var(--ease-spring);
}
.quest-chip:active { transform: scale(0.96); }
.quest-chip.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--lagoon-100); }
.quest-chip.done { background: var(--lagoon-50); border-color: var(--lagoon-200); }
.qc-emoji { font-size: 1.2rem; }
.qc-nom { font-size: 0.74rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.qc-prog { font-size: 0.68rem; font-weight: 700; color: var(--secondary); }
.quest-chip.done .qc-prog { color: #16a34a; }

.quest-banner {
    border: 1px solid var(--lagoon-200);
    border-radius: var(--r-md);
    background: var(--lagoon-50);
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.9rem;
}
.qb-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text); }
.qb-close { background: none; border: none; color: var(--text-soft); font-size: 0.9rem; cursor: pointer; }
.qb-bar { height: 7px; background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; margin: 0.5rem 0; }
.qb-bar > div { height: 100%; background: var(--primary); border-radius: var(--r-full); transition: width 0.5s var(--ease-spring); }
.qb-hint { font-size: 0.78rem; color: var(--text-soft); line-height: 1.4; }
.qb-cert {
    width: 100%;
    padding: 0.65rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--secondary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}
@media (prefers-color-scheme: dark) {
    .quest-chip.done, .quest-banner { background: rgba(45, 212, 191, 0.1); }
}

/* ========================================================
   COMPAGNONS DE CAGO
   ======================================================== */
.creatures-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.creature-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.7rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: pointer;
    transition: transform 0.15s var(--ease-out), box-shadow 0.2s;
}
.creature-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.creature-card img { width: 100%; height: 66px; object-fit: contain; }
.creature-card.locked img { filter: grayscale(1) opacity(0.28); }
.cc-nom { font-size: 0.74rem; font-weight: 700; color: var(--text); text-align: center; line-height: 1.15; }
.cc-hint { font-size: 0.64rem; color: var(--text-soft); text-align: center; line-height: 1.2; }
.creature-card.got { border-color: var(--lagoon-200); }

/* ========================================================
   CERTIFICAT
   ======================================================== */
.cert-card { max-width: 640px; }
.cert-inner { padding: 1.2rem; }
.cert-inner h2 { font-size: 1.1rem; color: var(--primary); margin-bottom: 0.8rem; }
#cert-name {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.95rem;
    margin-bottom: 0.9rem;
}
.cert-preview {
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 0.6rem;
    overflow: auto;
}
#cert-canvas { width: 100%; height: auto; display: block; border-radius: 4px; box-shadow: var(--shadow-sm); }
.cert-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.9rem; }
.cert-actions .game-cta, .cert-actions .game-skip { margin-top: 0; }

/* ========================================================
   BOUTIQUE
   ======================================================== */
.cart-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin-left: 4px;
    border-radius: var(--r-full);
    background: var(--secondary);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    vertical-align: middle;
}

.shop-list { display: flex; flex-direction: column; gap: 0.8rem; }
.shop-item {
    display: flex;
    gap: 0.8rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.shop-item.soon .shop-body { opacity: 0.85; }
.shop-cover {
    width: 84px;
    flex-shrink: 0;
    align-self: flex-start;
    border-radius: var(--r-sm);
    object-fit: cover;
    aspect-ratio: 900 / 640;
    box-shadow: var(--shadow-sm);
}
.shop-body { min-width: 0; flex: 1; }
.shop-body h3 { font-size: 0.92rem; color: var(--text); line-height: 1.2; }
.shop-desc {
    font-size: 0.78rem;
    color: var(--text-soft);
    line-height: 1.45;
    margin: 0.25rem 0 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.shop-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.shop-prix { font-size: 1rem; font-weight: 800; color: var(--text); }
.shop-add {
    margin-left: auto;
    padding: 0.5rem 0.9rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--secondary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}
.shop-add:active { transform: scale(0.96); }
.shop-soon { margin-left: auto; font-size: 0.76rem; font-weight: 700; color: var(--secondary); }
.qty { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.qty button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}
.qty span { min-width: 18px; text-align: center; font-weight: 800; }

.shop-cart {
    margin-top: 1rem;
    padding: 0.9rem;
    border: 1px solid var(--lagoon-200);
    border-radius: var(--r-md);
    background: var(--lagoon-50);
}
.shop-cart h3 { font-size: 0.95rem; color: var(--lagoon-700); margin-bottom: 0.5rem; }
.cart-lines { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.cart-lines li { display: flex; justify-content: space-between; font-size: 0.83rem; color: var(--text); }
.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    border-top: 1px solid var(--lagoon-200);
    margin-top: 0.55rem;
    padding-top: 0.55rem;
}
.shop-checkout {
    width: 100%;
    margin-top: 0.8rem;
    padding: 0.8rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--primary);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}
.shop-cancel {
    width: 100%;
    margin-top: 0.45rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}
.shop-note { font-size: 0.72rem; color: var(--text-soft); margin-top: 0.6rem; line-height: 1.4; }

.order-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; }
.order-form input, .order-form textarea {
    width: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 0.88rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
.order-form textarea { resize: vertical; }

.order-done { text-align: center; }
.od-emoji { font-size: 2.6rem; }
.order-done h3 { color: var(--lagoon-700); font-size: 1.05rem; margin: 0.3rem 0; }
.order-done p { font-size: 0.85rem; color: var(--text-soft); line-height: 1.5; }
.od-steps {
    text-align: left;
    margin: 0.7rem 0 0.9rem 1.1rem;
    padding: 0;
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.5;
}
.od-steps li { margin-bottom: 0.35rem; }
.od-pay {
    font-size: 1rem;
    padding: 0.85rem 1rem;
    animation: od-pay-pulse 1.8s ease-in-out infinite;
}
@keyframes od-pay-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.35); }
    50% { box-shadow: 0 0 0 8px rgba(15, 118, 110, 0); }
}
@media (prefers-reduced-motion: reduce) { .od-pay { animation: none; } }
.order-recap {
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.7rem;
    font-size: 0.74rem;
    line-height: 1.5;
    margin: 0.8rem 0;
    max-height: 220px;
    overflow: auto;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
    .shop-cart { background: rgba(45, 212, 191, 0.1); }
}

@media print {
    body * { visibility: hidden !important; }
    #cert-overlay, #cert-overlay * { visibility: visible !important; }
    #cert-overlay {
        position: absolute; inset: 0; opacity: 1 !important; background: #fff !important;
        display: block !important; padding: 0;
    }
    .cert-card { max-width: none; box-shadow: none; transform: none; }
    .overlay-close, #cert-name, .cert-actions, .cert-inner h2 { display: none !important; }
    .cert-preview { background: none; padding: 0; }
    #cert-canvas { max-width: 100%; box-shadow: none; }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 960px) and (min-width: 769px) {
    #sidebar { width: 340px; }
}

@media (max-width: 768px) {
    body { flex-direction: column; position: relative; }

    #map { position: absolute; inset: 0; height: 100%; width: 100%; }

    #sidebar {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 74dvh;
        border-right: none;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        box-shadow: 0 -6px 30px rgba(9, 15, 26, 0.18);
        transition: transform 0.38s var(--ease-spring);
        padding-bottom: var(--safe-bottom);
        overflow: hidden;
    }
    body.map-view #sidebar {
        transform: translateY(calc(74dvh - var(--sheet-peek, 160px)));
    }

    .sheet-handle {
        display: block;
        width: 40px;
        height: 5px;
        border-radius: 3px;
        background: rgba(255, 255, 255, 0.5);
        margin: 0.5rem auto 0.1rem;
        position: absolute;
        left: 0;
        right: 0;
        z-index: 2;
    }

    .header { padding-top: calc(0.9rem + var(--safe-top)); cursor: grab; }

    #view-toggle { display: block; }
    #toast-container { top: calc(var(--safe-top) + 60px); }
    body:not(.map-view) #route-banner { bottom: calc(74dvh + 12px); }

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

@media (max-width: 380px) {
    .brand-text h1 { font-size: 1rem; }
    .btn-group { flex-wrap: wrap; }
    .filter-row { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
    }
}
