/* Design tokens, reset, typography, buttons, forms and full-screen overlays. */
:root {
    --bg: #070414;
    --panel: rgba(9, 7, 28, 0.86);
    --panel-solid: #0b0920;
    --line: rgba(46, 249, 255, 0.28);
    --line-soft: rgba(255, 255, 255, 0.08);
    --cyan: #2ef9ff;
    /* Follows the background theme (zone-look.js); the menu title and Play button use it. */
    --theme-accent: #3fb4ff;
    --blue: #4d7cff;
    --violet: #b04dff;
    --pink: #ff2fb4;
    --gold: #ffd257;
    --amber: #ffc23d;
    --red: #ff4d6d;
    --orange: #ff8a3d;
    --ok: #4dffb4;
    --text: #eef4ff;
    --muted: #a8b0da;
    --focus: #ffffff;
    --font-d: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
    --font-b: 'Exo 2', 'Segoe UI', system-ui, sans-serif;
    --font-m: 'Share Tech Mono', ui-monospace, Consolas, monospace;
    --cut: 14px;
}
* { box-sizing: border-box; }
/* Scrollbars everywhere: a slim rounded thumb in the theme accent on a faint track, no arrows. */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); border-radius: 8px; }
::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--theme-accent) 55%, transparent);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--theme-accent); background-clip: padding-box; }
::-webkit-scrollbar-button, ::-webkit-scrollbar-corner { display: none; background: transparent; }
@supports (-moz-appearance: none) {
    * { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--theme-accent) 55%, transparent) rgba(255, 255, 255, 0.04); }
}
html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-b);
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
}
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-m); letter-spacing: 0.04em; }
.muted { color: var(--muted); font-size: 12px; }
.center { text-align: center; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-d); margin: 0 0 14px; letter-spacing: 0.08em; }
h2 { font-size: 22px; }
h3 { font-size: 13px; color: var(--cyan); letter-spacing: 0.2em; margin: 20px 0 6px; text-transform: uppercase; }
kbd {
    font-family: var(--font-m);
    font-size: 12px;
    padding: 2px 7px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
}

/* ---------- panels ---------- */
.panel {
    position: relative;
    width: min(460px, 100%);
    max-height: 100%;
    overflow-y: auto;
    background: linear-gradient(160deg, rgba(20, 14, 54, 0.92), var(--panel) 40%);
    border: 1px solid var(--line);
    padding: 26px 24px;
    clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
    box-shadow: inset 0 1px 0 rgba(46, 249, 255, 0.35), inset 0 0 60px rgba(176, 77, 255, 0.08);
    overscroll-behavior: contain;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: var(--cut);
    width: 90px;
    height: 3px;
    background: linear-gradient(90deg, var(--cyan), transparent);
}
.panel.wide { width: min(600px, 100%); }
.panel.narrow { width: min(380px, 100%); }
.card {
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--line-soft);
    border-radius: 12px;
}

/* ---------- buttons ---------- */
.btn {
    position: relative;
    min-height: 50px;
    border-radius: 10px;
    border: 1px solid rgba(46, 249, 255, 0.35);
    background: linear-gradient(180deg, rgba(46, 249, 255, 0.1), rgba(46, 249, 255, 0.03));
    padding: 10px 16px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 14px;
    transition: background 0.15s, box-shadow 0.15s, transform 0.08s, border-color 0.15s;
}
.btn:hover { background: rgba(46, 249, 255, 0.18); border-color: var(--cyan); box-shadow: 0 0 18px rgba(46, 249, 255, 0.25); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.loading:disabled { opacity: 1; cursor: progress; }
.btn.loading > .btn-orig { display: none; }
.btn-load { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.spin {
    width: 1em; height: 1em; flex: none; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.primary {
    border: none;
    color: #04030f;
    font-family: var(--font-d);
    font-weight: 800;
    font-size: 16px;
    background: var(--theme-accent);
    box-shadow: 0 0 26px color-mix(in srgb, var(--theme-accent) 40%, transparent);
}
.btn.primary:hover { background: var(--theme-accent); box-shadow: 0 0 36px color-mix(in srgb, var(--theme-accent) 60%, transparent); filter: brightness(1.1); }
.btn.xl { min-height: 64px; font-size: 22px; letter-spacing: 0.18em; display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; }
.btn.xl kbd { background: rgba(4, 3, 15, 0.25); border-color: rgba(4, 3, 15, 0.35); color: #04030f; font-size: 11px; }
.btn.ghost { background: transparent; border-color: var(--line-soft); }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 12px; }
.btns { display: grid; gap: 10px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btns .btn-row { margin-top: 0; }
.btn-row.one, .btn-row:has(> [hidden]) { grid-template-columns: 1fr; }
.icon-btn {
    pointer-events: auto;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(7, 4, 20, 0.6);
    display: grid;
    place-items: center;
    padding: 0;
    backdrop-filter: blur(6px);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { border-color: var(--cyan); }

/* ---------- forms ---------- */
label.field { display: block; margin: 0 0 14px; }
label.field span { display: block; font-family: var(--font-m); font-size: 12px; letter-spacing: 0.14em; color: var(--muted); margin-bottom: 8px; }
input[type=text] {
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.4);
    font-size: 18px;
    font-weight: 600;
    user-select: text;
}
input[type=text]:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(46, 249, 255, 0.2); outline: none; }
input[type=range] { width: 100%; accent-color: var(--cyan); height: 28px; }
select { min-height: 42px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.err { color: var(--red); font-size: 14px; min-height: 1.3em; margin: -6px 0 6px; font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 14px 0 0; }
.hint.lead { margin: 0 0 16px; }
.hint.tight { margin: 0 0 8px; font-size: 13px; }
.switch {
    width: 54px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.08);
    position: relative;
    padding: 0;
    flex: none;
}
.switch::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.15s, background 0.15s;
}
.switch[aria-checked=true] { background: rgba(46, 249, 255, 0.28); border-color: var(--cyan); }
.switch[aria-checked=true]::after { transform: translateX(22px); background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }

/* ---------- overlays ---------- */
#vignette, #flash, #scanlines { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#vignette {
    background: radial-gradient(ellipse at center, transparent 55%, rgba(3, 1, 12, 0.75) 100%);
    transition: box-shadow 0.2s;
}
/* The corruption closing in tints the screen edges (steady, no flashing). */
body.danger-near #vignette { box-shadow: inset 0 0 140px rgba(255, 42, 85, 0.3); }
body.danger-crit #vignette { box-shadow: inset 0 0 190px rgba(255, 20, 70, 0.55); }
#flash { background: #fff; opacity: 0; }
#flash.hit { background: var(--red); }
#scanlines {
    opacity: 0.08;
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 3px);
    mix-blend-mode: overlay;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
body.reduced *, body.reduced *::before, body.reduced *::after { transition: none !important; animation: none !important; }
