/* Local fonts with Latin and Greek letters (SIL Open Font License, see fonts/). */
@font-face{font-family:'Fira Sans Condensed';font-style:normal;font-weight:700;font-display:swap;src:url(fonts/FiraSansCondensed-Bold.woff2) format('woff2');}
@font-face{font-family:'Fira Sans Condensed';font-style:normal;font-weight:900;font-display:swap;src:url(fonts/FiraSansCondensed-Black.woff2) format('woff2');}
@font-face{font-family:'Fira Mono';font-style:normal;font-weight:500;font-display:swap;src:url(fonts/FiraMono-Medium.woff2) format('woff2');}
@font-face{font-family:'M PLUS Rounded 1c';font-style:normal;font-weight:800;font-display:swap;src:url(fonts/MPLUSRounded1c-ExtraBold.woff2) format('woff2');}

/* ══════════════════════════════════════════════════════════════════════
   MID-CENTURY MISSION CONTROL
   Near-black ground, bone signage, phosphor amber as the primary voice,
   phosphor green for nominal state, one alert red used only for danger.
   Every colour in this file resolves through these tokens.
   ══════════════════════════════════════════════════════════════════════ */
:root{
    /* ground */
    --void:#07080a;          /* deepest background */
    --panel:#101215;         /* console panel face */
    --panel-2:#171a1e;       /* raised panel */
    --rule:#2b3138;          /* hairline rules and borders */
    --rule-strong:#414a53;

    /* ink */
    --bone:#e8e4da;          /* primary signage text */
    --bone-dim:#9aa0a4;      /* secondary text */
    --bone-faint:#666d73;    /* tertiary / disabled */

    /* phosphor */
    --amber:#ffb020;         /* primary accent — the actionable thing */
    --amber-deep:#8a5c05;
    --green:#5ddba0;         /* nominal / success */
    --green-deep:#1d5f42;
    --alert:#e8452f;         /* danger only — collisions, failure */

    /* type */
    --display:'Fira Sans Condensed','Arial Narrow',system-ui,sans-serif;
    --mono:'Fira Mono','DejaVu Sans Mono',monospace;
    --toon:'M PLUS Rounded 1c','Fira Sans Condensed',system-ui,sans-serif;

    /* geometry — deliberately not all the same radius */
    --r-panel:3px;
    --r-card:2px;
    --r-pill:999px;
}
    *{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
    html,body{
        margin:0; padding:0; width:100%; height:100%; background:var(--void); color:var(--bone);
        font-family:var(--display); overflow:hidden; overscroll-behavior:none;
        font-weight:700; letter-spacing:0.01em;
        touch-action:none; -webkit-user-select:none; user-select:none;
    }
    #app{ position:fixed; inset:0; height:100dvh; width:100dvw; }
    #scene-grade{
        position:fixed; inset:0; z-index:5; pointer-events:none;
        background:
          radial-gradient(ellipse 78% 68% at 50% 46%, rgba(0,0,0,0) 42%, rgba(0,0,0,0.34) 78%, rgba(0,0,0,0.62) 100%),
          repeating-linear-gradient(0deg, rgba(255,255,255,0.016) 0 1px, rgba(0,0,0,0) 1px 3px);
    }
    #scene-grade::after{
        content:''; position:absolute; inset:0; opacity:.05; mix-blend-mode:overlay;
        background-image:var(--grain);
        background-size:180px 180px;
    }

    /* Icons are inline SVG symbols, sized by font context and inheriting colour. */
    .ico{ width:1em; height:1em; fill:currentColor; vertical-align:-0.12em; flex:none; }
    .ico-lg{ width:1.05em; height:1.05em; vertical-align:-0.10em; }
    .icon-btn .ico{ width:18px; height:18px; }
    #btn-super .sicon .ico{ width:22px; height:22px; }
    #crate-box .ico{ width:64px; height:64px; color:var(--amber); }

    .star{ width:14px; height:14px; fill:var(--rule); flex:none; }
    .star.on{ fill:var(--amber); }
    .star-lg{ width:52px; height:52px; }
    /* Stars stamp in one at a time with a scale overshoot. */
    .stars-crop .star{ transform:scale(0); animation:stamp .34s cubic-bezier(.2,1.6,.4,1) forwards;
        animation-delay:calc(0.32s + var(--i) * 0.18s); }
    @keyframes stamp{ 0%{ transform:scale(2.2); opacity:0; } 60%{ transform:scale(.88); opacity:1; }
        100%{ transform:scale(1); opacity:1; } }
    .stat-delta{ font-family:var(--mono); font-weight:500; color:var(--green); font-size:14px; margin-left:6px; }
    .lvl-stars{ display:flex; gap:5px; justify-content:center; align-items:center; }

    /* Monospace is reserved for numeric readouts so digits stay in column. */
    .num, #readout b, #trophy-count, .lvl-best, #fuel-val, #ro-alt, #ro-spd, #ro-per,
    #conj-time, #beam-count-val, #count-num, .stat-num{
        font-family:var(--mono); font-weight:500; font-variant-numeric:tabular-nums;
        letter-spacing:0; }
    canvas{ display:block; touch-action:none; }

    /* ── screens ── */
    .screen{
        position:absolute; inset:0; display:none; flex-direction:column;
        align-items:center; justify-content:center; z-index:40; padding:22px 16px; text-align:center;
        overflow-y:auto;
        background:radial-gradient(ellipse at 50% 30%, rgba(20,22,26,0.75), rgba(7,8,10,0.97) 70%);
    }
    .screen.visible{ display:flex; }
    .glow-title{font-weight:900; letter-spacing:0.02em; 
        font-size:clamp(26px,6.5vw,54px); color:var(--bone); letter-spacing:3px; margin:0 0 6px;
    }
    .sub{ font-size:clamp(14px,2.4vw,15px); color:var(--bone-dim); letter-spacing:1.5px; margin-bottom:26px;
        font-weight:700; text-shadow:none; }
    .big-btn{
        font-family:var(--display); font-size:clamp(14px,2.6vw,16px); color:var(--void);
        background:linear-gradient(180deg,var(--amber),var(--amber-deep)); border:none; border-radius:10px;
        padding:16px 38px; letter-spacing:1.5px; cursor:pointer; font-weight:bold; margin:8px;
        box-shadow:0 0 34px rgba(255,176,32,0.42), inset 0 -2px 0 rgba(0,0,0,0.3);
        touch-action:manipulation;
    }
    .big-btn:active{ transform:translateY(2px) scale(0.98); }
    .ghost-btn{
        font-family:var(--display); font-size:clamp(14px,2.2vw,14px); color:var(--bone);
        background:rgba(255,176,32,0.06); border:1px solid var(--rule); border-radius:8px;
        padding:12px 26px; letter-spacing:2px; cursor:pointer; margin:8px; touch-action:manipulation;
    }
    .ghost-btn:active{ background:rgba(255,176,32,0.16); }
    #logo-hero{ width:min(300px,56vw); height:auto; margin-bottom:18px; }
    #logo-corner{
        position:fixed; top:max(8px,env(safe-area-inset-top)); left:max(10px,env(safe-area-inset-left));
        height:42px; width:auto; z-index:70; display:none; pointer-events:none;
        filter:drop-shadow(0 0 6px rgba(232,228,218,0.45));
    }
    #logo-corner.visible{ display:block; }
    @media (max-width:480px){ #logo-corner{ height:32px; } }

    /* ── level select ── */
    /* Three columns so five missions read 3+2 with the last row left-aligned,
       instead of one orphan centred under a row of four. */
    #ls-grid{ display:grid; grid-template-columns:repeat(3, 150px); gap:10px;
        justify-content:center; justify-items:stretch; margin-bottom:14px; }
    @media (max-width:560px){ #ls-grid{ grid-template-columns:repeat(2, 46vw); } }
    .lvl-card{
        padding:12px 12px 11px; border-radius:var(--r-card); cursor:pointer; text-align:left;
        border:1px solid var(--rule); background:var(--panel); touch-action:manipulation;
        display:grid; grid-template-columns:auto 1fr; grid-template-rows:auto auto;
        column-gap:10px; row-gap:2px; align-items:center;
        transition:border-color .12s, background .12s;
    }
    .lvl-card:not(.locked):hover{ border-color:var(--rule-strong); background:var(--panel-2); }
    .lvl-card.locked{ opacity:0.4; cursor:default; }
    .lvl-card:not(.locked):active{ transform:scale(0.97); }
    .lvl-num{ font-family:var(--mono); font-weight:500; font-size:24px; color:var(--amber);
        grid-row:1 / span 2; align-self:center; line-height:1; }
    .lvl-name{font-weight:700;  font-size:13px; color:var(--bone-dim); letter-spacing:1px; margin-top:4px; min-height:24px;}
    .lvl-stars{ display:flex; gap:4px; align-items:center; }
    .lvl-meta{ display:flex; align-items:center; gap:9px; }    .lvl-best{ font-size:13px; color:var(--bone-faint); letter-spacing:0.5px; }

    /* ── HUD ── */
    #hud{ position:absolute; inset:0; z-index:20; display:none; pointer-events:none; }
    #hud.visible{ display:block; }
    #hud-top{
        position:absolute; top:max(10px,env(safe-area-inset-top)); left:0; right:0;
        display:flex; justify-content:space-between; align-items:flex-start; padding:0 12px 0 84px;
    }
    @media (max-width:480px){ #hud-top{ padding-left:62px; } }
    #level-banner{
        background:var(--panel); border:1px solid var(--rule); border-radius:8px; padding:8px 16px;
        font-size:clamp(14px,2vw,14px); color:var(--amber); letter-spacing:2px;
    }
    #level-banner .lname{ display:block; font-size:13px; color:var(--bone-dim); letter-spacing:2px; margin-top:2px;}
    #top-buttons{ display:flex; gap:8px; pointer-events:all; }
    .icon-btn{
        min-width:44px; height:44px; border-radius:8px; border:1px solid var(--rule); background:var(--panel);
        color:var(--amber); font-size:16px; display:flex; align-items:center; justify-content:center;
        cursor:pointer; touch-action:manipulation;
    }
    .icon-btn:active{ background:rgba(255,176,32,0.14); }

    #objectives{
        position:absolute; top:70px; left:max(10px,env(safe-area-inset-left));
        background:var(--panel); border-left:3px solid var(--amber); border-radius:0 8px 8px 0;
        padding:10px 14px; max-width:250px;
    }
    .obj-row{ font-size:14px; margin:5px 0; color:var(--bone-faint); display:flex; align-items:center; gap:6px;}
    .obj-row .dot{ width:8px; height:8px; border-radius:50%; background:var(--rule); flex:none;}
    .obj-row span:nth-child(2){ flex:1 1 auto; min-width:0; }
    .obj-row.done{ color:var(--green); }
    .obj-row.done .dot{ background:var(--green); box-shadow:0 0 8px var(--green);}
    .obj-row .bar{ width:44px; height:5px; background:var(--rule); border-radius:3px; overflow:hidden; flex:none;}
    .obj-row .bar i{ display:block; height:100%; width:0%; background:linear-gradient(90deg,var(--amber),var(--green)); }

    /* readout: altitude / speed / period */
    #readout{
        position:absolute; top:70px; right:max(10px,env(safe-area-inset-right));
        background:var(--panel); border-right:3px solid var(--amber); border-radius:8px 0 0 8px;
        padding:10px 14px; font-size:14px; color:var(--bone-dim); text-align:right; display:none;
    }
    #readout.visible{ display:block; }
    #readout b{ color:var(--amber); font-variant-numeric:tabular-nums; }
    #readout .rlabel{ color:var(--bone-faint); letter-spacing:1px; }

    /* fuel + combo */
    #fuel-wrap{
        position:absolute; top:158px; right:max(10px,env(safe-area-inset-right));
        background:var(--panel); border-right:3px solid var(--green); border-radius:8px 0 0 8px;
        padding:8px 14px; font-size:14px; color:var(--green); text-align:right; display:none;
    }
    #fuel-wrap.visible{ display:block; }
    #fuel-bar{ width:110px; height:8px; background:var(--rule); border-radius:4px; overflow:hidden; margin-top:5px;}
    #fuel-bar i{ display:block; height:100%; width:100%; background:linear-gradient(90deg,var(--alert),var(--amber),var(--green)); }
    #combo{
        position:absolute; top:50%; left:50%; transform:translate(-50%,-50%) scale(0.6);
        font-size:clamp(26px,7vw,54px); color:var(--amber); font-weight:bold; opacity:0;
        pointer-events:none; letter-spacing:2px;
        transition:opacity .18s ease, transform .18s ease;
    }
    #combo.visible{ opacity:1; transform:translate(-50%,-50%) scale(1); }

    /* conjunction alert */
    #conj-alert{
        position:absolute; top:19%; left:50%; transform:translate(-50%,0);
        background:rgba(28,12,10,0.94); border:1px solid var(--alert); border-radius:10px;
        color:var(--bone); font-size:15px; padding:8px 18px; letter-spacing:2px;
        display:none; animation:alertpulse 0.7s infinite; white-space:nowrap;
    }
    #conj-alert.visible{ display:block; }
    @keyframes alertpulse{ 0%,100%{ box-shadow:0 0 8px rgba(232,69,47,0.35);} 50%{ box-shadow:0 0 26px rgba(232,69,47,0.7);} }

    #cutscene-msg{
        position:absolute; top:34%; left:50%; transform:translate(-50%,-50%);
        font-size:clamp(14px,2.6vw,16px); color:var(--bone);
        opacity:0; transition:opacity .5s ease; letter-spacing:2px; text-align:center;
        max-width:88vw; pointer-events:none; white-space:pre-line;
    }
    #cutscene-msg.visible{ opacity:1; }
    #tutorial-step{
        position:absolute; top:13%; left:50%; transform:translate(-50%,0); z-index:35;
        background:var(--panel); border:1px solid var(--amber); border-radius:10px; padding:12px 22px;
        font-size:clamp(14px,2.4vw,14px); color:var(--bone); letter-spacing:1px; max-width:80vw;
        text-align:center; display:none;
    }
    #tutorial-step.visible{ display:block; }

    /* bottom controls */
    #controls{
        position:absolute; bottom:max(14px,env(safe-area-inset-bottom)); left:0; right:0;
        display:flex; flex-direction:column; align-items:center; gap:9px; pointer-events:none;
    }
    #rotate-hint{
        background:rgba(232,69,47,0.10); border:1px solid var(--alert); color:var(--bone); font-size:14px;
        padding:6px 14px; border-radius:20px; letter-spacing:1px; display:none;
    }
    #hint-line{ font-size:14px; color:var(--bone-dim); text-align:center;
        text-shadow:0 1px 3px rgba(0,0,0,0.9); }
    #instruction-bar{ font-size:14px; color:var(--bone-faint); letter-spacing:1px; text-align:center;
        text-shadow:0 1px 3px rgba(0,0,0,0.9); }
    #action-row{ display:none; gap:14px; pointer-events:all; align-items:center; }
    #action-row.visible{ display:flex; }
    #btn-deorbit{
        min-width:150px; height:66px; border-radius:var(--r-panel); border:1px solid var(--amber);
        background:radial-gradient(circle,rgba(255,176,32,0.16),rgba(16,18,21,0.94));
        color:var(--amber); font-family:var(--display); font-size:14px; font-weight:bold;
        letter-spacing:2px; cursor:pointer; touch-action:manipulation;

    }
    #btn-deorbit:disabled{ opacity:0.35; box-shadow:none; }
    #btn-deorbit:not(:disabled):active{ transform:translateY(2px) scale(0.98); }

    /* overlays */
    #overlay-panel{
        position:absolute; inset:0; z-index:50; display:none; align-items:center; justify-content:center;
        background:rgba(7,8,10,0.86);
    }
    #overlay-panel.visible{ display:flex; }
    /* Telemetry slip, not a web modal: left-aligned, header strip, registration
       brackets, and corner radii that deliberately differ per corner. */
    .panel-box{
        background:var(--panel); border:1px solid var(--rule-strong);
        border-radius:var(--r-panel) 14px var(--r-panel) var(--r-panel);
        padding:0 0 20px; text-align:left; max-width:92vw; width:430px;
        box-shadow:0 24px 60px rgba(0,0,0,0.65);
        position:relative; overflow:visible;
        animation:panelIn .42s cubic-bezier(.16,1.32,.4,1) both;
    }
    @keyframes panelIn{
        0%{ transform:translateY(26px) scale(.97); opacity:0; }
        70%{ transform:translateY(-4px) scale(1.006); opacity:1; }
        100%{ transform:translateY(0) scale(1); opacity:1; }
    }
    /* corner registration marks */
    .panel-box::before, .panel-box::after{
        content:''; position:absolute; width:14px; height:14px; pointer-events:none;
        border:1px solid var(--amber); opacity:.75;
    }
    .panel-box::before{ left:-1px; top:-1px; border-right:0; border-bottom:0; }
    .panel-box::after{ right:-1px; bottom:-1px; border-left:0; border-top:0; }
    .panel-head{
        display:flex; align-items:baseline; gap:10px; padding:9px 16px;
        border-bottom:1px solid var(--rule); background:var(--panel-2);
        border-radius:var(--r-panel) 13px 0 0;
    }
    .panel-id{ font-family:var(--mono); font-weight:500; font-size:14px; color:var(--amber); letter-spacing:1px; }
    .panel-status{ font-size:13px; letter-spacing:1.5px; color:var(--bone-faint); margin-left:auto; }
    .panel-body{ padding:16px 22px 0; position:relative; }
    /* oversized stars, top-left, cropped by the panel edge */
    .stars-crop{
        display:flex; gap:6px; margin:-30px 0 12px -34px; padding-left:0;
        clip-path:inset(0 0 0 12px);
    }
    .panel-box h2{ font-weight:900; color:var(--bone); font-size:clamp(17px,4vw,25px);
        letter-spacing:1.5px; margin:0 0 8px; }
    .panel-box h2.fail{ color:var(--alert); }
    .panel-box .stars-earned{ display:flex; gap:8px; margin:10px 0; }
    .panel-box .stat-line{ font-size:14px; color:var(--bone-dim); margin:5px 0; letter-spacing:1px; }
    .fact-box{
        background:transparent; border:0; border-left:2px solid var(--amber-deep);
        border-radius:0; padding:2px 0 2px 12px; margin-top:16px;
        font-size:14px; line-height:1.7; color:var(--bone-dim); text-align:left;
    }
    .fact-box b{ color:var(--amber); letter-spacing:2px; display:block; margin-bottom:4px; }
    .panel-btns{ display:flex; flex-wrap:wrap; justify-content:flex-start; gap:8px; margin-top:18px;}
    .panel-btns .big-btn, .panel-btns .ghost-btn{ margin:0; }

    /* ── SUPER ── */
    #super-wrap{ display:flex; flex-direction:column; align-items:center; gap:4px; pointer-events:all; }
    #btn-super{
        width:96px; height:96px; border-radius:50%; border:3px solid var(--rule);
        background:radial-gradient(circle, rgba(23,26,30,0.92), rgba(16,18,21,0.94));
        color:var(--bone-faint); font-family:var(--display); font-size:14px; font-weight:bold;
        letter-spacing:1px; cursor:pointer; touch-action:manipulation; position:relative;
        display:flex; flex-direction:column; align-items:center; justify-content:center; overflow:hidden;
    }
    #btn-super .sicon{ font-size:24px; line-height:1; }
    #super-fill{
        position:absolute; left:0; bottom:0; width:100%; height:0%;
        background:linear-gradient(180deg, rgba(255,176,32,0.40), rgba(138,92,5,0.34));
        pointer-events:none; transition:height .15s linear;
    }
    #btn-super.ready{
        border-color:var(--amber); color:var(--void);
        box-shadow:0 0 34px rgba(255,176,32,0.55), inset 0 0 22px rgba(255,176,32,0.22);
        animation:superpulse .9s infinite;
    }

    @keyframes superpulse{ 0%,100%{ transform:scale(1);} 50%{ transform:scale(1.07);} }
    #super-label{ font-size:13px; letter-spacing:2px; color:var(--bone-faint); }
    #btn-super.ready + #super-label{ color:var(--amber); }

    /* desaturating veil while the Guardian Pulse is active */
    #super-veil{
        position:absolute; inset:0; z-index:18; pointer-events:none; opacity:0;
        backdrop-filter:saturate(0.25) brightness(1.05);
        -webkit-backdrop-filter:saturate(0.25) brightness(1.05);
        background:radial-gradient(ellipse at 50% 50%, rgba(255,176,32,0.05), rgba(7,8,10,0.34) 75%);
        transition:opacity .25s ease;
    }
    #super-veil.on{ opacity:1; }

    /* ── COUNTDOWN ── */
    #countdown{
        position:absolute; inset:0; z-index:46; display:none;
        align-items:center; justify-content:center; pointer-events:none;
    }
    #countdown.visible{ display:flex; }
    #count-num{
        font-size:clamp(72px,22vw,190px); font-weight:bold; color:var(--bone);
        letter-spacing:3px; color:var(--amber);
    }
    #count-num.pop{ animation:countpop .62s ease-out; }
    @keyframes countpop{
        0%{ transform:scale(2.4); opacity:0; }
        25%{ transform:scale(1); opacity:1; }
        75%{ transform:scale(1); opacity:1; }
        100%{ transform:scale(0.82); opacity:0; }
    }

    /* ── SLAM BANNER (victory / defeat) ── */
    #slam{
        position:absolute; inset:0; z-index:48; display:none;
        align-items:center; justify-content:center; pointer-events:none;
    }
    #slam.visible{ display:flex; }
    #slam-text{font-weight:900; 
        font-size:clamp(34px,10vw,86px); font-weight:bold; letter-spacing:3px;
        color:var(--bone); text-align:center; animation:slamin .55s cubic-bezier(.2,1.4,.4,1);
    }
    #slam-text.win{ color:var(--green); }
    #slam-text.lose{ color:var(--alert); }
    @keyframes slamin{ 0%{ transform:scale(3.2); opacity:0; } 60%{ transform:scale(0.92); opacity:1; } 100%{ transform:scale(1); } }
    #slam-ring{
        position:absolute; width:40px; height:40px; border-radius:50%;
        border:5px solid rgba(232,228,218,0.85); animation:ringout .75s ease-out forwards;
    }
    @keyframes ringout{ 0%{ transform:scale(0.2); opacity:1; } 100%{ transform:scale(24); opacity:0; } }

    /* ── PILOT STRIP (mission select) ── */
    .section-label{ font-size:14px; letter-spacing:2px; color:var(--bone-faint);
        margin:0 0 8px; align-self:center; }
    #pilot-strip{ display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin-bottom:16px; }
    .pilot-card{
        width:118px; padding:9px 8px 8px; border-radius:var(--r-card); cursor:pointer;
        border:1px solid var(--rule); background:var(--panel); touch-action:manipulation;
        position:relative; transition:border-color .12s, background .12s;
    }
    .pilot-card .pilot-check{
        position:absolute; top:6px; right:6px; width:13px; height:13px;
        color:var(--void); background:var(--amber); border-radius:var(--r-pill);
        padding:2px; display:none;
    }
    .pilot-card.selected .pilot-check{ display:block; }
    .pilot-card.locked{ opacity:0.38; cursor:default; }
    .pilot-card.selected{ border-color:var(--amber); border-width:2px; background:var(--panel-2); padding:8px 7px 7px; }
    .pilot-card canvas{ width:74px; height:74px; display:block; margin:0 auto 4px; }
    .pilot-name{font-weight:900;  font-size:13px; color:var(--bone); letter-spacing:2px; }
    .pilot-role{ font-size:13px; color:var(--bone-dim); letter-spacing:2px; margin-top:1px; }
    .pilot-perk{ font-size:13px; color:var(--bone-dim); margin-top:5px; line-height:1.4; min-height:22px; }
    .pilot-lock{ font-size:13px; color:var(--bone-faint); margin-top:4px; }

    /* ── TROPHY BAR ── */
    #trophy-bar{
        display:flex; align-items:center; gap:10px; margin-bottom:14px;
        background:var(--panel); border:1px solid var(--rule); border-radius:10px; padding:8px 16px;
        font-size:14px; color:var(--amber); letter-spacing:2px; display:flex; align-items:center; gap:8px;
    }
    #trophy-bar .tcount{ font-size:17px; font-weight:bold; font-variant-numeric:tabular-nums; }

    /* ── CRATE ── */
    #crate-layer{
        position:absolute; inset:0; z-index:52; display:none;
        align-items:center; justify-content:center; flex-direction:column;
        background:rgba(7,8,10,0.93); text-align:center;
    }
    #crate-layer.visible{ display:flex; }
    #crate-box{
        width:150px; height:150px; border-radius:20px;
        background:linear-gradient(160deg,var(--panel-2),#123murky 60%,var(--panel));
        background:linear-gradient(160deg,var(--panel-2),var(--panel));
        border:2px solid var(--amber); box-shadow:inset 0 0 30px rgba(0,0,0,0.55);
        display:flex; align-items:center; justify-content:center; font-size:58px;
    }
    #crate-box.shaking{ animation:crateshake .34s infinite; }
    @keyframes crateshake{
        0%{ transform:translate(0,0) rotate(0deg);} 25%{ transform:translate(-5px,2px) rotate(-3deg);}
        50%{ transform:translate(4px,-3px) rotate(3deg);} 75%{ transform:translate(-3px,-2px) rotate(-2deg);}
        100%{ transform:translate(0,0) rotate(0deg);}
    }
    #crate-box.bursting{ animation:crateburst .5s ease-out forwards; }
    @keyframes crateburst{
        0%{ transform:scale(1); opacity:1; }
        45%{ transform:scale(1.45); opacity:1; filter:brightness(3); }
        100%{ transform:scale(2.6); opacity:0; }
    }
    #crate-rays{
        position:absolute; width:340px; height:340px; opacity:0;
        background:conic-gradient(from 0deg, rgba(255,176,32,0.5) 0 6deg, transparent 6deg 30deg,
                   rgba(255,176,32,0.5) 30deg 36deg, transparent 36deg 60deg,
                   rgba(255,176,32,0.5) 60deg 66deg, transparent 66deg 90deg,
                   rgba(255,176,32,0.5) 90deg 96deg, transparent 96deg 120deg,
                   rgba(255,176,32,0.5) 120deg 126deg, transparent 126deg 150deg,
                   rgba(255,176,32,0.5) 150deg 156deg, transparent 156deg 180deg,
                   rgba(255,176,32,0.5) 180deg 186deg, transparent 186deg 210deg,
                   rgba(255,176,32,0.5) 210deg 216deg, transparent 216deg 240deg,
                   rgba(255,176,32,0.5) 240deg 246deg, transparent 246deg 270deg,
                   rgba(255,176,32,0.5) 270deg 276deg, transparent 276deg 300deg,
                   rgba(255,176,32,0.5) 300deg 306deg, transparent 306deg 330deg,
                   rgba(255,176,32,0.5) 330deg 336deg, transparent 336deg 360deg);
        border-radius:50%; pointer-events:none;
    }
    #crate-rays.on{ animation:raysspin 2.4s linear infinite, raysfade .5s ease-out forwards;
        filter:drop-shadow(0 0 18px rgba(255,176,32,0.42)); }
    @keyframes raysspin{ to{ transform:rotate(360deg);} }
    @keyframes raysfade{ from{ opacity:0;} to{ opacity:0.35;} }
    #crate-reveal{ opacity:0; }
    #crate-reveal.on{ animation:revealin .5s ease-out forwards; }
    @keyframes revealin{ from{ transform:scale(0.5); opacity:0;} to{ transform:scale(1); opacity:1;} }
    #crate-kind{ font-size:14px; letter-spacing:2px; color:var(--bone-dim); margin-top:18px; }
    #crate-name{font-weight:900;  font-size:clamp(26px,6vw,42px); font-weight:bold; color:var(--amber);
        letter-spacing:1.5px; margin-top:4px; }
    #crate-desc{ font-size:14px; color:var(--bone-dim); margin-top:8px; }
    #crate-tap{ font-size:14px; color:var(--bone-faint); letter-spacing:1.5px; margin-top:26px; }
    .confetti{
        position:absolute; width:9px; height:14px; pointer-events:none;
        animation:confall 1.5s ease-in forwards;
    }
    @keyframes confall{
        0%{ transform:translateY(0) rotate(0deg); opacity:1; }
        100%{ transform:translateY(340px) rotate(540deg); opacity:0; }
    }
    @media (prefers-reduced-motion: reduce){
        #btn-super.ready, #crate-box.shaking, #crate-rays.on{ animation:none; }
    }

    /* CSS fill mode when the Fullscreen API is unavailable or blocked. */
    :root.pseudo-fs, :root.pseudo-fs body{ position:fixed; inset:0; width:100%; height:100%; overflow:hidden; }
    :root.pseudo-fs #rotate-hint{ display:none !important; }
    .icon-btn.on{ color:var(--amber); border-color:var(--amber); }

    .score-pop{
        position:absolute; font-size:22px; color:var(--amber); font-weight:bold;
        pointer-events:none; z-index:45;
        animation:popfloat 1s ease-out forwards;
    }
    @keyframes popfloat{
        0%{ transform:translate(-50%,-50%) scale(0.6); opacity:0; }
        15%{ transform:translate(-50%,-75%) scale(1.3); opacity:1; }
        100%{ transform:translate(-50%,-200%) scale(1); opacity:0; }
    }
    /* Reduced motion: hold the end state instead of animating toward it. */
    @media (prefers-reduced-motion: reduce){
        #btn-super.ready, #crate-box.shaking, #crate-rays.on, #conj-alert{ animation:none; }
        /* CSS fill mode when the Fullscreen API is unavailable or blocked. */
    :root.pseudo-fs, :root.pseudo-fs body{ position:fixed; inset:0; width:100%; height:100%; overflow:hidden; }
    :root.pseudo-fs #rotate-hint{ display:none !important; }
    .icon-btn.on{ color:var(--amber); border-color:var(--amber); }

    .score-pop{ animation-duration:0.5s; }
    }
    @media (max-width:480px){
        #tutorial-step{ top:150px; max-width:92vw; width:92vw; }
        #cutscene-msg{ top:40%; }
        #objectives{ max-width:172px; padding:8px 10px;}
        .obj-row{ font-size:13px; }
        #readout{ font-size:14px; padding:8px 10px; }
    }
    @media (orientation:portrait) and (max-width:600px){ #rotate-hint.show{ display:block; } }

.eu-funding{ margin-top:20px; }

.eu-funding{ margin-top:20px; }

.eu-funding{ margin-top:20px; }
/* eu-funding */
.eu-funding{ display:flex; align-items:center; justify-content:center; gap:9px; }
.eu-flag{ width:36px; height:24px; display:block; flex:none;
    outline:1px solid rgba(255,255,255,.85); outline-offset:-1px; }
.eu-text{ font-family:Arial,Helvetica,sans-serif; font-weight:400; font-size:14px;
    line-height:1.2; color:inherit; opacity:.62; letter-spacing:.02em;
    text-align:left; white-space:nowrap; }

.eu-funding{ margin-top:20px; }
/* /eu-funding */


/* level-briefings-font */
/* /level-briefings-font */
/* level-briefings */
.brief-veil{
    position:fixed; inset:0; z-index:80; display:none;
    align-items:center; justify-content:center; padding:20px;
    background:rgba(4,6,12,.72); backdrop-filter:blur(3px);
    -webkit-backdrop-filter:blur(3px);
}
.brief-veil.visible{ display:flex; }
/* The cloud: a rounded card with three bumps behind it, all the same colour,
   so the silhouette reads as a speech cloud rather than a dialog box. */
.brief-cloud{
    position:relative; max-width:min(92vw,620px); width:100%;
    max-height:86vh; overflow-y:auto;
    background:#fdfcf7; color:#171a24;
    border:5px solid #10121b; border-radius:34px;
    padding:26px 26px 20px; text-align:center;
    box-shadow:0 14px 0 rgba(16,18,27,.9), 0 30px 60px rgba(0,0,0,.55);
    transform:scale(.4) rotate(-4deg); opacity:0;
}
.brief-veil.visible .brief-cloud{ animation:brief-pop .48s cubic-bezier(.2,1.5,.4,1) forwards; }
.brief-veil.closing .brief-cloud{ animation:brief-away .3s cubic-bezier(.5,-.5,.7,.2) forwards; }
@keyframes brief-pop{
    0%{ transform:scale(.4) rotate(-4deg); opacity:0 }
    64%{ transform:scale(1.06) rotate(1.2deg); opacity:1 }
    100%{ transform:scale(1) rotate(0); opacity:1 }
}
@keyframes brief-away{
    0%{ transform:scale(1); opacity:1 }
    100%{ transform:scale(.35) rotate(5deg); opacity:0 }
}
.brief-cloud::before, .brief-cloud::after{
    content:''; position:absolute; background:#fdfcf7;
    border:5px solid #10121b; border-radius:50%; z-index:-1;
}
.brief-cloud::before{ width:74px; height:74px; left:8%;   top:-32px; }
.brief-cloud::after { width:62px; height:62px; right:11%; top:-28px; }
/* The big bump is deliberately off-centre: dead centre would sit behind the
   LEVEL badge and read as a white halo round it rather than as cloud. */
.brief-bump{
    position:absolute; width:92px; height:92px; left:30%; top:-42px;
    background:#fdfcf7; border:5px solid #10121b; border-radius:50%; z-index:-1;
}
.brief-badge{
    display:inline-block; font-family:var(--toon);
    font-size:13px; letter-spacing:2px; color:#fdfcf7; background:#ffb020;
    border:3px solid #10121b; border-radius:999px; padding:3px 16px 4px;
    margin-bottom:8px; position:relative; z-index:1;
}
.brief-title{
    font-family:var(--toon);
    font-size:clamp(28px,7vw,50px); line-height:1.02; margin:2px 0 12px;
    color:#ffb020; -webkit-text-stroke:3px #10121b; paint-order:stroke fill;
    text-shadow:0 5px 0 rgba(16,18,27,.22);
}
.brief-body{
    font-family:var(--toon);
    font-size:clamp(15px,3.1vw,21px); line-height:1.42; color:#232838;
    letter-spacing:.01em; margin:0 auto 6px; max-width:34em;
}
.brief-body b{ color:#a35c00; -webkit-text-stroke:.6px #a35c00; }
/* A real equation, set apart from the sentence around it. Serif italic
   because that is what an equation looks like everywhere else a child will
   meet one, and the cartoon face would make it read as decoration. */
.brief-eq{
    display:block; margin:11px auto 9px; padding:9px 14px; max-width:26em;
    background:rgba(23,26,36,.055); border:2px dashed rgba(23,26,36,.16);
    border-radius:14px;
    font-family:'Iowan Old Style','Palatino Linotype',Palatino,Georgia,serif;
    font-style:italic; font-size:clamp(15px,3.2vw,20px); color:#171a24; letter-spacing:.01em;
}
.brief-eq i{ font-style:italic; }
.brief-eq small{ display:block; margin-top:5px; font-family:var(--toon);
    font-style:normal; font-size:14px; color:#5a6076; letter-spacing:.03em; }
.brief-learn{
    display:block; margin-top:12px; padding-top:10px;
    border-top:3px dashed rgba(23,26,36,.18);
    font-family:var(--toon);
    font-size:clamp(14px,2.5vw,15px); color:#5a6076; letter-spacing:.04em;
}
.brief-go{
    margin-top:14px; font-family:var(--toon);
    font-size:clamp(16px,3.4vw,22px); letter-spacing:1px;
    color:#fdfcf7; background:#ffb020; border:4px solid #10121b;
    border-radius:999px; padding:9px 30px 11px; cursor:pointer;
    box-shadow:0 6px 0 #10121b; transition:transform .08s, box-shadow .08s;
}
.brief-go:active{ transform:translateY(4px); box-shadow:0 2px 0 #10121b; }
@media (prefers-reduced-motion: reduce){
    .brief-veil.visible .brief-cloud,.brief-veil.closing .brief-cloud{
        animation:none; transform:scale(1); opacity:1 }
}
/* /level-briefings */


/* ══════════════════════════════════════════════════════════════════════
   ADDED FOR THE BILINGUAL BUILD
   ══════════════════════════════════════════════════════════════════════ */
/* A screen taller than the window must scroll from its top. Centring with
   justify-content cuts the top off where it cannot be reached; auto margins
   centre when there is room and collapse when there is not. */
.screen{ justify-content:flex-start; touch-action:pan-y; }
.screen > :first-child{ margin-top:auto; }
.screen > :last-child{ margin-bottom:auto; }
.sub{ letter-spacing:1.5px; }
.glow-title{ letter-spacing:3px; }
.intro-row{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center; align-items:center; }
.intro-row .ghost-btn{ margin:4px; }
.big-btn, .ghost-btn{ min-height:44px; }
.lang-switch{ display:inline-flex; border:1px solid var(--rule); border-radius:8px; overflow:hidden; margin:4px; }
.lang-switch button{ font-family:var(--display); font-size:14px; font-weight:700; letter-spacing:1px; min-width:52px; min-height:44px;
    background:transparent; color:var(--bone-dim); border:0; cursor:pointer; touch-action:manipulation; }
.lang-switch button.on{ background:var(--amber); color:var(--void); }
.copyright{ margin-top:12px; font-family:Arial,Helvetica,sans-serif; font-size:11px; line-height:1.3; letter-spacing:.04em; opacity:.5; text-align:center; }
#tagline{ margin-top:18px; opacity:.75; }
#load-fail{ display:none; position:fixed; left:50%; bottom:18px; transform:translateX(-50%); z-index:200;
    background:var(--panel); border:1px solid var(--alert); color:var(--bone); padding:10px 16px; border-radius:8px; font-size:14px; }

/* mission board: eight cards, 4 x 2 on a desktop, 2 x 4 on a phone */
#ls-grid{ grid-template-columns:repeat(4, minmax(150px, 190px)); }
@media (max-width:820px){ #ls-grid{ grid-template-columns:repeat(2, minmax(0, 46vw)); } }
.lvl-name{ font-size:14px; letter-spacing:.5px; min-height:34px; line-height:1.15; }
.lvl-best{ font-size:13px; }
.lvl-card{ min-height:76px; }
.pilot-card{ width:150px; }
.pilot-role, .pilot-perk, .pilot-lock{ font-size:13px; letter-spacing:.5px; }
#trophy-next{ color:#a87; font-size:14px; }

/* HUD */
#hud-top{ gap:8px; }
#level-banner{ letter-spacing:1px; }
#level-banner .lname{ font-size:14px; letter-spacing:1px; white-space:nowrap; }
#btn-skip{ width:auto; padding:0 12px; gap:6px; font-family:var(--display); font-size:14px; font-weight:700; letter-spacing:1px; color:var(--bone-dim); }
#objectives{ top:76px; max-width:290px; }
.obj-row{ font-size:14px; }
#readout{ top:76px; font-size:14px; line-height:1.45; }
#readout .rnote{ display:block; margin-top:4px; padding-top:4px; border-top:1px solid var(--rule); color:var(--bone-faint); font-size:13px; }
#fuel-wrap{ top:196px; font-size:14px; }
#hint-line, #instruction-bar{ font-size:14px; }
#conj-alert{ letter-spacing:1px; }
#subtitle{ position:absolute; left:50%; bottom:calc(max(14px,env(safe-area-inset-bottom)) + 188px); transform:translateX(-50%);
    max-width:min(86vw,640px); padding:6px 14px; border-radius:8px; background:rgba(7,8,10,.78);
    color:var(--bone); font-size:clamp(15px,2.4vw,19px); letter-spacing:.3px; text-align:center;
    opacity:0; transition:opacity .2s ease; pointer-events:none; }
#subtitle.visible{ opacity:1; }
#btn-deorbit, .burn-btn{ font-size:16px; letter-spacing:1px; }
.burn-btn{ min-width:120px; height:66px; border-radius:var(--r-panel); border:1px solid var(--amber);
    background:radial-gradient(circle,rgba(255,176,32,0.16),rgba(16,18,21,0.94)); color:var(--amber);
    font-family:var(--display); font-weight:bold; cursor:pointer; touch-action:manipulation; }
.burn-btn:active{ transform:translateY(2px) scale(.98); }
.burn-btn.now{ background:var(--amber); color:var(--void); animation:superpulse .9s infinite; }
#burn-row{ display:none; gap:14px; pointer-events:all; align-items:center; }
#burn-row.visible{ display:flex; }
/* Catch-up numbers sit inside the readout box, under the real height and speed. */
#cu-panel{ display:none; margin-top:6px; padding-top:6px; border-top:1px solid var(--rule); }
#cu-panel.visible{ display:block; }
#cu-panel b{ color:var(--amber); font-family:var(--mono); font-weight:500; }
#super-label{ font-size:13px; letter-spacing:1px; }
#btn-super{ font-size:13px; }

/* Phone, upright: the play area is the scarce thing. Shrink panels, never text below 13px. */
@media (max-width:480px){
    #objectives{ max-width:56vw; padding:6px 8px; top:82px; }
    .obj-row{ font-size:13px; margin:3px 0; }
    .obj-row .bar{ width:28px; }
    #readout{ top:auto; bottom:calc(max(14px,env(safe-area-inset-bottom)) + 150px); font-size:13px; padding:6px 8px; }
    #fuel-wrap{ top:82px; font-size:13px; padding:6px 8px; }
    #fuel-bar{ width:70px; }
    #btn-skip span{ display:none; }
    #btn-skip{ padding:0; }
    #level-banner{ padding:6px 10px; min-width:0; }
    #level-banner .lname{ white-space:normal; font-size:13px; letter-spacing:0; line-height:1.15; }   /* long names wrap to a second line */
    #btn-fullscreen{ display:none; }   /* phones: full screen is on the first screen; the room goes to the mission name */
    #btn-super{ width:76px; height:76px; }
    #btn-deorbit{ min-width:130px; height:56px; }
    .burn-btn{ min-width:104px; height:56px; }
    #subtitle{ bottom:calc(max(14px,env(safe-area-inset-bottom)) + 280px); }
    #instruction-bar{ display:none; }
    #readout:has(#cu-panel.visible) > div:not(#cu-panel), #readout:has(#cu-panel.visible) > .rnote{ display:none; }
    #readout:has(#cu-panel.visible) #cu-panel{ margin-top:0; padding-top:0; border-top:0; }
}
/* Phone on its side: controls go to the two bottom corners so the Earth and
   the orbits stay clear in the middle. */
@media (orientation:landscape) and (max-height:520px){
    #controls{ flex-direction:row; align-items:flex-end; justify-content:space-between; gap:8px;
        padding:0 max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left)); }
    #hint-line{ position:absolute; left:50%; bottom:2px; transform:translateX(-50%); width:44vw; }
    #instruction-bar{ display:none; }
    /* Catch-up on a phone on its side: only the four catch-up numbers, so the box stays off the orbits */
    #readout:has(#cu-panel.visible) > div:not(#cu-panel), #readout:has(#cu-panel.visible) > .rnote{ display:none; }
    #readout:has(#cu-panel.visible) #cu-panel{ margin-top:0; padding-top:0; border-top:0; }
    #action-row, #burn-row{ order:1; }
    #super-wrap{ order:3; margin-left:auto; }
    #btn-super{ width:72px; height:72px; }
    #btn-deorbit{ min-width:120px; height:54px; }
    .burn-btn{ min-width:96px; height:54px; }
    #objectives{ top:60px; max-width:230px; padding:6px 10px; }
    .obj-row{ font-size:13px; margin:3px 0; }
    #readout{ top:60px; font-size:13px; padding:6px 10px; }
    #fuel-wrap{ top:auto; bottom:128px; right:max(10px,env(safe-area-inset-right)); font-size:13px; }
    #subtitle{ bottom:64px; font-size:15px; }
    #conj-alert{ top:60px; }
    #tutorial-step{ top:60px; max-width:44vw; padding:8px 12px; }
    #cutscene-msg{ top:46%; }
    .glow-title{ margin-top:4px; }
    #logo-hero{ width:min(150px,24vw); margin-bottom:6px; }
    #screen-intro .sub{ margin-bottom:10px; }
    #tagline{ margin-top:8px; }
}

