@font-face {
  font-family: "Press Start 2P";
  src: url("assets/fonts/press-start-2p.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "VT323";
  src: url("assets/fonts/vt323.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #030302;
  --panel: #090805;
  --panel-2: #050503;
  --cream: #efe7c8;
  --cream-dim: #c2b99e;
  --muted: #8b826b;
  --muted-2: #625b49;
  --line: #373125;
  --line-strong: #5a5140;
  --green: #8cff74;
  --green-bright: #c2ffb0;
  --green-dim: #4b7c40;
  --amber: #ffb454;
  --amber-bright: #ffd08e;
  --red: #ff6b4a;
  --pixel: "Press Start 2P", "Courier New", monospace;
  --terminal: "VT323", "Courier New", monospace;
  --radius: 2px;
}

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

html {
  color-scheme: dark;
}

body {
  min-height: 100svh;
  margin: 0;
  padding: clamp(14px, 2.4vw, 30px);
  color: var(--cream);
  font-family: var(--terminal);
  font-size: 20px;
  line-height: 1.35;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 680px at 50% -18%, rgba(255, 180, 84, 0.085), transparent 62%),
    radial-gradient(900px 600px at 102% 108%, rgba(140, 255, 116, 0.04), transparent 58%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 9px);
  background-attachment: fixed;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

body.overlay-open {
  overflow: hidden;
}

::selection {
  color: #061004;
  background: var(--green);
}

[hidden],
.hidden {
  display: none !important;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  user-select: none;
}

.brand-mark {
  width: 36px;
  height: 24px;
  flex: none;
  overflow: visible;
}

.brand-paddle-left {
  fill: var(--green);
  filter: drop-shadow(0 0 5px rgba(140, 255, 116, 0.55));
}

.brand-paddle-right {
  fill: var(--amber);
  filter: drop-shadow(0 0 5px rgba(255, 180, 84, 0.5));
}

.brand-ball {
  fill: var(--cream);
  filter: drop-shadow(0 0 4px rgba(239, 231, 200, 0.7));
}

.brand-text {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  font-family: var(--pixel);
  font-size: 14px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(239, 231, 200, 0.22);
}

.brand-accent {
  padding-left: 9px;
  border-left: 1px solid var(--line-strong);
  color: var(--amber);
  font-size: 7px;
  letter-spacing: 0.14em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 11px 16px;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: #0b0a07;
  color: var(--cream);
  font-family: var(--pixel);
  font-size: 9px;
  font-weight: 400;
  line-height: 1.45;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.8);
  transition:
    background-color 100ms ease,
    border-color 100ms ease,
    color 100ms ease,
    transform 80ms ease,
    box-shadow 80ms ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: var(--cream-dim);
  background: #15120c;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.85);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.85);
}

.btn:focus-visible,
.mode-btn:focus-visible,
input:focus-visible,
.text-link:focus-visible {
  outline: 2px dashed var(--green);
  outline-offset: 3px;
}

.btn-primary {
  border-color: var(--amber-bright);
  color: #1b1103;
  background: var(--amber);
  text-shadow: none;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.85);
}

.btn-primary:hover {
  border-color: #ffe2b6;
  color: #120b01;
  background: #ffc66e;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.85);
}

.btn-primary:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.85);
}

.btn-ghost {
  color: var(--cream);
  border-color: var(--line-strong);
  background: #0b0a07;
}

.btn-ghost:hover {
  border-color: var(--cream-dim);
  color: var(--cream);
  background: #15120c;
}

.btn-danger {
  color: var(--red);
  border-color: #6d3224;
  background: #0e0906;
}

.btn-danger:hover {
  border-color: var(--red);
  color: #ff9b83;
  background: #1a0d08;
}

.btn-icon {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  color: var(--cream);
}

.btn-icon:hover {
  color: var(--amber);
}

#pauseBtn {
  width: auto;
  min-width: 98px;
  height: 42px;
  padding: 0 13px;
  gap: 8px;
  border-color: var(--amber-bright);
  background: var(--amber);
  color: #1b1103;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: none;
  box-shadow:
    3px 3px 0 rgba(0, 0, 0, 0.85),
    0 0 18px rgba(255, 180, 84, 0.22);
}

