:root {
  color-scheme: dark;
  --bg: #0b0a0a;
  --panel: #171313;
  --panel-strong: #231a18;
  --text: #fff4e4;
  --muted: #c8b59b;
  --line: rgba(255, 244, 228, 0.16);
  --crimson: #d7263d;
  --brass: #f0b429;
  --bone: #f2f4f8;
  --green: #26c485;
  --steel: #9aa4b2;
  --danger: #ff4b3e;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    repeating-linear-gradient(112deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 18px),
    linear-gradient(135deg, rgba(215, 38, 61, 0.22), transparent 34%),
    linear-gradient(225deg, rgba(240, 180, 41, 0.13), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Arial Narrow", Arial, sans-serif;
}

button {
  border: 1px solid rgba(240, 180, 41, 0.42);
  background:
    linear-gradient(180deg, #34231f, #1b1514),
    #202738;
  color: var(--text);
  min-height: 42px;
  border-radius: 6px;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 22px rgba(0, 0, 0, 0.24);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  border-color: rgba(255, 244, 228, 0.48);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: default;
  opacity: 0.68;
  transform: none;
}

.menu-screen,
.controls-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #030202;
}

.menu-screen[hidden],
.controls-screen[hidden] {
  display: none;
}

.menu-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  opacity: 1;
  filter: none;
}

#main-menu .menu-bg {
  object-position: 50% 50%;
}

.menu-screen::after,
.controls-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 132, 39, 0.16), transparent 31%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0.1) 46%, rgba(0, 0, 0, 0.74)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.76));
}

#main-menu::after {
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 132, 39, 0.07), transparent 32%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.36), rgba(0, 0, 0, 0.02) 48%, rgba(0, 0, 0, 0.36)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.34));
}

.menu-content,
.controls-content {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 28px));
  display: grid;
  justify-items: center;
  gap: 24px;
  padding: 28px;
  text-align: center;
}

.menu-content h2,
.controls-content h2 {
  margin: 0;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(3.4rem, 11vw, 7.2rem);
  line-height: 0.9;
  color: #fff0d0;
  text-shadow:
    0 4px 0 #000,
    0 0 26px rgba(215, 38, 61, 0.82),
    0 0 62px rgba(240, 180, 41, 0.62);
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.menu-actions button,
.control-back {
  min-width: 220px;
  min-height: 58px;
  font-size: 1.06rem;
}

.track-content h2 {
  font-size: clamp(2.7rem, 8vw, 5.2rem);
}

.menu-track-picker {
  width: min(520px, 100%);
  display: grid;
  gap: 8px;
  text-align: left;
}

.menu-track-picker span,
.player-name-field span,
.difficulty-field legend {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.player-name-field {
  width: min(420px, 100%);
  display: grid;
  gap: 8px;
  text-align: left;
}

.player-name-field span {
  color: #fff0d0;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-transform: none;
  text-shadow:
    0 3px 0 #000,
    0 0 18px rgba(215, 38, 61, 0.86),
    0 0 34px rgba(240, 180, 41, 0.66);
}

.player-name-field input {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(240, 180, 41, 0.5);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 244, 228, 0.98), rgba(216, 188, 136, 0.96));
  color: #1b1010;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 900;
  padding: 0 14px;
  text-transform: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.player-name-field input:focus {
  outline: 2px solid rgba(240, 180, 41, 0.76);
  outline-offset: 2px;
}

.player-name-field input[aria-invalid="true"] {
  border-color: rgba(255, 36, 63, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 0 0 3px rgba(255, 36, 63, 0.24);
}

.menu-alert {
  width: min(420px, 100%);
  margin: -14px 0 0;
  border: 1px solid rgba(255, 36, 63, 0.72);
  border-radius: 6px;
  background: rgba(52, 5, 10, 0.78);
  color: #fff4e4;
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0;
  padding: 9px 12px;
  text-align: center;
  text-shadow: 0 2px 0 #000;
}

.menu-alert[hidden] {
  display: none;
}

.menu-track-picker select {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(240, 180, 41, 0.5);
  border-radius: 6px;
  background: linear-gradient(180deg, #fff4e4, #d8bc88);
  color: #1b1010;
  font: inherit;
  font-weight: 900;
  padding: 0 14px;
}

.start-message {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  background: rgba(4, 3, 3, 0.72);
}

.start-message[hidden] {
  display: none;
}

.start-message span {
  color: #fff0d0;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(2.7rem, 8vw, 6rem);
  line-height: 0.94;
  text-align: center;
  text-shadow: 0 4px 0 #000, 0 0 42px rgba(240, 180, 41, 0.72), 0 0 74px rgba(215, 38, 61, 0.72);
}

.pause-menu {
  position: fixed;
  inset: 0;
  z-index: 16;
  display: grid;
  place-items: center;
  background: rgba(4, 3, 3, 0.68);
}

.pause-menu[hidden] {
  display: none;
}

.pause-content {
  width: min(460px, calc(100vw - 28px));
  padding: 24px;
  display: grid;
  gap: 18px;
  border: 1px solid rgba(240, 180, 41, 0.4);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(38, 25, 21, 0.96), rgba(8, 7, 7, 0.94));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.pause-content h2 {
  margin: 0;
  color: #fff0d0;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  line-height: 0.9;
  text-align: center;
  text-shadow: 0 3px 0 #000, 0 0 28px rgba(215, 38, 61, 0.72);
}

.pause-actions {
  display: grid;
  gap: 10px;
}

.pause-actions button {
  width: 100%;
  min-height: 52px;
}

.controls-content {
  align-content: center;
  background: linear-gradient(180deg, rgba(35, 21, 18, 0.9), rgba(8, 7, 7, 0.82));
  border: 1px solid rgba(240, 180, 41, 0.36);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
}

.controls-content h2 {
  font-size: clamp(2.8rem, 7vw, 4.8rem);
}

.rules-screen {
  overflow: auto;
  align-items: start;
  padding: 18px;
}

.rules-content {
  position: relative;
  z-index: 1;
  width: min(1060px, calc(100vw - 28px));
  min-height: 0;
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 22px;
  text-align: center;
}

.rules-content h2 {
  margin: 0;
  color: #fff0d0;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(2.8rem, 8vw, 5rem);
  line-height: 0.9;
  text-shadow: 0 4px 0 #000, 0 0 30px rgba(215, 38, 61, 0.78);
}

.rules-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.rule-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(240, 180, 41, 0.3);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 10%, rgba(240, 180, 41, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(35, 21, 18, 0.94), rgba(8, 7, 7, 0.9));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

.rule-card h3 {
  margin: 0;
  color: #fff0d0;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 0.98;
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(215, 38, 61, 0.5);
}

.rule-card p {
  margin: 0;
  color: #f6e4c5;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.32;
}

.rule-picture {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 18 / 11;
  justify-self: center;
  border-radius: 7px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 244, 228, 0.08), rgba(0, 0, 0, 0.32));
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.34));
}

