:root {
  --bg: #0a0a0f;
  --panel-bg: #11111a;
  --ink: #f5f5fa;
  --accent: #ff4fa5;
  --accent-2: #ffb545;
  --muted: #7a7a88;
  --radius: 22px;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  height: 100dvh;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1400px 900px at 15% -10%, #281030 0%, transparent 55%),
    radial-gradient(1100px 800px at 90% 110%, #3a0a28 0%, transparent 60%),
    var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
}

/* Ensure HTML hidden attribute wins over component display rules. */
[hidden] {
  display: none !important;
}

/* ---------- boot ---------- */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
  background: var(--bg);
}

.boot__card {
  width: min(360px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: center;
}

.boot__btns {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.boot__link {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(245, 245, 250, 0.65);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}

.boot__link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- guide route ---------- */
.guide-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(18px, 4vh, 40px) 20px calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fade 0.25s ease both;
}

.guide-view__header {
  position: relative;
  width: min(720px, 100%);
  margin: 0 auto;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-view__back {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(245, 245, 250, 0.8);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.guide-view__back:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translate(-2px, -50%);
}

.guide-view__title {
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(245, 245, 250, 0.55);
}

.guide-view .guide__groups {
  width: min(720px, 100%);
  margin: 0 auto;
}

.guide__groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.guide__group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide__group-title {
  margin: 0;
  padding-left: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.guide__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.guide__tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  transition: transform 0.15s ease, background 0.15s ease,
    border-color 0.15s ease;
}

@media (hover: hover) {
  .guide__tile:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 79, 165, 0.3);
  }
}

.guide__tile-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: #fafafc;
  display: block;
}

.guide__tile-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
  text-align: center;
  color: rgba(245, 245, 250, 0.75);
}

@media (max-width: 480px) {
  .guide__grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
  }
  .guide__tile-label {
    font-size: 10px;
  }
}

.boot__title {
  font-size: clamp(56px, 12vw, 88px);
  letter-spacing: -0.06em;
  margin: 0;
  line-height: 0.9;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 900;
}

.boot__btn {
  width: 100%;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 14px 20px;
  border-radius: 999px;
  color: #1a1a22;
  background: linear-gradient(180deg, #ffe0ef 0%, var(--accent) 100%);
  border: 0;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(255, 79, 165, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease,
    opacity 0.2s ease;
}

.boot__btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.boot__btn:active {
  transform: translateY(0);
}

.boot__btn:disabled {
  opacity: 0.55;
  cursor: progress;
  box-shadow: none;
}

.boot__btn--ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.boot__btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  filter: none;
}

.boot__error {
  margin: 0;
  color: #ff7d8a;
  font-size: 13px;
  line-height: 1.45;
  max-width: 300px;
}

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

/* ---------- stage ---------- */
.stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
  animation: fade 0.5s ease both;
}

@media (max-width: 860px), (orientation: portrait) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 10px;
    gap: 10px;
  }
}

.panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.panel--cam {
  background: #000;
}

.panel--ham {
  background: #fafafc;
}

.panel__frame {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  background: #000;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transform: scaleX(-1);
}

.hamster {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  transition: transform 0.18s ease, opacity 0.18s ease;
  padding: 6%;
}

.hamster.is-swap {
  opacity: 0;
  transform: scale(0.97);
}

/* -------- minimal HUD -------- */
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  pointer-events: none;
}

.hud__pred {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(10, 10, 15, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 42px;
  text-align: center;
}

.hud__pred:empty {
  display: none;
}

.hud-meta {
  position: absolute;
  bottom: 12px;
  right: 14px;
  z-index: 3;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  display: flex;
  gap: 10px;
}

.credit {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 60;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(10, 10, 15, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.credit__sep {
  color: rgba(255, 255, 255, 0.35);
}

.credit__link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  margin-left: 5px;
}

.credit__link:hover {
  text-decoration: underline;
  filter: brightness(1.15);
}

@media (max-width: 520px) {
  .credit {
    font-size: 12.5px;
    padding: 7px 13px;
  }
}

/* Hide the credit once the camera is on — it overlaps the hamster and
   distracts from the live feed. Still visible on the boot and guide
   views so the artist remains credited up front. */
.stage:not([hidden]) ~ .credit {
  display: none;
}

/* ---------- instructions card (sibling of boot intro card) ---------- */
.boot__card--instr {
  gap: 24px;
  width: min(380px, 100%);
  padding: 8px 4px;
}

.instr__eyebrow {
  margin: 0;
  font-size: clamp(42px, 9vw, 64px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.9;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.instr__rules {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.instr__rules li {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(245, 245, 250, 0.88);
}

.instr__rules li span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 90%);
  color: #1a1a22;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.instr__best {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.instr__best strong {
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
}

/* ---------- game mode (full-screen overlay on top of stage) ---------- */
/* In game mode the cam panel becomes a darkened, blurred background and the
   hamster panel is hidden — the .game overlay takes over the whole viewport
   with its own centered layout. */
.stage.is-game {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  padding: 0;
  gap: 0;
}

.stage.is-game .panel {
  position: fixed;
  inset: 0;
  border-radius: 0;
  box-shadow: none;
}

.stage.is-game .panel--ham {
  display: none;
}

.stage.is-game #video,
.stage.is-game #overlay {
  filter: brightness(0.72) saturate(0.9);
}

.stage.is-game .hud__pred {
  background: rgba(10, 10, 15, 0.4);
  font-size: 11px;
}

.stage.is-game .hud-meta {
  opacity: 0.35;
}

.game {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0 clamp(20px, 5vw, 60px);
  padding: clamp(20px, 5vh, 48px) clamp(22px, 4vw, 56px) calc(28px + env(safe-area-inset-bottom));
  pointer-events: none;
  animation: fade 0.35s ease both;
}

.game > * {
  pointer-events: auto;
}

.game__dim {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(10, 10, 15, 0.65) 0%, rgba(10, 10, 15, 0.1) 38%, rgba(10, 10, 15, 0.1) 62%, rgba(10, 10, 15, 0.6) 100%),
    linear-gradient(180deg, rgba(10, 10, 15, 0.2) 0%, rgba(10, 10, 15, 0.45) 100%);
}

.game__left {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 3.5vh, 30px);
}

