:root{
  --bg:#120E1E; --panel:#1A1428; --ink:#F4E9C9; --gold:#FFD166; --rose:#A0526A;
  --muted:#8A83A0; --good:#7FB069; --slot:#43305F;
  box-sizing:border-box; padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px);
  color-scheme:dark;
}
/* The game keeps its night palette in both themes by design */
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){ --bg:#120E1E; --panel:#1A1428; --ink:#F4E9C9; } }
:root[data-theme="dark"]{ --bg:#120E1E; --panel:#1A1428; --ink:#F4E9C9; }
html{ scroll-padding-top:env(safe-area-inset-top,0px); }
html,body{ margin:0; }
*,*::before,*::after{ box-sizing:border-box; }
body{ background:var(--bg); color:var(--ink); font-family:'VT323',ui-monospace,Menlo,monospace; }
.px{ font-family:'Press Start 2P',ui-monospace,monospace; }
.game{ max-width:960px; margin:0 auto; padding:12px; display:flex; flex-direction:column; gap:10px; }
.hud{ display:flex; justify-content:space-between; align-items:stretch; gap:10px; flex-wrap:wrap; }
.box{ background:var(--panel); border:4px solid var(--ink); padding:10px 12px; }
.hud .title{ font-size:12px; }
.hud .timer{ font-size:10px; color:var(--gold); margin-top:8px; }
.hud .timer.late{ color:#FF8A6B; }
.hud .right{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.score{ font-size:11px; }
.score b{ color:var(--gold); font-weight:normal; }
.slots{ display:flex; gap:6px; }
.slot{ width:36px; height:36px; border:3px solid var(--slot); background:var(--panel); display:flex; align-items:center; justify-content:center; color:var(--muted); font-size:11px; }
.slot.active{ border-color:var(--ink); }
.slot.earned{ border-color:var(--gold); background:#3A2A18; }
.slot.pop{ animation:pop .6s steps(3); }
.stage{ position:relative; border:4px solid var(--ink); background:#2E2548; }
canvas{ display:block; width:100%; height:auto; aspect-ratio:240/150; image-rendering:pixelated; image-rendering:crisp-edges; cursor:pointer; touch-action:manipulation; }
.overlay{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(18,14,30,.72); padding:10px; overflow:auto; }
.overlay[hidden]{ display:none; }
.card{ background:var(--panel); border:6px double var(--ink); padding:14px; text-align:center; display:flex; flex-direction:column; gap:10px; align-items:center; max-width:440px; width:100%; }
.card .big{ font-size:14px; line-height:1.6; }
.card .sub{ font-size:10px; color:var(--gold); line-height:1.6; }
.dialog{ display:flex; gap:14px; align-items:flex-start; background:var(--panel); border:6px double var(--ink); padding:12px; }
.guide{ display:flex; flex-direction:column; align-items:center; gap:6px; flex-shrink:0; }
.guide .name{ font-size:9px; color:var(--gold); }
.talk{ flex:1; min-width:0; display:flex; flex-direction:column; gap:10px; }
.say{ font-size:25px; line-height:1.1; min-height:56px; }
.actions{ display:flex; flex-wrap:wrap; gap:12px; align-items:center; }
.btn{ min-height:44px; padding:0 14px; background:var(--gold); color:#1A1428; border:0; box-shadow:4px 4px 0 var(--rose); font-family:'Press Start 2P',monospace; font-size:10px; cursor:pointer; }
.btn:active{ transform:translate(2px,2px); box-shadow:2px 2px 0 var(--rose); }
.btn.alt{ background:var(--ink); }
.btn:focus-visible,.link:focus-visible{ outline:3px solid #7FB7E0; outline-offset:3px; }
.link{ font-family:'Press Start 2P',monospace; font-size:10px; color:var(--gold); line-height:1.6; }
.inv{ width:190px; flex-shrink:0; display:flex; flex-direction:column; gap:10px; font-size:9px; }
.row{ display:flex; justify-content:space-between; gap:8px; margin-bottom:5px; }
.segs{ display:flex; gap:3px; }
.seg{ flex:1; height:8px; background:var(--slot); }
.seg.on{ background:var(--good); }
.meter{ position:relative; width:220px; max-width:100%; height:20px; background:var(--slot); border:3px solid var(--ink); }
.zone{ position:absolute; top:0; bottom:0; left:40%; width:18%; background:var(--good); }
.marker{ position:absolute; top:-7px; width:4px; height:28px; background:var(--gold); left:0; }
.cert{ display:grid; grid-template-columns:minmax(0,1.35fr) minmax(0,1fr); gap:10px; align-items:start; }
.cert[hidden],.stage[hidden],.dialog[hidden]{ display:none; }
.cert canvas{ border:4px solid var(--ink); cursor:default; aspect-ratio:640/400; image-rendering:auto; }
.form{ display:flex; flex-direction:column; gap:12px; }
.form h2{ margin:0; font-size:12px; line-height:1.6; color:var(--gold); font-weight:normal; }
.form p{ margin:0; font-size:22px; line-height:1.1; }
.field{ display:flex; flex-direction:column; gap:6px; }
.field label{ font-size:9px; }
.field input{ min-height:44px; width:100%; background:var(--bg); color:var(--ink); border:3px solid var(--ink); border-radius:0; padding:4px 10px; font-family:'VT323',monospace; font-size:24px; }
.field input:focus-visible{ outline:3px solid #7FB7E0; outline-offset:2px; }
.check{ display:flex; gap:10px; align-items:flex-start; font-size:21px; line-height:1.1; }
.check input{ width:22px; height:22px; margin:0; flex-shrink:0; accent-color:#FFD166; }
.small{ font-size:19px; line-height:1.1; color:#C9C0DA; }
.small a{ color:var(--gold); }
.status{ font-size:21px; min-height:22px; color:var(--gold); }
.status.err{ color:#FF8A6B; }
@media (max-width:760px){ .cert{ grid-template-columns:minmax(0,1fr); } }
@keyframes pop{ 0%{transform:scale(1)} 50%{transform:scale(1.3)} 100%{transform:scale(1)} }
@media (prefers-reduced-motion: reduce){ .slot.pop{ animation:none; } }
@media (max-width:640px){
  .dialog{ flex-wrap:wrap; }
  .guide svg{ width:56px; height:56px; }
  .inv{ width:100%; flex-direction:row; flex-wrap:wrap; gap:12px; }
  .inv > div{ flex:1 1 40%; }
  .say{ font-size:22px; }
}