#pauseBtn:hover {
  border-color: #ffe2b6;
  background: #ffc66e;
  color: #120b01;
  box-shadow:
    3px 3px 0 rgba(0, 0, 0, 0.85),
    0 0 24px rgba(255, 180, 84, 0.4);
}

#pauseBtn svg {
  flex: none;
}

.btn-small {
  min-height: 38px;
  padding: 9px 13px;
  font-size: 8px;
}

.btn-block {
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  font-size: 10px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn-row .btn {
  flex: 1;
  min-width: 140px;
}

.hi-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 16px;
  padding: 0 3px;
  border: 1px solid currentColor;
  color: var(--amber);
  font-size: 6px;
  line-height: 1;
  letter-spacing: 0.02em;
}

#soundBtn .sound-off {
  display: none;
}

#soundBtn.is-muted {
  color: var(--muted);
}

#soundBtn.is-muted .sound-on {
  display: none;
}

#soundBtn.is-muted .sound-off {
  display: block;
}

/* ---------- HUD ---------- */

.main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #070604;
  box-shadow:
    4px 4px 0 rgba(0, 0, 0, 0.75),
    inset 0 0 0 1px #000;
}

.hud-side {
  min-width: 0;
}

.hud-side-right {
  text-align: right;
}

.hud-role {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hud-side-right .hud-role {
  justify-content: flex-end;
}

.dot {
  width: 6px;
  height: 6px;
  flex: none;
}

.dot-left {
  background: var(--green);
  box-shadow: 0 0 6px rgba(140, 255, 116, 0.7);
}

.dot-right {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(255, 180, 84, 0.65);
}

.hud-name {
  margin-top: 2px;
  overflow: hidden;
  color: var(--cream);
  font-family: var(--terminal);
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud-record {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted-2);
  font-family: var(--terminal);
  font-size: 14px;
  letter-spacing: 0.05em;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud-center {
  text-align: center;
}

.hud-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  font-family: var(--pixel);
  font-size: clamp(20px, 2.4vw, 26px);
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-shadow: 0 0 12px currentColor;
  font-variant-numeric: tabular-nums;
}

#leftScore {
  color: var(--green);
}

#rightScore {
  color: var(--amber);
}

.hud-sep {
  margin: 0 0.55em;
  color: var(--muted-2);
  text-shadow: none;
}

.hud-mode {
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- Arena / CRT ---------- */

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  overflow: hidden;
  border: 10px solid #17140f;
  border-radius: 10px;
  outline: 1px solid #3d3629;
  background: #000;
  box-shadow:
    0 12px 0 #020201,
    0 28px 60px rgba(0, 0, 0, 0.75),
    0 0 90px rgba(140, 255, 116, 0.055),
    inset 0 0 0 2px #000;
  isolation: isolate;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.28) 0,
    rgba(0, 0, 0, 0.28) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.55;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: 2px;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(140, 255, 116, 0.035) 0%, transparent 62%),
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.58) 100%),
    linear-gradient(115deg, rgba(255, 255, 255, 0.032), transparent 32%);
  animation: crt-flicker 9s steps(1, end) infinite;
}

.understage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  flex-wrap: wrap;
  padding-inline: 4px;
  color: var(--muted);
  font-size: 17px;
}

.controls {
  margin: 0;
  line-height: 1.6;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.controls kbd {
  display: inline-block;
  min-width: 22px;
  margin: 0 2px;
  padding: 1px 5px 2px;
  border: 1px solid #4a4334;
  border-radius: 0;
  background: #0d0b07;
  color: var(--cream);
  font-family: var(--terminal);
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 #000;
}

.persistence-note {
  margin: 0;
  color: var(--muted-2);
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 0.05em;
  line-height: 1.8;
  white-space: nowrap;
}

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(14px, 3vw, 34px);
  overflow-y: auto;
  background-color: rgba(2, 3, 2, 0.91);
  background-image:
    radial-gradient(ellipse at 50% 45%, rgba(255, 180, 84, 0.035), transparent 58%),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.16) 0,
      rgba(0, 0, 0, 0.16) 1px,
      transparent 1px,
      transparent 4px
    );
}

