/* BenchTested Games — matches the landing page: near-black bench, trace green, amber */
:root {
  --bg: #0a0e0d;
  --surface: #101614;
  --line: #1d2622;
  --trace: #46f2a0;
  --trace-dim: rgba(70, 242, 160, .14);
  --amber: #ffb454;
  --text: #e8edea;
  --muted: #8ba39a;
  --bad: #ff6b5e;
  --display: 'Chakra Petch', sans-serif;
  --body: 'IBM Plex Sans', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --radius: 10px;
  --tap: 52px;
  color-scheme: dark;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--body); line-height: 1.6;
  min-height: 100vh; display: flex; justify-content: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
a { color: var(--trace); }
:focus-visible { outline: 2px solid var(--trace); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

#app { width: 100%; max-width: 520px; padding: 28px 22px 56px; }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.bar .back {
  border: 1px solid var(--line); border-radius: 8px; height: 38px; padding: 0 14px;
  color: var(--muted); font-family: var(--mono); font-size: 12px;
}
.bar .back:hover { border-color: var(--trace); color: var(--text); }
.bar .title { font-family: var(--display); font-weight: 600; font-size: 18px; letter-spacing: .03em; flex: 1; text-transform: uppercase; }
.bar .best { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.bar .best b { color: var(--amber); }

/* ---------- home ---------- */
.home h1 {
  font-family: var(--display); font-weight: 700; font-size: clamp(32px, 9vw, 44px);
  letter-spacing: .04em; text-align: center; line-height: 1.05; text-transform: uppercase;
}
.home h1 span { color: var(--trace); }
.home .lede { text-align: center; color: var(--muted); font-size: 15px; margin: 16px auto 28px; max-width: 40ch; }

.workout {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px 18px; margin-bottom: 30px; border-radius: var(--radius);
  border: 1px solid var(--line); border-left: 2px solid var(--trace); background: var(--surface);
}
.workout div { flex: 1; }
.workout b { font-family: var(--display); font-size: 18px; letter-spacing: .03em; display: block; text-transform: uppercase; }
.workout small { font-family: var(--mono); font-size: 11.5px; color: var(--muted); line-height: 1.5; display: block; margin-top: 2px; }
.workout .go {
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--bg); background: var(--trace); border-radius: 8px; padding: 10px 14px; white-space: nowrap; font-weight: 500;
}

