/* Aubota Empire – V0.5.0 (tactile d'abord, plein écran) */
:root {
    /* Couleurs du jeu, définies une seule fois (13/11) */
    --empire-ambre: #f59e0b;
    --empire-ambre-fonce: #b45309;
    --empire-ardoise: #94a3b8;
    --empire-ardoise-claire: #cbd5e1;
    --empire-blanc: #ffffff;
    --empire-bleu-ciel: #60a5fa;
    --empire-bleu-profond: #2563eb;
    --empire-bronze: #a16207;
    --empire-brume: #e2e8f0;
    --empire-brun: #78350f;
    --empire-brun-roux: #92400e;
    --empire-creme: #fff7d6;
    --empire-encre: #1c1917;
    --empire-jaune: #facc15;
    --empire-mer: #15527a;
    --empire-or: #fbbf24;
    --empire-or-clair: #fcd34d;
    --empire-parchemin: #fef3c7;
    --empire-rose: #f472b6;
    --empire-rose-pale: #fecaca;
    --empire-rouge-pale: #fca5a5;
    --empire-turquoise: #14b8a6;
    --empire-vert-pale: #86efac;
    --empire-abysse-rgb: 5, 8, 12;
    --empire-ambre-rgb: 245, 158, 11;
    --empire-ardoise-nuit-rgb: 15, 23, 42;
    --empire-blanc-rgb: 255, 255, 255;
    --empire-bleu-rgb: 59, 130, 246;
    --empire-bleu-ciel-rgb: 96, 165, 250;
    --empire-brume-rgb: 226, 232, 240;
    --empire-corail-rgb: 248, 113, 113;
    --empire-fond-rgb: 12, 16, 23;
    --empire-herbe-rgb: 90, 150, 66;
    --empire-noir-rgb: 0, 0, 0;
    --empire-nuit-ambre-rgb: 66, 45, 6;
    --empire-nuit-bleue-rgb: 15, 20, 30;
    --empire-nuit-brune-rgb: 40, 25, 10;
    --empire-nuit-marine-rgb: 12, 35, 70;
    --empire-nuit-navy-rgb: 15, 25, 45;
    --empire-nuit-violette-rgb: 30, 20, 40;
    --empire-or-rgb: 251, 191, 36;
    --empire-rouge-rgb: 239, 68, 68;
    --empire-sang-rgb: 69, 10, 10;
    --empire-surface-rgb: 21, 28, 40;
    --empire-vert-rgb: 34, 197, 94;
    --bg: #0c1017;
    --surface: #151c28;
    --surface-2: #1c2535;
    --border: #2a3548;
    --text: #eef2f8;
    --text-muted: #8b9bb4;
    --accent: #3b82f6;
    --ok: #22c55e;
    --gold: #fbbf24;
    --danger: #ef4444;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --radius: 12px;
    --topbar: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    touch-action: manipulation;   /* V0.9 : pas de zoom de la page au double toucher (iOS ignore user-scalable=no) */
}

button { font: inherit; color: inherit; }

#app {
    display: grid;
    grid-template-rows: var(--topbar) 1fr;
    grid-template-columns: 1fr 240px;
    height: 100%;
    height: 100dvh;
}

/* ------------------------------------------------------------------ barre du haut */

#topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 20;
    min-width: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-shrink: 1;
}

.back-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.25rem;
    padding: 4px 8px;
    border-radius: 8px;
}
.back-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}

#topbar h1 {
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.version {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.resources {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
}
.resources::-webkit-scrollbar { display: none; }

.res {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    column-gap: 5px;
    align-items: center;
    padding: 3px 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.res-icon { grid-row: 1 / 3; font-size: 1rem; }
.res-val { font-weight: 600; font-size: 0.85rem; }
.res-cap { font-weight: 400; color: var(--text-muted); }
.res-taux { font-size: 0.66rem; color: var(--ok); min-height: 0.8em; }
.res-taux.neg { color: var(--danger); }
.res.res-golden .res-val { color: var(--gold); }
.res.alerte { border-color: rgba(var(--empire-rouge-rgb), 0.6); }

.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }

/* ------------------------------------------------------------------ carte */

#game-area {
    position: relative;
    overflow: hidden;
    background: var(--empire-mer);
    touch-action: none;
    cursor: grab;
}
#game-area:active { cursor: grabbing; }

#map-wrapper {
    position: absolute;
    inset: 0;
}

