:root {
  --bg: #160a26;
  --bg2: #1f1033;
  --ink: #f6f2ff;
  --ink-dim: #c8bdE0;
  --violet: #7c3aed;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --amber: #f59e0b;
  --radius: 22px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: radial-gradient(circle at 20% -10%, #2a1450 0%, var(--bg) 45%, #0d0617 100%);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.view {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  animation: view-in .28s ease both;
}
.view[hidden] {
  display: none;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

/* ===== HUB ===== */
.hub-header {
  text-align: center;
  padding: 28px 0 8px;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.brand-mark {
  font-size: 28px;
  color: var(--amber);
  animation: spin-slow 6s linear infinite;
  display: inline-block;
}
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.hub-header h1 {
  font-size: 40px;
  margin: 0;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, #cbb8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  color: var(--ink-dim);
  margin: 10px auto 0;
  max-width: 340px;
  font-size: 15px;
  line-height: 1.5;
}
.tagline em { color: var(--pink); font-style: normal; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 520px;
  width: 100%;
  margin: 24px auto;
  flex: 1;
}
@media (max-width: 420px) {
  .card-grid { grid-template-columns: 1fr; }
}

.game-card {
  position: relative;
  border-radius: var(--radius);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 150px;
  background: linear-gradient(155deg, var(--c1), var(--c2));
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.15);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.game-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 110%, rgba(255,255,255,.25), transparent 55%);
  pointer-events: none;
}
.game-card:active {
  transform: scale(.96);
}
@media (hover: hover) {
  .game-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 34px -12px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.2);
  }
}
.card-icon { font-size: 30px; }
.card-title { font-size: 18px; font-weight: 700; }
.card-hook { font-size: 13px; color: rgba(255,255,255,.85); line-height: 1.35; }
.card-tag {
  margin-top: auto;
  font-size: 10.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: rgba(255,255,255,.7);
  padding-top: 10px;
}

.hub-footer {
  text-align: center;
  color: rgba(246,242,255,.35);
  font-size: 12px;
  padding: 10px 0 4px;
}

/* ===== shared: back button, stage, pills ===== */
.back-btn {
  align-self: flex-start;
  font-size: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.back-btn:active { background: rgba(255,255,255,.18); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.pill-btn {
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  font-weight: 600;
  font-size: 14px;
  transition: transform .12s ease, background .12s ease;
}
.pill-btn:active { transform: scale(.94); background: rgba(255,255,255,.18); }
.pill-btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--pink));
}

/* ===== RIDDLES ===== */
.stage-riddles { gap: 14px; }
.riddles-stats {
  display: flex;
  gap: 26px;
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-num { font-size: 26px; font-weight: 800; }
.stat-label { font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .05em; }

.timer-track {
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transform-origin: left;
}
.timer-fill.running {
  animation: countdown 7s linear forwards;
}
@keyframes countdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.riddle-card {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 260px;
  justify-content: center;
}
.riddle-card.shake { animation: shake .4s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.riddle-q {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  text-align: center;
}
.riddle-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.riddle-choice {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  text-align: left;
  font-size: 15px;
  transition: background .15s ease, transform .1s ease;
}
.riddle-choice:active { transform: scale(.98); }
.riddle-choice.correct { background: #16a34a; border-color: #16a34a; }
.riddle-choice.wrong { background: #dc2626; border-color: #dc2626; }
.riddle-choice[disabled] { pointer-events: none; }
.riddle-feedback {
  min-height: 20px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-dim);
}

/* ===== DOODLE ===== */
.stage-doodle { position: relative; height: 100%; }
#doodle-canvas {
  width: 100%;
  flex: 1;
  border-radius: var(--radius);
  background: #0c0618;
  touch-action: none;
  border: 1px solid rgba(255,255,255,.08);
}
.doodle-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.doodle-hint {
  font-size: 12px;
  color: var(--ink-dim);
  text-align: center;
  margin: 0;
}

/* ===== ICEBREAKER ===== */
.stage-icebreaker { gap: 22px; }
.prompt-card {
  width: 100%;
  min-height: 260px;
  border-radius: var(--radius);
  background: linear-gradient(155deg, var(--cyan), #164e63);
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  box-shadow: 0 14px 34px -14px rgba(0,0,0,.6);
}
.prompt-card.flip { animation: card-flip .45s ease; }
@keyframes card-flip {
  0% { transform: rotateY(0deg) scale(1); }
  45% { transform: rotateY(90deg) scale(.92); opacity: .5; }
  55% { transform: rotateY(-90deg) scale(.92); opacity: .5; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}
.prompt-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: rgba(255,255,255,.2);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
}
.prompt-text {
  font-size: 21px;
  font-weight: 650;
  line-height: 1.4;
  margin: 0;
}
.icebreaker-controls {
  display: flex;
  gap: 12px;
}

/* ===== SURPRISE ===== */
.stage-surprise { position: relative; justify-content: center; }
#surprise-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.surprise-caption {
  position: relative;
  z-index: 1;
  color: var(--ink-dim);
  font-size: 14px;
  text-align: center;
  max-width: 260px;
}
.surprise-btn {
  position: relative;
  z-index: 1;
  padding: 26px 46px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--amber), #dc2626);
  box-shadow: 0 16px 40px -14px rgba(245,158,11,.6);
  transition: transform .12s ease;
}
.surprise-btn:active { transform: scale(.92); }

/* ===== toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: rgba(20,10,35,.95);
  border: 1px solid rgba(255,255,255,.15);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
