:root {
  --bg: #0f1226;
  --bg-2: #1a1f3d;
  --fg: #f5f6ff;
  --muted: #b3b8d6;
  --accent: #ffd400;
  --kahoot-red: #e21b3c;
  --kahoot-blue: #1368ce;
  --kahoot-yellow: #d89e00;
  --kahoot-green: #26890c;
  --kahoot-purple: #864cbf;
  --kahoot-teal: #0aa3a3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  height: 100%;
  overflow: hidden;
}

/* ---- Full-viewport screens (start / game / end) ---- */
.screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.screen-card {
  background: var(--bg-2);
  padding: 2rem 2.5rem;
  border-radius: 16px;
  text-align: center;
  max-width: 640px;
  width: calc(100% - 2rem);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.screen-card h1,
.screen-card h2 {
  margin-top: 0;
  color: var(--accent);
  font-size: clamp(1.25rem, 2.8vw, 2.1rem);
}
.screen-card p { color: var(--muted); margin: 0.4rem 0 1rem; }
.screen-card .hint { color: var(--fg); }

.primary-btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.85rem 1.75rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b89a00;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b89a00; }

/* ---- Game stage: video fills viewport, question popup overlays it ---- */
#game-stage { background: #000; }

#player-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
}
#player-container video,
#player-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
  object-fit: contain;   /* letterbox if aspect ratio doesn't match */
}
#youtube-wrap { position: absolute; inset: 0; }

/* Tap-to-play fallback (shown when autoplay is blocked). */
.tap-to-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(220px, 50vw);
  height: min(220px, 50vw);
  border-radius: 50%;
  border: none;
  background: rgba(255, 212, 0, 0.92);
  color: #1a1a1a;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  z-index: 8;
  animation: pulse 1.6s ease-in-out infinite;
}
.tap-to-play .tap-icon { font-size: 3.5rem; line-height: 1; }
.tap-to-play:hover { filter: brightness(1.05); }

/* Error overlay when a video fails to load. */
.video-error {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(560px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  background: var(--bg-2);
  color: var(--fg);
  border-radius: 14px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  z-index: 9;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}
.video-error h3 { margin: 0; color: var(--accent); font-size: 1.4rem; }
.video-error p {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  word-break: break-all;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

/* ---- Question popup overlay ---- */
#question-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 1.5rem;
  animation: fadeIn 0.25s ease;
  z-index: 10;
}

.question-card {
  background: var(--bg-2);
  border-radius: 16px;
  padding: 1.5rem 1.75rem;
  width: min(900px, 100%);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  animation: popIn 0.3s cubic-bezier(.2,1.3,.4,1);
}

.progress {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.question-card h2 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  text-align: center;
  line-height: 1.35;
  color: var(--fg);
}

.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 640px) {
  .answers-grid { grid-template-columns: 1fr; }
}

.answer-btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  min-height: 90px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35);
}
.answer-btn:hover { filter: brightness(1.1); }
.answer-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.35); }
.answer-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* Kahoot-style answer colors, cycled in order. Order is intentionally
 * independent of correctness — buttons reveal nothing about the answer. */
.answer-btn.c0 { background: var(--kahoot-red); }
.answer-btn.c1 { background: var(--kahoot-blue); }
.answer-btn.c2 { background: var(--kahoot-yellow); }
.answer-btn.c3 { background: var(--kahoot-green); }
.answer-btn.c4 { background: var(--kahoot-purple); }
.answer-btn.c5 { background: var(--kahoot-teal); }

.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