/* Briefing card: the GO button is always on screen; only the words scroll. */
.brief-veil{ padding:max(12px,env(safe-area-inset-top)) 12px max(12px,env(safe-area-inset-bottom)); }
.brief-cloud{ display:flex; flex-direction:column; max-height:calc(100dvh - 60px); overflow:visible; padding:22px 22px 16px; }
.brief-scroll{ overflow-y:auto; min-height:0; flex:1 1 auto; touch-action:pan-y; -webkit-overflow-scrolling:touch; padding:0 2px; }
.brief-badge{ align-self:center; flex:none; font-size:14px; letter-spacing:1px; }
.brief-title{ flex:none; }
.brief-go{ flex:none; align-self:center; min-height:48px; }
.brief-body{ font-size:clamp(16px,2.6vw,20px); }
.brief-learn{ font-size:clamp(14px,2.2vw,16px); letter-spacing:.02em; }
.brief-title{ font-size:clamp(26px,6vw,46px); }
@media (orientation:landscape) and (max-height:520px){
    .brief-cloud{ max-height:calc(100dvh - 44px); padding:14px 18px 10px; border-radius:26px; max-width:min(94vw,760px); }
    .brief-title{ font-size:26px; margin:0 0 6px; -webkit-text-stroke:2px #10121b; }
    .brief-body{ font-size:16px; line-height:1.3; }
    .brief-learn{ margin-top:8px; padding-top:6px; }
    .brief-go{ margin-top:8px; padding:6px 26px 8px; }
    .brief-bump, .brief-cloud::before, .brief-cloud::after{ display:none; }
}

/* results slip and settings */
.panel-box{ max-height:calc(100dvh - 24px); display:flex; flex-direction:column; width:460px; }
.panel-body{ overflow-y:auto; min-height:0; touch-action:pan-y; }
.panel-id{ font-size:14px; }
.panel-status{ font-size:14px; letter-spacing:1.5px; }
.stars-crop{ margin:4px 0 10px 0; clip-path:none; }
.star-lg{ width:44px; height:44px; }
.panel-box .stat-line{ font-size:15px; }
.fact-box{ font-size:15px; line-height:1.5; }
.fact-box b{ letter-spacing:1px; }
.stat-delta{ font-size:14px; }
.set-row{ display:flex; align-items:center; gap:12px; margin:10px 0; font-size:15px; color:var(--bone-dim); letter-spacing:1px; }
.set-row > span:first-child{ flex:0 0 118px; }
.set-row input[type=range]{ flex:1 1 auto; height:44px; accent-color:var(--amber); min-width:0; }
.set-row small{ display:block; font-size:13px; color:var(--bone-faint); letter-spacing:.3px; }
.seg{ display:inline-flex; flex-wrap:wrap; border:1px solid var(--rule); border-radius:8px; overflow:hidden; }
.seg button{ font-family:var(--display); font-weight:700; font-size:14px; letter-spacing:1px; min-height:44px; padding:0 14px;
    background:transparent; color:var(--bone-dim); border:0; cursor:pointer; touch-action:manipulation; }
.seg button.on{ background:var(--amber); color:var(--void); }
.note-list{ margin:6px 0 0; padding:0 0 0 18px; font-size:15px; line-height:1.5; color:var(--bone-dim); text-align:left; }
.note-list li{ margin:7px 0; }
.note-list b{ color:var(--amber); }

/* THE REAL SKY */
#rs-ui{ position:absolute; inset:0; z-index:30; display:none; pointer-events:none; }
#rs-ui.visible{ display:block; }
#rs-top{ position:absolute; top:max(10px,env(safe-area-inset-top)); left:84px; right:12px; display:flex; gap:8px; align-items:center; justify-content:space-between; pointer-events:all; }
#rs-title{ font-size:clamp(18px,3.4vw,28px); font-weight:900; letter-spacing:2px; color:var(--bone); }
#rs-chips{ position:absolute; left:max(10px,env(safe-area-inset-left)); top:70px; display:flex; flex-direction:column; gap:6px; pointer-events:all; }
.rs-chip{ font-family:var(--display); font-weight:700; font-size:14px; letter-spacing:1px; min-height:44px; padding:0 14px; text-align:left;
    background:var(--panel); color:var(--bone-dim); border:1px solid var(--rule); border-radius:8px; cursor:pointer; touch-action:manipulation; }
.rs-chip.on{ border-color:var(--amber); color:var(--amber); }
#rs-info{ position:absolute; left:50%; bottom:max(12px,env(safe-area-inset-bottom)); transform:translateX(-50%);
    width:min(94vw,760px); background:rgba(16,18,21,.92); border:1px solid var(--rule); border-radius:10px;
    padding:10px 16px; font-size:clamp(14px,2vw,17px); line-height:1.45; color:var(--bone-dim); text-align:left; pointer-events:all; }
