:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #ffd23f;
  --good: #3ddc84;
  --bad: #ff5a5f;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* The game owns the whole viewport: no page scroll, no text selection, no tap flash. */
body {
  position: fixed;
  inset: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

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

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

/* Probe read by game.js to learn the notch / home-indicator insets. */
#safe {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hud-buttons {
  position: absolute;
  z-index: 2;
  top: calc(env(safe-area-inset-top) + 12px);
  right: calc(env(safe-area-inset-right) + 12px);
  display: flex;
  gap: 8px;
}

input, button {
  font: inherit;
  color: var(--text);
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 16px;
  min-height: 44px;
  touch-action: manipulation;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button[type="submit"] { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }

/* Bottom sheet: game over result, name entry and the leaderboard. */
#panel {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  width: min(100%, 560px);
  max-height: 50vh;
  max-height: 50dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  animation: sheet 0.18s ease-out;
}

@keyframes sheet {
  from { transform: translateY(24px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #panel { animation: none; }
}

#over { margin-bottom: 8px; }
#over p { margin: 0 0 12px; }
#over-score { font-size: 1.2rem; font-weight: 700; }
#score-msg { color: var(--muted); }
#score-msg:empty { display: none; }

#score-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
#score-form input { flex: 1; min-width: 0; width: auto; }

input {
  -webkit-user-select: text;   /* iOS refuses to focus inputs under user-select: none */
  user-select: text;
  font-size: 18px;             /* 16px+ stops iOS zooming the page on focus */
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

h2 {
  margin: 8px 0;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  color: var(--muted);
}

ol { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; }

li {
  display: grid;
  grid-template-columns: 3ch 1fr auto;
  gap: 16px;
  padding: 7px 14px;
  font-variant-numeric: tabular-nums;
}
li + li { border-top: 1px solid var(--line); }
li .rank { color: var(--muted); }
li .name { font-weight: 700; letter-spacing: 0.1em; overflow-wrap: anywhere; }
li .pts { font-weight: 700; }
li.mine { background: rgba(255, 210, 63, 0.15); }
li.empty { display: block; color: var(--muted); }

[hidden] { display: none !important; }