.panel {
  position: relative;
  width: min(580px, 100%);
  margin-block: auto;
  padding: clamp(24px, 4vw, 34px);
  overflow: hidden;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow:
    8px 8px 0 rgba(0, 0, 0, 0.65),
    inset 0 0 0 1px #000,
    inset 0 0 90px rgba(140, 255, 116, 0.025);
  animation: panel-in 180ms ease both;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 9px;
  z-index: 0;
  border: 1px dashed rgba(255, 180, 84, 0.13);
  pointer-events: none;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 180, 84, 0.55) 0 10px,
    transparent 10px 20px
  );
  opacity: 0.28;
  pointer-events: none;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.panel-small {
  width: min(460px, 100%);
}

@keyframes panel-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes crt-flicker {
  0%,
  100% {
    opacity: 0.95;
  }
  48% {
    opacity: 0.93;
  }
  50% {
    opacity: 1;
  }
  52% {
    opacity: 0.92;
  }
  54% {
    opacity: 0.97;
  }
}

@keyframes blink {
  0%,
  54% {
    opacity: 1;
  }
  55%,
  100% {
    opacity: 0;
  }
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-family: var(--pixel);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.7;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "> ";
  color: var(--amber);
}

.title {
  margin: 0 0 8px;
  color: var(--cream);
  font-family: var(--pixel);
  font-size: clamp(42px, 7vw, 58px);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-shadow:
    0 0 22px rgba(239, 231, 200, 0.24),
    3px 3px 0 rgba(0, 0, 0, 0.85);
}

.title-sub {
  margin: -2px 0 20px 2px;
  color: var(--amber);
  font-family: var(--pixel);
  font-size: 12px;
  letter-spacing: 0.14em;
  line-height: 1.6;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(255, 180, 84, 0.35);
}

.title-cursor {
  color: var(--green);
  text-shadow: 0 0 16px rgba(140, 255, 116, 0.7);
  animation: blink 1.1s steps(1, end) infinite;
}

.lead {
  max-width: 52ch;
  margin: 0 0 20px;
  color: var(--cream-dim);
  font-size: 20px;
  line-height: 1.35;
}

h2 {
  margin: 0;
  color: var(--cream);
  font-family: var(--pixel);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.55;
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(239, 231, 200, 0.14);
}

.welcome {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  margin: 0 0 20px;
  padding: 8px 10px;
  border: 1px solid var(--green-dim);
  border-radius: 0;
  background: rgba(140, 255, 116, 0.045);
  color: var(--green-bright);
  font-family: var(--pixel);
  font-size: 7px;
  line-height: 1.7;
  text-transform: uppercase;
}

.welcome > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.welcome-dot {
  width: 6px;
  height: 6px;
  flex: none;
  background: var(--green);
  box-shadow: 0 0 7px rgba(140, 255, 116, 0.8);
  animation: blink 1.4s steps(1, end) infinite;
}

/* Mode picker */

.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 20px;
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #040402;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.7);
}

.mode-btn {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 13px 8px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 9px;
  font-weight: 400;
  line-height: 1.5;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color 100ms ease,
    border-color 100ms ease,
    color 100ms ease;
}

.mode-btn span {
  color: var(--muted-2);
  font-size: 7px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.mode-btn:hover {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.025);
}

.mode-btn.is-active {
  border-color: var(--green-dim);
  background: rgba(140, 255, 116, 0.075);
  color: var(--green-bright);
  text-shadow: 0 0 9px rgba(140, 255, 116, 0.35);
}

.mode-btn.is-active span {
  color: var(--amber);
}

/* Form */

.fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.fields.is-duo {
  grid-template-columns: 1fr 1fr;
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin: 0 0 7px 1px;
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.05em;
  line-height: 1.5;
  text-transform: uppercase;
}

input {
  width: 100%;
  height: 52px;
  padding: 0 12px;
  border: 2px solid #3c3629;
  border-radius: var(--radius);
  background: #040503;
  color: var(--green-bright);
  font-family: var(--terminal);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.02);
  transition:
    border-color 100ms ease,
    box-shadow 100ms ease,
    background-color 100ms ease;
}

input::placeholder {
  color: var(--muted-2);
  letter-spacing: 0.06em;
}

input:hover {
  border-color: #514936;
}

input:focus {
  border-color: var(--green);
  background: #050703;
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.8),
    0 0 0 2px rgba(140, 255, 116, 0.12),
    0 0 18px rgba(140, 255, 116, 0.12);
  outline: none;
}