.rule-picture rect:first-child {
  fill: rgba(8, 7, 7, 0.7);
  stroke: rgba(240, 180, 41, 0.42);
  stroke-width: 2;
}

.rule-picture line {
  stroke: rgba(255, 244, 228, 0.68);
  stroke-width: 4;
  stroke-linecap: round;
}

.rule-picture text {
  fill: #fff4e4;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
}

.rule-big-text {
  font-size: 22px;
  text-anchor: middle;
}

.rule-hit-line {
  stroke: rgba(255, 244, 228, 0.9);
  stroke-width: 5;
}

.rule-connector,
.rule-tail {
  fill: none;
  stroke: rgba(255, 244, 228, 0.78);
  stroke-width: 9;
  stroke-linecap: round;
}

.rule-tail {
  stroke: rgba(255, 244, 228, 0.46);
}

.rule-red {
  fill: var(--crimson);
  stroke: rgba(255, 244, 228, 0.78);
  stroke-width: 2;
}

.rule-gold {
  fill: var(--brass);
  stroke: rgba(255, 244, 228, 0.78);
  stroke-width: 2;
}

.rule-green {
  fill: var(--green);
  stroke: rgba(255, 244, 228, 0.78);
  stroke-width: 2;
}

.rule-bone {
  fill: var(--bone);
  stroke: rgba(20, 17, 17, 0.8);
  stroke-width: 3;
}

.rule-flame {
  fill: #ff7417;
  stroke: #ffd447;
  stroke-width: 2;
}

.rule-pointer {
  fill: #fff4e4;
}

#controls-hint {
  max-width: 520px;
  color: #fff4e4;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
}

.difficulty-field {
  width: min(520px, 100%);
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid rgba(255, 244, 228, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.difficulty-field legend {
  padding: 0 8px;
}

.difficulty-field label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid rgba(240, 180, 41, 0.28);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(52, 35, 31, 0.92), rgba(15, 13, 13, 0.92));
  color: var(--text);
  font-weight: 900;
  text-transform: uppercase;
}

