/* OneDrum v0 — one stylesheet, no fonts to download, no layout shift.
   The rim pulse is the hero beat channel (R2): iOS has no vibration API, so the
   eye carries the beat and haptics are a bonus. */

:root {
  --bg: #0b0b0f;
  --ink: #f4f2ee;
  --muted: #8b8a94;
  --hot: #ff5a3c;
  --good: #4ade80;
  --ghost: #6b7ba8;
  --pulse: 0; /* 0→1, driven per-frame from the clip clock */
  --meter: 0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 500 16px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
}

/* ── rim: full-screen inset glow, pre-cued 100ms early with an ease-in ─────── */
#rim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  box-shadow:
    inset 0 0 calc(12px + 90px * var(--pulse)) calc(2px + 14px * var(--pulse))
      rgba(255, 90, 60, calc(0.12 + 0.75 * var(--pulse)));
  transition: box-shadow 40ms linear;
}
/* The call is the machine's turn (hot); the answer slot is yours (green). */
:root[data-cue='response'] #rim {
  box-shadow:
    inset 0 0 calc(12px + 90px * var(--pulse)) calc(2px + 14px * var(--pulse))
      rgba(74, 222, 128, calc(0.12 + 0.6 * var(--pulse)));
}

#app {
  position: relative;
  z-index: 2;
  height: 100%;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen { display: none; width: 100%; max-width: 520px; text-align: center; }
.screen[data-active] { display: block; }

/* ── landing ──────────────────────────────────────────────────────────────── */
.wordmark {
  margin: 0 0 6px;
  font-size: clamp(34px, 11vw, 54px);
  font-weight: 800;
  letter-spacing: 0.12em;
}
.wordmark span { color: var(--hot); }
.viking-name {
  margin: 2px 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.42em;
  color: var(--hot);
  text-indent: 0.42em;
}
.tagline { margin: 0 0 22px; color: var(--muted); font-size: 15px; }

