:root {
  --bg: #0b1020;
  --bg-card: #151c34;
  --bg-elevated: #1e2746;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.12);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #ec4899;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;

  /* 4 high-visibility answer colors */
  --opt-0: #2563eb;
  --opt-1: #db2777;
  --opt-2: #d97706;
  --opt-3: #059669;

  --radius: 18px;
  --font-scale: 1;
}

/* Personal accessibility modes (player can toggle individually) */
body.high-contrast {
  --bg: #000000;
  --bg-card: #0a0a0a;
  --bg-elevated: #141414;
  --text: #ffffff;
  --text-muted: #fde047;
  --border: #ffffff;
  --primary: #facc15;
  --primary-hover: #eab308;
  --opt-0: #000000;
  --opt-1: #000000;
  --opt-2: #000000;
  --opt-3: #000000;
}

body.high-contrast .btn-primary {
  color: #000000;
}

body.high-contrast .answer-btn {
  border: 4px solid #facc15 !important;
  color: #ffffff !important;
  background: #000000 !important;
}

body.high-contrast .answer-btn:focus-visible,
body.high-contrast .answer-btn.selected {
  background: #facc15 !important;
  color: #000000 !important;
}

body.large-text {
  --font-scale: 1.24;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: radial-gradient(circle at top, #182246 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: calc(16px * var(--font-scale));
  line-height: 1.4;
}

body.high-contrast {
  background: #000000;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
}

.app-shell.player-mode {
  max-width: 680px;
  padding: 12px;
}

.app-shell.tv-mode {
  max-width: 1400px;
  padding: 28px 36px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.pill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 700;
}

.badge.highlight {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
}

/* Cards & Grids */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Typography */
h1, h2, h3 {
  margin: 0 0 10px 0;
  line-height: 1.2;
}

h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.85rem); }
h3 { font-size: 1.1rem; }

.muted {
  color: var(--text-muted);
}

/* Buttons */
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #facc15;
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-elevated);
  border: 2px solid var(--border);
}

.btn:hover:not(:disabled) {
  background: #283359;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #ffffff;
  border-color: transparent;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-accent {
  background: linear-gradient(135deg, #ec4899, #f59e0b);
  color: #ffffff;
  border-color: transparent;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
  border-color: transparent;
}

.btn-sm {
  padding: 8px 13px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.btn-xl {
  width: 100%;
  padding: 20px 24px;
  font-size: 1.25rem;
  border-radius: 18px;
}

/* Form controls */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  text-align: center;
  font-weight: 900;
  font-size: 1.7rem !important;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.seg-btn {
  padding: 12px 10px;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 12px;
  font-weight: 700;
  text-align: center;
}

.seg-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

body.high-contrast .seg-btn.active {
  color: #000000;
}

.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.playlist-card {
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
}

.playlist-card.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.2);
}

.playlist-card small {
  display: block;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Home Hero */
.hero {
  text-align: center;
  padding: 20px 10px 28px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(236, 72, 153, 0.18);
  border: 1px solid rgba(236, 72, 153, 0.45);
  color: #fbcfe8;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.role-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

/* Lobby & QR */
.lobby-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 820px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
}

.qr-box {
  background: #ffffff;
  color: #0b1020;
  border-radius: 20px;
  padding: 18px;
  text-align: center;
}

.qr-box svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 10px;
}

.room-code-big {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: #0b1020;
  margin: 4px 0;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  font-weight: 700;
  font-size: 1.05rem;
}

.player-chip.answered {
  border-color: var(--success);
  background: rgba(22, 163, 74, 0.22);
}

/* Vinyl Music Player Visual */
.vinyl-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.vinyl {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #0b1020 12%, #f59e0b 13%, #f59e0b 32%, #111827 33%, #1f2937 55%, #111827 75%, #000 100%);
  border: 3px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.vinyl.spinning {
  animation: spin 3.2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Timer Bar */
.timer-bar-wrap {
  width: 100%;
  height: 16px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0;
}

.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 0.2s linear;
}

/* Host/TV Question Options Preview */
.tv-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

@media (max-width: 640px) {
  .tv-options {
    grid-template-columns: 1fr;
  }
}

.tv-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-radius: 16px;
  font-size: clamp(1.15rem, 2.2vw, 1.6rem);
  font-weight: 800;
  color: #ffffff;
  border: 3px solid rgba(255, 255, 255, 0.15);
}

.tv-option.opt-0 { background: var(--opt-0); }
.tv-option.opt-1 { background: var(--opt-1); }
.tv-option.opt-2 { background: var(--opt-2); }
.tv-option.opt-3 { background: var(--opt-3); }

.tv-option.correct {
  box-shadow: 0 0 0 5px #22c55e, 0 0 28px rgba(34, 197, 94, 0.6);
  transform: scale(1.02);
}

.tv-option.dimmed {
  opacity: 0.3;
}

.shape-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.32);
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* =========================================================
   ACCESSIBLE MOBILE PLAYER ANSWER BUTTONS (EXTRA LARGE!)
   ========================================================= */
.a11y-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.a11y-toggle {
  flex: 1;
  min-width: 96px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
}

.a11y-toggle.active {
  background: #facc15;
  color: #000000;
  border-color: #facc15;
}

.player-question-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-prompt-box {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}

.player-prompt-text {
  font-size: clamp(1.2rem, 4.4vw, 1.65rem);
  font-weight: 800;
  margin: 4px 0 0;
}

.joker-row {
  display: flex;
  gap: 10px;
}

.joker-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 2px solid var(--warning);
  color: var(--text);
  font-weight: 800;
  font-size: 0.98rem;
}

.joker-btn.armed {
  background: var(--warning);
  color: #000000;
}

.answer-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 52dvh;
}

.answer-btn {
  flex: 1;
  min-height: 92px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 20px;
  color: #ffffff;
  text-align: left;
  font-size: clamp(1.3rem, 5vw, 1.95rem);
  font-weight: 900;
  line-height: 1.2;
  border: 3px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.answer-btn.opt-0 { background: var(--opt-0); }
.answer-btn.opt-1 { background: var(--opt-1); }
.answer-btn.opt-2 { background: var(--opt-2); }
.answer-btn.opt-3 { background: var(--opt-3); }

.answer-btn.eliminated {
  opacity: 0.16;
  text-decoration: line-through;
  pointer-events: none;
}

.answer-btn.selected {
  box-shadow: 0 0 0 5px #facc15;
}

/* Feedback Banner (Player Reveal) */
.feedback-banner {
  border-radius: 22px;
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 16px;
}

.feedback-banner.correct {
  background: linear-gradient(135deg, #15803d, #22c55e);
  color: #ffffff;
}

.feedback-banner.wrong {
  background: linear-gradient(135deg, #991b1b, #dc2626);
  color: #ffffff;
}

.feedback-icon {
  font-size: 3.4rem;
  line-height: 1;
  margin-bottom: 8px;
}

/* Reveal Track Card */
.track-reveal-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border-radius: 18px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  margin-top: 14px;
}

.track-cover {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: #ffffff;
  flex-shrink: 0;
  overflow: hidden;
}

.track-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scoreboard & Awards */
.standings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.standing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  font-size: 1.15rem;
  font-weight: 800;
}

.standing-row.rank-1 {
  border-color: #facc15;
  background: rgba(250, 204, 21, 0.14);
}

.standing-row.is-me {
  border-color: var(--primary);
}

.awards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.award-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: #0f172a;
  color: #ffffff;
  border: 2px solid var(--primary);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  transition: transform 0.25s ease;
  z-index: 100;
  max-width: 92vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
