/* Pulse styles. Phone first. Dark, neon, big type. The look rules:
   one deep background, four lane colours that glow, white for the
   important number, violet for the chrome. Nothing grey and flat. */

:root {
  --bg: #07060f;
  --panel: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f2ff;
  --dim: #a9a3c9;
  --violet: #b48bff;
  --pink: #ff4fd8;
  --cyan: #4df0ff;
  --lime: #b6ff3b;
  --amber: #ffb63b;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.playing { overflow: hidden; }

/* a slow moving glow behind everything */
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 50% at 20% 10%, rgba(180, 139, 255, 0.28), transparent 70%),
    radial-gradient(50% 40% at 85% 30%, rgba(255, 79, 216, 0.22), transparent 70%),
    radial-gradient(60% 50% at 50% 100%, rgba(77, 240, 255, 0.16), transparent 70%),
    var(--bg);
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(-3%, 2%, 0) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .bg { animation: none; } }

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; border: 0; background: none; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none !important; }

.screen { min-height: 100vh; }

/* ---- menu ---- */
#menu { max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; }
.hero h1 {
  margin: 8px 0 0;
  font-size: clamp(56px, 18vw, 96px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.95;
  background: linear-gradient(100deg, var(--cyan), var(--violet) 45%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(180, 139, 255, 0.45));
}
.tag { margin: 6px 0 24px; color: var(--dim); font-size: 17px; }

.track {
  --c: var(--cyan);
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px;
  width: 100%; text-align: left;
  padding: 14px 16px; margin: 0 0 10px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.track .num { grid-row: span 2; align-self: center; font-weight: 900; font-size: 28px; color: var(--c); text-shadow: 0 0 16px var(--c); }
.track .name { font-weight: 800; font-size: 20px; }
.track .meta { color: var(--dim); font-size: 14px; }
.track.on { border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 0 28px color-mix(in srgb, var(--c) 40%, transparent); transform: translateX(4px); }
.track:active { transform: scale(0.98); }

.pick { margin: 18px 0 28px; text-align: center; }
.diff { display: flex; gap: 8px; justify-content: center; }
.chip {
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 13px;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); box-shadow: 0 0 20px rgba(255, 255, 255, 0.35); }
.best { margin: 14px 0; color: var(--dim); font-weight: 600; }

.go {
  display: block; width: 100%; max-width: 320px; margin: 0 auto;
  min-height: 60px; border-radius: 999px;
  background: linear-gradient(100deg, var(--cyan), var(--violet) 55%, var(--pink));
  color: #0a0714; font-weight: 900; font-size: 20px; letter-spacing: 0.06em; text-transform: uppercase;
  box-shadow: 0 8px 30px rgba(180, 139, 255, 0.45);
  transition: transform 0.1s;
}
.go:active { transform: scale(0.97); }
.small {
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-weight: 600;
}
.keys { margin: 16px 0 0; color: var(--dim); font-size: 14px; }
.key {
  display: inline-block; min-width: 26px; padding: 2px 6px; margin-right: 4px;
  border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px;
  font-weight: 700; color: var(--text); text-align: center;
}

.settings { padding: 18px 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.settings h2 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.row > span:first-child { font-weight: 600; }
.row output { color: var(--violet); margin-left: 6px; }
input[type=range] { width: 50%; accent-color: var(--violet); }
.toggle { cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.switch { width: 52px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle input:checked + .switch { background: var(--lime); }
.toggle input:checked + .switch::after { transform: translateX(22px); }
.note { color: var(--dim); font-size: 14px; margin: 4px 0 8px; }

/* until game.js runs, the buttons are plain HTML and do nothing, so say so */
body:not(.ready) .pick, body:not(.ready) .settings { opacity: 0.35; pointer-events: none; }
.loading { text-align: center; padding: 20px 0; }
.loading::after { content: ""; display: inline-block; width: 1em; text-align: left; animation: dots 1s steps(4) infinite; }
@keyframes dots { to { content: "..."; } }

/* ---- play ---- */
#play-screen { position: fixed; inset: 0; }
#stage { display: block; touch-action: none; }
.hud {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none;
}
.hud button { pointer-events: auto; background: rgba(7, 6, 15, 0.55); }
.hud-left { display: flex; flex-direction: column; }
.hud-track { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--dim); }
.hud-score { font-size: 28px; font-weight: 900; letter-spacing: -0.02em; text-shadow: 0 0 18px rgba(180, 139, 255, 0.7); }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(7, 6, 15, 0.82); backdrop-filter: blur(6px);
}
.overlay h2 { font-size: 40px; font-weight: 900; margin: 0 0 8px; }

/* ---- results and calibrate ---- */
#results, #calib { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.card { width: 100%; max-width: 420px; text-align: center; padding: 24px 20px 28px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); }
.card h2 { margin: 0 0 10px; font-size: 32px; font-weight: 900; }
.grade {
  font-size: 140px; font-weight: 900; line-height: 1; letter-spacing: -0.06em; margin: 4px 0;
  background: linear-gradient(160deg, #fff, var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 30px rgba(180, 139, 255, 0.6));
  animation: land 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.grade[data-g="S"] { background-image: linear-gradient(160deg, #fff, var(--amber), var(--pink)); filter: drop-shadow(0 0 36px rgba(255, 182, 59, 0.7)); }
.grade[data-g="A"] { background-image: linear-gradient(160deg, #fff, var(--cyan)); }
.grade[data-g="B"] { background-image: linear-gradient(160deg, #fff, var(--lime)); }
.grade[data-g="D"] { background-image: linear-gradient(160deg, #fff, #ff5a7a); filter: none; }
@keyframes land { from { transform: scale(2.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.new { display: inline-block; margin: 0 0 8px; padding: 4px 12px; border-radius: 999px; background: var(--lime); color: var(--bg); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.big { margin: 0; font-size: 40px; font-weight: 900; letter-spacing: -0.02em; }
.acc { margin: 4px 0 16px; color: var(--dim); }
.acc strong { color: var(--text); }
.counts { display: flex; justify-content: center; gap: 22px; margin: 0 0 18px; }
.counts div { display: flex; flex-direction: column; }
.counts dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.counts dd { margin: 0; font-size: 24px; font-weight: 800; }
.hist-label { display: flex; justify-content: space-between; margin: 0 0 4px; font-size: 12px; color: var(--dim); }
.hist { display: flex; align-items: flex-end; gap: 3px; height: 56px; padding: 0 0 2px; border-bottom: 1px solid var(--line); }
.hist span { flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--dim); }
.hist span.mid { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.card .go { margin-top: 18px; }
.card .small { margin-top: 10px; }

.ring {
  display: block; width: 160px; height: 160px; margin: 20px auto; border-radius: 50%;
  border: 6px solid var(--line); transition: transform 0.05s;
}
.ring.lit { border-color: #fff; background: var(--violet); box-shadow: 0 0 60px var(--violet); transform: scale(1.08); }

@media (min-width: 760px) {
  .hero h1 { font-size: 110px; }
  .track:hover { border-color: var(--c); }
  .chip:hover, .small:hover { border-color: var(--text); }
  .go:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(180, 139, 255, 0.6); }
}
