:root {
    --olive: #c9c57d;
    --olive-bright: #e4e58f;
    --panel: rgba(14, 16, 9, .90);
    --line: rgba(231, 225, 181, .55);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #090a07; }
body {
    overflow: hidden;
    font-family: "Courier New", "Lucida Console", monospace;
    color: var(--olive-bright);
    -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }

.scene {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 520px;
    overflow: hidden;
    background: #111;
}

.scene-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    user-select: none;
    pointer-events: none;
    transition: filter .45s ease, transform .45s ease;
}

.scene.alt-visual .scene-bg {
    filter: grayscale(.78) sepia(.35) contrast(1.18) brightness(.72) saturate(.65);
    transform: scale(1.012);
}
.scene.alt-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(214,221,134,.025) 0 1px, transparent 1px 4px);
    mix-blend-mode: screen;
}

.mobile-header, .mobile-hero, .mobile-save-note, .mobile-icon { display: none; }

.visual-toggle {
    position: absolute;
    z-index: 20;
    top: 3.1%;
    right: 1.6%;
    width: 14.6%;
    min-width: 170px;
    height: 5.5%;
    min-height: 42px;
    opacity: 0;
    cursor: pointer;
    border: 0;
}
.visual-toggle:focus-visible { opacity: .35; outline: 2px solid var(--olive-bright); }

.hotspot {
    position: absolute;
    z-index: 10;
    width: 18%;
    height: 28%;
    pointer-events: none;
}
.hotspot-talios   { left: 8.5%;  top: 17.5%; }
.hotspot-bunker   { left: 74.2%; top: 17.5%; }
.hotspot-shahed   { left: 7.5%;  top: 63.5%; }
.hotspot-missile  { left: 41.0%; top: 65.0%; }
.hotspot-roquette { left: 75.0%; top: 64.0%; }

.plus {
    position: absolute;
    z-index: 5;
    pointer-events: auto;
    top: 10%;
    right: 2%;
    width: 28%;
    height: 21%;
    min-width: 50px;
    min-height: 42px;
    border: 1px solid rgba(193,190,113,.25);
    border-radius: 6px;
    background: rgba(39,43,23,.12);
    color: transparent;
    cursor: pointer;
    touch-action: manipulation;
}
.plus:hover { background: rgba(224,227,137,.12); }
.plus:active { transform: scale(.94); }
.plus:focus-visible { outline: 2px solid var(--olive-bright); background: rgba(224,227,137,.18); }
.plus.busy { cursor: wait; }

.counter-box {
    position: absolute;
    left: 17%;
    bottom: 0;
    min-width: 62%;
    padding: .45rem .7rem .28rem;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(27,30,16,.96), rgba(12,14,8,.96));
    box-shadow: 0 0 12px rgba(0,0,0,.65), inset 0 0 0 1px rgba(195,193,112,.14);
    text-align: center;
    pointer-events: none;
}
.counter-box span {
    display: block;
    color: #eee7b9;
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: clamp(13px, 1.45vw, 26px);
    letter-spacing: .03em;
    line-height: 1.05;
    white-space: nowrap;
}
.counter-box strong {
    display: block;
    margin-top: .14em;
    color: #dce77d;
    font-family: "Courier New", monospace;
    font-size: clamp(22px, 2.55vw, 45px);
    font-weight: 700;
    letter-spacing: .04em;
    line-height: .95;
    text-shadow: 0 0 7px rgba(220,231,125,.32);
}
.counter-box.pulse { animation: pulse .25s ease; }
@keyframes pulse {
    50% { transform: scale(1.06); box-shadow: 0 0 22px rgba(220,231,125,.38); }
}

