/* arcade.css -- the arcade hub and the play surface.
   Stays inside the "Keycap & Switch" language (brief §5): the frame reads as
   a keyboard case, the field is --housing, and --hit is spent only on the
   targeted enemy and the single primary action. No raw hex anywhere; the
   canvas reads the same tokens via getComputedStyle (modes/lib/canvas.js). */

/* ---------- hub ---------- */

.arcade-hub__title {
  margin: 0 0 var(--s-2);
  font-size: var(--t-xl);
}

.arcade-hub__lead {
  color: var(--muted);
  font-size: var(--t-sm);
  max-width: 60ch;
  margin: 0 0 var(--s-6);
}

.arcade-tile {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border: 1px solid rgb(242 179 61 / 0.30);
  background:
    radial-gradient(120% 140% at 100% 0%, rgb(242 179 61 / 0.09), transparent 60%),
    var(--plate);
}

.arcade-tile--soon {
  border-color: var(--plate-hi);
  background: var(--plate);
  opacity: 0.6;
}

.arcade-tile__title {
  margin: 0;
  font-size: var(--t-lg);
  color: var(--legend);
}

.arcade-tile__blurb {
  color: var(--muted);
  font-size: var(--t-sm);
  margin: 0;
}

.arcade-tile__how {
  margin: var(--s-2) 0 var(--s-4);
  padding-left: var(--s-4);
  color: var(--muted);
  font-size: var(--t-xs);
  line-height: 1.7;
}

.arcade-tile .btn { align-self: flex-start; }

.arcade-tile__footer {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.arcade-tile__pb {
  font-size: var(--t-xs);
  color: var(--muted);
}

.arcade-tile__pb strong {
  color: var(--hit);
  font-family: var(--f-display);
  font-size: var(--t-sm);
}

/* ---------- hub layout + leaderboard ---------- */

.arcade-hub__layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--s-4);
  align-items: start;
}

.arcade-board__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.arcade-board__head .dash__link {
  font-size: var(--t-xs);
  color: var(--pace);
  text-decoration: none;
}

.arcade-board__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.arcade-board__row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
}

.arcade-board__row.is-me {
  background: rgb(94 224 192 / 0.10);
  color: var(--pace);
}

.arcade-board__rank {
  width: 20px;
  flex-shrink: 0;
  text-align: right;
  color: var(--muted);
  font-size: var(--t-xs);
  font-variant-numeric: tabular-nums;
}

.arcade-board__rank--top { color: var(--hit); font-weight: 700; }

.arcade-board__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arcade-board__score {
  font-family: var(--f-display);
  font-variant-numeric: tabular-nums;
}

.arcade-board__foot,
.arcade-board__note {
  font-size: var(--t-xs);
  color: var(--muted);
  margin: var(--s-3) 0 0;
}

.arcade-board__note { opacity: 0.75; }

/* ---------- play surface ---------- */

.arcade-page {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  max-width: 900px;
  margin: 0 auto;
}

.arcade-frame {
  position: relative;
  background: var(--plate);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  box-shadow: var(--e-1);
}

.arcade-hud {
  display: flex;
  align-items: baseline;
  gap: var(--s-6);
  padding: 0 var(--s-2) var(--s-3);
  flex-wrap: wrap;
  /* Nothing in the HUD is worth selecting, and a double-click that selects
     "♥♥♥" takes focus off the hidden input -- which pauses the run two
     seconds later. Read-outs must not be selection targets during play. */
  user-select: none;
  -webkit-user-select: none;
}

.arcade-hud__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 52px;
}

/* Pushes the live wpm/accuracy pair to the far edge, away from the score. */
.arcade-hud__group--right { margin-left: auto; }

.arcade-hud__label {
  font-size: var(--t-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.arcade-hud__value {
  font-family: var(--f-display);
  font-size: var(--t-lg);
  color: var(--legend);
  font-variant-numeric: tabular-nums;
}

.arcade-hud__lives {
  color: var(--hit);
  letter-spacing: 2px;
}

.arcade-hud__lives.is-critical { color: var(--miss); }

.arcade-stage {
  position: relative;
  /* 16:9 keeps the field a predictable shape for the descent maths. */
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--housing);
  box-shadow: inset 0 2px 12px rgb(0 0 0 / 0.5);
}

.arcade-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: text;
}

