@font-face {
  font-family: 'Pixelify Sans';
  src: url('vendor/pixelify-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

/* A cold summit with one hot element: FireRed crimson marks the actions that start play. */
:root {
  --snow: #eef3f7;
  --ice: #c8d5e0;
  --slate: #243241;
  --dusk: #5a6c80;
  --bezel: #1a2430;
  --night: #22313f;
  --crimson: #d3202b;
  --crimson-deep: #a3151e;
  --blue: #2c6cb0;
  --blue-deep: #1d4d82;
  /* The Gauntlet: Team Rocket black and purple. */
  --rocket: #6a35a0;
  --rocket-deep: #3e1c63;
  --rocket-night: #160f1d;
  --on-dark: #f3f7fa;

  --page: var(--snow);
  --text: var(--slate);
  --muted: var(--dusk);
  --line: var(--ice);
  --surface: #ffffff;
  --picked: #e7eff9;

  --font-pixel: 'Pixelify Sans', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

  --column: 736px; /* the 720px (3x) screen plus its bezel */
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #131c26;
    --text: #dce6ee;
    --muted: #93a6b8;
    --line: #2c3b4b;
    --surface: #1a2532;
    --picked: #1b2b40;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 16px/1.55 var(--font-body);
}

a { color: inherit; text-underline-offset: 3px; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--crimson);
  outline-offset: 3px;
}

.app {
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 40px var(--gutter) 48px;
}

/* Masthead ----------------------------------------------------------------- */

.masthead { margin-bottom: 24px; }

.title {
  margin: 0;
  font: 700 60px/1 var(--font-pixel);
  letter-spacing: -1px;
}

/* Screen ------------------------------------------------------------------- */

.bezel {
  padding: 8px;
  background: var(--bezel);
  border-radius: 14px;
}

.screen {
  position: relative;
  aspect-ratio: 3 / 2;
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
  container-type: size; /* the title card scales with the screen (cqh units) */
}

/* Nostalgist sets inline sizes on the canvas; the screen box decides the real size. */
.game-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

.card {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  color: var(--on-dark);
  background: linear-gradient(180deg, #2b3d50 0%, var(--night) 55%, #1b2733 100%);
}

.app[data-state="title"] .card-title,
.app[data-state="loading"] .card-loading,
.app[data-state="error"] .card-error { display: flex; }

.card-heading {
  position: relative;
  margin: 0;
  font: 500 26px/1.2 var(--font-pixel);
}

.card-note {
  position: relative;
  max-width: 34ch;
  margin: 0;
  font-size: 15px;
  color: #b9c8d5;
}

/* Title card: RED, then one panel per mode (its record and its Play
   button, or today's result). Classic plays in FireRed crimson, Draft in
   blue: RED vs BLUE. The Gauntlet is Team Rocket black and purple. */
.card-title { gap: 4cqh; padding: 4cqh; }

.red-sprite {
  position: relative;
  height: 30cqh;
  width: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 1cqh 0 rgba(0, 0, 0, 0.35));
}

.modes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.4cqw;
  width: min(100%, 94cqw);
}

.mode-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6cqh;
  min-width: 0;
  padding: 3cqh 1.4cqw 3.6cqh;
  border-radius: 10px;
  background: rgba(10, 18, 26, 0.38);
  box-shadow: inset 0 0 0 1px rgba(185, 200, 213, 0.14);
}

.mode-panel p { margin: 0; }

.mode-title {
  margin: 0;
  font: 600 max(15px, 6cqh)/1 var(--font-pixel);
}

.mode-record {
  font: 700 max(14px, 4.8cqh)/1.1 var(--font-body);
  font-variant-numeric: tabular-nums;
}

.mode-record b { font-size: 1.25em; }

.mode-streaks {
  font-size: max(10px, 3cqh);
  line-height: 1.3;
  color: #b9c8d5;
}

.mode-streaks b { color: var(--on-dark); }

.card-title .button-mode {
  margin-top: auto; /* the Play buttons line up across the panels */
  padding: max(8px, 2.2cqh) max(22px, 7cqh);
  font-size: max(16px, 5.4cqh);
}

.button-play[data-play="draft"],
.button-battle {
  background: var(--blue);
  border-color: var(--blue-deep);
  box-shadow: 0 4px 0 var(--blue-deep);
}

