/**
 * The game surface. Shares the landing page's language — serif display face,
 * hairline rules, terracotta accent, warm off-white ink on near-black — so
 * walking from one to the other feels like the same product.
 */

:root {
  --ink: #f1ece3;
  --ink-2: rgba(241, 236, 227, 0.66);
  --ink-3: rgba(241, 236, 227, 0.4);
  --panel: rgba(13, 14, 18, 0.72);
  --rule: rgba(241, 236, 227, 0.14);
  --rule-soft: rgba(241, 236, 227, 0.08);
  --accent: #e2683c;
  --accent-ink: #f0a184;
  --teal: #4fc0ae;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: #05070d;
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  filter: saturate(1.05) contrast(1.02);
  background: #05070d;
}

#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Soft vignette so the scoreboard stays readable over a bright room. */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 55%, transparent 45%, rgba(5, 6, 10, 0.62) 100%);
}

/* ---------- Scoreboard (top right, nothing else) ---------- */

.hud {
  position: absolute;
  top: clamp(14px, 2.4vmin, 26px);
  right: clamp(14px, 2.4vmin, 26px);
  z-index: 3;
  min-width: 136px;
  padding: 14px 18px 13px;
  text-align: right;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--rule);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: 0 24px 50px -30px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 0.5s ease,
    transform 0.5s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.hud.is-live {
  opacity: 1;
  transform: none;
}

.hud-score {
  font-family: var(--serif);
  font-size: clamp(30px, 4.4vmin, 52px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: transform 0.14s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.hud-score.is-bump {
  transform: scale(1.12);
}

.hud-score-sub {
  font-size: clamp(20px, 2.7vmin, 32px);
  color: var(--accent-ink);
}

.hud-label {
  margin-top: 5px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.hud-divider {
  height: 1px;
  margin: 11px 0 10px;
  background: linear-gradient(90deg, transparent, var(--rule));
}

.hud-combo {
  margin-top: 11px;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(226, 104, 60, 0.45);
  background: rgba(226, 104, 60, 0.14);
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.hud-combo[hidden] {
  display: none;
}

/* ---------- Shared overlay shell ---------- */

.gate,
.over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate {
  z-index: 4;
  background:
    radial-gradient(70% 55% at 50% 38%, rgba(28, 24, 22, 0.72), transparent 70%),
    rgba(7, 8, 12, 0.94);
  transition: opacity 0.6s ease;
}

.gate.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.gate-card,
.over-card {
  width: min(440px, 100%);
  text-align: center;
}

.mark {
  width: 82px;
  height: 82px;
  animation: bob 5s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-8px);
  }
}

.gate h1 {
  margin: 16px 0 10px;
  font-family: var(--serif);
  font-size: clamp(30px, 5.6vmin, 46px);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 auto 26px;
  max-width: 36ch;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ---------- Mode chips ---------- */

.modes {
  /* Own line, centred: inline-flex would sit beside the start button. */
  display: flex;
  width: fit-content;
  padding: 4px;
  margin: 0 auto 24px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(241, 236, 227, 0.04);
  gap: 2px;
}

.mode-chip {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 8px 17px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 520;
  transition:
    color 0.2s ease,
    background 0.25s ease;
}

.mode-chip:hover {
  color: var(--ink);
}

.mode-chip.is-on {
  background: var(--ink);
  color: #0d0e12;
}

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

#start,
#restart {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 13px 28px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #150803;
  background: var(--accent);
  box-shadow: 0 14px 32px -14px rgba(226, 104, 60, 0.85);
  transition:
    transform 0.16s cubic-bezier(0.2, 1.4, 0.4, 1),
    background 0.2s ease,
    box-shadow 0.22s ease,
    opacity 0.2s ease;
}

#start:hover:not(:disabled),
#restart:hover {
  transform: translateY(-2px);
  background: #ef7448;
}

#start:active:not(:disabled),
#restart:active {
  transform: translateY(0) scale(0.98);
}

#start:disabled {
  cursor: default;
  opacity: 0.5;
}

.btn-share {
  appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: rgba(241, 236, 227, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 560;
  transition:
    transform 0.16s cubic-bezier(0.2, 1.4, 0.4, 1),
    background 0.2s ease,
    border-color 0.2s ease;
}

.btn-share svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.btn-share:hover {
  transform: translateY(-2px);
  background: rgba(241, 236, 227, 0.11);
  border-color: rgba(241, 236, 227, 0.34);
}

.btn-share:active {
  transform: translateY(0) scale(0.98);
}

/* ---------- Fine print ---------- */

.fine {
  margin: 20px auto 0;
  max-width: 36ch;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-3);
}

.fine a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.fine a:hover {
  color: var(--ink);
  border-color: var(--ink-3);
}

.status {
  margin: 14px 0 0;
  min-height: 1.2em;
  font-size: 12.5px;
  color: var(--accent-ink);
}

.status.is-error {
  color: #ff9d84;
}

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

.over {
  z-index: 5;
  background:
    radial-gradient(75% 55% at 50% 42%, rgba(74, 26, 14, 0.72), transparent 72%),
    rgba(6, 6, 10, 0.95);
  opacity: 0;
  transition: opacity 0.45s ease;
}

.over.is-shown {
  opacity: 1;
}

.over[hidden] {
  display: none;
}

.over-card {
  transform: translateY(14px) scale(0.97);
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.over.is-shown .over-card {
  transform: none;
}

.over-mark {
  width: 70px;
  height: 70px;
}

.over h2 {
  margin: 12px 0 10px;
  font-family: var(--serif);
  font-size: clamp(27px, 4.6vmin, 38px);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.over-sub {
  margin: 0 auto 28px;
  max-width: 34ch;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
}

.over-stats {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
}

.over-stat {
  flex: 1 1 0;
  min-width: 92px;
  padding: 16px 10px 14px;
  border-right: 1px solid var(--rule-soft);
}

.over-stat:last-child {
  border-right: 0;
}

.over-stat[hidden] {
  display: none;
}

.over-num {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.over-stat-best .over-num {
  color: var(--accent-ink);
}

.over-cap {
  margin-top: 7px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.over-who {
  margin: 0 0 22px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.over-who[hidden] {
  display: none;
}

.over-who img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  vertical-align: -5px;
  margin-right: 7px;
  border: 1px solid var(--rule);
}

.over-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  .mark {
    animation: none;
  }

  .hud,
  .gate,
  .over,
  .over-card,
  #start,
  #restart,
  .btn-share,
  .mode-chip {
    transition: none;
  }
}