/* Focus prompt. Sits UNDER .arcade-overlay in z-order so a game-over panel is
   never obscured by it. */
.arcade-focus {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgb(16 20 26 / 0.8);
  backdrop-filter: blur(3px);
  color: var(--muted);
  cursor: text;
  font-size: var(--t-sm);
  z-index: 2;
}

.arcade-focus--visible { display: flex; }

.arcade-focus .focus-prompt {
  padding: var(--s-3) var(--s-6);
  border-radius: var(--r-md);
  background: var(--plate-hi);
  box-shadow: var(--e-key);
}

.arcade-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  background: rgb(16 20 26 / 0.88);
  padding: var(--s-6);
  z-index: 3;
  /* .arcade-stage clips at its own edge (fixed 16:9 box, unaffected either
     way -- see AdPolicy's doc comment) but the overlay's OWN content can be
     taller than that box on a short viewport once the ad joins the stats.
     Scroll inside the overlay rather than silently clip it off-screen. */
  overflow-y: auto;
}

.arcade-overlay[hidden] { display: none; }

.arcade-overlay__body {
  text-align: center;
  max-width: 460px;
}

/* Sibling of __body, not a child of it -- arcade-page.js replaces __body's
   innerHTML wholesale on every state change, which would silently delete an
   ad unit living inside it along with everything else. */
.arcade-overlay__ad {
  width: 100%;
  max-width: 460px;
}

.arcade-over__title {
  font-family: var(--f-display);
  font-size: var(--t-xl);
  margin: 0 0 var(--s-6);
  color: var(--legend);
}

.arcade-over__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}

.arcade-over__stats .stat__value { font-size: var(--t-xl); }

.arcade-over__meta {
  color: var(--muted);
  font-size: var(--t-sm);
  margin: 0 0 var(--s-4);
}

.arcade-over__error {
  color: var(--miss);
  font-size: var(--t-sm);
  margin: 0 0 var(--s-4);
}

.arcade-over__actions {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
}

/* ---------- head-to-head ---------- */

.arcade-opponent {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-2);
  background: var(--housing);
  border-radius: var(--r-md);
  border: 1px solid var(--plate-hi);
  font-size: var(--t-sm);
  flex-wrap: wrap;
  /* Same reason as .arcade-hud: a double-click that selects the opponent's
     hearts takes focus off the input and pauses your own run. */
  user-select: none;
  -webkit-user-select: none;
}

.arcade-opponent[hidden] { display: none; }

.arcade-opponent__name {
  color: var(--pace);
  font-family: var(--f-display);
  flex: 1;
  min-width: 120px;
}

.arcade-opponent__stat { color: var(--muted); font-size: var(--t-xs); }
.arcade-opponent__stat b { color: var(--legend); font-family: var(--f-display); font-size: var(--t-sm); }
.arcade-opponent__lives { color: var(--hit); letter-spacing: 1px; }

.battle-invite {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--plate-hi);
  font-size: var(--t-sm);
  flex-wrap: wrap;
}

.battle-invite:last-child { border-bottom: none; }

.arcade-battle__room {
  text-align: center;
  margin-bottom: var(--s-6);
}

.battle-vs__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-6);
}

.battle-vs__side {
  flex: 1;
  text-align: center;
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--housing);
  border: 1px solid var(--plate-hi);
}

.battle-vs__side.is-winner {
  border-color: rgb(242 179 61 / 0.5);
  background: radial-gradient(120% 140% at 50% 0%, rgb(242 179 61 / 0.12), transparent 65%), var(--housing);
}