input[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.8),
    0 0 0 2px rgba(255, 107, 74, 0.12);
}

.form-error {
  min-height: 21px;
  margin: 7px 0 10px;
  color: var(--red);
  font-size: 17px;
  line-height: 1.3;
}

.save-note {
  margin: 16px 0 0;
  color: var(--muted-2);
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 0.04em;
  line-height: 1.9;
  text-transform: uppercase;
}

/* Pause */

.pause-score {
  margin-bottom: 4px;
  color: var(--cream);
  font-family: var(--terminal);
  font-size: 24px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-small .btn-row {
  margin-top: 22px;
}

/* Results */

.result-title {
  margin: 0 0 18px;
  font-family: var(--pixel);
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.35;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.result-title.is-win {
  color: var(--green-bright);
  text-shadow: 0 0 22px rgba(140, 255, 116, 0.45);
}

.result-title.is-win-amber {
  color: var(--amber-bright);
  text-shadow: 0 0 22px rgba(255, 180, 84, 0.4);
}

.result-title.is-loss {
  color: var(--red);
  text-shadow: 0 0 22px rgba(255, 107, 74, 0.35);
}

.result-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 15px 17px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #040402;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.6);
}

.result-name {
  overflow: hidden;
  color: var(--cream);
  font-family: var(--terminal);
  font-size: 21px;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.result-name-right {
  text-align: right;
}

.result-score {
  display: flex;
  align-items: baseline;
  font-family: var(--pixel);
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1.2;
  text-shadow: 0 0 14px currentColor;
}

#resultScoreLeft {
  color: var(--green);
}

#resultScoreRight {
  color: var(--amber);
}

.result-sep {
  margin: 0 0.45em;
  color: var(--muted-2);
  text-shadow: none;
}

.result-note {
  min-height: 22px;
  margin: 12px 1px 18px;
  color: var(--cream-dim);
  font-size: 19px;
  line-height: 1.35;
}

.result-arcade {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 22px;
  margin: 0 0 16px;
  padding: 9px 11px;
  border: 1px dashed var(--line);
  background: #050402;
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 0.04em;
  line-height: 1.8;
  text-transform: uppercase;
}

.result-arcade b {
  margin-left: 4px;
  color: var(--amber);
  font-weight: 400;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 10px 11px;
  border: 1px dashed var(--line);
  border-radius: 0;
  background: #060503;
}

