/* ============================================================
   You Call Yourself A Friend - styles
   ------------------------------------------------------------
   Brand: deep midnight blue + warm coral accent. Different
   palette from Lovers Quest (which is navy + gold) so the
   two games feel like siblings, not twins.
   ============================================================ */

:root {
  --bg: #0a1426;
  --bg-2: #142142;
  --panel: #17264a;
  --panel-2: #1e335f;
  --cream: #fef9f1;
  --cream-mute: rgba(254,249,241,.82);
  --cream-faint: rgba(254,249,241,.55);
  /* Pulled directly from the box cover so the page feels like an
     extension of the product, not a foreign container. */
  --coral: #ff8b4a;
  --coral-2: #e85c1a;
  --sun: #ffd24a;
  --sky: #4ab9ff;
  --teal: #4ec5b0;
  --pink: #ff6b9d;
  --line: rgba(254,249,241,.16);
  --ff: 'Playfair Display', Georgia, serif;
  --fn: 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(.22,.61,.36,1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--cream); }
body {
  font-family: var(--fn);
  font-weight: 400;
  line-height: 1.5;
  background:
    radial-gradient(ellipse at 18% 8%, rgba(255,139,74,.22), transparent 50%),
    radial-gradient(ellipse at 82% 18%, rgba(74,185,255,.18), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(255,210,74,.14), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  -webkit-font-smoothing: antialiased;
}

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: calc(env(safe-area-inset-top) + 1.25rem) 1.25rem calc(env(safe-area-inset-bottom) + 1.25rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 1; transition: opacity .35s var(--ease);
}

.screen > * {
  margin-top: auto;
  margin-bottom: auto;
  width: 100%;
}
.screen[hidden] { display: none; }
.screen.fading { opacity: 0; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--fn); font-size: .85rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 1rem 2rem; border-radius: 8px; border: none; cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease), color .25s var(--ease);
}
.btn-primary {
  background: linear-gradient(135deg, var(--coral), var(--coral-2)); color: #1a0a05;
  box-shadow: 0 12px 28px rgba(255,122,89,.28);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 36px rgba(255,122,89,.4); }
.btn-primary:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--cream-mute);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--cream); border-color: rgba(245,241,232,.36); }

/* ---------- router (landing) ---------- */
.router-inner {
  text-align: center; display: flex; flex-direction: column; align-items: center;
  gap: 1rem; max-width: 560px; position: relative; z-index: 2;
}
/* Big illustrated cover. The whole point of the page. */
.router-cover {
  width: clamp(220px, 60vw, 320px);
  margin-bottom: .8rem;
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    0 32px 60px rgba(0,0,0,.55),
    0 0 0 1px rgba(255,210,74,.22),
    0 0 80px rgba(255,139,74,.22);
  transform: rotate(-2.5deg);
  animation: cover-float 4.5s var(--ease) infinite alternate;
}
.router-cover img { display: block; width: 100%; height: auto; }
@keyframes cover-float {
  from { transform: rotate(-2.5deg) translateY(0); }
  to   { transform: rotate(2deg) translateY(-6px); }
}
.brand-eyebrow {
  font-family: var(--fn); font-size: .82rem; font-weight: 600;
  letter-spacing: .28em; text-transform: uppercase;
  color: var(--sun); opacity: .85; margin: 0;
}
.brand-title {
  font-family: var(--ff); font-weight: 800;
  font-size: clamp(2.4rem, 9vw, 3.8rem);
  letter-spacing: -.01em; line-height: 1.02; margin: 0;
  background: linear-gradient(135deg, #fff, #ffe6dc 30%, var(--coral) 70%, var(--sun));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 18px rgba(255,139,74,.25));
}
.brand-sub {
  font-family: var(--ff); font-style: italic; font-weight: 500;
  font-size: clamp(1.05rem, 3.8vw, 1.3rem);
  color: var(--cream); margin: 0; max-width: 38ch; line-height: 1.45;
}
.brand-byline {
  font-size: .75rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cream-faint); margin-top: 1.2rem;
}
.router-actions {
  display: flex; flex-direction: column; gap: .9rem;
  width: min(340px, 100%); margin-top: .8rem;
}
/* Make the primary button pop with a soft pulse so the page feels alive */
#screen-router .btn-primary {
  font-size: .95rem; padding: 1.15rem 2.2rem;
  background: linear-gradient(135deg, var(--coral), var(--coral-2));
  box-shadow: 0 14px 32px rgba(255,139,74,.42), 0 0 0 1px rgba(255,210,74,.3);
  animation: btn-pulse 2.4s ease-in-out infinite;
}
@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 14px 32px rgba(255,139,74,.42), 0 0 0 1px rgba(255,210,74,.3); }
  50%      { box-shadow: 0 18px 44px rgba(255,139,74,.55), 0 0 0 1px rgba(255,210,74,.6); }
}