#rs-info b{ color:var(--amber); }
#rs-info small{ display:block; margin-top:6px; font-size:13px; color:var(--bone-faint); }
.rs-label{ position:absolute; transform:translate(10px,-50%); font-size:14px; letter-spacing:1px; color:#fff;
    text-shadow:0 0 4px #000, 0 0 2px #000; pointer-events:none; white-space:nowrap; }
.rs-label::before{ content:''; position:absolute; left:-14px; top:50%; width:8px; height:8px; margin-top:-5px; border:1px solid #fff; border-radius:50%; }
@media (max-width:640px), (max-height:520px){
    #rs-chips{ flex-direction:row; flex-wrap:wrap; top:62px; right:10px; }
    .rs-chip{ padding:0 10px; font-size:13px; }
    #rs-info{ font-size:14px; padding:8px 12px; max-height:38vh; overflow-y:auto; touch-action:pan-y; }
    #rs-top{ left:62px; }
}

/* FINALE and CERTIFICATE */
#screen-finale .fin-stars{ display:flex; gap:6px; justify-content:center; margin:6px 0 4px; }
#screen-finale .fin-stars .star{ width:22px; height:22px; }
#fin-text{ max-width:620px; font-size:clamp(15px,2.4vw,19px); line-height:1.5; color:var(--bone-dim); letter-spacing:.3px; margin:10px auto 16px; font-weight:700; }
#fin-name{ font-family:var(--display); font-weight:700; font-size:20px; text-align:center; width:min(86vw,360px); min-height:48px;
    background:var(--panel); color:var(--bone); border:1px solid var(--rule-strong); border-radius:8px; padding:6px 12px;
    -webkit-user-select:text; user-select:text; touch-action:auto; }
#fin-privacy{ font-size:13px; color:var(--bone-faint); margin:6px 0 12px; letter-spacing:.3px; }
#certificate{ display:none; }
@media print{
    @page{ size:A4 landscape; margin:0; }
    html, body{ background:#fff !important; overflow:visible !important; height:auto !important; }
    body > *:not(#certificate){ display:none !important; }
    #certificate{ display:flex !important; flex-direction:column; align-items:center; justify-content:center; text-align:center;
        width:297mm; height:209mm; box-sizing:border-box; padding:16mm 22mm; color:#10121b; background:#fff;
        border:3mm solid #10121b; outline:1mm solid #ffb020; outline-offset:-6mm; font-family:var(--display);
        -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    #certificate img{ height:24mm; }
    #cert-head{ font-size:14pt; letter-spacing:4pt; color:#8a5c05; margin-top:5mm; }
    #cert-title{ font-family:var(--toon); font-size:44pt; color:#ffb020; -webkit-text-stroke:1.2pt #10121b; paint-order:stroke fill; margin:2mm 0 4mm; }
    #cert-given{ font-size:14pt; color:#444; }
    #cert-name{ font-family:var(--toon); font-size:34pt; margin:3mm 0; border-bottom:.6mm solid #10121b; min-width:120mm; padding:0 8mm 1mm; }
    #cert-body{ font-size:13pt; line-height:1.4; max-width:215mm; margin-top:2mm; }
    #cert-learned{ font-size:10.5pt; line-height:1.4; max-width:225mm; margin-top:4mm; color:#555; }
    #cert-stars{ display:flex; gap:1.5mm; justify-content:center; margin-top:5mm; }
    #cert-stars .star{ width:7mm; height:7mm; fill:#ccc; }
    #cert-stars .star.on{ fill:#ffb020; }
    #cert-foot{ display:flex; justify-content:space-between; width:100%; margin-top:6mm; font-size:10.5pt; color:#444; }
}

/* CALM MODE: no shake, no slow motion, no flashing, no pulsing. */
:root.calm #btn-super.ready, :root.calm #conj-alert, :root.calm .burn-btn.now,
:root.calm #crate-box.shaking, :root.calm #crate-rays.on{ animation:none; }
:root.calm #super-veil{ display:none; }
:root.calm #count-num.pop, :root.calm #slam-text, :root.calm .stars-crop .star{ animation:none; transform:none; opacity:1; }
:root.calm #slam-ring, :root.calm .confetti{ display:none; }
:root.calm .brief-veil.visible .brief-cloud, :root.calm .brief-veil.closing .brief-cloud, :root.calm .panel-box{ animation:none; transform:none; opacity:1; }

#ro-name{ color:var(--amber); font-weight:900; letter-spacing:1px; }
.obj-row .olabel{ flex:1 1 auto; }