.button-play[data-play="draft"]:hover,
.button-battle:not(:disabled):hover { background: #3a7ec4; }
.button-play[data-play="draft"]:active,
.button-battle:not(:disabled):active { box-shadow: 0 1px 0 var(--blue-deep); }

.button-play[data-play="gauntlet"],
.button.button-gauntlet {
  background: var(--rocket);
  border-color: var(--rocket-deep);
  box-shadow: 0 4px 0 var(--rocket-deep);
}

.button-play[data-play="gauntlet"]:hover,
.button.button-gauntlet:not(:disabled):hover { background: #7d45b8; }
.button-play[data-play="gauntlet"]:active,
.button.button-gauntlet:not(:disabled):active { box-shadow: 0 1px 0 var(--rocket-deep); }
.button.button-gauntlet:disabled { box-shadow: none; transform: none; }
.button.button-gauntlet:disabled:hover { background: var(--rocket); }

.mode-panel[data-mode="gauntlet"] {
  background: linear-gradient(180deg, rgba(62, 28, 99, 0.55) 0%, rgba(22, 15, 29, 0.7) 100%);
  box-shadow: inset 0 0 0 1px rgba(160, 120, 210, 0.28);
}

.run-progress {
  font-size: max(10px, 3.2cqh);
  line-height: 1.3;
  color: #d9c6f0;
}

.practice-note { font-size: max(11px, 3.4cqh); }

/* How to play (top right) and the version (bottom right) sit in the card's
   corners, clear of RED and the mode panels. */
.howto-open {
  position: absolute;
  top: 2.6cqh;
  right: 2cqw;
  padding: max(5px, 1.4cqh) max(10px, 2.2cqh);
  border: 1px solid rgba(185, 200, 213, 0.35);
  border-radius: 999px;
  font: 600 max(12px, 3.4cqh)/1 var(--font-pixel);
  color: var(--on-dark);
  background: rgba(10, 18, 26, 0.38);
  cursor: pointer;
}

.howto-open:hover { border-color: rgba(185, 200, 213, 0.7); background: rgba(10, 18, 26, 0.6); }

.version {
  position: absolute;
  right: 2cqw;
  bottom: 2cqh;
  margin: 0;
  font: 500 max(10px, 2.8cqh)/1 var(--font-pixel);
  color: #8fa3b5;
  font-variant-numeric: tabular-nums;
}

/* On a phone the screen is short: drop RED's sprite to make room. */
@container (max-height: 300px) {
  .red-sprite { display: none; }
  .card-title { gap: 3cqh; }
}

.played {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1cqh;
  margin-top: 1cqh;
  text-align: center;
}

.played p { margin: 0; }

.played-result { font: 600 max(13px, 4.4cqh)/1.2 var(--font-pixel); }

.played-next {
  font-size: max(10px, 3.2cqh);
  color: #b9c8d5;
  font-variant-numeric: tabular-nums;
}

/* Snow on the title card: the page's one piece of ambient motion. */
.snow {
  position: absolute;
  inset: -160px 0 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 110px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 150px 60px, #dfe9f1 50%, transparent 51%),
    radial-gradient(2px 2px at 60px 150px, #fff 50%, transparent 51%);
  background-size: 160px 160px;
  opacity: 0.55;
  animation: snowfall 9s linear infinite;
}

@keyframes snowfall {
  from { transform: translate(0, 0); }
  to { transform: translate(-40px, 160px); }
}

@media (prefers-reduced-motion: reduce) {
  .snow { animation: none; }
}

.meter {
  width: min(320px, 70%);
  height: 10px;
  padding: 2px;
  border: 2px solid #8fa3b5;
  border-radius: 3px;
}

.meter-fill {
  width: 0;
  height: 100%;
  background: var(--crimson);
  transition: width 0.2s linear;
}

/* Buttons ------------------------------------------------------------------ */

.button {
  font: 600 18px/1 var(--font-pixel);
  padding: 12px 20px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  color: inherit;
  background: none;
}

.button:disabled { cursor: default; opacity: 0.45; }

.button-play {
  position: relative;
  padding: 16px 44px;
  font-size: 26px;
  color: #fff;
  background: var(--crimson);
  border-color: var(--crimson-deep);
  box-shadow: 0 4px 0 var(--crimson-deep);
}

.button-play:hover { background: #e2303a; }
.button-play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--crimson-deep); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.button-run {
  color: #fff;
  background: var(--crimson);
  border-color: var(--crimson-deep);
}

.button-run:not(:disabled):hover { background: #e2303a; }

.button-quiet {
  border-color: var(--line);
}

.button-quiet:not(:disabled):hover { border-color: var(--muted); }

/* Fast-forward stays lit while it's on. */
.button-speed[aria-pressed="true"] {
  color: #fff;
  background: var(--crimson);
  border-color: var(--crimson-deep);
}

.button-speed[aria-pressed="true"]:not(:disabled):hover { background: #e2303a; border-color: var(--crimson-deep); }

/* Touch controls (phones and tablets only) ---------------------------------- */

.pad {
  display: none;
  grid-template-columns: 1fr auto;
  grid-template-areas: "dpad face" "meta meta";
  align-items: center;
  gap: 18px 12px;
  margin-top: 18px;
  padding: 18px 12px 8px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (pointer: coarse) {
  .pad { display: grid; }
}

.dpad {
  grid-area: dpad;
  position: relative;
  width: 144px;
  height: 144px;
  touch-action: none;
}

.dpad-arm {
  position: absolute;
  width: 48px;
  height: 48px;
  background: var(--bezel);
}

.dpad-up { left: 48px; top: 0; border-radius: 8px 8px 0 0; }
.dpad-down { left: 48px; bottom: 0; border-radius: 0 0 8px 8px; }
.dpad-left { left: 0; top: 48px; border-radius: 8px 0 0 8px; }
.dpad-right { right: 0; top: 48px; border-radius: 0 8px 8px 0; }
.dpad-center { left: 48px; top: 48px; }

.dpad[data-dir="up"] .dpad-up,
.dpad[data-dir="down"] .dpad-down,
.dpad[data-dir="left"] .dpad-left,
.dpad[data-dir="right"] .dpad-right { background: var(--crimson); }

.face {
  grid-area: face;
  display: flex;
  gap: 16px;
  padding-right: 4px;
}

.pad-button {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  font: 700 24px/1 var(--font-body);
  color: var(--on-dark);
  background: var(--bezel);
  touch-action: none;
}

.pad-a { transform: translateY(-22px); }

.pad-button.is-down,
.pad-pill.is-down { background: var(--crimson); }

.meta {
  grid-area: meta;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.pad-pill {
  padding: 8px 18px;
  border: none;
  border-radius: 999px;
  font: 600 15px/1 var(--font-pixel);
  color: var(--on-dark);
  background: var(--dusk);
  touch-action: none;
}

/* Full screen: the console fills the display, screen as large as fits. */
.console:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  background: var(--bezel);
  color: var(--on-dark);
}

.console:fullscreen .bezel {
  width: min(100%, calc((100vh - 120px) * 1.5));
  margin: 0 auto;
  padding: 0;
}

.console:fullscreen .toolbar { justify-content: center; }
.console:fullscreen .button-quiet { border-color: #3a4c5e; }

@media (pointer: coarse) {
  .console:fullscreen .bezel { width: min(100%, calc((100vh - 360px) * 1.5)); }
}

/* Key reminder under the toolbar (keyboards only; How to play has the rest). */
.key-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.key-hint kbd { font-size: 12px; padding: 1px 5px; border-bottom-width: 3px; }

@media (pointer: coarse) {
  .key-hint { display: none; }
}

/* How to play ---------------------------------------------------------------- */

.howto { display: none; }
.app[data-state="howto"] .howto { display: block; }
.app[data-state="howto"] .console { display: none; }

.howto-lead { margin: 12px 0 0; max-width: 64ch; }

.howto .guide-heading { margin-top: 32px; }

.guide-heading {
  margin: 0 0 12px;
  font: 600 21px/1.2 var(--font-pixel);
}

.keys { margin: 0; max-width: 34em; }

.guide-heading-next { margin-top: 28px; }

.mode-guide { margin: 0; max-width: 44em; }

.mode-guide div {
  display: grid;
  grid-template-columns: 6em 1fr;
  gap: 12px;
  padding: 6px 0;
}

.mode-guide dt { font: 600 17px/1.4 var(--font-pixel); }
.mode-guide dd { margin: 0; }
.mode-guide dd p { margin: 0 0 8px; max-width: 64ch; }
.mode-guide dd p:last-child { margin-bottom: 0; }

/* Each mode in its Play button's colour. */
.mode-guide div { padding: 10px 0 10px 14px; border-left: 4px solid var(--crimson); margin-bottom: 8px; }
.mode-guide [data-mode="draft"] { border-left-color: var(--blue); }
.mode-guide [data-mode="gauntlet"] { border-left-color: var(--rocket); }

.howto-tips { margin: 0; padding-left: 1.2em; max-width: 64ch; }
.howto-tips li { margin: 0 0 6px; }

/* The phone buttons, drawn small like the real ones under the screen. */
.touch-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--on-dark);
  background: var(--bezel);
  font: 700 14px/1 var(--font-body);
}

.touch-round { width: 30px; height: 30px; border-radius: 50%; }
.touch-pill { padding: 6px 12px; border-radius: 999px; font: 600 13px/1 var(--font-pixel); background: var(--dusk); }
.touch-button {
  padding: 6px 10px;
  border: 2px solid var(--line);
  border-radius: 6px;
  font: 600 13px/1 var(--font-pixel);
  color: var(--text);
  background: none;
}

/* A small d-pad: a plus of two bars. */
.touch-dpad {
  position: relative;
  width: 30px;
  height: 30px;
  background: none;
}

.touch-dpad::before,
.touch-dpad::after {
  content: '';
  position: absolute;
  background: var(--bezel);
  border-radius: 3px;
}

.touch-dpad::before { left: 10px; top: 0; width: 10px; height: 30px; }
.touch-dpad::after { left: 0; top: 10px; width: 30px; height: 10px; }

@media (prefers-color-scheme: dark) {
  .touch-round,
  .touch-dpad::before,
  .touch-dpad::after { background: #34495e; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

code { font-size: 0.92em; }

.keys div {
  display: grid;
  grid-template-columns: 9.5em 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
}

.keys dt { display: flex; flex-wrap: wrap; gap: 4px; }
.keys dd { margin: 0; }

kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 2px 6px;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 6px;
  font: 600 14px/1.3 var(--font-pixel);
  text-align: center;
}

.guide-note {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* Footer: the fan-project disclaimer and the licenses link. */

.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 2px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.footer p { margin: 0 0 8px; max-width: 64ch; }
.footer p:last-child { margin-bottom: 0; }

/* Draft -------------------------------------------------------------------- */

.mode-name[data-mode="draft"] { background: var(--blue); }
.mode-name[data-mode="gauntlet"] { background: var(--rocket); }

.mode-name {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 12px 4px;
  border-radius: 8px;
  font-size: 0.5em;
  letter-spacing: 0;
  vertical-align: middle;
  color: #fff;
  background: var(--crimson);
}

.button-back {
  margin: 0 0 10px -4px;
  padding: 6px 4px;
  font: 500 15px/1.2 var(--font-body);
  color: var(--muted);
}

.button-back:hover { color: var(--text); }

.draft,
.gauntlet { display: none; }
.app[data-state="draft"] .draft,
.app[data-state="gauntlet"] .gauntlet { display: block; }
.app[data-state="draft"] .console,
.app[data-state="gauntlet"] .console { display: none; }

.draft-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}

.draft-heading {
  margin: 0;
  font: 600 30px/1.15 var(--font-pixel);
}

.draft-level { margin: 0; color: var(--muted); }
.draft-level strong { color: var(--text); font-weight: 700; font-size: 18px; }

.draft-subheading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  margin: 28px 0 12px;
  font: 600 20px/1.2 var(--font-pixel);
}

.draft-total,
.draft-note {
  font: 400 14px/1.4 var(--font-body);
  color: var(--muted);
}

.draft-footnote { margin: 14px 0 0; max-width: 64ch; }

.red-team,
.pool,
.team-slots {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* RED's six: compact, on the summit's night colours. */
.red-team {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  color: var(--on-dark);
  background: linear-gradient(180deg, #2b3d50 0%, var(--night) 100%);
}

.red-mon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  text-align: center;
}

.red-mon .mon-name { font: 600 15px/1.2 var(--font-pixel); overflow-wrap: anywhere; }

.red-hidden {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 72px;
  aspect-ratio: 1;
  margin: 0 auto;
  border: 2px dashed #4a5d70;
  border-radius: 10px;
  font: 700 28px/1 var(--font-pixel);
  color: #8fa3b5;
}

.classic-tag,
.legend-tag {
  padding: 1px 6px;
  border-radius: 4px;
  font: 600 11px/1.4 var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.classic-tag { position: absolute; top: 0; right: 0; color: #fff; background: var(--crimson); }
.legend-tag { color: #3d2c00; background: #f2c94c; vertical-align: 2px; }

.mon-sprite {
  display: block;
  image-rendering: pixelated;
}

.types { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }

.type {
  padding: 1px 7px;
  border-radius: 4px;
  font: 600 12px/1.45 var(--font-body);
  color: #1b2733;
  background: #a8a878;
}

.type[data-type="FIGHTING"] { background: #c03028; color: #fff; }
.type[data-type="FLYING"] { background: #a890f0; }
.type[data-type="POISON"] { background: #a040a0; color: #fff; }
.type[data-type="GROUND"] { background: #e0c068; }
.type[data-type="ROCK"] { background: #b8a038; }
.type[data-type="BUG"] { background: #a8b820; }
.type[data-type="GHOST"] { background: #705898; color: #fff; }
.type[data-type="STEEL"] { background: #b8b8d0; }
.type[data-type="FIRE"] { background: #f08030; }
.type[data-type="WATER"] { background: #6890f0; }
.type[data-type="GRASS"] { background: #78c850; }
.type[data-type="ELECTRIC"] { background: #f8d030; }
.type[data-type="PSYCHIC"] { background: #f85888; }
.type[data-type="ICE"] { background: #98d8d8; }
.type[data-type="DRAGON"] { background: #7038f8; color: #fff; }
.type[data-type="DARK"] { background: #705848; color: #fff; }

/* The pool: each card is one big button. */
.pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 10px;
}

.pool li { display: flex; }

.pool-mon {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  font: inherit;
  color: inherit;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
}

@media (hover: hover) {
  .pool-mon:not(:disabled):not([aria-pressed="true"]):hover { border-color: var(--muted); }
}
.pool-mon:disabled { cursor: default; opacity: 0.5; }

.pool-mon[aria-pressed="true"] {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  background: var(--picked);
}

.pool-mon .mon-sprite { margin: -14px 0 -10px; }
.pool-mon .mon-name { font: 600 17px/1.2 var(--font-pixel); overflow-wrap: anywhere; }
.mon-dex { font: 500 13px/1 var(--font-body); color: var(--muted); }

.mon-facts {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.mon-facts b { color: var(--text); font-weight: 600; }

.pick-badge:empty { display: none; }

.pick-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 6px;
  font: 700 14px/1.2 var(--font-pixel);
  color: #fff;
  background: var(--blue);
}

/* Your team, the totals and Battle RED stay in view while scrolling the pool. */
.draft-bar {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "slots actions" "total actions";
  align-items: center;
  gap: 8px 16px;
  margin: 20px calc(-1 * var(--gutter)) 0;
  padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
  border-top: 2px solid var(--line);
  background: var(--page);
}

.team-slots { grid-area: slots; display: flex; gap: 6px; }

.slot {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: none;
}

.slot-filled {
  border-style: solid;
  background: var(--surface);
  cursor: pointer;
}

.team-slots li:first-child .slot-filled { border-color: var(--blue); }

.team-total {
  grid-area: total;
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.team-total strong { color: var(--text); font-weight: 600; }

.draft-actions { grid-area: actions; display: flex; gap: 8px; }

.button-battle { padding: 12px 22px; font-size: 20px; }
.button-battle:disabled { box-shadow: none; transform: none; }
.button-battle:disabled:hover { background: var(--blue); }

@media (max-width: 720px) {
  .red-team { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; }
  .draft-bar {
    grid-template-columns: 1fr;
    grid-template-areas: "slots" "total" "actions";
  }
  .draft-actions { justify-content: flex-end; }
  .team-slots { justify-content: space-between; }
  .slot { width: min(52px, calc((100vw - 2 * var(--gutter) - 30px) / 6)); height: auto; aspect-ratio: 1; }
  .slot .mon-sprite { width: 100%; height: auto; }
}

@media (max-width: 400px) {
  .pool { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pool-mon .mon-sprite { width: 96px; height: 96px; margin: -10px 0 -8px; }
  .pool-mon { padding: 4px 6px 10px; }
  .mon-facts { font-size: 12px; }
}

/* Small screens ------------------------------------------------------------ */

@media (max-width: 640px) {
  .app { padding-top: 24px; }
  .title { font-size: clamp(24px, 8.4vw, 44px); }
  .draft-heading { font-size: 26px; }
  .bezel { padding: 5px; border-radius: 10px; }
  .card-loading, .card-error { gap: 12px; padding: 16px; }
  .card-heading { font-size: 20px; }
  .card-note { font-size: 13px; }
  .card-error .button-play { padding: 12px 32px; font-size: 22px; }
  .toolbar .button { padding: 10px 14px; font-size: 16px; }
}

/* Gauntlet ------------------------------------------------------------------ */

.gauntlet-step { margin-top: 6px; }

.gauntlet .pool-mon[aria-pressed="true"] {
  border-color: var(--rocket);
  box-shadow: inset 0 0 0 1px var(--rocket);
  background: var(--picked-rocket);
}

.gauntlet .pick-badge { background: var(--rocket); }
.gauntlet-locked .pool-mon:disabled { opacity: 1; }
.gauntlet .team-slots li:first-child .slot-filled { border-color: var(--rocket); }
.gauntlet .slot-filled:disabled { cursor: default; }

:root { --picked-rocket: #f1eafa; }
@media (prefers-color-scheme: dark) {
  :root { --picked-rocket: #2a1e3a; }
}

.signature-tag {
  padding: 1px 6px;
  border-radius: 4px;
  font: 600 11px/1.4 var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: 2px;
  color: #fff;
  background: var(--rocket);
}

/* "You beat LEADER BROCK!" with the trainer, on the summit's night colours. */
.gauntlet-beat {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0 4px;
  padding: 8px 18px 8px 10px;
  border-radius: 14px;
  font: 600 19px/1.3 var(--font-pixel);
  color: var(--on-dark);
  background: linear-gradient(180deg, #3e1c63 0%, var(--rocket-night) 100%);
}

.gauntlet-beat[hidden] { display: none; }

.trainer-sprite {
  display: block;
  flex: none;
  image-rendering: pixelated;
}

/* The end of a run, on the game screen. */
.app[data-state="gauntlet-over"] .card-over { display: flex; }

.card-over {
  gap: 1.8cqh;
  padding: 4cqh;
  background: linear-gradient(180deg, #3e1c63 0%, #241433 50%, var(--rocket-night) 100%);
}

.card-over p { position: relative; margin: 0; }

.over-title {
  font: 600 max(12px, 3.6cqh)/1 var(--font-pixel);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d9c6f0;
}

.card-over .card-heading { font-size: max(20px, 7.5cqh); }

.over-beaten-by {
  display: flex;
  align-items: center;
  gap: 2cqw;
  font: 500 max(13px, 4cqh)/1.2 var(--font-pixel);
}

.over-beaten-by:empty { display: none; }
.over-beaten-by .trainer-sprite { width: max(40px, 13cqh); height: auto; }

.over-history {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.over-history[hidden] { display: none; }

.over-history li {
  display: grid;
  place-items: center;
  width: max(26px, 8cqh);
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.over-history .trainer-sprite { width: 100%; height: auto; }
.over-history .more { font: 600 max(11px, 3.2cqh)/1 var(--font-body); color: #d9c6f0; }

.over-share {
  max-width: 46ch;
  white-space: pre-line;
  font-size: max(10px, 3cqh);
  line-height: 1.35;
  color: #b9a7cf;
  user-select: all;
}

.over-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 1cqh; }
.over-actions .button { padding: max(8px, 2cqh) max(14px, 4cqh); font-size: max(14px, 4.4cqh); }
.button-on-dark { border-color: rgba(217, 198, 240, 0.4); }
.button-on-dark:not(:disabled):hover { border-color: #d9c6f0; }

/* On a phone the end card is short: drop the share text (Copy still works). */
@container (max-height: 300px) {
  .over-share { display: none; }
  .card-over { gap: 1.2cqh; padding: 2.5cqh; }
}

@media (max-width: 640px) {
  .gauntlet-beat { font-size: 16px; }
  .gauntlet-beat .trainer-sprite { width: 48px; height: 48px; }
}

/* The phone chips have no text baseline to line up on. */
.touch-keys div { align-items: center; }

@media (max-width: 520px) {
  .mode-guide div { grid-template-columns: 1fr; gap: 4px; }
  .keys div { grid-template-columns: 7.5em 1fr; }
}