/* ---------- confetti dots (floating background decoration) ---------- */
.confetti {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.confetti .dot {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  opacity: .55; filter: blur(.5px);
  animation: confetti-drift 14s linear infinite;
}
.confetti .d1  { left: 6%;  top: 12%; background: var(--coral); animation-duration: 16s; animation-delay: 0s; }
.confetti .d2  { left: 88%; top: 8%;  background: var(--sun);   animation-duration: 12s; animation-delay: 1s; width: 10px; height: 10px; }
.confetti .d3  { left: 16%; top: 78%; background: var(--sky);   animation-duration: 18s; animation-delay: 2s; }
.confetti .d4  { left: 80%; top: 64%; background: var(--pink);  animation-duration: 15s; animation-delay: 0.5s; width: 8px; height: 8px; }
.confetti .d5  { left: 4%;  top: 50%; background: var(--teal);  animation-duration: 20s; animation-delay: 1.5s; width: 12px; height: 12px; }
.confetti .d6  { left: 90%; top: 38%; background: var(--coral); animation-duration: 13s; animation-delay: 3s; width: 9px; height: 9px; }
.confetti .d7  { left: 22%; top: 28%; background: var(--sun);   animation-duration: 17s; animation-delay: 0.8s; width: 8px; height: 8px; }
.confetti .d8  { left: 72%; top: 86%; background: var(--sky);   animation-duration: 14s; animation-delay: 2.5s; width: 12px; height: 12px; }
.confetti .d9  { left: 36%; top: 92%; background: var(--coral); animation-duration: 19s; animation-delay: 1.2s; width: 7px; height: 7px; }
.confetti .d10 { left: 60%; top: 6%;  background: var(--pink);  animation-duration: 16s; animation-delay: 2.8s; width: 11px; height: 11px; }
.confetti .d11 { left: 50%; top: 48%; background: var(--sun);   animation-duration: 22s; animation-delay: 4s; width: 6px; height: 6px; }
.confetti .d12 { left: 30%; top: 60%; background: var(--teal);  animation-duration: 15s; animation-delay: 3.5s; width: 9px; height: 9px; }
@keyframes confetti-drift {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(-40px) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .router-cover, #screen-router .btn-primary, .confetti .dot { animation: none !important; }
}

/* ---------- sheet (host setup, join setup, pairing placeholder) ---------- */
.sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2.2rem 1.8rem 2rem;
  max-width: 460px; width: 100%;
  box-shadow: 0 30px 70px rgba(0,0,0,.5);
}
.sheet-title {
  font-family: var(--ff); font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 2rem);
  color: var(--cream); margin: 0 0 .5rem;
}
.sheet-lead { color: var(--cream-mute); margin: 0 0 1.4rem; }
.sheet-actions { display: flex; gap: .8rem; justify-content: flex-end; margin-top: 1.4rem; flex-wrap: wrap; }
.dim-text { color: var(--cream-faint); font-size: .9rem; }

