/* Neon Vault — one dark arcade theme by choice.
   Layout: status bar on top; zoomable board fills the left; action rail on the right (landscape). */
:root {
  --bg: #0e0a1c; --panel: #19122e; --panel-2: #231a40; --line: #3a2d63;
  --ink: #f1eaff; --muted: #a497cc; --pink: #ff4fb3; --cyan: #3de8ff; --gold: #ffd34d; --bad: #ff6b6b; --good: #6dff9e;
  --f-display: "Pixelify Sans", "Courier New", monospace;
  --f-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail: 264px; --bar: 34px;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 var(--f-body); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; margin: 0; letter-spacing: .02em; text-wrap: balance; }
h1 { font-size: clamp(26px, 5vw, 44px); line-height: 1; color: var(--pink); text-shadow: 0 0 14px rgba(255,79,179,.5); }
h2 { font-size: 18px; color: var(--cyan); }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
p { margin: 0; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.btn { border: 2px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 8px 12px; font-family: var(--f-display); font-weight: 500; letter-spacing: .03em; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--pink); border-color: var(--pink); color: #1a0716; font-weight: 700; }
.btn.cyan { border-color: var(--cyan); color: var(--cyan); }
.btn.gold { border-color: var(--gold); color: var(--gold); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn small { font-family: var(--f-body); font-size: 11px; opacity: .8; font-weight: 400; }

.spr { background: url(../assets/atlas.webp) 0 0 / 800% 600% no-repeat; aspect-ratio: 1; border-radius: 6px; flex: none; }
.face { border-radius: 50%; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }

/* setup */
.setup { overflow-y: auto; }
.setup-in { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 1.6fr); gap: 20px; padding: 18px max(16px, var(--safe-r)) 18px max(16px, var(--safe-l)); max-width: 1200px; margin: 0 auto; width: 100%; }
.setup-l { display: flex; flex-direction: column; gap: 12px; }
.kicker { font-family: var(--f-display); color: var(--gold); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.codebox { display: flex; gap: 8px; }
.codebox input { flex: 1; min-width: 0; background: var(--bg); border: 2px solid var(--line); border-radius: 6px; color: var(--gold); font: 700 20px var(--f-display); letter-spacing: .12em; padding: 6px 10px; text-transform: uppercase; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pick { position: relative; background: var(--panel-2); border: 2px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; text-align: center; min-width: 0; }
.pick .spr { width: 100%; }
.pick .nm { font-size: 13px; font-weight: 700; line-height: 1.15; }
.pick .rl { font-size: 11px; color: var(--muted); line-height: 1.15; }
.pick[aria-pressed="true"] { border-color: var(--seat); box-shadow: 0 0 0 1px var(--seat), 0 0 16px -2px var(--seat); }
.pick .seat { position: absolute; top: 8px; left: 8px; background: var(--seat); color: #120a20; font: 700 12px var(--f-display); border-radius: 4px; padding: 1px 6px; }
.rules { font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.rules b { color: var(--cyan); }
.legend-chip { display: inline-block; width: 14px; height: 10px; border: 2px solid; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

/* game */
.status { height: calc(var(--bar) + var(--safe-t)); padding: var(--safe-t) max(12px, var(--safe-r)) 0 max(12px, var(--safe-l)); display: flex; align-items: center; gap: 12px; background: #0a0716; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; flex: none; position: relative; z-index: 3; }
.status .code { font-family: var(--f-display); color: var(--gold); font-size: 13px; letter-spacing: .08em; }
.status .who { display: flex; align-items: center; gap: 6px; font-family: var(--f-display); font-weight: 700; font-size: 14px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status .who .spr { width: 22px; border: 2px solid var(--seat); }
.status .sp { flex: 1; }
.status .tod { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.clock { font-family: var(--f-display); font-weight: 700; font-size: 18px; color: var(--ink); background: none; border: 0; padding: 2px 6px; border-radius: 6px; display: flex; align-items: baseline; gap: 6px; }
.clock .blink { animation: blink 1s steps(1) infinite; }
.clock small { font-size: 10px; color: var(--muted); font-weight: 500; letter-spacing: .1em; }
.clock.late { color: var(--gold); } .clock.dawn { color: var(--bad); }
@keyframes blink { 50% { opacity: 0; } }
.main { flex: 1; display: flex; min-height: 0; }
.boardwrap { position: relative; flex: 1; min-width: 0; }
.boardwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.zoombar { position: absolute; left: max(10px, var(--safe-l)); bottom: max(10px, var(--safe-b)); display: flex; flex-direction: column; gap: 6px; }
.zoombar button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: rgba(25,18,46,.9); font: 700 18px var(--f-display); }
.chip { position: absolute; left: 50%; bottom: max(10px, var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: rgba(14,10,28,.94); border: 2px solid var(--cyan); border-radius: 10px; padding: 6px 6px 6px 12px; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.chip.dash { border-color: var(--gold); }
.chip b { font-family: var(--f-display); }
.rail { width: calc(var(--rail) + var(--safe-r)); padding: 10px max(12px, var(--safe-r)) max(10px, var(--safe-b)) 12px; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: none; }
.me { display: flex; gap: 10px; align-items: center; }
.me .spr { width: 46px; border: 3px solid var(--seat); }
.me .nm { font-family: var(--f-display); font-weight: 700; font-size: 16px; }
.me .loc { font-size: 12px; color: var(--muted); }
.ap { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.pip { width: 16px; height: 16px; transform: rotate(45deg); border: 2px solid var(--cyan); border-radius: 2px; }
.pip.on { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.actions .wide { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); }
.dame { display: flex; gap: 8px; align-items: flex-start; border-left: 3px solid var(--gold); background: var(--panel-2); padding: 6px 8px; border-radius: 6px; font-size: 12.5px; }
.dame .spr { width: 30px; }
.dame p { font-style: italic; }

/* toasts — phone-style banners */
#toasts { position: fixed; top: calc(var(--bar) + var(--safe-t) + 8px); right: calc(var(--rail) + max(12px, var(--safe-r)) + 12px); width: min(340px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 6px; z-index: 20; pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; background: rgba(36,27,64,.96); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 8px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.55); animation: drop .32s cubic-bezier(.2,.9,.3,1.2); touch-action: pan-y; cursor: pointer; }
.toast .spr { width: 34px; grid-row: span 3; border-radius: 9px; }
.toast .app { display: flex; justify-content: space-between; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.toast .tt { font-weight: 700; font-size: 13.5px; }
.toast .bd { font-size: 13px; color: #dcd3f5; }
.toast.out { animation: lift .25s ease-in forwards; }
@keyframes drop { from { transform: translateY(-24px) scale(.96); opacity: 0; } }
@keyframes lift { to { transform: translateX(110%); opacity: 0; } }

/* lock screen */
.lock { align-items: center; justify-content: center; background: radial-gradient(ellipse at 30% 20%, #2a1650 0%, var(--bg) 60%); }
.lock-in { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 1.2fr); gap: 24px; width: min(900px, 100%); padding: 16px max(16px, var(--safe-r)) 16px max(16px, var(--safe-l)); align-items: center; }
.lock-clock { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.lock-clock .big { font-family: var(--f-display); font-weight: 700; font-size: clamp(56px, 12vw, 96px); line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 0 24px rgba(61,232,255,.35); }
.lock-clock .date { color: var(--muted); font-size: 13px; letter-spacing: .08em; }
.lock-clock .spr { width: 84px; border: 3px solid var(--seat); margin-top: 10px; }
.lock-list { display: flex; flex-direction: column; gap: 8px; max-height: min(64vh, 520px); overflow-y: auto; }
.lock-list .toast { animation: none; }
.lock-list .toast.hidden-n .bd { color: var(--muted); font-style: italic; }
.lock-empty { color: var(--muted); text-align: center; padding: 20px; border: 1px dashed var(--line); border-radius: 12px; }

/* overlays */
.ov { position: fixed; inset: 0; z-index: 30; background: rgba(8,5,18,.86); display: flex; align-items: center; justify-content: center; padding: max(10px, var(--safe-t)) max(12px, var(--safe-r)) max(10px, var(--safe-b)) max(12px, var(--safe-l)); }
.sheet { width: 100%; max-width: 960px; max-height: 100%; overflow-y: auto; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sheet.narrow { max-width: 480px; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.choices { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.choices.w { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.choices.r { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.ch { background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px; padding: 3px; display: flex; flex-direction: column; gap: 2px; text-align: center; font-size: 10.5px; line-height: 1.1; font-weight: 700; min-width: 0; position: relative; }
.ch .spr { width: 100%; }
.ch[aria-pressed="true"] { border-color: var(--pink); box-shadow: 0 0 12px -2px var(--pink); }
.ch .seen { position: absolute; top: 3px; right: 3px; background: rgba(14,10,28,.85); color: var(--good); font-size: 11px; border-radius: 4px; padding: 0 4px; }
.cards { display: flex; gap: 10px; flex-wrap: wrap; }
.card { width: 112px; background: var(--panel-2); border: 2px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; text-align: center; }
.card .spr { width: 100%; }
.card .k { font: 500 10px var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.card span { font-size: 12.5px; font-weight: 700; line-height: 1.15; }
button.card:hover { border-color: var(--pink); }
.clue { font-size: 13.5px; padding: 8px 10px; background: var(--panel-2); border-left: 3px solid var(--cyan); border-radius: 4px; }

/* notebook drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); z-index: 25; background: var(--panel); border-left: 2px solid var(--line); display: flex; flex-direction: column; padding: max(10px, var(--safe-t)) max(14px, var(--safe-r)) max(10px, var(--safe-b)) 14px; gap: 10px; box-shadow: -20px 0 40px rgba(0,0,0,.5); animation: slide .25s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer .body { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.tabs { display: flex; gap: 6px; }
.tabs button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font-family: var(--f-display); color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--ink); background: var(--panel-2); border-color: var(--pink); }
.nbgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.nb { position: relative; background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px; padding: 3px; display: flex; flex-direction: column; gap: 2px; text-align: center; font-size: 10.5px; line-height: 1.1; font-weight: 700; }
.nb .spr { width: 100%; }
.nb .mk { position: absolute; top: 3px; right: 3px; min-width: 22px; height: 22px; border-radius: 5px; background: rgba(14,10,28,.88); font: 700 14px/22px var(--f-display); }
.nb.seen .spr { filter: grayscale(.85) brightness(.55); }
.nb.seen .mk { color: var(--good); }
.nb[data-m="x"] .spr { filter: grayscale(.85) brightness(.55); } .nb[data-m="x"] .mk { color: var(--muted); }
.nb[data-m="q"] { border-color: var(--gold); } .nb[data-m="q"] .mk { color: var(--gold); }
.nb[data-m="s"] { border-color: var(--pink); box-shadow: 0 0 10px -2px var(--pink); } .nb[data-m="s"] .mk { color: var(--pink); }
.nb .src { font-weight: 400; color: var(--muted); font-size: 9.5px; }

/* notification shade (history) */
.shade { position: fixed; left: 0; right: 0; top: 0; max-height: 80%; z-index: 26; background: rgba(14,10,28,.97); border-bottom: 2px solid var(--line); padding: calc(var(--safe-t) + 10px) max(16px, var(--safe-r)) 12px max(16px, var(--safe-l)); display: flex; flex-direction: column; gap: 8px; animation: pull .25s ease-out; }
@keyframes pull { from { transform: translateY(-30px); opacity: 0; } }
.shade .list { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.shade .toast { animation: none; }

/* reveal */
.over { overflow-y: auto; }
.over-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 16px max(16px, var(--safe-r)) 16px max(16px, var(--safe-l)); max-width: 1100px; margin: 0 auto; width: 100%; }
.tl { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.tl th, .tl td { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tl td.k { color: var(--pink); font-weight: 700; }
.tlwrap { overflow-x: auto; }

/* rotate prompt */
#rotate { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.rot-card { display: flex; flex-direction: column; gap: 12px; align-items: center; max-width: 320px; }
.rot-phone { width: 56px; height: 96px; border: 4px solid var(--cyan); border-radius: 12px; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 40%, 70% { transform: rotate(-90deg); } }

/* portrait / small fallbacks */
@media (orientation: portrait) {
  #toasts { right: max(12px, var(--safe-r)); }
  .main { flex-direction: column; }
  .rail { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 46%; padding: 10px max(16px, var(--safe-r)) max(10px, var(--safe-b)) max(16px, var(--safe-l)); }
  .setup-in, .lock-in, .over-in { grid-template-columns: 1fr; }
  .choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .choices.w { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .choices.r { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-height: 460px) and (orientation: landscape) {
  #toasts .toast:nth-child(n+3) { display: none; }
  #toasts { width: min(300px, calc(100vw - 24px)); }
  :root { --rail: 236px; }
  .rail { gap: 6px; }
  .btn { min-height: 36px; padding: 6px 10px; }
  .me .spr { width: 38px; }
  .ch .spr { width: min(100%, 60px); margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; }
}