.game__right {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  min-width: 160px;
}

.game__chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(245, 245, 250, 0.65);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 10, 15, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-variant-numeric: tabular-nums;
}

.game__chip strong {
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-transform: none;
}

.game__chip.is-pop {
  animation: chipPop 0.4s ease;
}

@keyframes chipPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); box-shadow: 0 0 0 6px rgba(255, 79, 165, 0.18); }
  100% { transform: scale(1); }
}

.game__timer {
  font-size: clamp(54px, 9vw, 88px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-shadow: 0 6px 40px rgba(0, 0, 0, 0.55);
}

.game__timer.is-warn {
  color: var(--accent-2);
  animation: timerPulse 0.5s ease-in-out infinite alternate;
}

@keyframes timerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.game__ring {
  position: relative;
  width: clamp(220px, 36vmin, 340px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 30px 60px rgba(0, 0, 0, 0.5));
}

.game__ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.game__ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 4;
}

.game__ring-bar {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.08s linear, stroke 0.2s ease;
}

.game__ring-bar.is-warn {
  stroke: var(--accent-2);
}

.game__hamster {
  width: 82%;
  height: 82%;
  object-fit: contain;
  border-radius: 50%;
  background: #fafafc;
  padding: 6%;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s ease;
}

.game__hamster.is-hit {
  animation: hitPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hitPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.game__hamster.is-swap {
  opacity: 0;
  transform: scale(0.94);
}

.game__label {
  font-size: clamp(18px, 2.6vw, 26px);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #1a1a22;
  background: #fff;
  padding: 12px 24px;
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.game__elapsed {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(245, 245, 250, 0.55);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

.game__mute {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(245, 245, 250, 0.55);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  margin-top: 4px;
}

.game__mute:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.04);
}

.game__mute[data-muted="true"] {
  color: rgba(245, 245, 250, 0.35);
  border-style: dashed;
}

@media (max-width: 720px), (orientation: portrait) {
  .game {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    gap: clamp(14px, 3vh, 24px);
    padding: clamp(14px, 3vh, 24px);
    justify-items: center;
  }
  .game__left {
    grid-column: 1;
    grid-row: 1;
  }
  .game__right {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    min-width: 0;
    gap: 10px;
  }
  .game__timer {
    font-size: clamp(36px, 10vw, 56px);
    order: -1;
    flex-basis: 100%;
    text-align: center;
  }
  .game__elapsed,
  .game__mute {
    flex-basis: 100%;
    text-align: center;
  }
}

/* match-flash: brief radial pulse when the user nails a gesture */
.game.is-flash::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(50% 45% at 50% 45%, rgba(255, 180, 70, 0.45) 0%, transparent 65%);
  animation: flashOut 0.4s ease forwards;
}

@keyframes flashOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ---------- game over ---------- */
.game-over {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(10, 10, 15, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 20px;
  pointer-events: auto;
  animation: fade 0.25s ease both;
}

.game-over__title {
  margin: 0;
  font-size: clamp(38px, 7.5vw, 60px);
  font-weight: 900;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-over__stats {
  margin: 0;
  display: flex;
  gap: 28px;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(245, 245, 250, 0.55);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.game-over__stats span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-over__stats strong {
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
  text-transform: none;
}

.game-over__new {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  animation: fade 0.4s ease 0.2s both;
}

.game-over__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(240px, 100%);
  margin-top: 6px;
}

@media (max-width: 520px) {
  .game-over__stats {
    gap: 18px;
  }
  .game-over__stats strong {
    font-size: 24px;
  }
}