.difficulty-field input {
  accent-color: var(--brass);
}

.control-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 12px;
}

.control-bind {
  --lane-color: var(--crimson);
  min-height: 156px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 9px;
  padding: 14px 10px;
  border-color: color-mix(in srgb, var(--lane-color), #fff4e4 18%);
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--lane-color), transparent 58%), transparent 44%),
    linear-gradient(180deg, #2a1d1a, #0f0d0d);
}

.control-bind[hidden] {
  display: none;
}

.control-bind.is-listening {
  transform: translateY(-2px);
  border-color: #fff4e4;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--lane-color), transparent 38%), 0 18px 42px rgba(0, 0, 0, 0.42);
}

.control-point {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 48% 31%, #fff4e4 0 12%, transparent 13%),
    linear-gradient(180deg, color-mix(in srgb, var(--lane-color), #fff4e4 26%), var(--lane-color) 46%, color-mix(in srgb, var(--lane-color), #000 38%));
  border: 6px solid #090808;
  outline: 4px solid var(--lane-color);
  box-shadow: 0 0 24px color-mix(in srgb, var(--lane-color), transparent 44%);
}

.control-lane-name {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.control-key {
  max-width: 100%;
  color: #fff4e4;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(1.24rem, 3vw, 1.9rem);
  line-height: 1;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 0 #000, 0 0 18px color-mix(in srgb, var(--lane-color), transparent 35%);
}

.game-shell {
  width: min(1180px, calc(100vw - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 22px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(320px, 1.5fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(240, 180, 41, 0.26);
  background:
    linear-gradient(180deg, rgba(43, 29, 26, 0.96), rgba(17, 14, 14, 0.94)),
    var(--panel);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 18%, #f6d36a 18% 28%, transparent 28% 44%, #d7263d 44% 60%, transparent 60%),
    linear-gradient(45deg, #141111, #3a2824);
  border: 1px solid rgba(240, 180, 41, 0.48);
  box-shadow: 0 0 22px rgba(215, 38, 61, 0.35);
  flex: 0 0 auto;
}

h1,
p {
  margin: 0;
}

h1,
dialog h2 {
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  letter-spacing: 0;
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(215, 38, 61, 0.42);
}

h1 {
  font-size: clamp(1.72rem, 4.5vw, 2.34rem);
  line-height: 0.94;
  color: #fff0d0;
}

.brand p {
  color: var(--muted);
  margin-top: 5px;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
  gap: 8px;
}

.metrics div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(255, 244, 228, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 244, 228, 0.055), rgba(255, 244, 228, 0.02)),
    rgba(0, 0, 0, 0.22);
  border-radius: 7px;
}

.metrics span,
.energy-label span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(1rem, 2.8vw, 1.42rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
  color: #fff7e8;
}

.actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 0;
}

.action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}

.action-buttons button {
  min-width: 92px;
}

.track-picker {
  display: grid;
  gap: 4px;
  width: min(390px, 100%);
  min-width: min(330px, 100%);
}

.track-picker span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.track-picker select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(240, 180, 41, 0.42);
  border-radius: 6px;
  background: linear-gradient(180deg, #fff4e4, #d8bc88);
  color: #1b1010;
  font: inherit;
  font-weight: 800;
  padding: 0 12px;
}

.track-picker select option {
  background: #fff4e4;
  color: #1b1010;
  font-weight: 800;
}

.track-picker select:disabled {
  color: rgba(27, 16, 16, 0.72);
  opacity: 0.78;
}

.stage-wrap {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(620px, 1fr) auto;
  gap: 12px;
}

#game-canvas {
  width: 100%;
  height: min(calc(100vh - 124px), 980px);
  min-height: 680px;
  display: block;
  border: 1px solid rgba(240, 180, 41, 0.34);
  border-radius: 8px;
  background: #100d0c;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.44), 0 0 42px rgba(215, 38, 61, 0.14);
}

.health-row {
  display: grid;
  grid-template-columns: minmax(78px, auto) 1fr;
  align-items: start;
  gap: 14px;
  padding: 0 4px;
}

.energy-label {
  display: grid;
  gap: 4px;
  padding-top: 3px;
}

.energy-label strong {
  color: #fff7e8;
  font-size: 1.02rem;
  line-height: 1;
}

.energy-panel {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.meter {
  position: relative;
  height: 28px;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 244, 228, 0.22), rgba(0, 0, 0, 0.36)),
    linear-gradient(90deg, var(--danger) 0 28%, var(--brass) 45% 58%, var(--green) 78% 100%);
  overflow: visible;
  border: 1px solid rgba(255, 244, 228, 0.24);
  box-shadow: inset 0 1px 8px rgba(0, 0, 0, 0.62), 0 0 18px rgba(215, 38, 61, 0.1);
}

.meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(255, 244, 228, 0.46) calc(10% - 1px) 10%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 48%, rgba(0, 0, 0, 0.34));
  pointer-events: none;
}

