:root {
  --bg: #03050c;
  --glass: rgba(10, 15, 32, 0.85);
  --line: rgba(148, 163, 184, 0.18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --cyan: #22d3ee;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --gold: #fcd34d;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  padding: 12px 16px;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at 18% 15%, rgba(6, 182, 212, 0.14) 0%, transparent 45%),
    radial-gradient(circle at 82% 20%, rgba(217, 70, 239, 0.12) 0%, transparent 50%),
    var(--bg);
  display: flex;
  flex-direction: column;
}
body > * { width: 100%; max-width: 1180px; margin-left: auto; margin-right: auto; }
.mono { font-family: var(--mono); }
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); }
button, select { font: inherit; color: inherit; cursor: pointer; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 10px; }
.brand h1 { margin: 2px 0 0; font-size: 20px; font-weight: 800; background: linear-gradient(90deg, #fff, #a5f3fc, #f0abfc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 2px 10px; border-radius: 99px; }
.chip.cyan { color: #67e8f9; background: rgba(6, 182, 212, .18); border: 1px solid rgba(6, 182, 212, .4); }
.chip.green { color: #6ee7b7; background: rgba(16, 185, 129, .14); border: 1px solid rgba(16, 185, 129, .3); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: rgba(2, 6, 23, .9); border: 1px solid rgba(51, 65, 85, .8); font: 700 11px var(--mono); text-transform: uppercase; color: var(--muted); }
.field select { background: transparent; border: 0; color: #67e8f9; font: 700 13px var(--mono); text-transform: none; outline: none; }
.field select option { background: #0f172a; }
.toggle { padding: 7px 12px; border-radius: 10px; font: 800 12px var(--mono); background: rgba(2, 6, 23, .95); border: 1px solid rgba(217, 70, 239, .45); color: #f0abfc; }
.toggle[aria-pressed="false"] { color: var(--muted); border-color: rgba(71, 85, 105, .6); text-decoration: line-through; }
.go { padding: 10px 20px; border: 0; border-radius: 12px; font: 800 15px var(--mono); text-transform: uppercase; color: #020617; background: linear-gradient(135deg, #06b6d4, #10b981); box-shadow: 0 4px 0 #064e3b; }
.go:active { transform: translateY(3px); box-shadow: 0 1px 0 #064e3b; }
.ghost { padding: 8px 12px; border-radius: 10px; background: #1e293b; border: 1px solid #475569; font: 700 12px var(--mono); }
.next { padding: 10px 18px; border: 0; border-radius: 12px; font: 800 14px var(--mono); text-transform: uppercase; color: #020617; background: #d946ef; }

.layout { flex: 1; display: grid; grid-template-columns: minmax(240px, 330px) 1fr; gap: 16px; min-height: 0; }
.side { padding: 14px 16px; align-self: start; }
.side-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #67e8f9; margin: 0 0 8px; }
.rules { margin: 0 0 14px; padding-left: 18px; font-size: 13px; line-height: 1.5; color: #cbd5e1; }
.rules li { margin-bottom: 4px; }
.rules.fair { list-style: "✓  "; color: #a7f3d0; }
.cyan-t { color: var(--cyan); } .amber-t { color: var(--amber); } .gold-t { color: var(--gold); } .red-t { color: var(--red); }
.tip { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 8px 0 0; }
.tip.lock { color: var(--amber); }

.stage-wrap { display: flex; justify-content: center; align-items: flex-start; min-height: 0; }
.stage {
  position: relative;
  height: min(calc(100vh - 110px), 960px);
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(6, 182, 212, .45);
  box-shadow: 0 20px 50px -10px rgba(6, 182, 212, .3);
  background: #050814;
  touch-action: none;
}
.stage canvas { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; background: rgba(2, 6, 23, .8); backdrop-filter: blur(4px); }
.overlay[hidden], [hidden] { display: none !important; }
.ov-title { font-size: 30px; font-weight: 900; color: #67e8f9; margin-bottom: 8px; letter-spacing: .02em; }
.ov-title.lose { color: var(--red); }
.ov-title.win { color: #6ee7b7; }
.ov-sub { font-size: 14px; color: #cbd5e1; max-width: 360px; margin: 0 0 12px; line-height: 1.5; white-space: pre-line; }
.ov-stars { font-size: 38px; letter-spacing: 6px; color: var(--gold); margin-bottom: 16px; min-height: 0; text-shadow: 0 0 14px rgba(252, 211, 77, .6); }
.ov-stars .off { color: #334155; text-shadow: none; }
.ov-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.how { display: flex; flex-direction: column; gap: 10px; max-width: 380px; margin: 0 0 18px; text-align: left; font-size: 14px; line-height: 1.45; color: #e2e8f0; }
.how-step { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 12px; background: rgba(15, 23, 42, .75); border: 1px solid rgba(148, 163, 184, .18); }
.how-n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 900 13px var(--mono); color: #020617; background: var(--cyan); }
.how-demo { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; align-items: center; }
.how-demo .mini:nth-child(1) { grid-column: 1; grid-row: 1; }
.how-demo .mini:nth-child(2) { grid-column: 1; grid-row: 2; }
.how-demo > div:nth-child(3) { grid-column: 2; grid-row: 1 / 3; }
.mini { display: flex; justify-content: center; gap: 4px; }
.m { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 900 13px var(--mono); border: 2px solid #475569; }
.m.amber { border-color: var(--amber); color: #fff; box-shadow: 0 0 8px rgba(251, 191, 36, .6); }
.m.q { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(34, 211, 238, .7); }
.green-t { color: var(--green); }
.key { display: inline-block; padding: 0 6px; border-radius: 5px; border: 1px solid #475569; background: #1e293b; font: 700 12px var(--mono); }
@media (max-height: 760px) { .how { font-size: 12.5px; gap: 6px; } .how-step { padding: 6px 8px; } }

.hint-btn { position: absolute; right: 3%; bottom: 2.2%; z-index: 1; padding: 8px 14px; border-radius: 12px; font: 800 14px var(--mono); color: #fde68a; background: rgba(2, 6, 23, .88); border: 2px solid rgba(251, 191, 36, .6); box-shadow: 0 0 14px rgba(251, 191, 36, .25); }
.hint-btn.on { color: #020617; background: var(--amber); }
body.rec .hint-btn { cursor: none; }

/* Record mode: only the 9:16 game, centred, no cursor (Esc to leave). */
body.rec { padding: 0; background: #000; cursor: none; }
body.rec .top, body.rec .side { display: none; }
body.rec .layout { display: flex; justify-content: center; align-items: center; height: 100vh; max-width: none; }
body.rec .stage { height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
body.rec .overlay button { cursor: none; }

@media (max-width: 760px) {
  body { padding: 8px; }
  .layout { grid-template-columns: 1fr; }
  .side { order: 2; }
  .stage { height: auto; width: 100%; }
  .brand h1 { font-size: 16px; }
}
