:root {
  --bg: #0b0e1c;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7dff00;
  --accent-2: #00e5ff;
  --chrome-height: 128px; /* header + footer, used to size the stage */
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px;
}

.logo {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.logo span {
  color: var(--accent);
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--badge, #888);
  color: #111;
  font-weight: 800;
}

.badge:empty {
  display: none;
}

.stage-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0 16px;
}

/* Fixed 16:9 so every player sees exactly the same amount of upcoming level. */
.stage {
  position: relative;
  width: min(100%, calc((100dvh - var(--chrome-height)) * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 10px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(60%, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}

.progress {
  flex: 1;
  height: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: left;
}

.progress-label {
  min-width: 4ch;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 16px;
  background: rgba(5, 8, 20, 0.55);
  text-align: center;
  pointer-events: none;
}

.overlay[hidden] {
  display: none;
}

.overlay p {
  margin: 0;
}

.overlay-title {
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  font-weight: 900;
  text-shadow: 0 3px 0 #000;
}

.overlay-detail {
  font-weight: 700;
}

.overlay-prompt {
  color: var(--muted);
}

.overlay .overlay-note {
  margin-top: 6px;
  color: var(--accent);
  font-weight: 700;
}

.overlay-note:empty {
  display: none;
}

.hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  padding: 10px 16px 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

kbd {
  padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  font: inherit;
  font-size: 0.8rem;
}

@media (hover: none) {
  .desktop-only {
    display: none;
  }
}

/* Practice mode: place and remove checkpoints with a tap (Z / X on a keyboard). */
.checkpoint-buttons {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
}

.checkpoint-buttons[hidden] {
  display: none;
}

.checkpoint-buttons button {
  min-width: 52px;
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}

.checkpoint-buttons button:first-child {
  color: #2bff6a;
}

.checkpoint-buttons span {
  color: var(--muted);
  font-size: 0.75rem;
}

@media (hover: none) {
  .checkpoint-buttons span {
    display: none;
  }
}

/* Start screen: start on the left, today's leaderboard on the right; stacked on phones. */
.menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  width: min(100%, 960px);
  padding: 8px 0 16px;
}

.menu[hidden],
.stage[hidden],
[hidden].name-field,
[hidden].name-show {
  display: none;
}

@media (max-width: 720px) {
  .menu {
    grid-template-columns: minmax(0, 1fr);
  }
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.panel p,
.panel h2 {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.menu-title {
  color: var(--badge, var(--text));
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 900;
}

.menu-detail {
  color: var(--muted);
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

.name-field input {
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
}

.name-field input:focus {
  border-color: var(--accent);
  outline: none;
}

.name-error {
  min-height: 1.2em;
  color: #ff6b6b;
  font-size: 0.9rem;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

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

.stats div {
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  text-align: center;
}

.stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.stats dd {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.menu-result {
  font-weight: 800;
}

.menu-result:empty {
  display: none;
}

.menu-actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-top: auto;
}

/* After the day's win only Practice is left, and it takes the whole row. */
.menu-actions:has(.start[hidden]) {
  grid-template-columns: 1fr;
}

.start[hidden] {
  display: none;
}

.practice-button {
  padding: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}

.practice-button:hover {
  border-color: #2bff6a;
}

.start {
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  box-shadow: 0 4px 0 #3c7a00;
  color: #0b0e1c;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
}

.start:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #3c7a00;
}

.start:disabled {
  opacity: 0.6;
  cursor: progress;
}

.start-hint {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.board-head h2 {
  font-size: 1.3rem;
  font-weight: 900;
}

.board-head span {
  color: var(--muted);
  font-size: 0.85rem;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.board-row {
  display: grid;
  grid-template-columns: 2.5em minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font-variant-numeric: tabular-nums;
}

.board-row.you {
  outline: 2px solid var(--accent);
}

.board-row.apart {
  margin-top: 10px;
}

.board-rank {
  color: var(--muted);
  font-weight: 800;
}

.board-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-attempts {
  font-weight: 900;
}

.board-note {
  color: var(--muted);
  font-size: 0.9rem;
}

/* 404.html */
.notfound {
  flex: 1;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
}

.notfound p {
  margin: 0;
}

.notfound a {
  color: var(--accent);
  font-weight: 800;
}
