:root {
  --bg: #050716;
  --bg2: #181b3a;
  --card-bg: #151b2c;
  --accent: #32d47b;
  --accent2: #04b4ff;
  --accent-soft: rgba(50, 212, 123, 0.18);
  --danger: #ff4d6a;
  --text: #f5f7ff;
  --muted: #9aa4c6;
  --border: #232a3f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  --radius-lg: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #3c1e6e 0, #050814 45%, #000 100%);
  background-size: 200% 200%;
  animation: bgShift 18s ease-in-out infinite;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px;
}

@keyframes bgShift {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

.app {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-header {
  text-align: center;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 2.3rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(4, 180, 255, 0.6);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(0,0,0,0.75));
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px 18px;
  box-shadow: var(--shadow), 0 0 25px rgba(4, 180, 255, 0.18);
  backdrop-filter: blur(10px);
}

.setup-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
}

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

.field-row label {
  font-size: 0.9rem;
  color: var(--muted);
}

.field-row input,
.field-row select {
  background: #050815;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  font-size: 0.9rem;
  min-width: 180px;
}

.field-row input:focus,
.field-row select:focus {
  outline: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(50,212,123,0.65);
}

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 8px 18px;
  background: #1f2740;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #050814;
  font-weight: 600;
  box-shadow: 0 12px 22px rgba(0,0,0,0.6), 0 0 20px rgba(50,212,123,0.6);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 25px rgba(0,0,0,0.7);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(0,0,0,0.55);
}

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

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.hud span {
  font-weight: 700;
  color: var(--text);
}

.question-card {
  margin-top: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid #243055;
  padding: 14px 14px 10px;
  background: radial-gradient(circle at top left, rgba(50,212,123,0.10), rgba(0,0,0,0.9));
  box-shadow: 0 0 18px rgba(4, 180, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.question-text {
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.answers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.answer-btn {
  border-radius: 999px;
  border: 1px solid #283354;
  background: #050815;
  padding: 9px 13px;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
}

.answer-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(4,180,255,0.4), rgba(50,212,123,0.4));
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 0.18s ease;
}

.answer-btn:hover {
  border-color: var(--accent);
  background: #0c1125;
  box-shadow: 0 0 14px rgba(4,180,255,0.35);
}

.answer-btn:hover::before {
  opacity: 0.3;
}

.answer-btn.correct {
  background: #0f3a21;
  border-color: #3edc83;
  box-shadow: 0 0 16px rgba(50,212,123,0.8);
}

.answer-btn.wrong {
  background: #3a0714;
  border-color: var(--danger);
  box-shadow: 0 0 16px rgba(255,77,106,0.7);
}

.answer-btn:active {
  transform: scale(0.98);
}

.feedback {
  min-height: 18px;
  margin-top: 6px;
  font-size: 0.9rem;
}

.feedback.correct {
  color: #68f2a2;
}

.feedback.wrong {
  color: var(--danger);
}

.game-over {
  text-align: center;
}

.game-over h2 {
  margin-top: 0;
}

.leaderboard-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaderboard-tabs {
  display: inline-flex;
  border-radius: 999px;
  background: rgba(5, 8, 21, 0.9);
  padding: 2px;
}

.lb-tab {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  font-size: 0.85rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.lb-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.leaderboard-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.leaderboard-list {
  flex: 2;
  min-width: 260px;
}

.leaderboard-topic {
  flex: 1.2;
  min-width: 220px;
}

.leaderboard-table {
  border-radius: 12px;
  border: 1px solid #232a3f;
  background: #050815;
  padding: 8px;
  max-height: 260px;
  overflow: auto;
  font-size: 0.85rem;
}

.leaderboard-table.small {
  max-height: 220px;
}

.leaderboard-note {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

/* Flash animations when answering */
.question-card.flash-correct {
  animation: flashCorrect 0.5s ease-out;
}

.question-card.flash-wrong {
  animation: flashWrong 0.5s ease-out;
}

@keyframes flashCorrect {
  0% { box-shadow: 0 0 0 rgba(50,212,123,0.9); }
  50% { box-shadow: 0 0 30px rgba(50,212,123,0.9); }
  100% { box-shadow: 0 0 18px rgba(4,180,255,0.2); }
}

@keyframes flashWrong {
  0% { box-shadow: 0 0 0 rgba(255,77,106,0.9); }
  50% { box-shadow: 0 0 30px rgba(255,77,106,0.9); }
  100% { box-shadow: 0 0 18px rgba(4,180,255,0.2); }
}

@media (max-width: 720px) {
  body {
    padding: 16px;
  }
  .setup-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .leaderboard-layout {
    flex-direction: column;
  }
}

/* Timer bar */
.timer-wrapper {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.timer-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(5, 8, 21, 0.9);
  overflow: hidden;
  box-shadow: 0 0 10px rgba(4,180,255,0.5) inset;
}

#timerBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  box-shadow: 0 0 12px rgba(50,212,123,0.9);
  transform-origin: left center;
  transition: width 0.05s linear;
}

#timerBar.timer-active {
  animation: timerGlow 1.4s ease-in-out infinite;
}

@keyframes timerGlow {
  0% { box-shadow: 0 0 6px rgba(50,212,123,0.5); }
  50% { box-shadow: 0 0 18px rgba(4,180,255,0.95); }
  100% { box-shadow: 0 0 6px rgba(50,212,123,0.5); }
}

/* Score pop-up */
.score-pop {
  position: absolute;
  right: 16px;
  top: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: #9fffd2;
  pointer-events: none;
  text-shadow: 0 0 12px rgba(4,180,255,0.9);
  opacity: 0;
}

.score-pop-anim {
  animation: scorePop 0.7s ease-out forwards;
}

@keyframes scorePop {
  0% {
    transform: translateY(8px) scale(0.9);
    opacity: 0;
  }
  25% {
    transform: translateY(-2px) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translateY(-18px) scale(1);
    opacity: 0;
  }
}

/* HUD stat pulse & hot multiplier */
.hud .stat-pulse {
  animation: statPulse 0.45s ease-out;
}

@keyframes statPulse {
  0% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(50,212,123,0);
  }
  40% {
    transform: scale(1.12);
    text-shadow: 0 0 18px rgba(50,212,123,0.9);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(50,212,123,0);
  }
}

#multiplierDisplay.multiplier-hot {
  color: var(--accent);
  text-shadow: 0 0 14px rgba(255,215,0,0.85);
}




/* Override leaderboard display for all game cards to match Colour Critic styling */
.leaderboard-card .leaderboard-note {
  font-size: 0.9rem;
  opacity: 0.9;
}

.leaderboard-card .leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  border-radius: 0;
  border: none;
  background: transparent;
  padding: 0;
  max-height: none;
  overflow: visible;
}

.leaderboard-card .leaderboard-table th,
.leaderboard-card .leaderboard-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: left;
}

.leaderboard-card .leaderboard-table th {
  font-weight: 600;
  background: rgba(0,0,0,0.3);
}