.field-label {
  display: block; font-size: .75rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--cream-mute); margin: .8rem 0 .4rem;
}
.text-input {
  -webkit-appearance: none; appearance: none;
  width: 100%;
  font-family: var(--fn); font-size: 1.05rem;
  color: var(--cream); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .85rem 1rem;
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.text-input:focus { outline: none; border-color: var(--coral); background: rgba(255,122,89,.06); }
.code-input {
  font-family: 'Courier New', monospace; font-size: 1.8rem;
  letter-spacing: .42em; font-weight: 700; text-align: center; text-transform: uppercase;
}
.error-text { color: #ff9c8a; font-size: .9rem; margin: .6rem 0 0; }

/* ---------- lobby ---------- */
.lobby-inner {
  text-align: center; display: flex; flex-direction: column; align-items: center;
  gap: 1.1rem; max-width: 520px; width: 100%;
}
.lobby-eyebrow {
  font-size: .7rem; letter-spacing: .32em; text-transform: uppercase;
  color: var(--cream-faint); margin: 0;
}
.lobby-code {
  font-family: 'Courier New', monospace; font-weight: 700;
  font-size: clamp(3rem, 12vw, 4.4rem); letter-spacing: .18em;
  color: var(--coral); margin: 0;
}
.lobby-qr {
  width: 188px; height: 188px;
  background: #fff; border-radius: 14px; padding: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 20px 40px rgba(0,0,0,.4);
}
.lobby-qr img, .lobby-qr canvas { display: block; width: 100%; height: 100%; }
.lobby-share-note {
  color: var(--cream-mute); font-size: .92rem; max-width: 36ch; margin: .2rem auto 0;
}
.kbd {
  display: inline; font-family: 'Courier New', monospace; font-size: .9em;
  background: var(--panel-2); padding: .12em .42em; border-radius: 4px; color: var(--cream);
}
.lobby-section-title {
  font-family: var(--ff); font-weight: 700;
  font-size: 1.05rem; letter-spacing: .04em;
  color: var(--cream); margin: 1.6rem 0 .4rem;
}
.player-list {
  list-style: none; padding: 0; margin: 0;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: .5rem;
}
.player-list li {
  display: flex; align-items: center; gap: .8rem;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: .8rem 1rem;
  animation: pop-in .35s var(--ease) both;
}
.player-list li.is-host .player-name::after,
.player-list li.is-you .player-name::after {
  margin-left: .6rem;
  font-size: .62rem; letter-spacing: .2em;
  padding: .18rem .5rem; border-radius: 999px;
  vertical-align: middle;
}
.player-list li.is-host .player-name::after {
  content: 'HOST'; color: var(--coral); background: rgba(255,139,74,.14);
}
.player-list li.is-you .player-name::after {
  content: 'YOU'; color: var(--teal); background: rgba(78,197,176,.14);
}
.player-list li.is-host.is-you .player-name::after { content: 'HOST · YOU'; }
.player-list li .player-name { flex: 1 1 auto; }

/* Host-only remove button at the end of each non-host player row */
.player-remove {
  -webkit-appearance: none; appearance: none;
  margin-left: auto;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid rgba(255,139,74,.32);
  color: var(--coral);
  border-radius: 50%; cursor: pointer;
  font-size: 1.2rem; line-height: 1; padding: 0;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.player-remove:hover, .player-remove:focus-visible {
  background: rgba(255,139,74,.18); border-color: var(--coral); color: #fff; outline: none;
}
.player-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--teal);
}
.player-name { color: var(--cream); font-weight: 500; }
.lobby-count {
  font-size: .8rem; color: var(--cream-faint); margin: .2rem 0;
  letter-spacing: .14em; text-transform: uppercase;
}
.lobby-actions {
  display: flex; flex-direction: column; gap: .8rem;
  align-items: center; margin-top: 1rem;
  width: min(320px, 100%);
}
.lobby-host-note {
  font-size: .82rem; color: var(--cream-faint); max-width: 32ch; line-height: 1.45;
  font-style: italic; margin: 0;
}

/* ---------- pairing screen ---------- */
.pairing-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: .8rem; max-width: 560px; width: 100%;
  text-align: center;
}
.pairing-eyebrow {
  font-size: .7rem; letter-spacing: .32em; text-transform: uppercase;
  color: var(--sun); opacity: .85; margin: 0;
}
.pairing-title {
  font-family: var(--ff); font-weight: 800;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  background: linear-gradient(135deg, #fff, var(--coral) 60%, var(--sun));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  margin: 0;
}
.pairing-lead {
  color: var(--cream-mute); margin: .2rem 0 1rem; max-width: 38ch; line-height: 1.5;
}

/* All players appear as tiles in a single grid the host taps */
.players-grid {
  list-style: none; padding: 0; margin: 0;
  width: 100%; max-width: 460px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .7rem;
}
.players-grid li {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 1rem .8rem;
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  cursor: pointer; user-select: none;
  transition: transform .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
  animation: pop-in .35s var(--ease) both;
  position: relative;
}
.players-grid li:hover { transform: translateY(-1px); background: var(--panel-2); }
.players-grid li.read-only { cursor: default; }
.players-grid li.read-only:hover { transform: none; background: var(--panel); }
.players-grid .grid-name {
  color: var(--cream); font-weight: 600; font-size: 1rem;
  text-align: center; word-break: break-word;
}
.players-grid .grid-role {
  font-size: .58rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--cream-faint); margin-top: .1rem;
}
/* Selected (first tap, waiting for second tap) */
.players-grid li.is-selected {
  border-color: #fff; background: rgba(255,255,255,.08);
  animation: pulse-select 1.4s ease-in-out infinite;
}
@keyframes pulse-select {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.0); }
  50%      { box-shadow: 0 0 0 6px rgba(255,255,255,.14); }
}
/* Paired tiles, color-coded by pair index */
.players-grid li.paired { font-weight: 700; }
.players-grid li.paired::after {
  content: ''; position: absolute; bottom: 8px; right: 10px;
  width: 10px; height: 10px; border-radius: 50%;
}
.players-grid li.pair-coral { border-color: var(--coral); background: rgba(255,139,74,.16); }
.players-grid li.pair-coral::after { background: var(--coral); }
.players-grid li.pair-sky   { border-color: var(--sky);   background: rgba(74,185,255,.16); }
.players-grid li.pair-sky::after   { background: var(--sky); }
.players-grid li.pair-sun   { border-color: var(--sun);   background: rgba(255,210,74,.16); }
.players-grid li.pair-sun::after   { background: var(--sun); }
.players-grid li.pair-pink  { border-color: var(--pink);  background: rgba(255,107,157,.16); }
.players-grid li.pair-pink::after  { background: var(--pink); }
.players-grid li.pair-teal  { border-color: var(--teal);  background: rgba(78,197,176,.16); }
.players-grid li.pair-teal::after  { background: var(--teal); }

.pairing-status {
  margin: 1rem 0 0;
  font-size: .8rem; color: var(--cream-faint);
  letter-spacing: .14em; text-transform: uppercase;
}
.pairing-actions {
  display: flex; flex-direction: column; gap: .6rem; align-items: center;
  margin-top: 1rem; width: min(320px, 100%);
}
.pairing-host-note {
  font-size: .82rem; color: var(--cream-faint); max-width: 32ch; line-height: 1.45;
  font-style: italic; margin: 0;
}

