:root {
  color-scheme: dark;
  --bg: #181a20;
  --text: #f1f2f5;
  --muted: #a6abb8;
  --accent: #ffb443;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

main {
  width: min(100%, 560px);
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

h1 { margin: 0; font-size: 1.5rem; letter-spacing: 0.01em; }

#lives { font-size: 1.4rem; display: flex; gap: 6px; }
#lives .spent { filter: grayscale(1); opacity: 0.3; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 12px;
}
.stats div:nth-child(2) { text-align: center; }
.stats div:nth-child(3) { text-align: right; }
.stats dt { color: var(--muted); font-size: 0.78rem; }
.stats dd { margin: 0; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }

#board {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid #0b0c0f;
  border-radius: 8px;
  overflow: hidden;
  touch-action: manipulation;
}

.tile {
  appearance: none;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0 solid #0b0c0f;
  border-radius: 0;
  font-size: var(--tile-font);
  line-height: 1;
  color: #1c1e26;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.tile.marked { color: rgb(20 22 28 / 0.65); font-weight: 700; }
.tile.running, .tile.mouse { background: #3b3f4a !important; }
.tile.missed { filter: saturate(0.5); }

.runner {
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

.rules {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
  margin: 12px 0 0;
}
.rules strong { color: var(--text); }

.controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

button {
  font: inherit;
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
}

button { background: var(--accent); color: #231703; font-weight: 600; cursor: pointer; }
button.secondary { background: #2a2d36; color: var(--text); }
button:disabled { opacity: 0.5; cursor: default; }

dialog {
  border: 0;
  border-radius: 14px;
  background: #23262e;
  color: var(--text);
  padding: 24px;
  text-align: center;
  width: min(86vw, 320px);
}
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
dialog h2 { margin: 0 0 18px; font-size: 1.3rem; }
#result-score { margin-bottom: 14px; }
#result-score p {
  display: flex;
  justify-content: space-between;
  margin: 4px 0;
  color: var(--muted);
}
#result-score p:last-child {
  margin-top: 10px;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
}
#result-score p.total {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
}
#result-score p.heading { margin-top: 14px; font-size: 0.85rem; }
#result-score p.you, #result-score p.you:last-child {
  margin-top: 4px;
  color: var(--accent);
  font-size: inherit;
  font-weight: 700;
}
dialog button { display: block; width: 100%; margin-top: 8px; }
#auth-dialog { user-select: text; -webkit-user-select: text; }
dialog button[hidden] { display: none; }
#result-score p.share { display: block; color: var(--text); word-break: break-all; user-select: text; -webkit-user-select: text; }
#auth-help { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }
#auth-error { margin: 8px 0 0; color: #ff9c8f; font-size: 0.88rem; min-height: 1.2em; }
dialog input {
  width: 100%;
  font: inherit;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: #2a2d36;
  color: var(--text);
}