/* ── Viking longship: hand-drawn SVG, rights-clean, ~2kB, rows on a loop ───── */
.longship svg { display: block; width: min(76vw, 300px); height: auto; margin: 0 auto 6px; }
.longship .hull { fill: #b9b6ad; }
.longship .gunwale { fill: none; stroke: #8f8c84; stroke-width: 1.4; }
.longship .lr-rowers circle { fill: #e9e6de; stroke: #14100e; stroke-width: 1; }
.longship .mast { stroke: #8a7a68; stroke-width: 2.4; stroke-linecap: round; }
.longship .sail { fill: #ece9e2; }
.longship .stripe { fill: var(--hot); }
.longship .dragon { fill: #b9b6ad; stroke: #8f8c84; stroke-width: 1; }
.longship .lr-oars line { stroke: #cfccc4; stroke-width: 2.6; stroke-linecap: round; }
.longship .lr-sea .wave { fill: none; stroke: var(--ghost); stroke-width: 2; stroke-linecap: round; opacity: 0.5; }
.longship .lr-sea .wave2 { opacity: 0.28; }

.longship .lr-ship { animation: lrBob 1.7s ease-in-out infinite; }
.longship .lr-oars {
  transform-box: view-box; transform-origin: 142px 84px;
  animation: lrOar 0.9s ease-in-out infinite;
}
.longship .lr-rowers {
  transform-box: view-box; transform-origin: 140px 74px;
  animation: lrLean 0.9s ease-in-out infinite;
}
.longship .lr-sail {
  transform-box: view-box; transform-origin: 140px 40px;
  animation: lrSail 2.6s ease-in-out infinite;
}
.longship .lr-sea { animation: lrWave 3s linear infinite; }

@keyframes lrBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes lrOar { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes lrLean { 0%, 100% { transform: translate(2px, -1px); } 50% { transform: translate(-2px, 1px); } }
@keyframes lrSail { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(1.05); } }
@keyframes lrWave { from { transform: translateX(0); } to { transform: translateX(-40px); } }

@media (prefers-reduced-motion: reduce) {
  .longship .lr-ship, .longship .lr-oars, .longship .lr-rowers,
  .longship .lr-sail, .longship .lr-sea { animation: none; }
}

.big-tap {
  display: block;
  width: min(74vw, 280px);
  aspect-ratio: 1;
  margin: 0 auto 26px;
  border: 3px solid var(--hot);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(255, 90, 60, 0.22), transparent 62%);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  animation: breathe 2.2s ease-in-out infinite;
}
.big-tap:active { transform: scale(0.97); }
.big-tap:disabled { opacity: 0.5; cursor: default; animation: none; }
.big-tap:disabled:active { transform: none; }
.big-tap-label { display: block; font-size: 20px; font-weight: 800; letter-spacing: 0.14em; }
.big-tap-sub { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 60, 0.35); }
  50% { box-shadow: 0 0 0 18px rgba(255, 90, 60, 0); }
}
@media (prefers-reduced-motion: reduce) { .big-tap { animation: none; } }

.fineprint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.fineprint.muted { opacity: 0.75; }
.fineprint a { color: var(--hot); }
.next { margin-top: 14px; }

/* ── HUD ──────────────────────────────────────────────────────────────────── */
.hud { display: flex; justify-content: center; gap: 26px; margin-bottom: 10px; }
.hud-cell { min-width: 72px; }
.hud-value { display: block; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-label { display: block; font-size: 11px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.hud-streak.hot .hud-value { color: var(--hot); }

/* ── arena ────────────────────────────────────────────────────────────────── */
.arena {
  position: relative;
  width: min(86vw, 360px);
  aspect-ratio: 1;
  margin: 10px auto 14px;
}
.arena-ring { position: absolute; inset: 0; }

.dot {
  position: absolute;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--ghost);
  opacity: 0.34;
  transition: opacity 120ms ease-out, transform 120ms ease-out, background-color 120ms;
}
.dot.lit { opacity: 1; transform: scale(1.85); background: var(--good); }
/* Live players idle bright white (present), ghosts stay grey-blue. Red is reserved
   for a miss on your own circle — never an identity colour. Both flash green on a
   certified tap. */
.dot.live { background: #ffffff; opacity: 0.6; }

.you {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  transition: transform 90ms ease-out, border-color 160ms, box-shadow 160ms;
}
/* The chant's answer slot: the circle opens, inviting the stroke into the silence. */
.you.open { border-color: rgba(74, 222, 128, 0.55); box-shadow: 0 0 0 8px rgba(74, 222, 128, 0.08); }
/* Local acknowledgement fires on touch; the server verdict overrides it ~50ms later. */
.you.tapped { transform: scale(1.06); border-color: rgba(255, 255, 255, 0.55); }
.you.hit { transform: scale(1.12); border-color: var(--good); box-shadow: 0 0 26px rgba(74, 222, 128, 0.5); }
.you.miss { border-color: var(--hot); box-shadow: 0 0 20px rgba(255, 90, 60, 0.35); }

.meter {
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  width: 62%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: calc(var(--meter) * 100%);
  background: linear-gradient(90deg, var(--hot), var(--good));
  transition: width 200ms linear;
}

.coach { margin: 16px 0 10px; min-height: 20px; font-size: 14px; color: var(--muted); }

/* The whole screen is the tap target — there is no separate pad. Eye and thumb
   share one anchor: the circle carries the aim and the verdict. */
#screen-play { cursor: pointer; }
.circle-note { margin-top: 18px; }

/* ── end card ─────────────────────────────────────────────────────────────── */
.end-eyebrow { margin: 0; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.end-score { font-size: clamp(56px, 20vw, 92px); font-weight: 800; line-height: 1; margin: 6px 0 4px; }
.end-score small { display: block; font-size: 13px; font-weight: 500; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }
.end-stats { display: flex; justify-content: center; gap: 22px; margin: 22px 0; }
.end-stats dt { font-size: 11px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.end-stats dd { margin: 4px 0 0; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.end-flag { margin: 0 0 14px; padding: 10px; border: 1px solid var(--hot); border-radius: 10px; font-size: 13px; color: var(--hot); }

.end-actions { display: grid; gap: 10px; margin-bottom: 16px; }
.btn {
  padding: 15px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--hot); border-color: var(--hot); color: #14100e; }
.btn:active { transform: translateY(1px); }
/* Share button: icon + label centered so it clearly reads as a share action. */
#btn-share { display: flex; align-items: center; justify-content: center; gap: 10px; }
#btn-share .share-ico { flex: 0 0 auto; }

/* ── toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 5;
  max-width: 90vw;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms, transform 180ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