/* Game-started placeholder until Phase 3 ships the real round loop */
.paired-summary {
  list-style: none; padding: 0; margin: 1.2rem 0 0;
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: .6rem;
}
.paired-summary li {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  background: linear-gradient(135deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  border: 2px solid var(--line);
  border-radius: 12px; padding: .8rem 1rem;
  color: var(--cream); font-weight: 600;
}
.paired-summary li.pair-coral { border-color: var(--coral); background: rgba(255,139,74,.12); }
.paired-summary li.pair-sky   { border-color: var(--sky);   background: rgba(74,185,255,.12); }
.paired-summary li.pair-sun   { border-color: var(--sun);   background: rgba(255,210,74,.12); }
.paired-summary li.pair-pink  { border-color: var(--pink);  background: rgba(255,107,157,.12); }
.paired-summary li.pair-teal  { border-color: var(--teal);  background: rgba(78,197,176,.12); }

/* ============================================================
   Phase 3: live game screen
   ============================================================ */
.play-screen { align-items: flex-start; }
.play-inner {
  width: 100%; max-width: 560px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 1.2rem;
  padding-top: .25rem;
}

/* ---------- race track ---------- */
.race-wrap {
  width: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .8rem 1rem .9rem;
}
.race-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .7rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--cream-mute);
  margin-bottom: .55rem;
}
.race-label { color: var(--sun); font-weight: 700; }
.race-round { color: var(--cream-mute); font-weight: 600; }
.race-track {
  position: relative;
  width: 100%; min-height: 140px;
  border-radius: 10px;
  background:
    repeating-linear-gradient(90deg,
      rgba(255,255,255,.04) 0 calc(100% / 5),
      rgba(255,255,255,.08) calc(100% / 5) calc(100% / 5 + 1px)
    ),
    linear-gradient(180deg, rgba(255,210,74,.04), rgba(255,210,74,.01));
  border: 1px dashed rgba(255,210,74,.22);
}
.race-finish {
  position: absolute; top: 0; right: 0; bottom: 0; width: 6px;
  background: repeating-linear-gradient(0deg, var(--sun) 0 8px, #1a0a05 8px 16px);
  border-radius: 0 8px 8px 0;
}
.race-cars {
  list-style: none; padding: 0; margin: 0;
  position: absolute; top: 0; left: 26px; right: 26px; bottom: 0;
  display: block;
}
.race-car {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  transition: left .55s cubic-bezier(.22,.61,.36,1);
  white-space: nowrap;
}
.race-car-icon {
  font-size: 1.5rem; line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}
.race-car-score {
  font-size: .68rem; font-weight: 800;
  letter-spacing: .04em;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: var(--cream);
  border: 1px solid rgba(254,249,241,.22);
  min-width: 1.6rem; text-align: center;
}
.race-car.pair-coral .race-car-score { border-color: var(--coral); }
.race-car.pair-sky   .race-car-score { border-color: var(--sky); }
.race-car.pair-sun   .race-car-score { border-color: var(--sun); color: #1a0a05; background: var(--sun); }
.race-car.pair-pink  .race-car-score { border-color: var(--pink); }
.race-car.pair-teal  .race-car-score { border-color: var(--teal); }

/* Stagger cars vertically so they don't sit on top of each other.
   Optimized for the common 2-3 pair case (4-6 players). */
.race-car:nth-child(1) { top: 25%; }
.race-car:nth-child(2) { top: 75%; }
.race-car:nth-child(3) { top: 50%; }
.race-car:nth-child(4) { top: 12%; }
.race-car:nth-child(5) { top: 88%; }

/* ---------- card frame ---------- */
.card-frame {
  background: linear-gradient(160deg, rgba(255,139,74,.10), rgba(255,210,74,.05));
  border: 1px solid rgba(255,210,74,.24);
  border-radius: 18px;
  padding: 1.1rem 1.2rem 1.3rem;
  display: flex; flex-direction: column; gap: .35rem;
  box-shadow: 0 12px 32px rgba(0,0,0,.32);
}
.card-frame-head {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  flex-wrap: wrap;
}
.card-theme {
  font-size: .7rem; letter-spacing: .22em;
  color: var(--sun); font-weight: 700;
  margin: 0;
}
.card-type-label {
  font-size: .58rem; letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(254,249,241,.78);
  background: rgba(0,0,0,.32);
  border: 1px solid rgba(254,249,241,.18);
  padding: .15rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
}
/* Bonus card banner: appears on bonus cards, sits between the card-frame-head
   and the subject hint. Big enough to be unmissable, animated to make it pop. */
.card-bonus-banner {
  display: inline-block;
  align-self: flex-start;
  margin-top: .2rem;
  font-size: .68rem; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase;
  padding: .25rem .7rem;
  border-radius: 999px;
  background: var(--sun);
  color: #1a0a05;
  border: 1px solid var(--sun);
  box-shadow: 0 0 0 2px rgba(255,210,74,.25);
  animation: bonus-pulse 1.6s ease-in-out infinite;
}
@keyframes bonus-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 2px rgba(255,210,74,.25); }
  50%      { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(255,210,74,.18); }
}
.card-subject-hint {
  font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cream-faint);
  margin: 0;
}
.card-text {
  font-family: var(--ff);
  font-size: 1.25rem; line-height: 1.3;
  color: var(--cream);
  margin: .2rem 0 0;
}