.battle-vs__name { margin: 0 0 var(--s-2); color: var(--muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.battle-vs__score { margin: 0; font-family: var(--f-display); font-size: var(--t-2xl); color: var(--legend); }
.battle-vs__meta { margin: var(--s-1) 0 0; color: var(--muted); font-size: var(--t-xs); }
.battle-vs__sep { color: var(--muted); font-family: var(--f-display); }

.battle-vs__verdict {
  text-align: center;
  font-family: var(--f-display);
  font-size: var(--t-xl);
  margin: var(--s-6) 0;
}

.battle-vs__verdict--win { color: var(--pace); }
.battle-vs__verdict--loss { color: var(--muted); }
.battle-vs__verdict--draw { color: var(--hit); }

.arcade-over__verdict {
  font-family: var(--f-display);
  font-size: var(--t-lg);
  color: var(--pace);
  margin: 0 0 var(--s-3);
}

/* Same trick as the test surface: a real focusable input, visually gone. */
.arcade-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.arcade-hint {
  text-align: center;
  color: var(--muted);
  font-size: var(--t-xs);
  margin: 0;
}

/* ---------- battle game picker ---------- */

.battle-game { margin-bottom: var(--s-4); }

.battle-game__row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
  margin-top: var(--s-2);
}

.battle-game__opt {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  text-align: left;
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--housing);
  border: 1px solid var(--plate-hi);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.battle-game__opt strong { color: var(--legend); font-size: var(--t-sm); }
.battle-game__opt span { font-size: var(--t-xs); }
.battle-game__opt:hover { border-color: var(--muted); }

.battle-game__opt.is-active {
  border-color: var(--hit);
  box-shadow: inset 0 0 0 1px var(--hit);
}

@media (max-width: 640px) {
  .battle-game__row { grid-template-columns: 1fr; }
}

/* ---------- super moves (read-only reference strip) ---------- */

.arcade-supers {
  background: var(--plate);
  border: 1px solid var(--plate-hi);
  border-radius: var(--r-md);
  padding: var(--s-3);
  margin-bottom: var(--s-3);
}

.arcade-supers__lead {
  color: var(--muted);
  font-size: var(--t-xs);
  margin: 0 0 var(--s-3);
}

.arcade-supers__lead strong { color: var(--hit); }

.arcade-supers__row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-2);
}

.arcade-supers__tier {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-2);
  border-radius: var(--r-sm);
  background: var(--housing);
  border-left: 3px solid var(--hit);
}

/* The reward ramps with the streak, so the strip should look like it does. */
.arcade-supers__tier[data-tier="20"],
.arcade-supers__tier[data-tier="30"] { border-left-color: var(--miss); }

.arcade-supers__at {
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.10em;
}

.arcade-supers__name {
  color: var(--legend);
  font-family: var(--f-display);
  font-size: var(--t-xs);
}

@media (max-width: 720px) {
  .arcade-supers__row { grid-template-columns: repeat(2, 1fr); }
}

.arcade-hud__mult {
  font-size: var(--t-xs);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  line-height: 1;
}

.arcade-hud__mult.is-bonus { color: var(--pace); }
.arcade-hud__mult.is-penalty { color: var(--miss); }

.arcade-board__tabs {
  display: flex;
  gap: var(--s-1);
  margin-bottom: var(--s-3);
}

.arcade-board__tab {
  flex: 1;
  text-align: center;
  padding: var(--s-2) var(--s-1);
  border-radius: var(--r-sm);
  background: var(--housing);
  color: var(--muted);
  font-size: var(--t-xs);
  text-decoration: none;
  border: 1px solid transparent;
}

.arcade-board__tab:hover { color: var(--legend); }

.arcade-board__tab.is-active {
  color: var(--legend);
  border-color: var(--plate-hi);
  background: var(--plate-hi);
}

.arcade-hint strong { color: var(--legend); }

/* Keycaps in the hint match the SPACE cue the canvas paints over an armed
   zombie -- the instruction and the in-game prompt have to look like the same
   thing or students read them as two unrelated rules. */
.arcade-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--plate-hi);
  color: var(--legend);
  font-family: var(--f-mono);
  font-size: 0.92em;
  box-shadow: var(--e-key);
}

@media (max-width: 860px) {
  .arcade-hub__layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .arcade-hud { gap: var(--s-4); }
  .arcade-hud__group--right { margin-left: 0; }
  .arcade-over__stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- difficulty picker (free play only) ---------- */

.arcade-diff {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-bottom: var(--s-2);
  font-size: var(--t-xs);
}

.arcade-diff__label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: var(--s-1);
}

.arcade-diff__opt {
  background: none;
  border: 1px solid var(--plate-hi);
  border-radius: var(--r-sm);
  box-shadow: none;
  padding: 2px var(--s-3);
  color: var(--muted);
  font-size: var(--t-xs);
  cursor: pointer;
}

.arcade-diff__opt:hover { color: var(--legend); }

.arcade-diff__opt.is-active {
  border-color: rgb(242 179 61 / 0.55);
  background: rgb(242 179 61 / 0.10);
  color: var(--hit);
}
