:root {
  color-scheme: dark;
  --bg: #000000;
  --fg: #ffffff;
  --goal-width: 240px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---------- mini game: goal + HUD ---------- */

.goal {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 5;
  width: var(--goal-width);
  height: 2px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -24px);
  transition: opacity 180ms ease, transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* hides the puck as it slides out through the goal mouth */
.goal::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 100vh;
  background: var(--bg);
}

.goal::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--fg);
  opacity: 0.8;
}

.goal.is-scored::after {
  animation: goal-flash 380ms ease-out;
}

@keyframes goal-flash {
  35% {
    opacity: 1;
    box-shadow: 0 0 16px 2px var(--fg);
  }
}

.hud {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 6;
  display: flex;
  width: var(--goal-width);
  justify-content: space-between;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.game-mode .goal {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.game-mode .hud {
  opacity: 0.75;
  transform: translate(-50%, 0);
}

.score-burst {
  position: fixed;
  top: 44px;
  left: 50%;
  z-index: 7;
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 10px) scale(0.7);
}

.score-burst.is-visible {
  animation: score-burst 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes score-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.65);
  }
  22% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.18);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -6px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -22px) scale(0.92);
  }
}

/* ---------- mini game: results card ---------- */

.end-card {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
  user-select: text;
  -webkit-user-select: text;
}

body.show-results .end-card {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

.end-card-panel {
  width: min(360px, 100%);
  max-height: calc(100svh - 48px);
  overflow-y: auto;
  scrollbar-width: none;
  text-align: center;
  transform: translateY(18px) scale(0.96);
  transition: transform 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

body.show-results .end-card-panel {
  transform: none;
}

.end-card h2 {
  display: flex;
  flex-direction: column;
  margin: 0 0 4px;
  font-weight: 400;
}

.final-score {
  font-size: clamp(64px, 18vw, 90px);
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.final-label {
  margin-top: 12px;
  font-size: 18px;
}

.end-card-sub {
  margin: 0;
  font-size: 13px;
  opacity: 0.55;
}

.board {
  margin: 20px 0 18px;
  padding: 12px 0;
  border-top: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-bottom: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  text-align: left;
}

.board-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.55;
}

.board-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.board-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: baseline;
}

.board-list li.is-empty {
  display: block;
  font-size: 13px;
  opacity: 0.6;
}

.board-list li.is-new {
  font-weight: 700;
}

.board-rank {
  font-size: 11px;
  opacity: 0.45;
}

.board-initials {
  font-weight: 500;
  letter-spacing: 0.14em;
}

.board-form {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.board-form[hidden] {
  display: none;
}

.board-form label {
  font-size: 12px;
  opacity: 0.65;
}

.board-form-row {
  display: flex;
  gap: 8px;
}

.board-form input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 16px;
  color: var(--fg);
  font: inherit;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid color-mix(in srgb, currentColor 55%, transparent);
  border-radius: 999px;
  outline: none;
}

.board-form input:focus {
  border-color: currentColor;
  box-shadow: inset 0 0 0 1px currentColor;
}

.end-card button {
  min-height: 48px;
  padding: 12px 18px;
  color: var(--bg);
  font: inherit;
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 999px;
  cursor: pointer;
}

.end-card button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.board-form button {
  min-width: 76px;
  min-height: 42px;
  padding: 8px 16px;
}

.end-card .btn-replay {
  width: 100%;
  color: var(--fg);
  background: transparent;
}

.end-card .btn-done {
  min-height: 36px;
  margin-top: 10px;
  padding: 6px 14px;
  color: var(--fg);
  background: transparent;
  border-color: transparent;
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .goal,
  .hud,
  .end-card,
  .end-card-panel {
    transition: none;
  }
}