/* ---------- action area shared ---------- */
.play-action { display: flex; flex-direction: column; gap: 1rem; }
.action-eyebrow {
  font-size: .7rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--cream-mute); margin: 0; font-weight: 700;
}
.action-status {
  font-size: .82rem; color: var(--cream-faint);
  margin: 0; text-align: center;
}

/* ---------- answer grid (guesser + subject) ---------- */
.answer-grid {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .55rem;
}
.answer-tile {
  display: flex; align-items: center; gap: .8rem;
  padding: .85rem 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 2px solid var(--line);
  border-radius: 12px;
  color: var(--cream);
  font-weight: 500;
  cursor: pointer;
  transition: transform .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.answer-tile:active { transform: scale(.98); }
.answer-tile.is-selected {
  border-color: var(--coral);
  background: linear-gradient(180deg, rgba(255,139,74,.18), rgba(255,139,74,.06));
  box-shadow: 0 0 0 1px var(--coral), 0 8px 22px rgba(255,139,74,.18);
}
.answer-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,210,74,.18); color: var(--sun);
  font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}
.answer-tile.is-selected .answer-letter {
  background: var(--coral); color: #1a0a05;
}
/* Read-only tiles for the spectator view: visible so spectators can play
   along mentally, but not interactive. Dimmed and de-saturated so they
   read as "not your turn" without being invisible. */
.answer-tile.is-readonly {
  opacity: .58;
  cursor: default;
  filter: grayscale(.35);
}
.spectator-options { margin-top: .25rem; }
.answer-text { flex: 1; line-height: 1.3; }

/* ---------- reveal view ---------- */
.reveal-truth {
  margin: 0;
  font-family: var(--ff);
  font-size: 1.1rem; line-height: 1.35;
  color: var(--cream);
  padding: .85rem 1rem;
  background: linear-gradient(135deg, rgba(255,210,74,.16), rgba(255,210,74,.04));
  border: 1px solid var(--sun);
  border-radius: 12px;
}
/* Persistent Leave Game button for mid-game escape (Phase 5.5) */
.btn-leave {
  margin-top: .8rem;
  font-size: .7rem;
  letter-spacing: .14em;
  opacity: .6;
  padding: .65rem 1.2rem;
}
.btn-leave:hover { opacity: 1; }

