:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111827;
  color: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(17, 24, 39, 0.72), rgba(17, 24, 39, 0.72)),
    url('./player-bg.jpg') center/cover no-repeat fixed;
}

button,
input {
  font: inherit;
}

.player-shell {
  min-height: 100vh;
  padding: 24px;
}

.player-nav {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.player-nav a {
  border: 1px solid #475569;
  border-radius: 8px;
  color: #f8fafc;
  font-weight: 900;
  padding: 10px 14px;
  text-decoration: none;
}

.player-nav a:first-child {
  color: #f8c537;
}

#player-auth-status {
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 800;
}

.screen {
  display: none;
}

.screen.active {
  display: grid;
  gap: 24px;
}

.eyebrow {
  color: #8bd3dd;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

h1 {
  font-size: 44px;
  line-height: 1;
  margin: 0;
}

.join-form {
  display: grid;
  gap: 14px;
}

input,
button {
  border-radius: 8px;
  min-height: 58px;
  padding: 0 16px;
}

input {
  background: #1f2937;
  border: 1px solid #475569;
  color: #f8fafc;
}

button {
  background: #f8c537;
  border: 0;
  color: #111827;
  cursor: pointer;
  font-weight: 900;
}

.message {
  color: #fca5a5;
  min-height: 22px;
}

.status {
  color: #cbd5e1;
  font-size: 22px;
  margin: 0;
}

.top-row {
  display: flex;
  font-size: 18px;
  font-weight: 800;
  justify-content: space-between;
}

.timer-track {
  background: #334155;
  border-radius: 999px;
  height: 16px;
  overflow: hidden;
  position: relative;
}

.timer-bar {
  background: #22c55e;
  height: 100%;
  transition: width 0.2s linear;
  width: 100%;
}

.timer-seconds {
  color: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  left: 50%;
  position: absolute;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.answer-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin-top: 12px;
}

.question-bubble {
  background: #1f2937;
  border: 2px solid #475569;
  border-radius: 16px;
  padding: 24px 28px;
  margin-top: 12px;
}

.question-bubble p {
  color: #f8fafc;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.4;
  margin: 0;
  text-align: center;
}

.color-options {
  display: none;
  gap: 10px;
  grid-template-columns: 1fr;
}

.color-options.active {
  display: grid;
}

.color-option {
  align-items: center;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #fff;
  display: flex;
  gap: 12px;
  min-height: 64px;
  padding: 12px 14px;
}

.color-option-name {
  background: rgba(0, 0, 0, 0.24);
  border-radius: 6px;
  flex: 0 0 72px;
  font-size: 14px;
  font-weight: 900;
  padding: 8px;
  text-align: center;
  text-transform: uppercase;
}

.color-option-text {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
}

.answer {
  align-items: center;
  border: 0;
  color: #fff;
  display: flex;
  font-size: 22px;
  font-weight: 900;
  justify-content: flex-start;
  min-height: 104px;
  padding: 18px;
  text-align: left;
}

.answer span {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
  display: inline-grid;
  margin-right: 12px;
  min-width: 38px;
  padding: 8px;
  place-items: center;
}

.answer-a {
  background: #dc2626;
}

.answer-b {
  background: #2563eb;
}

.answer-c {
  background: #ca8a04;
}

.answer-d {
  background: #16a34a;
}

.answer-true {
  background: #16a34a;
  font-size: 36px;
  min-height: 140px;
}

.answer-false {
  background: #dc2626;
  font-size: 36px;
  min-height: 140px;
}

.answer.selected {
  outline: 5px solid #f8fafc;
}

/* ── Color choice shapes (player) ─────────── */
.answer-grid-shapes {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.answer-shape {
  align-items: center;
  background: #1f2937;
  border: 2px solid #475569;
  color: #f8fafc;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  min-height: 160px;
  padding: 16px;
}

.answer-shape.selected {
  outline: 5px solid #f8fafc;
  border-radius: 12px;
}

.shape {
  display: block;
}

.answer-shape .shape,
.answer-shape .shape-label {
  background: transparent;
  margin: 0;
  min-width: 0;
  padding: 0;
}

/* Red — Square */
.shape-square {
  width: 82px;
  height: 82px;
  background: #dc2626 !important;
  border-radius: 8px;
}

/* Blue — Circle */
.shape-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #2563eb !important;
}

/* Yellow — Triangle */
.shape-triangle {
  width: 0;
  height: 0;
  border-left: 45px solid transparent;
  border-right: 45px solid transparent;
  border-bottom: 80px solid #eab308;
}

/* Green — Star */
.shape-star {
  background: transparent !important;
  color: #16a34a;
  display: block;
  font-size: 96px;
  line-height: 0.85;
  position: relative;
  width: 92px;
  height: 92px;
}

.shape-star::before {
  content: "★";
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.shape-label {
  background: transparent !important;
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
}

.color-red { background: #dc2626; }
.color-blue { background: #2563eb; }
.color-yellow { background: #ca8a04; }
.color-green { background: #16a34a; }

.leaderboard {
  display: grid;
  gap: 8px;
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

.leaderboard li {
  background: #1f2937;
  border: 1px solid #334155;
  border-radius: 8px;
  display: flex;
  font-size: 20px;
  font-weight: 800;
  justify-content: space-between;
  padding: 14px;
}

/* ── Countdown overlay ───────────────────── */
.countdown-overlay {
  align-items: center;
  background: rgba(0, 0, 0, 0.82);
  display: none;
  height: 100%;
  justify-content: center;
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
}

.countdown-overlay.active {
  display: flex;
}

.countdown-number {
  animation: countdown-pop 0.9s ease-out forwards;
  color: #f8c537;
  font-size: clamp(120px, 30vw, 320px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 80px rgba(248, 197, 55, 0.5);
}

@keyframes countdown-pop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  20% {
    opacity: 1;
    transform: scale(1.15);
  }
  40% {
    transform: scale(0.95);
  }
  60% {
    transform: scale(1.05);
  }
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

/* ── Answer reveal animations ────────────── */
@keyframes flash-correct {
  0% { background: rgba(34, 197, 94, 0); }
  25% { background: rgba(34, 197, 94, 0.25); }
  75% { background: rgba(34, 197, 94, 0.08); }
  100% { background: rgba(34, 197, 94, 0); }
}

@keyframes flash-wrong {
  0% { background: rgba(239, 68, 68, 0); }
  25% { background: rgba(239, 68, 68, 0.25); }
  75% { background: rgba(239, 68, 68, 0.08); }
  100% { background: rgba(239, 68, 68, 0); }
}

@keyframes reveal-bounce {
  0% { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

.result-flash {
  animation-duration: 0.8s;
  animation-fill-mode: forwards;
  border-radius: 8px;
  padding: 20px;
}

.result-flash.correct {
  animation-name: flash-correct;
}

.result-flash.wrong {
  animation-name: flash-wrong;
}

.result-effect {
  min-height: 170px;
  overflow: hidden;
  position: relative;
}

.result-face {
  align-items: center;
  border-radius: 50%;
  display: flex;
  height: 132px;
  justify-content: center;
  left: 50%;
  line-height: 1;
  position: absolute;
  top: 18px;
  transform: translateX(-50%);
  width: 132px;
  z-index: 2;
}

.face-eye {
  background: currentColor;
  border-radius: 50%;
  height: 18px;
  position: absolute;
  top: 42px;
  width: 18px;
}

.face-eye.left {
  left: 38px;
}

.face-eye.right {
  right: 38px;
}

.face-mouth {
  border: 8px solid currentColor;
  border-left-color: transparent;
  border-right-color: transparent;
  border-top-color: transparent;
  height: 44px;
  position: absolute;
  width: 70px;
}

.face-mouth.smile {
  border-radius: 0 0 70px 70px;
  bottom: 26px;
}

.face-mouth.frown {
  border-bottom-color: transparent;
  border-radius: 70px 70px 0 0;
  border-top-color: currentColor;
  bottom: 18px;
}

.happy-face {
  animation: happy-pop 0.8s ease-out forwards;
  background: #f8c537;
  box-shadow: 0 0 42px rgba(248, 197, 55, 0.35);
  color: #111827;
}

.sad-face {
  animation: sad-drop 0.75s ease-out forwards;
  background: #1f2937;
  border: 3px solid #60a5fa;
  box-shadow: 0 0 34px rgba(96, 165, 250, 0.22);
  color: #bfdbfe;
}

.storm-cloud {
  animation: cloud-drift 1.5s ease-in-out infinite alternate;
  background: #475569;
  border-radius: 999px;
  height: 34px;
  opacity: 0.78;
  position: absolute;
  top: 28px;
  width: 92px;
  z-index: 1;
}

.storm-cloud::before,
.storm-cloud::after {
  background: #64748b;
  border-radius: 50%;
  content: "";
  position: absolute;
}

.storm-cloud::before {
  height: 48px;
  left: 16px;
  top: -22px;
  width: 48px;
}

.storm-cloud::after {
  height: 38px;
  right: 12px;
  top: -14px;
  width: 38px;
}

.cloud-left {
  left: 12%;
}

.cloud-right {
  animation-delay: 0.25s;
  right: 10%;
  top: 42px;
}

.lightning {
  animation: lightning-flash 1.1s steps(2, end) infinite;
  background: #fde047;
  clip-path: polygon(42% 0, 72% 0, 58% 36%, 84% 36%, 35% 100%, 46% 52%, 22% 52%);
  height: 82px;
  opacity: 0;
  position: absolute;
  top: 64px;
  width: 46px;
  z-index: 1;
}

.bolt-left {
  left: 22%;
}

.bolt-right {
  animation-delay: 0.4s;
  right: 20%;
}

.confetti-piece {
  animation: confetti-fall var(--duration) ease-in forwards;
  animation-delay: var(--delay);
  background: var(--color);
  border-radius: 3px;
  height: 16px;
  left: var(--x);
  opacity: 0;
  position: absolute;
  top: -24px;
  transform: rotate(var(--rotate));
  width: 9px;
  z-index: 1;
}

.tear-drop {
  animation: tear-fall var(--duration) ease-in forwards;
  animation-delay: var(--delay);
  background: #60a5fa;
  border-radius: 50% 50% 55% 55%;
  height: 20px;
  left: var(--x);
  opacity: 0;
  position: absolute;
  top: 88px;
  transform: rotate(45deg);
  width: 14px;
}

@keyframes happy-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.35) rotate(-10deg); }
  45% { opacity: 1; transform: translateX(-50%) scale(1.16) rotate(6deg); }
  70% { transform: translateX(-50%) scale(0.96) rotate(-3deg); }
  100% { opacity: 1; transform: translateX(-50%) scale(1) rotate(0); }
}

@keyframes sad-drop {
  0% { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(0.88); }
  65% { opacity: 1; transform: translateX(-50%) translateY(8px) scale(1.03); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes confetti-fall {
  0% { opacity: 0; transform: translateY(-20px) rotate(var(--rotate)); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translateY(190px) rotate(calc(var(--rotate) + 360deg)); }
}

@keyframes tear-fall {
  0% { opacity: 0; transform: translateY(0) rotate(45deg) scale(0.7); }
  20% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(96px) rotate(45deg) scale(1); }
}

@keyframes cloud-drift {
  0% { transform: translateX(-6px); }
  100% { transform: translateX(8px); }
}

@keyframes lightning-flash {
  0%, 58%, 100% { opacity: 0; }
  60%, 72% { opacity: 1; }
}

#player-correct-answer.reveal {
  animation: reveal-bounce 0.4s ease-out forwards;
}

#rank-status.reveal {
  animation: reveal-slide-up 0.4s ease-out 0.3s forwards;
  opacity: 0;
}

@keyframes reveal-slide-up {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}
