:root {
  --ink: #102037;
  --cream: #fff8dd;
  --hot: #ff3f7f;
  --aqua: #15d6d1;
  --gold: #ffd43d;
  --panel: rgba(255, 248, 221, 0.9);
  --shadow: 0 18px 60px rgba(13, 19, 43, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 212, 61, 0.85), transparent 26rem),
    radial-gradient(circle at 82% 12%, rgba(21, 214, 209, 0.7), transparent 24rem),
    linear-gradient(135deg, #ff8b3d 0%, #f7417f 52%, #5939d9 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  touch-action: none;
}

button {
  border: 0;
  font: inherit;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: fixed;
  inset: max(16px, env(safe-area-inset-top)) 16px auto 16px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  gap: 14px;
  align-items: start;
  pointer-events: none;
}

.brand,
.timer,
.scoreboard {
  border: 4px solid rgba(16, 32, 55, 0.14);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  width: fit-content;
  padding: 12px 16px;
  border-radius: 22px;
}

.logo-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, white 0 12%, transparent 13%),
    conic-gradient(from 30deg, var(--hot), var(--gold), var(--aqua), var(--hot));
  box-shadow: 0 5px 0 rgba(16, 32, 55, 0.22);
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2,
.timer,
#startButton,
.touch-controls button {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  letter-spacing: 0.035em;
}

h1 {
  font-size: clamp(1.05rem, 2.4vw, 1.6rem);
  line-height: 1;
}

.brand p {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.68;
}

.timer {
  min-width: 118px;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: clamp(1.25rem, 3vw, 2.1rem);
  text-align: center;
}

.scoreboard {
  justify-self: end;
  min-width: 220px;
  margin: 0;
  padding: 10px;
  border-radius: 22px;
  list-style: none;
}

.scoreboard li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 14px;
  font-weight: 900;
}

.scoreboard li:first-child {
  background: rgba(255, 212, 61, 0.5);
}

.score-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(16, 32, 55, 0.3);
  border-radius: 50%;
}

.start-panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 32, 55, 0.18);
}

.start-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.panel-card {
  width: min(980px, 100%);
  padding: clamp(24px, 5vw, 44px);
  border: 5px solid rgba(16, 32, 55, 0.12);
  border-radius: 34px;
  background: var(--cream);
  box-shadow: var(--shadow);
  text-align: center;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.8fr);
  gap: clamp(20px, 4vw, 36px);
  align-items: start;
  text-align: left;
}

.panel-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.eyebrow {
  color: var(--hot);
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h2 {
  margin-top: 8px;
  max-width: 8ch;
  font-size: clamp(3.1rem, 7.2vw, 6.2rem);
  line-height: 0.84;
  text-wrap: balance;
}

.panel-card p:not(.eyebrow) {
  margin: 18px auto 0;
  max-width: 32rem;
  font-size: 1.14rem;
  font-weight: 700;
  line-height: 1.5;
}

.panel-copy p:not(.eyebrow) {
  margin-left: 0;
  margin-right: 0;
}

#startButton {
  margin-top: 26px;
  padding: 14px 26px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  box-shadow: 0 8px 0 rgba(16, 32, 55, 0.25);
  cursor: pointer;
  font-size: 1.1rem;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease;
}

#startButton:hover {
  transform: translateY(2px);
  box-shadow: 0 6px 0 rgba(16, 32, 55, 0.25);
}

.honors-board {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 100%;
  padding: 22px 22px 18px;
  border: 4px solid rgba(16, 32, 55, 0.12);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 248, 221, 0.92));
}

.board-kicker {
  margin: 0;
  color: var(--hot);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.high-scores {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.high-scores li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.54);
  font-weight: 900;
}

.high-scores li:first-child {
  background: rgba(255, 212, 61, 0.4);
}

.high-score-rank {
  width: 1.6rem;
  text-align: center;
  color: rgba(16, 32, 55, 0.7);
}

.high-score-name {
  letter-spacing: 0.14em;
}

.high-score-value {
  font-variant-numeric: tabular-nums;
}

.high-scores-empty {
  grid-template-columns: 1fr;
  justify-items: center;
  color: rgba(16, 32, 55, 0.68);
}

.score-form {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 2px dashed rgba(16, 32, 55, 0.14);
}

.score-form.hidden {
  display: none;
}

.score-form-label {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
}

.score-form-copy,
.score-form-status {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.score-form-status {
  min-height: 1.35em;
  color: rgba(16, 32, 55, 0.72);
}

.score-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

#initialsInput,
#submitScoreButton {
  border-radius: 18px;
  font-weight: 900;
}

#initialsInput {
  width: 100%;
  padding: 12px 14px;
  border: 3px solid rgba(16, 32, 55, 0.16);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  font-size: 1.35rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
}

#submitScoreButton {
  padding: 0 18px;
  background: var(--hot);
  color: white;
  box-shadow: 0 6px 0 rgba(173, 33, 87, 0.28);
  cursor: pointer;
}

#submitScoreButton:disabled {
  opacity: 0.55;
  cursor: wait;
}

.touch-controls {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: none;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.touch-cluster {
  display: grid;
  gap: 12px;
  pointer-events: auto;
}

.touch-steer {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-items: start;
}

.touch-drive {
  justify-items: end;
}

.touch-controls button {
  width: clamp(72px, 18vw, 92px);
  height: clamp(72px, 18vw, 92px);
  border: 4px solid rgba(16, 32, 55, 0.14);
  border-radius: 26px;
  background: rgba(255, 248, 221, 0.84);
  box-shadow: 0 8px 0 rgba(16, 32, 55, 0.16);
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 2.5rem);
  touch-action: manipulation;
}

.touch-drive button:first-child {
  background:
    linear-gradient(180deg, rgba(255, 212, 61, 0.95), rgba(255, 166, 0, 0.82)),
    rgba(255, 248, 221, 0.84);
}

.touch-drive button:last-child {
  background:
    linear-gradient(180deg, rgba(21, 214, 209, 0.9), rgba(45, 120, 255, 0.72)),
    rgba(255, 248, 221, 0.84);
}

.touch-controls button:active {
  transform: translateY(3px);
  box-shadow: 0 5px 0 rgba(16, 32, 55, 0.16);
}

@media (pointer: coarse), (max-width: 760px) {
  .hud {
    grid-template-columns: 1fr auto;
  }

  .brand {
    display: none;
  }

  .scoreboard {
    grid-column: 1 / -1;
    justify-self: stretch;
    min-width: 0;
  }

  .scoreboard li {
    grid-template-columns: 18px 1fr auto;
    padding: 4px 6px;
    font-size: 0.9rem;
  }

  .timer {
    grid-column: 2;
    grid-row: 1;
  }

  .touch-controls {
    display: flex;
  }

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

  .panel-copy {
    align-items: center;
    text-align: center;
  }

  h2 {
    max-width: 9ch;
    font-size: clamp(2.4rem, 13vw, 4.4rem);
  }

  .panel-copy p:not(.eyebrow) {
    margin-left: auto;
    margin-right: auto;
  }

  .honors-board {
    min-height: 0;
  }
}
