/* ==========================================================================
   VAULT//PROTOCOL — design tokens
   White · Black · Charcoal · Deep Blue, with light-blue accent lines.
   ========================================================================== */
:root {
    --black:      #04060b;
    --ink:        #070b14;
    --charcoal:   #161a22;
    --charcoal-2: #20252f;
    --deep-blue:  #0a1f4f;
    --deep-blue-2:#11307a;
    --blue:       #2f6bff;
    --accent:     #5cc8ff;   /* light blue — lines, points of interest */
    --accent-2:   #9fe1ff;
    --white:      #f3f6fb;
    --muted:      #8b97ad;
    --danger:     #ff5c7a;

    --glass-bg:     rgba(18, 26, 46, 0.48);
    --glass-bg-2:   rgba(24, 34, 60, 0.62);
    --glass-border: rgba(130, 190, 255, 0.16);
    --glass-hi:     rgba(255, 255, 255, 0.06);
    --blur: 18px;

    --r-sm: 10px;
    --r:    18px;
    --r-lg: 26px;

    --font: "Space Grotesk", system-ui, -apple-system, Segoe UI, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

    --ease: cubic-bezier(.22, 1, .36, 1);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    /* fixed: the gradient is painted once for the viewport instead of repeating
       every 100vh (that repeat caused the hard colour seam at the bottom of long pages) */
    background:
        radial-gradient(1200px 700px at 75% -10%, rgba(17, 48, 122, .45), transparent 60%),
        radial-gradient(900px 600px at -10% 110%, rgba(10, 31, 79, .55), transparent 60%),
        var(--black);
    background-attachment: fixed;
    color: var(--white);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: block; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

.mono   { font-family: var(--mono); }
.small  { font-size: 12px; }
.muted  { color: var(--muted); }
.dim    { color: var(--muted); opacity: .75; }
.danger { color: var(--danger) !important; }

.eyebrow {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
}

/* film grain */
.noise {
    position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- glass ---------- */
.glass {
    background: linear-gradient(160deg, var(--glass-bg-2), var(--glass-bg));
    border: 1px solid var(--glass-border);
    border-radius: var(--r);
    backdrop-filter: blur(var(--blur)) saturate(140%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    box-shadow:
        inset 0 1px 0 var(--glass-hi),
        0 20px 60px -20px rgba(0, 0, 0, .7);
}

/* ---------- buttons ---------- */
.btn {
    --h: 50px;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    height: var(--h); padding: 0 24px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, .04);
    font-weight: 500; letter-spacing: .02em;
    cursor: pointer;
    transition: transform .3s var(--ease), background .3s, border-color .3s, box-shadow .3s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-2px); border-color: rgba(92, 200, 255, .45); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:focus-visible, .icon-btn:focus-visible, .card:focus-visible, .code-btn:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 3px;
}
.btn-primary {
    background: linear-gradient(135deg, var(--deep-blue-2), var(--blue));
    border-color: rgba(159, 225, 255, .35);
    box-shadow: 0 10px 30px -8px rgba(47, 107, 255, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { box-shadow: 0 14px 40px -8px rgba(92, 200, 255, .7), inset 0 1px 0 rgba(255, 255, 255, .3); }
.btn-ghost:hover { background: rgba(92, 200, 255, .08); }
.btn-sm { --h: 38px; padding: 0 16px; font-size: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

.icon-btn {
    width: 40px; height: 40px; display: grid; place-items: center;
    border-radius: 12px; border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, .03); cursor: pointer;
    transition: background .2s, border-color .2s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: rgba(92, 200, 255, .1); border-color: rgba(92, 200, 255, .4); }

.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.chip {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
    padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .03); color: var(--muted);
}
.chip-dev { color: #ffd27a; border-color: rgba(255, 210, 122, .35); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* ==========================================================================
   Landing
   ========================================================================== */
#hero-canvas, #bg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
.page-menu, .page-game { background: #040507; }
.page-landing { overflow: hidden; cursor: crosshair; }

.landing {
    position: relative; z-index: 2;
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
    padding: 0 clamp(20px, 8vw, 140px);
    pointer-events: none;
}
.landing > * { pointer-events: auto; }
.hero-title {
    font-size: clamp(42px, 8vw, 112px);
    line-height: .95; font-weight: 700; letter-spacing: -0.03em;
    background: linear-gradient(180deg, var(--white) 30%, #9fb4d8);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    text-shadow: 0 0 60px rgba(92, 200, 255, .15);
    max-width: 10ch;
}
.hero-sub { margin: 22px 0 34px; max-width: 460px; color: #b7c3d9; font-size: clamp(15px, 1.4vw, 18px); }
.hint { margin-top: 34px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); opacity: .7; }

.hud { position: fixed; inset: 0; z-index: 1; pointer-events: none; font-size: 11px; letter-spacing: .12em; }
.hud > div { position: absolute; line-height: 1.7; }
.hud-tl { top: 28px; left: 32px; }
.hud-tr { top: 28px; right: 32px; text-align: right; }
.hud-bl { bottom: 28px; left: 32px; color: var(--accent); }
.hud-br { bottom: 28px; right: 32px; }
.corner { position: absolute; width: 18px; height: 18px; border: 1px solid rgba(92, 200, 255, .5); }
.c-tl { top: 14px; left: 14px; border-right: 0; border-bottom: 0; }
.c-tr { top: 14px; right: 14px; border-left: 0; border-bottom: 0; }
.c-bl { bottom: 14px; left: 14px; border-right: 0; border-top: 0; }
.c-br { bottom: 14px; right: 14px; border-left: 0; border-top: 0; }

/* ---------- modal ---------- */
.modal {
    position: fixed; inset: 0; z-index: 50;
    display: grid; place-items: center; padding: 16px;
    background: rgba(2, 4, 9, .55);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal-card {
    position: relative; width: min(560px, 100%);
    max-height: calc(100dvh - 32px); overflow: auto;
    padding: clamp(22px, 4vw, 36px);
    border-radius: var(--r-lg);
}
.modal-card h2 { font-size: clamp(24px, 3vw, 32px); margin-bottom: 8px; }
.modal-close { position: absolute; top: 16px; right: 16px; }

.cam-frame {
    position: relative; margin-top: 18px;
    aspect-ratio: 4 / 3; border-radius: var(--r);
    overflow: hidden; background: var(--ink);
    border: 1px solid var(--glass-border);
}
.cam-frame video, .cam-frame img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-overlay { position: absolute; inset: 0; pointer-events: none; }
.face-guide { position: absolute; inset: 8% 25%; width: 50%; height: 84%; }
.face-guide ellipse { fill: none; stroke: rgba(92, 200, 255, .55); stroke-width: 1.2; stroke-dasharray: 6 6; animation: dash 12s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -240; } }
.bracket { position: absolute; width: 26px; height: 26px; border: 2px solid var(--accent); }
.b-tl { top: 12px; left: 12px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.b-tr { top: 12px; right: 12px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.b-bl { bottom: 12px; left: 12px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.b-br { bottom: 12px; right: 12px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.scanline {
    position: absolute; left: 0; right: 0; height: 2px; top: 0; opacity: 0;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 18px 4px rgba(92, 200, 255, .45);
}
.cam-frame.is-scanning .scanline { opacity: 1; animation: scan 1.6s var(--ease) infinite alternate; }
.cam-frame.is-scanning .face-guide ellipse { stroke: var(--accent); stroke-dasharray: none; }
@keyframes scan { from { top: 4%; } to { top: 96%; } }
.cam-mesh { position: absolute; inset: 0; }
.cam-mesh canvas { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-frame.ok   { border-color: rgba(92, 200, 255, .8); box-shadow: 0 0 40px -6px rgba(92, 200, 255, .6); }
.cam-mesh .scan-fx { position: absolute; inset: 0; transform: none; }
/* while analysing: the frozen photo slowly pushes in and gets a cold "sensor" grade,
   so the frame never looks static. `scale` keeps the inline mirror transform intact. */
.cam-frame.is-scanning #cam-still,
.cam-frame.is-scanning .cam-mesh canvas { animation: camPush 5s cubic-bezier(.22, 1, .36, 1) forwards; }
.cam-frame.is-scanning #cam-still { filter: grayscale(.55) contrast(1.15) brightness(.82); transition: filter .8s; }
.cam-frame.is-scanning::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(92, 200, 255, .05) 0 1px, transparent 1px 3px);
    mix-blend-mode: screen; animation: camRoll 1.2s linear infinite;
}
.cam-frame.ok #cam-still { filter: none; }
@keyframes camPush { from { scale: 1; } to { scale: 1.07; } }
@keyframes camRoll { to { background-position: 0 3px; } }

.scan-progress { margin-top: 12px; }
.scan-progress-bar { position: relative; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.scan-progress-bar span {
    position: absolute; inset: 0 auto 0 0; width: 0;
    background: linear-gradient(90deg, var(--blue), var(--accent));
    box-shadow: 0 0 12px var(--accent);
}
.scan-progress-bar span::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
    animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.scan-progress-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; letter-spacing: .1em; color: var(--accent-2); text-transform: uppercase; }
.scan-progress.ok .scan-progress-bar span { background: linear-gradient(90deg, #1fa37a, #78ffc8); box-shadow: 0 0 12px #78ffc8; }
.scan-progress.ok .scan-progress-bar span::after, .scan-progress.fail .scan-progress-bar span::after { display: none; }
.scan-progress.ok .scan-progress-meta { color: #78ffc8; }
.scan-progress.fail .scan-progress-bar span { background: var(--danger); box-shadow: 0 0 12px var(--danger); }
.scan-progress.fail .scan-progress-meta { color: var(--danger); }

.cam-frame.fail { border-color: rgba(255, 92, 122, .7); }
.cam-error {
    position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
    padding: 24px; color: var(--muted); font-size: 14px; background: var(--ink);
}

.scan-log {
    list-style: none; margin: 14px 0 0; padding: 0;
    font-size: 12px; color: var(--muted); min-height: 20px;
}
.scan-log li { padding: 2px 0; }
.scan-log li::before { content: "› "; color: var(--accent); }
.scan-log li.ok { color: var(--accent-2); }
.scan-log li.err { color: var(--danger); }

.granted-icon {
    width: 72px; height: 72px; border-radius: 50%; margin-bottom: 18px;
    display: grid; place-items: center;
    background: radial-gradient(circle, rgba(92, 200, 255, .25), rgba(17, 48, 122, .3));
    border: 1px solid rgba(92, 200, 255, .5);
    box-shadow: 0 0 40px rgba(92, 200, 255, .35);
}
.granted-icon svg { width: 36px; height: 36px; color: var(--accent-2); }

/* ==========================================================================
   Top bar + code drawer
   ========================================================================== */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px clamp(16px, 4vw, 40px);
    background: linear-gradient(180deg, rgba(4, 5, 7, .8) 0%, rgba(4, 5, 7, .45) 55%, rgba(4, 5, 7, 0) 100%);
}
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 13px; letter-spacing: .16em; }
.brand-mark {
    width: 22px; height: 22px; border-radius: 7px;
    border: 1px solid var(--accent);
    background: linear-gradient(135deg, var(--deep-blue-2), transparent);
    box-shadow: 0 0 14px rgba(92, 200, 255, .4), inset 0 0 8px rgba(92, 200, 255, .3);
    transform: rotate(45deg) scale(.8);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.code-btn {
    display: inline-flex; align-items: center; gap: 10px;
    height: 44px; padding: 0 14px 0 12px;
    border-radius: 14px; cursor: pointer;
    transition: border-color .3s, box-shadow .3s, transform .3s var(--ease);
}
.code-btn:hover { border-color: rgba(92, 200, 255, .5); transform: translateY(-1px); }
.code-btn .lock-svg { width: 20px; height: 20px; color: var(--accent); }
.code-btn-label { font-family: var(--mono); font-size: 12px; letter-spacing: .16em; }
.code-btn-count {
    font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 8px;
    background: rgba(92, 200, 255, .12); color: var(--accent-2);
}
.code-btn.is-open { border-color: rgba(92, 200, 255, .7); box-shadow: 0 0 30px -4px rgba(92, 200, 255, .55); }
.code-btn.pulse { animation: pulse 1s var(--ease) 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(92, 200, 255, .15), 0 0 40px rgba(92, 200, 255, .6); } }

/* lock shackle opens */
.lock-shackle { transition: transform .6s var(--ease); transform-origin: 16px 11px; }
.is-open .lock-shackle, .lock-svg.is-open .lock-shackle { transform: translateY(-2.5px) rotate(28deg); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(2, 4, 9, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.code-drawer {
    position: fixed; z-index: 41; top: 74px; right: clamp(12px, 3vw, 40px);
    width: min(420px, calc(100vw - 24px));
    padding: 24px; border-radius: var(--r-lg);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.drawer-head h2 { font-size: 24px; }
.code-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.slot {
    position: relative; aspect-ratio: 3 / 4;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    border-radius: 14px; background: rgba(4, 6, 11, .55);
    border: 1px solid var(--glass-border);
    font-family: var(--mono);
    overflow: hidden;
}
.slot .lock-svg { width: 22px; height: 22px; color: var(--muted); opacity: .6; }
.slot-digit { font-size: 34px; font-weight: 700; color: var(--white); line-height: 1; }
.slot-label { position: absolute; bottom: 8px; font-size: 10px; letter-spacing: .14em; color: var(--muted); }
.slot.filled {
    border-color: rgba(92, 200, 255, .55);
    background: linear-gradient(180deg, rgba(17, 48, 122, .5), rgba(4, 6, 11, .6));
    box-shadow: inset 0 0 24px rgba(92, 200, 255, .15), 0 0 24px -8px rgba(92, 200, 255, .5);
}
.slot.filled .slot-digit { text-shadow: 0 0 18px rgba(92, 200, 255, .8); }
.code-progress { margin-top: 20px; }
.code-progress-bar { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .06); overflow: hidden; margin-bottom: 8px; }
.code-progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--accent)); box-shadow: 0 0 12px var(--accent); transition: width .8s var(--ease); }
.code-final { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--glass-border); }
.code-final-msg { font-size: 15px; }

/* ==========================================================================
   Menu / grid
   ========================================================================== */
.menu, .game-page {
    position: relative; z-index: 2;
    max-width: 1240px; margin: 0 auto;
    padding: clamp(16px, 4vw, 40px) clamp(16px, 4vw, 40px) 80px;
}
.menu-head { margin: 10px 0 36px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.restart-btn { color: var(--muted); }
.restart-btn svg { width: 16px; height: 16px; }
.restart-btn:hover { color: var(--white); }
.card[data-status="locked"] { opacity: .7; filter: saturate(.5); }
.card[data-status="locked"] .dot { background: #ffb3a3; box-shadow: 0 0 8px rgba(255, 106, 77, .6); }
.menu-title { font-size: clamp(34px, 5vw, 64px); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }

.grid {
    display: grid; gap: clamp(14px, 2vw, 24px);
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    perspective: 1400px;
}
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
    --mx: 50%; --my: 50%;
    position: relative; display: flex; flex-direction: column;
    min-height: 340px; padding: 22px;
    border-radius: var(--r-lg); overflow: hidden;
    transform-style: preserve-3d;
    transition: border-color .4s, box-shadow .4s;
    will-change: transform;
}
a.card { cursor: pointer; }
.card-glow {
    position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
    background: radial-gradient(420px circle at var(--mx) var(--my), rgba(92, 200, 255, .16), transparent 45%);
}
.card:hover .card-glow { opacity: 1; }
a.card:hover { border-color: rgba(92, 200, 255, .45); box-shadow: 0 30px 80px -30px rgba(47, 107, 255, .55), inset 0 1px 0 var(--glass-hi); }
.card::after { /* top accent line */
    content: ""; position: absolute; left: 22px; right: 22px; top: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(92, 200, 255, .6), transparent); opacity: .6;
}
.card-top { display: flex; justify-content: space-between; align-items: center; transform: translateZ(30px); }
.card-index { font-size: 13px; color: var(--muted); letter-spacing: .12em; }
.card-status { display: inline-flex; align-items: center; gap: 8px; font-size: 10px; letter-spacing: .16em; color: var(--muted); }
.card-icon {
    width: 86px; height: 86px; margin: 34px 0 26px;
    display: grid; place-items: center; border-radius: 22px;
    background: radial-gradient(circle at 30% 20%, rgba(92, 200, 255, .18), rgba(10, 31, 79, .35));
    border: 1px solid var(--glass-border);
    color: var(--accent);
    transform: translateZ(50px);
    box-shadow: 0 16px 40px -14px rgba(47, 107, 255, .6);
}
.card-icon svg { width: 44px; height: 44px; }
.card-title { font-size: 22px; margin-bottom: 6px; transform: translateZ(40px); }
.card-tag { color: var(--muted); font-size: 14px; transform: translateZ(30px); }
.card-owner { margin-top: 8px; font-size: 11px; color: #ffd27a; opacity: .8; }
.card-foot {
    margin-top: auto; padding-top: 22px;
    display: flex; justify-content: space-between; align-items: center;
    transform: translateZ(30px);
}
.card-digit {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 8px 14px 8px 10px; border-radius: 12px;
    background: rgba(4, 6, 11, .55); border: 1px solid var(--glass-border);
}
.card-digit .lock-svg { width: 18px; height: 18px; color: var(--muted); }
.card-digit b { font-size: 20px; min-width: 1ch; text-align: center; }
.card-cta { font-size: 12px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; transition: color .3s, transform .3s var(--ease); }
a.card:hover .card-cta { color: var(--accent); transform: translateX(4px); }

.card[data-status="open"] .dot { animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.card[data-status="soon"] { opacity: .55; filter: saturate(.4); }
.card[data-status="soon"] .dot { background: var(--muted); box-shadow: none; }
.card[data-status="completed"] {
    border-color: rgba(92, 200, 255, .5);
    background: linear-gradient(160deg, rgba(17, 48, 122, .55), rgba(10, 20, 44, .5));
}
.card[data-status="completed"] .card-status { color: var(--accent-2); }
.card[data-status="completed"] .card-digit { border-color: rgba(92, 200, 255, .6); box-shadow: 0 0 20px -4px rgba(92, 200, 255, .55); }
.card[data-status="completed"] .card-digit .lock-svg { color: var(--accent); }
.card[data-status="completed"] .card-digit b { color: var(--white); text-shadow: 0 0 14px rgba(92, 200, 255, .9); }
.card[data-status="completed"] .card-icon { color: var(--white); border-color: rgba(92, 200, 255, .5); }

.final-banner {
    margin-top: 28px; padding: 24px 28px;
    display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
    border-color: rgba(92, 200, 255, .5);
}
.final-banner h2 { font-size: clamp(20px, 2.6vw, 28px); }

/* ==========================================================================
   Game shell
   ========================================================================== */
.game-head { display: flex; align-items: center; gap: 20px; margin: 6px 0 24px; flex-wrap: wrap; }
.game-title { font-size: clamp(28px, 4vw, 46px); font-weight: 700; }
.game-stage { min-height: 60vh; padding: clamp(18px, 3vw, 32px); border-radius: var(--r-lg); position: relative; overflow: hidden; }
.game-loading { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(92, 200, 255, .25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* form controls usable by game modules */
.field {
    width: 100%; height: 52px; padding: 0 18px;
    border-radius: 14px; border: 1px solid var(--glass-border);
    background: rgba(4, 6, 11, .6); color: var(--white);
    font-family: var(--mono); font-size: 16px; letter-spacing: .06em;
    transition: border-color .2s, box-shadow .2s;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(92, 200, 255, .12); }
.field.shake { animation: shake .45s; border-color: var(--danger); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.placeholder-game { max-width: 620px; }
.placeholder-game h2 { font-size: 26px; margin-bottom: 10px; }
.placeholder-game .answer-row { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.placeholder-game .answer-row .field { flex: 1 1 240px; }
.banner-done {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 22px;
    border-radius: 14px; border: 1px solid rgba(92, 200, 255, .45); background: rgba(17, 48, 122, .35);
    font-family: var(--mono); font-size: 13px;
}

.unlock-overlay {
    position: fixed; inset: 0; z-index: 60;
    display: grid; place-items: center; text-align: center; padding: 16px;
    background: radial-gradient(circle at center, rgba(17, 48, 122, .55), rgba(2, 4, 9, .92) 65%);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.unlock-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.unlock-lock { width: 96px; height: 96px; color: var(--accent); filter: drop-shadow(0 0 24px rgba(92, 200, 255, .7)); margin-bottom: 10px; }
.unlock-digit {
    font-size: clamp(110px, 20vw, 200px); font-weight: 700; line-height: 1;
    color: var(--white); text-shadow: 0 0 50px rgba(92, 200, 255, .9), 0 0 120px rgba(47, 107, 255, .6);
}
.unlock-inner .btn { margin-top: 18px; }

.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
    padding: 12px 18px; border-radius: 12px; font-size: 14px;
    background: rgba(18, 26, 46, .9); border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    animation: toastIn .4s var(--ease);
}
.toast.err { border-color: rgba(255, 92, 122, .5); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ==========================================================================
   Enroll (admin)
   ========================================================================== */
.enroll { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.enroll-card { width: min(680px, 100%); padding: clamp(22px, 4vw, 36px); border-radius: var(--r-lg); }
.enroll-card h1 { font-size: 30px; margin-bottom: 10px; }
.enroll-card > .mono { margin-top: 16px; color: var(--accent-2); font-size: 13px; }
.enroll-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; margin-top: 16px; }
.enroll-thumbs figure { margin: 0; position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--glass-border); }
.enroll-thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.enroll-thumbs figcaption { position: absolute; bottom: 0; left: 0; right: 0; font: 10px var(--mono); padding: 4px; background: rgba(4, 6, 11, .75); text-align: center; }
.enroll-thumbs .ok figcaption { color: var(--accent-2); }
.enroll-thumbs .bad figcaption { color: var(--danger); }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
    .hud-tl, .hud-tr { top: 22px; }
    .hud-bl, .hud-br { display: none; }
    .chip-user { display: none; }
    .brand-text { display: none; }
    .card { min-height: 290px; }
    .code-drawer { top: 70px; right: 12px; }
}

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

/* completed = shackle open */
.card[data-status="completed"] .lock-shackle,
.slot.filled .lock-shackle { transform: translateY(-2.5px) rotate(28deg); }

/* ---------- room viewing + post-phase cinematic ---------- */
.menu-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.menu-tools svg { width: 16px; height: 16px; }
.menu { transition: opacity .9s var(--ease), transform .9s var(--ease); }
body.is-viewing .menu, body.is-cinematic .menu { opacity: 0; transform: translateY(24px); pointer-events: none; }
/* the top bar (code + operator) stays visible during the cinematic so the code is always in reach */
body.is-viewing, body.is-cinematic { overflow: hidden; }
.back-to-grid { position: fixed; left: 50%; bottom: 28px; translate: -50% 0; z-index: 35; }
.back-to-grid svg { width: 16px; height: 16px; }
.awaken {
    position: fixed; left: 50%; bottom: clamp(28px, 8vh, 80px); translate: -50% 0; z-index: 35;
    width: min(560px, calc(100vw - 32px)); text-align: center; pointer-events: none;
}
.awaken > * { pointer-events: auto; }
.awaken-title { font-size: clamp(30px, 5vw, 54px); font-weight: 700; letter-spacing: -.02em; text-shadow: 0 0 40px rgba(92, 200, 255, .55); }
.awaken-sub { margin-top: 8px; color: #c4d0e4; text-shadow: 0 2px 20px #000; }
.awaken-bar { height: 2px; width: 220px; margin: 18px auto 0; background: rgba(255, 255, 255, .1); border-radius: 2px; overflow: hidden; }
.awaken-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--accent)); box-shadow: 0 0 10px var(--accent); }
.awaken-skip { margin-top: 14px; opacity: .7; }

/* sound toggle */
.mute-btn .snd-off { display: none; }
.mute-btn.is-muted .snd-on { display: none; }
.mute-btn.is-muted .snd-off { display: block; }
.mute-btn.is-muted { color: var(--muted); }

/* open padlocks: the shackle swings up out of the icon box — let it, and give it room */
.lock-svg { overflow: visible; }
.card-digit { padding: 12px 14px 8px 10px; }
.card-digit .lock-svg { margin-top: -2px; }
.slot { padding-top: 6px; }

/* ---------- how-to-play card ---------- */
.howto { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; padding: 16px; background: rgba(2, 4, 9, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.howto-card { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: clamp(22px, 4vw, 34px); border-radius: var(--r-lg); }
.howto-card h2 { font-size: clamp(24px, 3vw, 30px); margin-bottom: 8px; }
.howto-lead { color: #c4d0e4; margin-bottom: 18px; }
.howto-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.howto-steps li { display: flex; gap: 14px; align-items: center; font-size: 15px; }
.howto-ico { flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--accent-2); background: rgba(92, 200, 255, .08); border: 1px solid var(--glass-border); }
.howto-ico svg { width: 22px; height: 22px; }
.howto-green { color: #86efac; background: rgba(74, 222, 128, .1); border-color: rgba(74, 222, 128, .4); }
.howto-red { color: #ffb3a3; background: rgba(255, 106, 77, .1); border-color: rgba(255, 106, 77, .4); }
.howto-bolt { color: #ffd27a; }
.howto-note { margin-top: 16px; font-size: 12px; color: var(--muted); }
.howto-go { margin-top: 22px; width: 100%; }

/* ---------- cipher video (after Code Acquired) ---------- */
.video-modal { position: fixed; inset: 0; z-index: 65; display: grid; place-items: center; padding: 16px; background: rgba(2, 4, 9, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.video-frame { width: min(1100px, 100%); }
.video-stage { position: relative; }
.video-frame video { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100dvh - 120px); border-radius: 16px; background: #000; box-shadow: 0 30px 90px -20px rgba(0, 0, 0, .9), 0 0 0 1px rgba(92, 200, 255, .25); }
.video-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; border-radius: 16px; background: radial-gradient(600px 400px at 50% 50%, #0b1730, #03050a 75%); transition: opacity .5s var(--ease), visibility .5s; }
.video-loading.is-done { opacity: 0; visibility: hidden; }
.video-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; color: var(--accent-2); font-size: 12px; letter-spacing: .12em; }

/* ==========================================================================
   Loading screen — transform/opacity only, so it stays smooth while the page is busy
   ========================================================================== */
.loader {
    position: fixed; inset: 0; z-index: 200;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
    background: radial-gradient(900px 600px at 50% 45%, #0b1730, #04060b 70%);
    transition: opacity .7s var(--ease), visibility .7s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader-core { position: relative; width: 84px; height: 84px; }
.loader-core i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid transparent; will-change: transform; }
.loader-core i:nth-child(1) { border-top-color: var(--accent); border-right-color: rgba(92, 200, 255, .35); animation: ldSpin 1.6s linear infinite; }
.loader-core i:nth-child(2) { inset: 12px; border-bottom-color: #9fe1ff; border-left-color: rgba(159, 225, 255, .3); animation: ldSpin 2.4s linear infinite reverse; }
.loader-core i:nth-child(3) { inset: 24px; border-top-color: #ffd27a; animation: ldSpin 1.1s linear infinite; }
.loader-core b { position: absolute; inset: 36px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 18px var(--accent); animation: ldPulse 1.6s ease-in-out infinite; }
@keyframes ldSpin { to { transform: rotate(360deg); } }
@keyframes ldPulse { 50% { transform: scale(.55); opacity: .6; } }
.loader-eyebrow { font-size: 11px; letter-spacing: .3em; color: var(--muted); margin: 0; }
/* six phrases, each sweeping up into view, holding, then sweeping out (10.8s loop) */
.loader-words { position: relative; height: 26px; width: min(420px, 90vw); overflow: hidden; text-align: center; }
.loader-words span {
    position: absolute; inset: 0; font-size: 15px; letter-spacing: .16em; text-transform: uppercase; color: var(--white);
    opacity: 0; transform: translateY(110%); will-change: transform, opacity;
    animation: ldWord 10.8s cubic-bezier(.22, 1, .36, 1) infinite;
    animation-delay: calc(var(--i) * 1.8s);
}
.loader-words span::after { content: "…"; color: var(--accent); }
@keyframes ldWord {
    0%     { opacity: 0; transform: translateY(110%); }
    3%     { opacity: 1; transform: translateY(0); }
    14%    { opacity: 1; transform: translateY(0); }
    16.66% { opacity: 0; transform: translateY(-110%); }
    100%   { opacity: 0; transform: translateY(-110%); }
}
.loader-sweep { position: relative; width: min(260px, 70vw); height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.loader-sweep i { position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), transparent); box-shadow: 0 0 12px var(--accent); animation: ldSweep 1.8s cubic-bezier(.65, 0, .35, 1) infinite; will-change: transform; }
@keyframes ldSweep { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .loader-words span { animation-duration: 10.8s !important; animation-iteration-count: infinite !important; } }