#map-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.overlay { z-index: 10; }

/* Colonne du haut : objectif, saison, marchand, messages (jamais les uns sur les autres) */
#hud-top {
    position: absolute;
    top: 10px;
    left: 10px;
    width: min(360px, calc(100% - 70px));
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    pointer-events: none;
}
#hud-top > * { pointer-events: auto; }

.carte {
    width: 100%;
    background: rgba(var(--empire-surface-rgb), 0.94);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    box-shadow: 0 8px 24px rgba(var(--empire-noir-rgb), 0.35);
}

.obj-titre { font-weight: 600; font-size: 0.9rem; }
.obj-num {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--surface-2);
    border-radius: 999px;
    padding: 1px 7px;
    vertical-align: 1px;
}
.obj-aide { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; line-height: 1.35; }
.obj-gain { font-size: 0.75rem; color: var(--gold); margin-top: 4px; }

.chip {
    background: rgba(var(--empire-surface-rgb), 0.9);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.offre-titre { font-weight: 600; }
.offre-texte { font-size: 0.85rem; color: var(--text-muted); margin: 4px 0 8px; }
.offre-boutons { display: flex; gap: 8px; }

#toast-zone { width: 100%; }
.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 0.85rem;
    line-height: 1.35;
    box-shadow: 0 8px 24px rgba(var(--empire-noir-rgb), 0.4);
    cursor: pointer;
    animation: entree 0.2s ease-out;
}
.toast-succes { border-left-color: var(--ok); }
.toast-alerte { border-left-color: var(--danger); }
.toast.sortie { opacity: 0; transform: translateY(-6px); transition: 0.18s; }
@keyframes entree { from { opacity: 0; transform: translateY(-6px); } }

/* Barre de visite chez un ami */
#visite-bar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(var(--empire-surface-rgb), 0.96);
    border: 1px solid var(--accent);
    border-radius: 999px;
    max-width: calc(100% - 20px);
    font-size: 0.85rem;
    white-space: nowrap;
}
#visite-texte { overflow: hidden; text-overflow: ellipsis; }
.en-visite #hud-top,
.en-visite #build-bar,
.en-visite #btn-construire,
.en-visite #bas { display: none !important; }
.en-visite #game-area { grid-column: 1 / -1; }

/* Bas gauche : fiche d'un bâtiment, mode construction */
#bas {
    position: absolute;
    bottom: 12px;
    left: 12px;
    width: min(330px, calc(100% - 70px));
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#building-info {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(var(--empire-noir-rgb), 0.4);
    max-height: 55vh;
    overflow-y: auto;
}
#building-info.hidden { display: none; }

.info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    position: sticky;
    top: 0;
    background: var(--surface);
}
#info-close, .btn-x {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
#info-close:hover, .btn-x:hover { color: var(--text); }
.info-body { padding: 12px; }
.info-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.info-lignes { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 0.82rem; }
.info-lignes .ok { color: var(--empire-vert-pale); }
.info-lignes .ko { color: var(--empire-rouge-pale); }
.info-actions { display: flex; flex-direction: column; gap: 6px; }
.info-max { font-size: 0.82rem; color: var(--gold); text-align: center; padding: 4px; }
.info-astuce { font-size: 0.72rem; color: var(--text-muted); margin-top: 8px; }
.info-astuce a { color: var(--accent); text-underline-offset: 2px; }
.confirmer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.8rem; color: var(--text-muted); }
.confirmer span { width: 100%; }

#build-mode {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(var(--empire-surface-rgb), 0.96);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 0.82rem;
}
#build-mode-texte { flex: 1; }

/* Boutons */
.btn {
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
}
.btn:hover { border-color: var(--text-muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: var(--empire-blanc); }
.btn-primaire:hover { background: var(--empire-bleu-profond); }
.btn.cant { opacity: 0.6; }
.btn-danger {
    background: rgba(var(--empire-rouge-rgb), 0.15);
    border-color: rgba(var(--empire-rouge-rgb), 0.4);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(var(--empire-rouge-rgb), 0.25); }

#zoom-ctrl {
    position: absolute;
    right: 10px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#zoom-ctrl button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(var(--empire-surface-rgb), 0.94);
    border: 1px solid var(--border);
    font-size: 1.2rem;
    cursor: pointer;
}

#btn-construire { display: none; }