/* Phase 5: spectator view + single-partner reveal */
.spectator-view {
  display: flex; flex-direction: column; gap: .7rem; align-items: center; text-align: center;
}
.spectator-line {
  margin: 0;
  font-size: .95rem; line-height: 1.4;
  color: var(--cream);
  padding: .85rem 1rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.reveal-partner-line {
  margin: .2rem 0 0;
  font-size: .95rem;
  font-weight: 600;
  padding: .65rem .85rem;
  border-radius: 10px;
  text-align: center;
  background: rgba(255,255,255,.04);
}
.reveal-partner-line.guess-right { background: rgba(78,197,176,.18); color: var(--teal); }
.reveal-partner-line.guess-wrong { background: rgba(255,107,157,.14); color: var(--pink); }

.reveal-guesses {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .35rem;
}
.reveal-guesses li {
  display: grid; grid-template-columns: 1fr auto 1.4rem;
  gap: .6rem; align-items: center;
  padding: .55rem .8rem;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  font-size: .9rem;
}
.reveal-guesses .g-name { color: var(--cream); font-weight: 600; }
.reveal-guesses .g-pick { color: var(--cream-mute); font-size: .82rem; }
.reveal-guesses .g-mark { text-align: center; font-weight: 700; font-size: 1.1rem; }
.reveal-guesses li.guess-right { background: rgba(78,197,176,.15); }
.reveal-guesses li.guess-right .g-mark { color: var(--teal); }
.reveal-guesses li.guess-wrong { background: rgba(255,107,157,.10); }
.reveal-guesses li.guess-wrong .g-mark { color: var(--pink); }

.reveal-scores {
  list-style: none; padding: 0; margin: .4rem 0 0;
  display: flex; flex-direction: column; gap: .35rem;
}
.reveal-scores li {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem .8rem;
  background: rgba(255,255,255,.04);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  font-size: .9rem;
}
.reveal-scores li.pair-coral { border-left-color: var(--coral); }
.reveal-scores li.pair-sky   { border-left-color: var(--sky); }
.reveal-scores li.pair-sun   { border-left-color: var(--sun); }
.reveal-scores li.pair-pink  { border-left-color: var(--pink); }
.reveal-scores li.pair-teal  { border-left-color: var(--teal); }
.reveal-scores .s-name { font-weight: 600; }
.reveal-scores .s-score { font-weight: 700; color: var(--sun); }

/* ---------- game over screen ---------- */
.game-over-inner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: .9rem;
  max-width: 520px; width: 100%;
}
.game-over-eyebrow {
  font-size: .8rem; letter-spacing: .28em; text-transform: uppercase;
  color: var(--sun); font-weight: 700; margin: 0;
}
.game-over-title {
  font-family: var(--ff);
  font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 1.05; margin: 0;
  background: linear-gradient(120deg, var(--coral), var(--sun));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.game-over-lead {
  font-size: 1rem; color: var(--cream-mute);
  max-width: 32ch; margin: 0;
}
.final-scores {
  list-style: none; padding: 0; margin: .6rem 0 0;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: .5rem;
}
.final-scores li {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-weight: 600;
}
.final-scores li.pair-coral { border-color: var(--coral); }
.final-scores li.pair-sky   { border-color: var(--sky); }
.final-scores li.pair-sun   { border-color: var(--sun); }
.final-scores li.pair-pink  { border-color: var(--pink); }
.final-scores li.pair-teal  { border-color: var(--teal); }
.final-scores li.is-winner {
  background: linear-gradient(135deg, rgba(255,210,74,.18), rgba(255,139,74,.10));
  box-shadow: 0 8px 24px rgba(255,210,74,.18);
}
.final-scores .s-score { color: var(--sun); font-weight: 700; }
.game-over-actions { margin-top: .8rem; }

/* ============================================================
   Phase 4: Team Setup (icon picker + confirmation)
   ============================================================ */
.team-setup-inner {
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: 1rem;
  text-align: center;
}
.team-setup-view { display: flex; flex-direction: column; gap: 1rem; }

.team-rows {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .6rem;
}
.team-row {
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: .6rem .85rem;
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.team-row.is-open {
  background: linear-gradient(180deg, rgba(255,210,74,.12), rgba(255,210,74,.04));
  border-color: var(--sun);
}
.team-row.pair-coral { border-left: 4px solid var(--coral); }
.team-row.pair-sky   { border-left: 4px solid var(--sky); }
.team-row.pair-sun   { border-left: 4px solid var(--sun); }
.team-row.pair-pink  { border-left: 4px solid var(--pink); }
.team-row.pair-teal  { border-left: 4px solid var(--teal); }
.team-row-head {
  display: flex; align-items: center; gap: .8rem;
  text-align: left;
}
.team-row-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(254,249,241,.18);
  font-size: 1.5rem; line-height: 1;
  flex-shrink: 0;
}
.team-row-names { color: var(--cream); font-weight: 600; flex: 1; }
.team-row-meta { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.team-row-team-name {
  color: var(--cream); font-weight: 700; line-height: 1.2;
}
.team-row-members {
  color: var(--cream-faint); font-size: .8rem;
}

.icon-picker {
  list-style: none; padding: .8rem 0 .2rem; margin: 0;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem;
}
.icon-tile {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: rgba(0,0,0,.32);
  border: 2px solid rgba(254,249,241,.14);
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
.icon-tile:active { transform: scale(.92); }
.icon-tile.is-selected {
  border-color: var(--sun);
  background: rgba(255,210,74,.18);
  box-shadow: 0 0 0 1px var(--sun);
}
.icon-tile.is-taken {
  opacity: .25; cursor: not-allowed; filter: grayscale(.8);
}

.team-name-editor {
  margin-top: .7rem;
  display: flex; gap: .5rem; align-items: stretch;
}
.team-name-editor .text-input { flex: 1; }
.team-name-save {
  padding: .7rem 1rem;
  font-size: .7rem;
}

.team-setup-actions {
  display: flex; flex-direction: column; gap: .6rem;
  align-items: stretch; margin-top: .4rem;
}
.team-setup-actions .btn { width: 100%; }

/* ---------- Depth picker (Phase 6 infrastructure) ---------- */
.depth-picker-wrap {
  margin-top: 1.2rem;
  display: flex; flex-direction: column; gap: .55rem;
  text-align: center;
}
.depth-eyebrow { margin: 0; }
.depth-picker {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem;
}
.depth-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .25rem;
  padding: .75rem .5rem;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 2px solid var(--line);
  color: var(--cream);
  font-family: var(--fn);
  cursor: default;
  text-align: center;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease);
}
.depth-tile-name {
  font-family: var(--ff);
  font-size: 1.05rem; font-weight: 700;
  line-height: 1.1;
}
.depth-tile-sub {
  font-size: .65rem; color: var(--cream-faint);
  line-height: 1.2;
}
.depth-tile-badge {
  margin-top: .2rem;
  font-size: .55rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cream-faint);
  padding: .15rem .4rem;
  border-radius: 999px;
  background: rgba(0,0,0,.32);
  border: 1px solid rgba(254,249,241,.14);
}
.depth-tile-badge-active {
  color: var(--sun);
  border-color: var(--sun);
  background: rgba(255,210,74,.14);
}
.depth-tile.depth-selectable { cursor: pointer; }
.depth-tile.depth-selectable:active { transform: scale(.97); }
.depth-tile.is-selected {
  border-color: var(--coral);
  background: linear-gradient(180deg, rgba(255,139,74,.18), rgba(255,139,74,.06));
  box-shadow: 0 0 0 1px var(--coral), 0 8px 22px rgba(255,139,74,.18);
}
.depth-tile.depth-locked {
  opacity: .55;
  filter: grayscale(.4);
}
.depth-host-note {
  font-size: .75rem; color: var(--cream-faint);
  margin: .25rem 0 0;
}