#health-meter {
  position: absolute;
  top: -8px;
  left: 100%;
  width: 0;
  height: 44px;
  transition: left 120ms ease;
  filter: drop-shadow(0 0 10px rgba(255, 244, 228, 0.55));
}

#health-meter::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 0;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 13px solid #fff4e4;
}

#health-meter::after {
  content: "";
  position: absolute;
  left: -2px;
  top: 10px;
  width: 4px;
  height: 34px;
  border-radius: 3px;
  background: #fff4e4;
}

.energy-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  color: rgba(255, 244, 228, 0.74);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.energy-scale span {
  text-align: center;
}

.energy-scale span:first-child {
  text-align: left;
}

.energy-scale span:last-child {
  text-align: right;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid rgba(240, 180, 41, 0.3);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #251915, #141110),
    var(--panel);
  color: var(--text);
  padding: 22px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52);
}

dialog::backdrop {
  background: rgba(2, 2, 2, 0.74);
}

dialog h2 {
  margin: 0 0 18px;
  font-size: clamp(2.4rem, 8vw, 4rem);
  line-height: 0.92;
  text-align: center;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0 0 18px;
}

.result-grid div {
  padding: 12px;
  border: 1px solid rgba(255, 244, 228, 0.14);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.22);
}

.result-grid dt {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  font-weight: 800;
}

.result-grid dd {
  margin: 4px 0 0;
  font-size: 1.34rem;
  font-weight: 900;
}

.leaderboard-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px;
  border: 1px solid rgba(240, 180, 41, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 228, 0.045), rgba(0, 0, 0, 0.12)),
    rgba(0, 0, 0, 0.22);
}

.leaderboard-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-heading h3 {
  margin: 0;
  color: #fff0d0;
  font-family: "Old English Text MT", "UnifrakturCook", "UnifrakturMaguntia", Georgia, serif;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 0.96;
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(215, 38, 61, 0.42);
}

.leaderboard-heading p {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-align: right;
  text-transform: uppercase;
}

.leaderboard-table-wrap {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  font-size: 0.82rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 8px 7px;
  border-bottom: 1px solid rgba(255, 244, 228, 0.1);
  text-align: left;
  white-space: nowrap;
}

.leaderboard-table th {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-table td {
  color: #fff7e8;
  font-weight: 800;
}

.leaderboard-table td:nth-child(1),
.leaderboard-table td:nth-child(4),
.leaderboard-table td:nth-child(5),
.leaderboard-table td:nth-child(6) {
  text-align: center;
}

.leaderboard-table tr.is-current td {
  color: #ffd24a;
  background: rgba(240, 180, 41, 0.08);
}

.leaderboard-empty {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

dialog form {
  display: grid;
  gap: 10px;
  margin: 0;
}

dialog button {
  width: 100%;
}

@media (max-width: 840px) {
  .game-shell {
    width: min(100vw - 16px, 680px);
    padding-top: 8px;
  }

  .top-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    justify-items: stretch;
  }

  .action-buttons {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
  }

  .action-buttons button {
    min-width: 0;
    padding: 0 8px;
  }

  .track-picker {
    width: 100%;
    min-width: 0;
  }

  #game-canvas {
    height: 72vh;
    min-height: 600px;
  }

  .rules-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 1.55rem;
  }

  .metrics strong {
    font-size: 1rem;
  }

  .actions {
    gap: 7px;
  }

  .action-buttons {
    gap: 6px;
  }

  .action-buttons button {
    font-size: 0.74rem;
    padding: 0 5px;
  }

  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls-content {
    padding: 20px 14px;
  }

  .leaderboard-heading {
    display: grid;
    justify-items: start;
  }

  .leaderboard-heading p {
    text-align: left;
  }

  .rules-screen {
    padding: 10px;
  }

  .rules-content {
    width: min(100vw - 12px, 420px);
    padding: 14px 8px;
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }
}
