/* ==========================================================================
   Theme: champagne gold, blush pink, deep plum. No external fonts/requests -
   font stacks fall back gracefully to installed serif/script faces.
   ========================================================================== */
:root {
  --plum-950: #12060f;
  --plum-900: #1a0a1f;
  --plum-800: #2a0b2e;
  --plum-700: #3d1442;
  --plum-600: #5a2160;
  --blush: #ffc2d9;
  --blush-strong: #ff6fa5;
  --rose: #e2557f;
  --champagne: #f4d58d;
  --gold: #d4af37;
  --gold-deep: #a8841f;
  --cream: #fff8ef;
  --ink: #fff8ef;
  --muted: #e9cfe0;
  --bride: #ff6fa5;
  --bride-deep: #c2336f;
  --groom: #e9b949;
  --groom-deep: #9d7413;
  --neither: #a593e0;
  --neither-deep: #6a54b8;
  --ok: #4fd1a5;
  --bad: #ff6b6b;
  --radius: 18px;
  --radius-lg: 28px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --glow-gold: 0 0 0 2px rgba(244, 213, 141, 0.6), 0 0 28px rgba(244, 213, 141, 0.55);
  --font-display: 'Playfair Display', 'Bodoni 72', Didot, 'Didot LT STD', 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --font-script: 'Great Vibes', 'Pinyon Script', 'Snell Roundhand', 'Apple Chancery', 'Segoe Script', 'Lucida Handwriting', 'Brush Script MT', cursive;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --grad-gold: linear-gradient(135deg, #fff3c4 0%, #f4d58d 30%, #d4af37 60%, #fff0b8 100%);
  --grad-blush: linear-gradient(135deg, #ffe3ee, #ff8fb8 55%, #e2557f);
  --grad-bg: radial-gradient(1200px 700px at 15% -10%, rgba(255, 111, 165, 0.28), transparent 60%),
    radial-gradient(900px 600px at 110% 10%, rgba(212, 175, 55, 0.22), transparent 60%),
    radial-gradient(800px 800px at 50% 120%, rgba(165, 147, 224, 0.25), transparent 60%),
    linear-gradient(180deg, #250b2a 0%, #1a0a1f 55%, #12060f 100%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--plum-900);
}
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--grad-bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
}
body.is-game {
  overscroll-behavior: none;
  touch-action: manipulation;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  touch-action: manipulation;
}
a {
  color: var(--champagne);
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:focus-visible {
  outline: 3px solid var(--champagne);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 52px;
  padding: 0.75em 1.3em;
  border-radius: 999px;
  border: 0;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--grad-gold);
  color: var(--plum-900);
  box-shadow: 0 6px 22px rgba(212, 175, 55, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn-secondary {
  background: var(--grad-blush);
  color: #3a0620;
  box-shadow: 0 6px 22px rgba(255, 111, 165, 0.3);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  color: var(--cream);
  border: 1px solid rgba(244, 213, 141, 0.35);
}
.btn-sm {
  min-height: 48px;
  font-size: 0.95rem;
  padding: 0.5em 1em;
}
.btn-xl {
  min-height: 64px;
  font-size: 1.25rem;
  width: 100%;
}
.icon-btn {
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(244, 213, 141, 0.35);
  background: rgba(26, 10, 31, 0.6);
  color: var(--cream);
  font-size: 1.25rem;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(6px);
}

/* ---------------------------------------------------------------- inputs */
.code-input,
.name-input {
  width: 100%;
  min-height: 56px;
  padding: 0.6em 0.9em;
  border-radius: var(--radius);
  border: 2px solid rgba(244, 213, 141, 0.45);
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.25rem; /* >=16px prevents iOS zoom */
  outline: none;
}
.code-input {
  text-transform: uppercase;
  text-align: center;
  font-family: var(--font-display);
  letter-spacing: 0.4em;
  font-size: 2rem;
  font-weight: 800;
}
.code-input:focus,
.name-input:focus {
  border-color: var(--champagne);
  box-shadow: var(--glow-gold);
}

/* ---------------------------------------------------------------- wordmark */
.wordmark {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.15em 0.35em;
  font-family: var(--font-script);
  font-size: clamp(3rem, 13vw, 6.5rem);
  line-height: 1.05;
  text-align: center;
}
.wordmark.small {
  font-size: clamp(2rem, 8vw, 3rem);
}
.wm-name {
  background: var(--grad-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 12px rgba(244, 213, 141, 0.35));
  background-size: 200% 100%;
  animation: shimmer 6s ease-in-out infinite;
}
.wm-amp {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--blush-strong);
  font-size: 0.7em;
  text-shadow: 0 0 22px rgba(255, 111, 165, 0.6);
}
@keyframes shimmer {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* ---------------------------------------------------------------- sparkles */
.sparkle-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.sparkle {
  position: absolute;
  bottom: -5vh;
  color: var(--champagne);
  text-shadow: 0 0 8px rgba(244, 213, 141, 0.9);
  animation: floatUp linear infinite;
}
.sparkle:nth-child(3n) {
  color: var(--blush);
  text-shadow: 0 0 8px rgba(255, 111, 165, 0.9);
}
@keyframes floatUp {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
  }
  50% {
    transform: translateY(-55vh) translateX(3vw) rotate(180deg);
  }
  100% {
    transform: translateY(-110vh) translateX(-2vw) rotate(360deg);
  }
}

/* ---------------------------------------------------------------- misc */
.error-banner {
  position: relative;
  z-index: 5;
  margin: 0.6rem auto;
  max-width: 640px;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  background: rgba(255, 107, 107, 0.18);
  border: 1px solid rgba(255, 107, 107, 0.6);
  color: #ffe1e1;
  font-weight: 600;
  text-align: center;
}
.pulse-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--champagne);
  box-shadow: 0 0 0 0 rgba(244, 213, 141, 0.7);
  animation: pulse 1.4s infinite;
  display: inline-block;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(244, 213, 141, 0.7);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(244, 213, 141, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(244, 213, 141, 0);
  }
}
.player-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
}
.chip {
  padding: 0.35em 0.9em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(244, 213, 141, 0.45);
  font-weight: 700;
  transform: rotate(calc(var(--h, 0) * 0.15deg));
}
.pop-in {
  animation: popIn 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes popIn {
  from {
    transform: scale(0.2);
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.center-card {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 12vh auto;
  padding: 2rem;
  display: grid;
  gap: 1rem;
  text-align: center;
  background: rgba(42, 11, 46, 0.75);
  border: 1px solid rgba(244, 213, 141, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.center-card h1 {
  font-family: var(--font-display);
  margin: 0;
}


/* ---------------------------------------------------------------- scoring badge / Speed Bonus toggle */
.scoring-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  padding: 0.28em 0.85em;
  border-radius: 999px;
  font-weight: 800;
  font-size: max(11px, 0.78rem);
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid rgba(244, 213, 141, 0.45);
  background: rgba(18, 6, 15, 0.55);
  color: var(--muted);
}
.scoring-badge.is-on {
  color: var(--plum-900);
  background: var(--grad-gold);
  border-color: var(--champagne);
  box-shadow: 0 0 16px rgba(244, 213, 141, 0.45);
}
.scoring-badge.is-off {
  color: var(--blush);
  border-color: rgba(255, 194, 217, 0.45);
}
.scoring-badge.is-compact {
  font-size: max(10px, 0.7rem);
  padding: 0.2em 0.7em;
}
.scoring-badge.is-toggle {
  cursor: pointer;
  user-select: none;
}
.scoring-badge.is-toggle:focus-visible {
  outline: 2px solid var(--champagne);
  outline-offset: 3px;
}

.speed-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid rgba(244, 213, 141, 0.35);
  background: rgba(18, 6, 15, 0.4);
  cursor: pointer;
  text-align: left;
}
.speed-toggle.is-on {
  border-color: var(--champagne);
  background: rgba(212, 175, 55, 0.16);
}
.speed-toggle.is-disabled {
  opacity: 0.72;
  cursor: not-allowed;
}
.speed-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.speed-toggle-ui {
  flex: 0 0 2.6rem;
  width: 2.6rem;
  height: 1.45rem;
  margin-top: 0.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.speed-toggle-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}
.speed-toggle.is-on .speed-toggle-ui {
  background: var(--gold);
  border-color: var(--champagne);
}
.speed-toggle.is-on .speed-toggle-ui::after {
  transform: translateX(1.15rem);
}
.speed-toggle-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.speed-toggle-label {
  font-weight: 800;
}
.speed-toggle.is-on .speed-toggle-label {
  color: var(--champagne);
}
.speed-toggle-hint {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.3;
}
.speed-toggle input:focus-visible + .speed-toggle-ui {
  outline: 2px solid var(--champagne);
  outline-offset: 2px;
}

.player-bar .scoring-badge,
.pb-badge .scoring-badge {
  font-size: 0.68rem;
  padding: 0.15em 0.55em;
}
.q-header {
  gap: 0.6em;
  flex-wrap: wrap;
}
.q-header .scoring-badge {
  margin-inline: auto;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .sparkle-field {
    display: none;
  }
}