.group { margin-bottom: 26px; }
.group h2 {
  font-family: var(--mono); font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); font-weight: 400; text-align: center; margin: 0 0 14px;
}
.game-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; min-height: 66px;
  padding: 14px 18px; margin-bottom: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s ease, transform .15s ease;
}
.game-row:hover, .game-row:focus-visible { border-color: var(--trace); transform: translateY(-1px); }
.game-row div { flex: 1; }
.game-row b { font-weight: 600; font-size: 16px; line-height: 1.25; display: block; }
.game-row span { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.game-row .score { flex: none; text-align: right; font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--amber); font-variant-numeric: tabular-nums; }
.game-row .score i { display: block; font-style: normal; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.foot { margin-top: 42px; text-align: center; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* ---------- game screen ---------- */
.stage { display: flex; flex-direction: column; }
.intro { text-align: center; padding: 26px 4px; }
.intro p { color: var(--muted); font-size: 15px; max-width: 40ch; margin: 0 auto 26px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 22px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 16px; user-select: none; -webkit-user-select: none;
  transition: border-color .15s ease;
}
.btn:hover, .btn:focus-visible { border-color: var(--trace); }
.btn.primary { background: var(--trace); border-color: var(--trace); color: #06100c; font-family: var(--display); letter-spacing: .04em; text-transform: uppercase; }
.btn.big { min-height: 60px; font-size: 18px; padding: 0 30px; }
.btn.wide { width: 100%; }
.btn:active { transform: translateY(1px); filter: brightness(.94); }
.btn:disabled { opacity: .45; }

.hud { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.hud b { color: var(--text); font-weight: 500; }
.timebar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 18px; }
.timebar i { display: block; height: 100%; background: var(--trace); box-shadow: 0 0 6px rgba(70,242,160,.5); width: 100%; transition: width .25s linear; }

.readout {
  text-align: center; padding: 30px 16px; margin: 18px 0 20px; border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--trace-dim) 1px, transparent 1px) 0 0/100% 25%,
    linear-gradient(90deg, var(--trace-dim) 1px, transparent 1px) 0 0/12.5% 100%,
    radial-gradient(ellipse at 50% 60%, #0e1512 0%, var(--bg) 80%);
}
.readout .num { font-family: var(--display); font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.readout .lbl { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.readout .pb { font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--trace); margin-top: 12px; }
.readout .stats { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 8px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.prompt { text-align: center; font-family: var(--display); font-size: clamp(30px, 9vw, 52px); font-weight: 700; min-height: 1.2em; margin: 16px 0 24px; line-height: 1.1; }
.prompt.small { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 400; margin: 0 0 6px; min-height: 0; }
.choices { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.choices .btn { min-height: 62px; font-size: 19px; }
.feedback { text-align: center; font-family: var(--mono); font-size: 12px; min-height: 22px; margin-top: 14px; color: var(--muted); }

/* grid recall */
.grid { display: grid; gap: 6px; margin: 0 auto; width: min(100%, 340px); aspect-ratio: 1; }
.grid button { border-radius: 6px; background: #17201c; border: 1px solid var(--line); padding: 0; }
.grid button.lit { background: var(--trace); border-color: var(--trace); box-shadow: 0 0 10px rgba(70,242,160,.45); }
.grid button.hit { background: rgba(70,242,160,.35); border-color: var(--trace); }
.grid button.miss { background: rgba(255,107,94,.35); border-color: var(--bad); }

/* reaction */
.pad {
  min-height: 44vh; border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  text-align: center; font-family: var(--display); font-size: 20px; letter-spacing: .04em; text-transform: uppercase;
  user-select: none; -webkit-user-select: none; padding: 20px;
  background: var(--surface); border: 1px solid var(--line);
}
.pad.wait { background: rgba(255,107,94,.16); border-color: var(--bad); color: var(--bad); }
.pad.go { background: var(--trace); border-color: var(--trace); color: #06100c; }

/* rotation */
.shapes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 6px auto 20px; width: min(100%, 420px); }
.shapes svg { width: 100%; aspect-ratio: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.shapes rect { fill: var(--trace); }

/* unscramble */
.letters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0 16px; }
.letters .btn { min-width: 50px; min-height: 50px; padding: 0; font-family: var(--display); font-size: 22px; text-transform: uppercase; }
.answer { text-align: center; font-family: var(--display); font-size: 30px; letter-spacing: .16em; min-height: 1.3em; text-transform: uppercase; color: var(--trace); margin-bottom: 8px; }

/* workout */
.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.steps i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.steps i.done { background: var(--trace); }
.steps i.now { background: var(--amber); }
.summary { list-style: none; margin: 0 0 22px; }
.summary li { display: flex; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.summary li b { font-family: var(--display); color: var(--amber); font-variant-numeric: tabular-nums; }

@media (min-width: 480px) { .choices.four { grid-template-columns: repeat(4, 1fr); } }

/* ---------- RAM 2048 ---------- */
.ram { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(100%, 360px); aspect-ratio: 1; margin: 0 auto; user-select: none; -webkit-user-select: none; }
.ram .tile { display: flex; align-items: center; justify-content: center; border-radius: 8px; background: #17201c; border: 1px solid var(--line); font-family: var(--display); font-weight: 700; font-size: clamp(13px, 4vw, 18px); color: var(--muted); }
.ram .t1 { color: var(--text); } .ram .t2 { color: var(--text); border-color: #2a3a32; }
.ram .t3, .ram .t4 { color: var(--trace); border-color: #2f5a46; background: #14241c; }
.ram .t5, .ram .t6 { color: var(--trace); background: #1a3527; border-color: var(--trace); }
.ram .t7, .ram .t8 { color: #0a0e0d; background: var(--trace); border-color: var(--trace); }
.ram .t9, .ram .t10, .ram .t11 { color: #0a0e0d; background: var(--amber); border-color: var(--amber); box-shadow: 0 0 14px rgba(255,180,84,.45); }

/* ---------- Circuit connect ---------- */
.circuit { display: grid; gap: 0; width: min(100%, 360px); aspect-ratio: 1; margin: 0 auto; background: #0e1512 linear-gradient(rgba(70,242,160,.07) 1px, transparent 1px) 0 0/100% calc(100%/var(--n,4)), linear-gradient(90deg, rgba(70,242,160,.07) 1px, transparent 1px) 0 0/calc(100%/var(--n,4)) 100%; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ccell { padding: 0; border: 0; background: transparent; }
.ccell svg { display: block; width: 100%; height: 100%; }
.ccell line { stroke: #35473f; stroke-width: 6; stroke-linecap: round; }
.ccell circle { fill: #35473f; }
.ccell .chip { fill: var(--amber); }
.ccell.on line { stroke: var(--trace); filter: drop-shadow(0 0 3px rgba(70,242,160,.7)); }
.ccell.on circle { fill: var(--trace); }
.ccell.on .led { filter: drop-shadow(0 0 5px var(--trace)); }

/* ---------- Bad sector scan ---------- */
.sectors { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; width: min(100%, 360px); aspect-ratio: 1; margin: 0 auto; user-select: none; -webkit-user-select: none; }
.sec { padding: 0; border-radius: 4px; background: #1b2620; border: 1px solid #263329; font-family: var(--mono); font-weight: 500; font-size: clamp(12px, 3.6vw, 16px); }
.sec.open { background: #0e1512; border-color: #14201a; }
.sec.flag { color: var(--amber); border-color: var(--amber); }
.sec.bad { background: rgba(255,107,94,.25); color: var(--bad); border-color: var(--bad); }
.sec.hit { background: var(--bad); color: #0a0e0d; }
.sec.n1 { color: var(--trace); } .sec.n2 { color: #9ad9ff; } .sec.n3 { color: var(--amber); } .sec.n4 { color: #ff9e8c; }
.sec.n5, .sec.n6, .sec.n7, .sec.n8 { color: var(--bad); }

/* ---------- canvas games ---------- */
.scope { display: block; width: 100%; aspect-ratio: 8/5; border: 1px solid var(--line); border-radius: var(--radius); background: #0a0e0d; }

/* ---------- Port match ---------- */
.choices.ports { grid-template-columns: repeat(2, 1fr); }
.btn.port { flex-direction: column; gap: 4px; min-height: 84px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.btn.port svg { width: 48px; height: 44px; fill: var(--trace); }
.btn.port svg path, .btn.port svg rect, .btn.port svg circle { stroke: none; }