/* ------------------------------------------------------------------ liste « Construire » */

#build-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    z-index: 15;
}

.build-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.build-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.build-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-align: left;
    width: 100%;
}
.build-item:hover,
.build-item.active {
    border-color: var(--accent);
    background: rgba(var(--empire-bleu-rgb), 0.12);
}
.build-item.cant .cost { color: var(--empire-rouge-pale); }
.build-item.locked { opacity: 0.55; }
.build-item .icon { font-size: 1.35rem; }
.build-item .meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.build-item .name { font-size: 0.86rem; font-weight: 500; }
.build-item .name small {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.72rem;
}
.build-item .cost { font-size: 0.74rem; color: var(--text-muted); }
.build-item .lock { font-size: 0.7rem; color: var(--text-muted); }
.build-item.agrandir { margin-top: auto; border-style: dashed; }

/* ------------------------------------------------------------------ fenêtres */

#modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(var(--empire-abysse-rgb), 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-box {
    width: min(460px, 100%);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(var(--empire-noir-rgb), 0.5);
    animation: entree 0.18s ease-out;
}
.modal-tete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.modal-tete h2 { font-size: 1.05rem; }
.modal-corps {
    padding: 14px 16px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.45;
    user-select: text;
    -webkit-user-select: text;
}
.modal-corps p + p, .modal-corps p + ul { margin-top: 8px; }
.modal-corps ul { padding-left: 4px; list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.modal-pied {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.menu .modal-pied { justify-content: stretch; }
.menu-ligne { color: var(--text-muted); font-size: 0.85rem; }
.champ {
    width: 100%;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    color: var(--text);
    user-select: text;
    -webkit-user-select: text;
}
.champ:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.cadeau-jours { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 10px; }
.cadeau-jour {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
}
.cadeau-jour b { color: var(--text); font-size: 0.72rem; }
.cadeau-jour.pris { opacity: 0.45; }
.cadeau-jour.aujourdhui { border-color: var(--gold); background: rgba(var(--empire-or-rgb), 0.12); }

.classement { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.classement li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.classement li.moi { border-color: var(--accent); }
.classement .rang { width: 26px; text-align: center; font-weight: 600; }
.classement .qui { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.classement .qui b, .classement .qui small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classement .qui small { color: var(--text-muted); font-size: 0.72rem; }
.classement .score { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--gold); }
.classement .act { display: flex; gap: 4px; }
.classement .act .btn { padding: 5px 8px; font-size: 0.78rem; }

/* ------------------------------------------------------------------ téléphone */

@media (max-width: 700px) {
    #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    #topbar { gap: 4px; padding: 6px; padding-top: calc(6px + env(safe-area-inset-top)); align-items: flex-start; }
    #topbar h1, .version { display: none; }
    /* Les 7 ressources sur deux lignes, sans défilement */
    .resources { flex-wrap: wrap; justify-content: flex-start; gap: 4px; overflow: visible; }
    .res { display: flex; gap: 3px; padding: 3px 6px; border-radius: 8px; }
    .res-icon { font-size: 0.85rem; }
    .res-val { font-size: 0.78rem; }
    .res-cap, .res-taux { display: none; }
    .icon-btn { width: 34px; height: 34px; }
    #btn-aide { display: none; }

    #hud-top { width: calc(100% - 64px); }
    .obj-aide { display: none; }
    #objectif { padding: 8px 10px; }
    /* Toucher le titre montre l’aide (pas toute la carte : le bouton « Construire » ne doit pas bouger sous le doigt) */
    #objectif .obj-titre:active + .obj-aide { display: block; }

    #bas { bottom: calc(64px + env(safe-area-inset-bottom)); width: calc(100% - 70px); }
    #building-info { max-height: 45vh; }

    #btn-construire {
        display: block;
        position: absolute;
        left: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        padding: 12px 18px;
        border-radius: 999px;
        border: 1px solid var(--accent);
        background: var(--accent);
        color: var(--empire-blanc);
        font-weight: 600;
        box-shadow: 0 8px 24px rgba(var(--empire-noir-rgb), 0.4);
        cursor: pointer;
    }

    /* La liste « Construire » devient un tiroir qui monte du bas */
    #build-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 62dvh;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 18px 18px 0 0;
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
        transform: translateY(105%);
        transition: transform 0.22s ease-out;
        box-shadow: 0 -12px 40px rgba(var(--empire-noir-rgb), 0.5);
        z-index: 30;
    }
    #build-bar.ouvert { transform: none; }
    .build-list { display: grid; grid-template-columns: 1fr 1fr; }
    .build-item .lock { white-space: normal; }
}

/* ------------------------------------------------------------------ V0.6 : vignettes, « Ma ville », trophées */

.icon-btn { position: relative; }
.pastille {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger);
    color: var(--empire-blanc);
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
}
.pastille[hidden] { display: none; }

