/* agame — minimal retro arcade. Mobile first; wider screens just get more breathing room. */

:root {
  --bg: #000000;
  --fg: #f2f2f2;
  --muted: #6f6f80;
  --line: #2a2a36;
  --accent: #ffd23f;
  --good: #3cff7a;
  --bad: #ff4d4d;
  --font: "Cascadia Mono", "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Faint scanlines */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px);
}

[hidden] { display: none !important; }

#app {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen { display: flex; flex-direction: column; gap: 20px; }
.screen-center {
  min-height: calc(100vh - 32px);
  min-height: calc(100dvh - 32px);
  justify-content: center;
}

h1, h2 { margin: 0; font-weight: 800; line-height: 1.1; }
p { margin: 0; }

.logo { font-size: 3rem; letter-spacing: 0.12em; text-align: center; color: var(--accent); }
.logo-small { font-size: 1.1rem; text-align: left; }
.tagline { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: -8px; }
.eyebrow { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.12em; }

.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- Forms ---- */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.12em; }

input, select {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 16px; /* stops iOS zooming on focus */
  text-transform: none;
  color: var(--fg);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 0;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.hint { font-size: 0.7rem; color: var(--muted); text-transform: none; letter-spacing: 0; }
.error { font-size: 0.8rem; color: var(--bad); text-transform: none; letter-spacing: 0; }
.error:empty { display: none; }

.switch { text-align: center; font-size: 0.8rem; color: var(--muted); }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg);
  background: transparent;
  border: 2px solid var(--fg);
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translate(1px, 1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-primary { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.btn-block { width: 100%; }

.link {
  padding: 4px 0;
  font: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* ---- Home ---- */

.topbar { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; }
.spacer { flex: 1; }
.who { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; }
.tag { padding: 0 6px; font-size: 0.65rem; color: var(--accent); border: 1px solid var(--accent); }

.today {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 0 28px;
  text-align: center;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}
.today > div { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.today-sub { color: var(--muted); font-size: 0.8rem; }

.btn-start {
  width: 100%;
  min-height: 88px;
  font-size: 1.5rem;
  color: var(--accent);
  border-color: var(--accent);
}

.big-score { font-size: 3.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.big-score small { font-size: 0.4em; color: var(--muted); }
.big-score-xl { font-size: 5.5rem; text-align: center; color: var(--accent); }

.next { color: var(--muted); font-size: 0.8rem; }
.next strong { color: var(--fg); font-variant-numeric: tabular-nums; }

.scoreboard { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.scoreboard div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.scoreboard dt { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.12em; }
.scoreboard dd { margin: 0; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.history-wrap { display: flex; flex-direction: column; gap: 10px; }
.history {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.history li { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bar { position: relative; width: 100%; height: 56px; background: #0e0e16; }
.bar-fill { position: absolute; inset: auto 0 0 0; background: var(--accent); }
.bar.missed { background: transparent; border: 1px dashed var(--line); }
.bar.today { box-shadow: inset 0 0 0 1px var(--fg); }
.bar-score { font-size: 0.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-day { font-size: 0.55rem; color: var(--muted); }

.dev-panel { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px dashed var(--line); }
.dev-row { display: flex; gap: 8px; }
.dev-row select { flex: 1; min-width: 0; text-transform: uppercase; }

/* ---- Game ---- */

.screen-game { gap: 12px; }
body.playing { overflow: hidden; overscroll-behavior: none; }

.game-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; }
.game-head h2 { font-size: 1rem; letter-spacing: 0.12em; color: var(--accent); }

.pips { display: flex; gap: 4px; }
.pip { width: 10px; height: 10px; border: 2px solid var(--line); }
.pip.on { background: var(--accent); border-color: var(--accent); }

/* Size the board (any shape; --aspect = width / height) to fit the screen height,
   leaving room for the touch pad on phones when the game has one. */
.stage {
  --chrome: 110px;
  width: min(100%, calc((100vh - var(--chrome)) * var(--aspect, 1)));
  width: min(100%, calc((100dvh - var(--chrome)) * var(--aspect, 1)));
  margin: 0 auto;
}
@media (pointer: coarse) {
  .screen-game:has(.pad) .stage { --chrome: 290px; }
}

.game-canvas {
  display: block;
  width: 100%;
  border: 2px solid var(--line);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Touch pad (only on touch screens) ---- */

.pad {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 4px 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.pad > :only-child { margin: 0 auto; }
@media (pointer: coarse) {
  .pad { display: flex; }
}

.dpad { display: grid; gap: 6px; }
.dpad-four { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 52px); }
.dpad-horizontal { grid-template-columns: repeat(2, 84px); grid-template-rows: 72px; }
.dpad-vertical { grid-template-columns: 84px; grid-template-rows: repeat(2, 64px); }
.dpad-four .dpad-up { grid-area: 1 / 2; }
.dpad-four .dpad-left { grid-area: 2 / 1; }
.dpad-four .dpad-right { grid-area: 2 / 3; }
.dpad-four .dpad-down { grid-area: 3 / 2; }

.dpad-btn, .pad-fire {
  font: inherit;
  font-weight: 800;
  color: var(--fg);
  background: transparent;
  border: 2px solid var(--line);
  border-radius: 0;
  touch-action: none;
  cursor: pointer;
}
.dpad-btn { font-size: 1.1rem; }
.dpad-btn:active, .pad-fire:active { background: var(--line); }
.pad-fire {
  width: 96px;
  height: 96px;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border-color: var(--accent);
  border-radius: 50%;
}

/* ---- Result ---- */

.screen-center .eyebrow, .result-message, .result-total { text-align: center; }
.result-message { font-size: 0.95rem; text-transform: none; letter-spacing: 0; }
.result-total { color: var(--muted); font-size: 0.8rem; }

/* ---- Wider screens ---- */

@media (min-width: 600px) {
  #app { padding-top: 32px; }
  .logo { font-size: 3.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
