:root {
  --bg: #000;
  --ink: #f5f5f3;
  --muted: #6b6b6b;
  --accent: #f0c150;
  --line: #1a1a1a;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  cursor: crosshair;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 1.1rem 1.5rem env(safe-area-inset-top, 1.1rem);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#hud.show { opacity: 1; }
#hud #score { color: var(--ink); }
#hud #timer { color: var(--accent); }

.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 2rem 1.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.screen.active { display: flex; animation: fadein 0.3s ease; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wordmark {
  font-family: var(--mono);
  font-size: clamp(3.5rem, 12vw, 6rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
  color: var(--ink);
  line-height: 0.95;
  text-transform: uppercase;
}

h2 {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 1.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rules {
  color: var(--muted);
  margin: 0 0 2rem;
  font-size: 1.05rem;
  max-width: 24rem;
  line-height: 1.5;
}

kbd {
  display: inline-block;
  padding: 0 0.4em;
  margin: 0 0.1em;
  border: 1px solid var(--muted);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--ink);
  background: rgba(255,255,255,0.04);
}

button {
  display: block;
  margin: 0.5rem auto;
  border: none;
  border-radius: 4px;
  padding: 0.9rem 2.5rem;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  min-width: 12rem;
  transition: filter 0.15s, transform 0.05s, background 0.15s, border 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.primary {
  background: var(--accent);
  color: var(--bg);
}
.primary:hover { filter: brightness(1.15); }
.primary:active { transform: translateY(1px); }
.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.ghost:hover { color: var(--ink); border-color: var(--muted); }
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.result {
  margin: 0 0 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}
.result-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  font-family: var(--mono);
}
.result-row .label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 4rem;
  text-align: right;
}
.result-row .value {
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-width: 4ch;
  text-align: left;
}

.status {
  margin-top: 0.6rem;
  min-height: 1.4em;
  font-size: 0.9rem;
  color: var(--muted);
  font-family: var(--mono);
}

footer {
  position: fixed;
  bottom: 0.85rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  pointer-events: none;
  opacity: 0.5;
  letter-spacing: 0.04em;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

@media (max-width: 420px) {
  #hud { padding: 0.85rem 1rem; font-size: 1.05rem; }
  footer { font-size: 0.66rem; }
}