/* ---------- animations ---------- */
@keyframes pop-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .06s !important; }
}

/* ---------- shared icon button (drawer/modal close) ---------- */
.icon-btn {
  -webkit-appearance: none; appearance: none; background: transparent;
  border: none; cursor: pointer; color: var(--cream-mute);
  width: 38px; height: 38px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { background: rgba(255,210,74,.08); color: var(--cream); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- onboarding walkthrough ---------- */
.onboarding-sheet {
  max-width: 520px; text-align: center; position: relative; padding-top: 1.4rem;
  box-shadow: 0 36px 90px rgba(0,0,0,.6), 0 0 0 1px rgba(255,210,74,.16), 0 0 60px rgba(255,139,74,.12);
}
.onb-cover {
  margin: 0 auto 1.4rem; width: clamp(160px, 42vw, 220px);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 18px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(255,210,74,.22);
}
.onb-cover img { display: block; width: 100%; height: auto; }
.onb-cover[hidden] { display: none; }
.onb-orn {
  width: 50px; height: 50px; margin: .2rem auto 1rem; color: var(--sun);
  filter: drop-shadow(0 0 12px rgba(255,210,74,.4));
}
.onb-orn svg { width: 100%; height: 100%; fill: currentColor; }
.onb-orn[hidden] { display: none; }
.onboarding-step-num {
  font-family: var(--fn); font-size: .68rem; letter-spacing: .3em; text-transform: uppercase;
  color: var(--coral); margin-bottom: .7rem; opacity: .9;
}
.onb-flourish { width: 150px; height: 14px; margin: .5rem auto 1.1rem; color: var(--sun); opacity: .7; }
.onb-flourish svg { width: 100%; height: 100%; stroke: currentColor; fill: currentColor; stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.onboarding-sheet .sheet-title {
  font-size: clamp(1.5rem, 5.2vw, 1.95rem); letter-spacing: .01em; margin-bottom: .2rem;
  background: linear-gradient(135deg, var(--sun), var(--coral));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.onboarding-body { margin: .6rem 0 1.5rem; }
.onboarding-body p { margin: 0 0 1rem; line-height: 1.7; color: var(--cream-mute); font-size: 1rem; }
.onboarding-body p:first-child { font-size: 1.06rem; color: var(--cream); }
.onboarding-body p:last-child { margin-bottom: 0; }
.onboarding-body em { color: var(--cream); font-style: italic; }
.onboarding-actions { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: .4rem; flex-wrap: wrap; }
.onboarding-actions .onb-back[hidden] { display: none; }

/* ---------- help menu: hamburger fab + drawer ---------- */
.menu-fab {
  position: fixed; z-index: 30;
  top: calc(env(safe-area-inset-top) + .8rem); right: calc(env(safe-area-inset-right) + .8rem);
  width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background: rgba(23,38,74,.7); border: 1px solid var(--line);
  color: var(--cream); backdrop-filter: blur(6px);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.menu-fab:hover { background: rgba(30,51,95,.9); transform: translateY(-1px); }
.menu-fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu-fab[hidden] { display: none; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(10,20,38,.6); backdrop-filter: blur(3px); opacity: 0; transition: opacity .4s var(--ease); }
.drawer-backdrop.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(82vw, 340px);
  background: linear-gradient(180deg, var(--panel), var(--bg));
  border-left: 1px solid var(--line); box-shadow: -20px 0 60px rgba(0,0,0,.5);
  padding: calc(env(safe-area-inset-top) + 1.5rem) 1.5rem calc(env(safe-area-inset-bottom) + 1.5rem);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .42s var(--ease);
}
.drawer.show { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1.8rem; }
.drawer-brand { font-family: var(--ff); font-weight: 700; font-size: 1.1rem; color: var(--sun); line-height: 1.2; }
.drawer-nav { display: flex; flex-direction: column; gap: .25rem; }
.drawer-item {
  text-align: left; background: transparent; border: none; cursor: pointer;
  font-family: var(--ff); font-weight: 500; font-size: 1.2rem; color: var(--cream);
  padding: .9rem .4rem; border-bottom: 1px solid rgba(255,210,74,.1);
  transition: color .25s, padding-left .25s;
}
.drawer-item:hover { color: var(--sun); padding-left: .8rem; }
.drawer-foot { margin-top: auto; font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--cream-faint); text-align: center; }

/* ---------- about modal ---------- */
.about-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(10,20,38,.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 1.25rem;
  opacity: 0; transition: opacity .3s var(--ease);
}
.about-backdrop.show { opacity: 1; }
.about-modal {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 2rem 1.6rem 1.8rem; max-width: 380px; width: 100%; text-align: center;
  box-shadow: 0 30px 70px rgba(0,0,0,.5);
}
.about-close { position: absolute; top: .6rem; right: .6rem; }
.about-title { font-family: var(--ff); font-weight: 700; font-size: 1.3rem; color: var(--cream); margin: .2rem 0 .8rem; }
.about-body { color: var(--cream-mute); line-height: 1.6; margin: 0 0 1.1rem; }
.about-by { font-family: var(--ff); font-style: italic; color: var(--cream-faint); margin: 0 0 1rem; }
.about-link { color: var(--sun); text-decoration: none; font-weight: 600; letter-spacing: .04em; }
.about-link:hover { text-decoration: underline; }

/* ============================================================
   #86: overtime banner, inline explain, recognition + win confetti
   ============================================================ */

/* ---------- overtime (tie-breaker) banner ---------- */
.overtime-banner {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  margin: 0 0 .7rem; padding: .5rem .8rem; border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,210,74,.18), rgba(255,139,74,.12));
  border: 1px solid rgba(255,210,74,.5);
}
.overtime-banner[hidden] { display: none; }
.ot-badge {
  font-family: var(--fn); font-weight: 700; font-size: .74rem; letter-spacing: .18em;
  text-transform: uppercase; color: #08111f; background: var(--sun);
  padding: .25rem .6rem; border-radius: 999px;
}
.ot-round {
  font-family: var(--fn); font-weight: 600; font-size: .8rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sun);
}
/* Gold accent on the race + card frame while in overtime. */
.overtime-banner ~ .card-frame { border-color: rgba(255,210,74,.45); }