.build-cat {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 8px 2px 0;
}
.build-cat:first-child { margin-top: 0; }
.build-list .build-cat { grid-column: 1 / -1; }
.build-item .vignette {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: radial-gradient(circle at 50% 70%, rgba(var(--empire-herbe-rgb), 0.35), rgba(var(--empire-herbe-rgb), 0) 70%);
}
.build-item .vignette canvas { display: block; }

.info-tete { display: flex; gap: 10px; align-items: flex-start; }
.info-tete canvas {
    flex: 0 0 auto;
    border-radius: 10px;
    background: radial-gradient(circle at 50% 70%, rgba(var(--empire-herbe-rgb), 0.4), rgba(var(--empire-herbe-rgb), 0) 70%), var(--surface-2);
}
.info-famille { font-size: 0.8rem; font-weight: 600; margin-bottom: 2px; }

.ville h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 14px 0 6px;
}
.ville-tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ville-tuile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 8px 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.ville-tuile b { font-size: 0.98rem; font-variant-numeric: tabular-nums; }
.ville-tuile small { font-size: 0.66rem; color: var(--text-muted); text-align: center; }
.vt-icon { font-size: 1.1rem; }
.ville-tab { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.ville-tab th { font-size: 0.66rem; color: var(--text-muted); font-weight: 500; text-align: right; padding: 2px 4px; }
.ville-tab td { text-align: right; padding: 5px 4px; border-top: 1px solid var(--border); }
.ville-tab td.vt-nom { text-align: left; }
.ville-tab td.vt-nom small { display: block; font-size: 0.66rem; color: var(--text-muted); }
.ville-tab td.pos { color: var(--empire-vert-pale); }
.ville-tab td.neg { color: var(--empire-rouge-pale); }
.ville-courbes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.courbe { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-width: 0; }
.courbe-tete { display: flex; justify-content: space-between; font-size: 0.78rem; margin-bottom: 4px; }
.courbe canvas { display: block; }
.courbe-pied { display: block; font-size: 0.62rem; color: var(--text-muted); margin-top: 3px; }
.trophees { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.trophees li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.trophees li.pret { border-color: var(--gold); background: rgba(var(--empire-or-rgb), 0.08); }
.tr-icon { font-size: 1.3rem; }
.tr-mil { flex: 1; min-width: 0; }
.tr-nom { font-size: 0.85rem; font-weight: 600; }
.tr-medailles { font-weight: 400; font-size: 0.75rem; letter-spacing: 1px; }
.tr-mil small { font-size: 0.7rem; color: var(--text-muted); }
.tr-barre { height: 5px; border-radius: 3px; background: rgba(var(--empire-blanc-rgb), 0.08); margin-top: 4px; overflow: hidden; }
.tr-barre i { display: block; height: 100%; background: linear-gradient(90deg, var(--empire-ambre), var(--empire-or-clair)); border-radius: 3px; }
.tr-fini { color: var(--gold); font-weight: 700; }
.trophees .btn { white-space: nowrap; font-size: 0.75rem; padding: 6px 9px; }
@media (max-width: 520px) {
    .ville-courbes { grid-template-columns: 1fr; }
    .trophees li { flex-wrap: wrap; }
    .trophees .btn { width: 100%; }
}
.obj-pied { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.obj-pied .obj-gain { margin-top: 0; }
.btn-obj { padding: 4px 9px; font-size: 0.74rem; border-radius: 8px; background: rgba(var(--empire-bleu-rgb), 0.18); border-color: rgba(var(--empire-bleu-rgb), 0.5); }
.btn-obj:hover { background: rgba(var(--empire-bleu-rgb), 0.3); }

.rang {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}
#photo-sortie { display: none; }
body.photo #topbar, body.photo #build-bar, body.photo .overlay { display: none !important; }
body.photo #app { grid-template-rows: 1fr; grid-template-columns: 1fr; }
body.photo #photo-sortie {
    display: block;
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(var(--empire-blanc-rgb), 0.25);
    background: rgba(var(--empire-ardoise-nuit-rgb), 0.55);
    color: var(--empire-blanc);
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 50;
}
@media (max-width: 700px) { .rang { display: none; } }
.obj-barre { position: relative; height: 14px; border-radius: 7px; background: rgba(var(--empire-blanc-rgb), 0.07); margin-top: 6px; overflow: hidden; }
.obj-barre i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--empire-bleu-profond), var(--empire-bleu-ciel)); border-radius: 7px; transition: width 0.4s; }
.obj-barre span { position: relative; display: block; text-align: center; font-size: 0.66rem; line-height: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ V0.7 : onglets, commerce, épreuves, mini-jeu (05/11) */
.modal-box:has(.commerce), .modal-box:has(.amis), .modal-box:has(.mj) { width: min(520px, 100%); }
.onglets { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; scrollbar-width: none; }
.onglets::-webkit-scrollbar { display: none; }
.onglet { flex: 1 0 auto; padding: 7px 10px; font-size: 0.8rem; border-radius: 999px; white-space: nowrap; }
.onglet.actif { background: var(--accent); border-color: var(--accent); color: var(--empire-blanc); }
.onglet-zone h3 { font-size: 0.84rem; margin: 14px 0 6px; color: var(--text-muted); font-weight: 600; }
.onglet-zone h3:first-child { margin-top: 0; }
.vide, .note { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.modal-corps .note { margin-top: 6px; }
.onglet-zone > .btn-primaire { margin-top: 8px; }
.carte-offre { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; }
.co-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.co-tete small { color: var(--text-muted); font-size: 0.72rem; }
.co-etat { font-size: 0.7rem; padding: 1px 7px; border-radius: 999px; background: var(--surface); color: var(--text-muted); }
.co-acceptee { color: var(--ok); }
.co-message { font-size: 0.8rem; font-style: italic; margin: 4px 0; }
.co-lignes { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 0.84rem; margin-top: 4px; }
.co-recoit { color: var(--ok); font-weight: 600; }
.co-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.co-actions .btn { padding: 6px 12px; font-size: 0.82rem; }
.modal-corps ul.convois { gap: 4px; margin-top: 0; }
.convois li { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; }
.convois small { color: var(--text-muted); white-space: nowrap; }
.commerce-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.commerce-form > .btn { align-self: flex-start; }
.cf-ligne { display: flex; align-items: center; gap: 6px; font-size: 0.84rem; }
.cf-ligne > span { width: 70px; color: var(--text-muted); flex: none; }
.cf-ligne input, .cf-ligne select, .mj-corr {
    background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
    padding: 7px 8px; font: inherit; font-size: 0.86rem; min-width: 0;
}
.cf-ligne input { width: 92px; }
.cf-ligne select { flex: 1; }
.marche-tab td, .marche-tab th { text-align: right; }
.marche-tab .vt-nom { text-align: left; }
.bulle-aia { border: 1px solid rgba(var(--empire-bleu-rgb), 0.5); background: rgba(var(--empire-bleu-rgb), 0.12); border-radius: 12px; padding: 8px 10px; margin-top: 10px; font-size: 0.84rem; }
.bulle-aia b { display: block; font-size: 0.74rem; color: var(--accent); }
.classement li.ia { border-color: rgba(var(--empire-bleu-rgb), 0.55); }
.classement .qui small.titre-badge { color: var(--gold); }
.cl-rang { width: 26px; text-align: center; font-weight: 600; flex: none; }
.ep-tete { display: flex; align-items: center; gap: 10px; }
.ep-icone { font-size: 1.8rem; }
.ep-tete div { display: flex; flex-direction: column; }
.ep-tete small { color: var(--text-muted); font-size: 0.74rem; }
.ep-moi { font-weight: 600; margin: 8px 0 2px; font-size: 0.88rem; }
.modal-corps .ep-prix { color: var(--gold); }
.ep-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.ep-liste .classement li { padding: 6px 8px; }
@media (max-width: 520px) {
    .ep-colonnes { grid-template-columns: 1fr; }
    .onglets { gap: 3px; }
    .onglet { padding: 6px 8px; font-size: 0.74rem; }
}
.mj-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.mj-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; text-align: left; }
.mj-mode b { font-size: 0.95rem; }
.mj-mode small { color: var(--text-muted); font-size: 0.76rem; line-height: 1.35; }
.mj-consigne { font-weight: 600; margin-bottom: 8px; text-align: center; }
.mj-papier { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; touch-action: manipulation; }
.mj-papier img { display: block; width: auto; height: auto; max-width: 100%; max-height: 50vh; border-radius: 6px; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.mj-point {
    position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 50%;
    background: var(--accent); color: var(--empire-blanc); font-size: 0.72rem; font-weight: 700; display: flex; align-items: center;
    justify-content: center; box-shadow: 0 0 0 2px var(--empire-blanc); pointer-events: none;
}
.mj-zone { position: absolute; border: 2px solid var(--ok); border-radius: 4px; pointer-events: none; background: rgba(var(--empire-vert-rgb), 0.12); }
.mj-zone.ko { border-color: var(--gold); background: rgba(var(--empire-or-rgb), 0.15); }
.mj-lecture { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.mj-ligne { display: grid; grid-template-columns: 64px 1fr auto auto; gap: 6px; align-items: center; font-size: 0.84rem; }
.mj-champ { color: var(--text-muted); }
.mj-lu { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mj-oui, .mj-non { padding: 5px 8px; font-size: 0.76rem; }
.mj-oui.choisi { background: rgba(var(--empire-vert-rgb), 0.25); border-color: var(--ok); }
.mj-non.choisi { background: rgba(var(--empire-rouge-rgb), 0.2); border-color: var(--danger); }
.mj-corr { grid-column: 2 / -1; }
.modal-corps .mj-resultat ul { gap: 3px; font-size: 0.84rem; }
.mj-resultat li.ko { color: var(--gold); }
.mj-points { font-weight: 700; color: var(--gold); margin-top: 6px; }

/* ===================================================================== V0.8 : récit, choix, menaces, écran titre */
.portrait { border-radius: 14px; flex: 0 0 auto; display: block; background: var(--surface-2); }

/* Conseiller : une carte en bas à gauche, jamais bloquante */
#conseiller {
    position: absolute; left: 12px; bottom: 74px; z-index: 30; max-width: min(380px, calc(100% - 24px));
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 16px;
    background: rgba(var(--empire-nuit-bleue-rgb), 0.94); border: 1px solid var(--border); border-left: 4px solid var(--perso, var(--accent));
    box-shadow: 0 12px 30px rgba(var(--empire-noir-rgb), 0.45); animation: cons-entree 0.25s ease-out;
}
#conseiller.sortie { opacity: 0; transform: translateY(8px); transition: 0.2s; }
@keyframes cons-entree { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.cons-corps { min-width: 0; }
.cons-nom { font-size: 0.78rem; color: var(--perso, var(--accent)); filter: brightness(1.6); letter-spacing: 0.02em; }
.cons-texte { font-size: 0.88rem; line-height: 1.35; margin: 2px 0 8px; }
.cons-pied { display: flex; gap: 6px; flex-wrap: wrap; }
.cons-pied .btn { padding: 6px 12px; font-size: 0.8rem; min-height: 36px; }

/* Décisions et parades */
.decision .dec-tete { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.dec-qui { font-size: 0.8rem; color: var(--text-muted); }
.dec-texte { font-size: 0.95rem; line-height: 1.4; margin-top: 2px; }
.dec-choix { display: flex; flex-direction: column; gap: 8px; }
.dec-option {
    text-align: left; padding: 12px 14px; min-height: 52px; border-radius: 12px; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px;
}
.dec-option:hover, .dec-option:focus-visible { border-color: var(--accent); outline: none; }
.dec-option b { font-size: 0.92rem; }
.dec-option small { font-size: 0.76rem; color: var(--text-muted); line-height: 1.35; }
.dec-option.cant { opacity: 0.55; }
.dec-option.actif { border-color: var(--gold); background: rgba(var(--empire-or-rgb), 0.08); }

/* Carte de menace (en haut, avec le compte à rebours) */
.carte.menace { border-color: rgba(var(--empire-corail-rgb), 0.55); background: linear-gradient(135deg, rgba(var(--empire-sang-rgb), 0.92), rgba(var(--empire-nuit-violette-rgb), 0.92)); }
.carte.menace.menace-secheresse { border-color: rgba(var(--empire-or-rgb), 0.6); background: linear-gradient(135deg, rgba(var(--empire-nuit-ambre-rgb), 0.92), rgba(var(--empire-nuit-brune-rgb), 0.92)); }
.carte.menace.menace-crue { border-color: rgba(var(--empire-bleu-ciel-rgb), 0.6); background: linear-gradient(135deg, rgba(var(--empire-nuit-marine-rgb), 0.94), rgba(var(--empire-nuit-navy-rgb), 0.92)); }
.carte.menace.en-cours { animation: menace-pulse 1.4s ease-in-out infinite; }
@keyframes menace-pulse { 50% { box-shadow: 0 0 0 4px rgba(var(--empire-corail-rgb), 0.25); } }
.menace-titre { font-weight: 700; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.menace-texte { font-size: 0.8rem; color: var(--empire-brume); margin: 4px 0 8px; line-height: 1.35; }

/* Carnet */
.onglets { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.onglets .btn { padding: 6px 10px; font-size: 0.8rem; }
.onglets .btn.actif { border-color: var(--accent); background: rgba(var(--empire-bleu-rgb), 0.15); }
.carnet-intro { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 8px; }
.chapitre { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2); }
.chapitre p { font-size: 0.84rem; margin-top: 4px; line-height: 1.4; }
.chapitre small { color: var(--text-muted); font-size: 0.74rem; }
.chapitre.verrou { opacity: 0.5; }
.chapitre.encours { border-color: var(--accent); }
.chap-fin { color: var(--gold); font-style: italic; }
.perso { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.perso b { display: block; }
.perso small { color: var(--text-muted); font-size: 0.74rem; }
.perso p { font-size: 0.82rem; margin-top: 3px; line-height: 1.4; }
.perso.verrou b { color: var(--text-muted); }
.chronique { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.chronique li { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.chr-quand { font-size: 0.68rem; color: var(--text-muted); }
.chr-texte { font-size: 0.82rem; line-height: 1.35; }

/* Écran titre : la ville vit derrière, la Brume se lève */
#ecran-titre {
    position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; overflow: hidden;
    background: radial-gradient(ellipse at 50% 60%, rgba(var(--empire-fond-rgb), 0.25), rgba(var(--empire-fond-rgb), 0.85) 75%);
    transition: opacity 0.6s ease;
}
/* Pas de flou ni de zoom pendant la sortie : léger pour les petits téléphones (et les rendus sans carte graphique) */
#ecran-titre.sortie { opacity: 0; pointer-events: none; }
#ecran-titre.sortie .titre-brume { animation: none; display: none; }
.titre-brume { position: absolute; width: 140vmax; height: 50vmax; border-radius: 50%; opacity: 0.5; will-change: transform;
    background: radial-gradient(ellipse, rgba(var(--empire-brume-rgb), 0.55), rgba(var(--empire-brume-rgb), 0) 65%); animation: brume 18s linear infinite; }
.titre-brume.b1 { top: 5%; left: -60%; }
.titre-brume.b2 { top: 45%; left: -80%; animation-duration: 26s; animation-delay: -9s; opacity: 0.35; }
.titre-brume.b3 { top: 70%; left: -70%; animation-duration: 22s; animation-delay: -4s; opacity: 0.4; }
@keyframes brume { to { transform: translateX(120vmax); } }
.titre-contenu { position: relative; text-align: center; padding: 24px; }
.titre-sur { letter-spacing: 0.5em; font-weight: 800; font-size: 0.9rem; color: var(--empire-ardoise-claire); margin-right: -0.5em; }
.titre-logo {
    font-size: clamp(3.2rem, 15vw, 6.5rem); line-height: 0.95; font-weight: 900; letter-spacing: -0.02em; margin: 4px 0 6px;
    background: linear-gradient(180deg, var(--empire-creme) 0%, var(--empire-or) 55%, var(--empire-ambre-fonce) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 6px 18px rgba(var(--empire-noir-rgb), 0.6));
}
.titre-sous { font-size: 1.05rem; color: var(--empire-brume); font-style: italic; text-shadow: 0 2px 10px rgba(var(--empire-noir-rgb), 0.8); }
.titre-btn { margin-top: 26px; font-size: 1.15rem; padding: 14px 30px; min-height: 54px; border-radius: 999px; box-shadow: 0 10px 30px rgba(var(--empire-bleu-rgb), 0.45); }
.titre-pied { margin-top: 18px; font-size: 0.78rem; color: var(--empire-ardoise); }
.titre-pied a { color: var(--empire-ardoise-claire); }
@media (max-width: 700px) {
    #conseiller { left: 8px; right: 8px; max-width: none; bottom: 72px; padding: 8px 10px; gap: 8px; }
    #conseiller .portrait { width: 42px; height: 42px; border-radius: 11px; }
    .cons-texte { font-size: 0.82rem; margin-bottom: 6px; }
    .cons-pied .btn { min-height: 32px; padding: 4px 12px; }
}
/* Pendant la construction, le conseiller monte au-dessus de la barre « Terminer » */
#app:has(#build-mode:not([hidden])) #conseiller { bottom: 132px; }
@media (prefers-reduced-motion: reduce) { .titre-brume, .carte.menace.en-cours { animation: none; } }

/* ------------------------------------------------------------------ V0.9 « Routes » */
#actions-bas { position: absolute; right: 60px; bottom: 12px; display: flex; gap: 8px; align-items: center; }
#btn-routes {
    padding: 10px 16px; border-radius: 999px; border: 1px solid var(--empire-bronze); background: var(--empire-brun); color: var(--empire-parchemin);
    font-weight: 600; box-shadow: 0 8px 24px rgba(var(--empire-noir-rgb), 0.4); cursor: pointer; min-height: 44px;
}
#btn-routes:hover { background: var(--empire-brun-roux); }
#btn-routes.actif { background: var(--empire-ambre); border-color: var(--empire-or); color: var(--empire-encre); }
.en-visite #actions-bas { display: none !important; }
.chip-trafic { cursor: pointer; color: var(--empire-rose-pale); border-color: rgba(var(--empire-rouge-rgb), 0.55); background: rgba(var(--empire-sang-rgb), 0.88); font: inherit; font-size: 0.75rem; }
#route-bar {
    display: flex; flex-direction: column; gap: 6px;
    background: rgba(var(--empire-surface-rgb), 0.97); border: 1px solid var(--empire-ambre); border-radius: var(--radius); padding: 8px; font-size: 0.8rem;
    box-shadow: 0 12px 40px rgba(var(--empire-noir-rgb), 0.45);
}
#route-bar[hidden] { display: none !important; }
.rb-ligne { display: flex; flex-wrap: wrap; gap: 5px; align-items: stretch; }
.rb-type, .rb-outil { padding: 6px 9px; font-size: 0.78rem; min-height: 36px; border-radius: 9px; }
.rb-type { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; flex: 1 1 0; min-width: 0; }
.rb-type small { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }
.rb-type.actif, .rb-outil.actif { border-color: var(--empire-ambre); background: rgba(var(--empire-ambre-rgb), 0.18); }
.rb-type.locked { opacity: 0.55; }
.rb-fin { margin-left: auto; padding: 6px 12px; min-height: 36px; }
.rb-info p { color: var(--text-muted); line-height: 1.35; }
.rb-info .rb-ko { color: var(--empire-rouge-pale); }
.rb-legende { font-size: 0.72rem; margin-top: 3px; }
.rb-ligne-bus { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--text); }
.rb-ligne-bus .btn-x { margin-left: auto; font-size: 1rem; }
.rb-pastille { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(var(--empire-noir-rgb), 0.4); }
.rb-c0 { background: var(--empire-jaune); } .rb-c1 { background: var(--empire-turquoise); } .rb-c2 { background: var(--empire-rose); } .rb-c3 { background: var(--empire-bleu-ciel); }
@media (min-width: 701px) {
    #bas { width: min(380px, calc(100% - 300px)); }
    /* Fiche ou barre des routes ouverte : le conseiller passe à droite, au-dessus des boutons */
    #app:has(#route-bar:not([hidden])) #conseiller,
    #app:has(#building-info:not(.hidden)) #conseiller { left: auto; right: 64px; bottom: 74px; }
}
@media (max-width: 700px) {
    #actions-bas { left: 12px; right: auto; bottom: calc(12px + env(safe-area-inset-bottom)); }
    #actions-bas #btn-construire { position: static; }
    #btn-routes { padding: 12px 16px; }
    .rb-type small { display: none; }
    .rb-type, .rb-outil { padding: 6px 8px; }
    #route-bar { max-height: 46vh; overflow-y: auto; }
    #app:has(#route-bar:not([hidden])) #conseiller { bottom: 250px; }
}