.stat-label {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-value {
  overflow: hidden;
  color: var(--cream);
  font-family: var(--terminal);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* High scores */

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.panel-head h2 {
  font-size: 21px;
}

.panel-head .btn-icon {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  margin-top: -3px;
  font-family: var(--terminal);
  font-size: 26px;
  line-height: 1;
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: min(46vh, 370px);
  margin: 16px 0 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 28px 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 9px;
  border: 1px solid transparent;
  border-bottom: 1px dashed var(--line);
  background: transparent;
}

.leaderboard li:last-child {
  border-bottom-color: transparent;
}

.leaderboard li.is-you {
  border-color: var(--green-dim);
  background: rgba(140, 255, 116, 0.04);
  box-shadow: inset 3px 0 0 var(--green);
}

.lb-rank {
  color: var(--muted-2);
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.lb-rank.rank-1 {
  color: var(--amber);
}

.lb-rank.rank-2 {
  color: var(--cream);
}

.lb-rank.rank-3 {
  color: #c98952;
}

.lb-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #0b0a06;
  color: var(--green);
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 #000;
}

.lb-avatar.tone-1 {
  color: var(--amber);
}

.lb-avatar.tone-2 {
  color: var(--cream);
}

.lb-player {
  min-width: 0;
}

.lb-name {
  overflow: hidden;
  color: var(--cream);
  font-family: var(--terminal);
  font-size: 21px;
  letter-spacing: 0.03em;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.lb-sub {
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.lb-extra::before {
  content: " · ";
}

.lb-record {
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.6;
  text-align: right;
  white-space: nowrap;
}

.lb-record b {
  color: var(--cream);
  font-weight: 400;
}

.lb-record .lb-muted {
  color: var(--muted-2);
}

.empty {
  margin: 18px 0 0;
  padding: 28px 20px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 19px;
  line-height: 1.4;
  text-align: center;
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.panel-foot .save-note {
  margin: 0;
}

.text-link {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--green);
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.8;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color 100ms ease;
}

.text-link:hover {
  color: var(--green-bright);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-link:focus-visible {
  outline: 2px dashed var(--green);
  outline-offset: 3px;
}

/* ---------- Responsive ---------- */

@media (min-width: 900px) and (min-height: 700px) {
  .app {
    max-width: min(1120px, calc((100svh - 255px) * 5 / 3));
  }
}

@media (max-width: 700px) {
  body {
    padding: 12px;
    font-size: 18px;
  }

  .app {
    gap: 12px;
  }

  .topbar {
    gap: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 30px;
  }

  .brand-text {
    font-size: 11px;
  }

  .brand-accent {
    font-size: 6px;
    padding-left: 7px;
  }

  .hud {
    gap: 8px;
    padding: 9px 11px;
  }

  .hud-name {
    font-size: 20px;
  }

  .hud-record {
    font-size: 12px;
  }

  .hud-role {
    font-size: 6px;
  }

  .hud-score {
    font-size: 18px;
  }

  .hud-mode {
    font-size: 5.5px;
  }

  .stage {
    border-width: 7px;
    border-radius: 7px;
    box-shadow:
      0 8px 0 #020201,
      0 18px 36px rgba(0, 0, 0, 0.7),
      0 0 60px rgba(140, 255, 116, 0.05);
  }

  .understage {
    font-size: 15px;
    padding-inline: 2px;
  }

  .controls kbd {
    min-width: 20px;
    font-size: 12px;
  }

  .persistence-note {
    display: none;
  }

  .panel {
    padding: 22px 20px;
  }

  .title {
    font-size: 40px;
  }

  .title-sub {
    margin-bottom: 16px;
    font-size: 9px;
  }

  .lead {
    font-size: 18px;
    margin-bottom: 16px;
  }

  .eyebrow {
    font-size: 7px;
  }

  .welcome {
    font-size: 6px;
  }

  .mode-picker {
    margin-bottom: 16px;
  }

  .mode-btn {
    font-size: 8px;
    padding: 12px 6px;
    gap: 5px;
  }

  .mode-btn span {
    font-size: 6px;
  }

  .fields.is-duo {
    grid-template-columns: 1fr;
  }

  input {
    height: 48px;
    font-size: 22px;
  }

  .result-stats {
    gap: 6px;
  }

  .stat {
    padding: 9px 8px;
  }

  .stat-label {
    font-size: 6px;
  }

  .stat-value {
    font-size: 19px;
  }

  .result-arcade {
    gap: 5px 14px;
    font-size: 6px;
  }

  .btn {
    font-size: 8px;
    padding-inline: 12px;
  }

  .btn-small {
    font-size: 7px;
  }

  .btn-block {
    font-size: 9px;
  }

  .text-link {
    font-size: 7px;
  }

  .save-note {
    font-size: 6px;
  }

  .btn-row .btn {
    min-width: 0;
  }
}

@media (max-width: 430px) {
  .brand-accent {
    display: none;
  }

  .btn-small {
    padding-inline: 9px;
    gap: 5px;
  }

  #leaderboardBtn > span:last-child {
    display: none;
  }

  #leaderboardBtn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
  }

  #pauseBtn {
    width: auto;
    min-width: 86px;
    height: 38px;
    min-height: 38px;
    padding: 0 9px;
    gap: 6px;
    font-size: 8px;
  }

  #soundBtn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .btn-row {
    flex-direction: column-reverse;
  }

  .btn-row .btn {
    width: 100%;
  }

  .panel-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .result-stats {
    grid-template-columns: 1fr 1fr;
  }

  .result-stats .stat:last-child {
    grid-column: span 2;
  }

  .leaderboard li {
    grid-template-columns: 23px 28px minmax(0, 1fr) auto;
    gap: 7px;
    padding-inline: 5px;
  }

  .lb-avatar {
    width: 28px;
    height: 28px;
    font-size: 7px;
  }

  .lb-name {
    font-size: 19px;
  }

  .lb-sub {
    font-size: 12px;
    line-height: 1.25;
    white-space: normal;
  }

  .lb-extra {
    display: block;
  }

  .lb-extra::before {
    content: "";
  }

  .lb-record {
    font-size: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .btn:hover {
    transform: none;
  }
}