.save-status {
    position: absolute;
    z-index: 20;
    left: 50%;
    bottom: 1.25%;
    transform: translateX(-50%);
    width: 47%;
    min-width: 360px;
    min-height: 5.2%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .4rem 1rem;
    border: 1px solid rgba(192,190,110,.20);
    border-radius: 8px;
    background: rgba(16,18,10,.94);
    color: #c7bd75;
    font-size: clamp(10px, 1.15vw, 20px);
    letter-spacing: .05em;
    text-align: center;
    box-shadow: 0 4px 18px rgba(0,0,0,.45);
}
.save-status.ok { color: #e4ea91; }
.save-status.error { color: #ffc1a5; }

/* Téléphones et petites tablettes : interface pensée pour le tactile. */
@media (max-width: 900px) {
    body { overflow: auto; }

    .scene {
        width: 100%;
        height: auto;
        min-height: 100dvh;
        overflow: visible;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        align-content: start;
        padding: calc(10px + var(--safe-top)) 12px calc(22px + var(--safe-bottom));
        background:
            radial-gradient(circle at 50% 15%, rgba(120,113,61,.18), transparent 42%),
            #0b0c08;
    }

    .scene::after { display: none; }
    .scene-bg, .visual-toggle { display: none; }

    .mobile-header {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 64px;
        padding: 8px 4px 4px;
    }
    .mobile-emblem {
        flex: 0 0 48px;
        height: 48px;
        display: grid;
        place-items: center;
        border: 1px solid rgba(201,197,125,.48);
        clip-path: polygon(50% 0, 90% 18%, 82% 72%, 50% 100%, 18% 72%, 10% 18%);
        color: var(--olive-bright);
        font-size: 24px;
        text-shadow: 0 0 8px rgba(228,229,143,.3);
    }
    .mobile-kicker {
        color: #96915f;
        font-size: 10px;
        letter-spacing: .18em;
        font-weight: 700;
    }
    .mobile-header h1 {
        margin: 2px 0 0;
        color: #d7d09a;
        font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
        font-size: clamp(24px, 8vw, 38px);
        line-height: .95;
        letter-spacing: .045em;
        font-weight: 700;
    }

    .mobile-hero {
        position: relative;
        grid-column: 1 / -1;
        display: block;
        width: 100%;
        aspect-ratio: 16 / 8.7;
        overflow: hidden;
        border: 1px solid rgba(201,197,125,.28);
        border-radius: 14px;
        background: #17170e;
        box-shadow: 0 12px 30px rgba(0,0,0,.36);
    }
    .mobile-hero img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: 50% 48%;
        transform: scale(1.16);
        filter: saturate(.82) contrast(1.04) brightness(.82);
    }
    .mobile-hero-shade {
        position: absolute;
        inset: 0;
        background: linear-gradient(180deg, rgba(0,0,0,.04), rgba(0,0,0,.16) 62%, rgba(8,9,5,.56));
        pointer-events: none;
    }

    .mobile-save-note {
        grid-column: 1 / -1;
        display: block;
        margin: -4px 2px 2px;
        color: #888459;
        font-size: 10px;
        text-align: center;
        letter-spacing: .05em;
    }

    .hotspot,
    .hotspot-talios,
    .hotspot-bunker,
    .hotspot-shahed,
    .hotspot-missile,
    .hotspot-roquette {
        position: relative;
        inset: auto;
        z-index: 2;
        width: auto;
        height: clamp(154px, 42vw, 205px);
        min-width: 0;
        display: flex;
        align-items: flex-end;
        justify-content: stretch;
        overflow: hidden;
        border: 1px solid rgba(202,198,119,.29);
        border-radius: 14px;
        background: linear-gradient(180deg, rgba(34,34,20,.96), rgba(13,15,8,.98));
        box-shadow: 0 8px 24px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.025);
        pointer-events: auto;
        cursor: pointer;
        touch-action: manipulation;
    }

    .hotspot:active { transform: scale(.985); }
    .hotspot-roquette { grid-column: 1 / -1; height: clamp(150px, 37vw, 190px); }

    .mobile-icon {
        display: block;
        position: absolute;
        inset: 0 0 48px 0;
        width: 100%;
        height: calc(100% - 48px);
        object-fit: cover;
        object-position: center;
        opacity: .88;
        filter: sepia(.15) saturate(.7) contrast(1.1) brightness(.72);
        pointer-events: none;
    }
    .hotspot::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 1;
        background: linear-gradient(180deg, transparent 28%, rgba(8,9,5,.2) 52%, rgba(8,9,5,.96) 78%);
        pointer-events: none;
    }

    .plus {
        z-index: 4;
        top: 10px;
        right: 10px;
        width: 58px;
        height: 48px;
        min-width: 58px;
        min-height: 48px;
        border: 1px solid rgba(221,218,137,.48);
        border-radius: 9px;
        background: rgba(42,46,24,.92);
        color: #e8e993;
        font-size: 21px;
        font-weight: 700;
        text-shadow: 0 0 7px rgba(228,229,143,.26);
        box-shadow: 0 4px 12px rgba(0,0,0,.35);
    }
    .plus:active { background: rgba(73,78,39,.96); transform: scale(.92); }
    .plus.busy { opacity: .55; }

    .counter-box {
        z-index: 3;
        position: relative;
        left: auto;
        bottom: auto;
        width: 100%;
        min-width: 0;
        min-height: 58px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 10px 12px;
        border-radius: 0;
        background: rgba(11,13,7,.92);
        box-shadow: inset 0 1px 0 rgba(198,195,116,.15);
        text-align: left;
    }
    .counter-box span {
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: clamp(13px, 3.8vw, 18px);
        white-space: nowrap;
    }
    .counter-box strong {
        flex: 0 0 auto;
        margin: 0;
        font-size: clamp(23px, 6.3vw, 32px);
        line-height: 1;
    }

    .save-status {
        position: sticky;
        z-index: 25;
        grid-column: 1 / -1;
        left: auto;
        bottom: calc(8px + var(--safe-bottom));
        transform: none;
        width: 100%;
        min-width: 0;
        min-height: 44px;
        margin-top: 2px;
        padding: 8px 10px;
        border-color: rgba(192,190,110,.25);
        font-size: 10px;
        line-height: 1.25;
        letter-spacing: .03em;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* Très petits téléphones : une seule colonne, boutons encore plus faciles à toucher. */
@media (max-width: 430px) {
    .scene { grid-template-columns: 1fr; gap: 10px; padding-left: 10px; padding-right: 10px; }
    .mobile-hero, .mobile-header, .mobile-save-note, .save-status,
    .hotspot, .hotspot-roquette { grid-column: 1; }
    .hotspot, .hotspot-roquette { height: 150px; }
    .counter-box span { font-size: 16px; }
    .counter-box strong { font-size: 29px; }
    .plus { width: 62px; height: 50px; }
}

/* Téléphone en paysage : deux colonnes compactes, sans perdre les contrôles. */
@media (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
    body { overflow: auto; }
    .scene {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
        display: grid;
        grid-template-columns: repeat(3, minmax(0,1fr));
        gap: 10px;
        padding: calc(6px + var(--safe-top)) 10px calc(12px + var(--safe-bottom));
        background: #0b0c08;
    }
    .scene-bg, .visual-toggle { display: none; }
    .mobile-header { display: flex; grid-column: 1 / -1; min-height: 45px; }
    .mobile-emblem { width: 36px; height: 36px; flex-basis: 36px; font-size: 18px; }
    .mobile-header h1 { font-size: 25px; }
    .mobile-kicker { display: none; }
    .mobile-hero { display: block; grid-column: 1 / -1; aspect-ratio: 16 / 4.8; }
    .mobile-hero img { object-position: 50% 49%; transform: scale(1.1); }
    .mobile-save-note { display: block; grid-column: 1 / -1; }
    .hotspot, .hotspot-talios, .hotspot-bunker, .hotspot-shahed, .hotspot-missile, .hotspot-roquette {
        position: relative; inset: auto; width: auto; height: 125px; display: flex; pointer-events: auto;
        overflow: hidden; border-radius: 12px; border: 1px solid rgba(202,198,119,.29);
        background: #12140a;
    }
    .hotspot-roquette { grid-column: auto; }
    .mobile-icon { display:block; position:absolute; inset:0 0 42px; width:100%; height:calc(100% - 42px); object-fit:cover; filter: brightness(.68) sepia(.12); }
    .hotspot::before { content:""; position:absolute; inset:0; z-index:1; background:linear-gradient(180deg,transparent 35%,rgba(7,8,4,.96) 79%); }
    .plus { top:7px; right:7px; width:54px; height:44px; min-width:54px; min-height:44px; color:#e8e993; background:rgba(42,46,24,.94); border:1px solid rgba(221,218,137,.5); }
    .counter-box { z-index:3; position:relative; left:auto; bottom:auto; width:100%; margin-top:auto; min-height:42px; display:flex; align-items:center; justify-content:space-between; padding:6px 8px; border-radius:0; background:rgba(10,12,6,.94); }
    .counter-box span { font-size:12px; }
    .counter-box strong { margin:0; font-size:22px; }
    .save-status { position:sticky; grid-column:1/-1; left:auto; bottom:4px; transform:none; width:100%; min-width:0; min-height:38px; font-size:9px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