/* ---------- inline explain (reveal view) ---------- */
.reveal-explain { width: 100%; margin: .2rem 0 .9rem; text-align: left; }
.reveal-explain[hidden] { display: none; }
.reveal-explain .action-eyebrow { margin-bottom: .35rem; }
#reveal-explain-input {
  width: 100%; box-sizing: border-box; resize: none; min-height: 2.6rem;
  font-family: var(--fn); font-size: .95rem;
}

/* ---------- confetti dot colors (shared) ---------- */
.dot-coral { background: var(--coral); }
.dot-sun   { background: var(--sun); }
.dot-sky   { background: var(--sky); }
.dot-pink  { background: var(--pink); }
.dot-teal  { background: var(--teal); }

/* ---------- recognition burst (Fix 4): ~600ms near scoring car ---------- */
.recog-burst { position: absolute; left: 50%; top: 0; width: 0; height: 0; pointer-events: none; z-index: 6; }
.recog-dot {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  left: 0; top: 0; opacity: 0;
  animation: recog-pop .6s ease-out forwards;
}
.recog-dot.rd1 { --rx: -22px; --ry: -26px; }
.recog-dot.rd2 { --rx: 20px;  --ry: -30px; animation-delay: .04s; }
.recog-dot.rd3 { --rx: -30px; --ry: -8px;  animation-delay: .02s; }
.recog-dot.rd4 { --rx: 30px;  --ry: -12px; animation-delay: .06s; }
.recog-dot.rd5 { --rx: 0px;   --ry: -36px; animation-delay: .08s; }
@keyframes recog-pop {
  0%   { opacity: 0; transform: translate(0,0) scale(.4); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--rx), var(--ry)) scale(1); }
}

/* ---------- win celebration (Fix 5): ~2.5s from top of game-over ---------- */
.celebrate { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 4; }
.celebrate-dot {
  position: absolute; top: -6%; width: 10px; height: 10px; border-radius: 50%;
  opacity: 0; animation: celebrate-fall 2.5s linear forwards;
}
@keyframes celebrate-fall {
  0%   { opacity: 0; transform: translateY(0) translateX(0) rotate(0deg); }
  8%   { opacity: 1; }
  100% { opacity: 0; transform: translateY(105vh) translateX(var(--drift, 0)) rotate(540deg); }
}

/* Winning team highlight ring + pulse on the game-over scoreboard. */
.final-scores li.is-winner {
  box-shadow: 0 0 0 2px var(--sun), 0 0 22px rgba(255,210,74,.35);
  animation: winner-pulse 1.4s ease-in-out 3;
}
@keyframes winner-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--sun), 0 0 14px rgba(255,210,74,.25); }
  50%      { box-shadow: 0 0 0 3px var(--sun), 0 0 30px rgba(255,210,74,.55); }
}

/* Reduced motion: drop the confetti + pulse entirely (audio still plays). */
@media (prefers-reduced-motion: reduce) {
  .recog-burst, .celebrate { display: none !important; }
  .final-scores li.is-winner { animation: none !important; }
}
