/* Kahoot Light Minimal Theme (shared) */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --bg-grad: radial-gradient(1200px 700px at 15% 20%, rgba(120, 119, 255, 0.16), transparent 55%),
             radial-gradient(900px 600px at 85% 30%, rgba(72, 209, 204, 0.14), transparent 50%),
             radial-gradient(900px 600px at 45% 95%, rgba(255, 182, 193, 0.16), transparent 55%),
             linear-gradient(180deg, #ffffff 0%, #fbfcff 35%, #f6f7fb 100%);

  --surface: #ffffff;
  --surface-2: #f7f8fd;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
  --shadow-sm: 0 10px 25px rgba(15, 23, 42, 0.08);

  --text: #0f172a;
  --muted: rgba(15, 23, 42, 0.62);

  --brand: #6d5efc;
  --brand-2: #29c6ff;
  --brand-grad: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);

  --success: #16a34a;
  --danger: #ef4444;
  --warn: #f59e0b;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --focus: 0 0 0 4px rgba(109, 94, 252, 0.22);
  --anim-fast: 140ms;
  --anim: 220ms;
  --anim-slow: 420ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg-grad);
  background-attachment: fixed;
  overflow-x: hidden;
}
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}
.container {
  width: min(1100px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

/* Header (shared) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.75);
  backdrop-filter: none;
  box-shadow: var(--shadow-sm);
  animation: kFadeDown var(--anim-slow) cubic-bezier(.2,.8,.2,1) both;
}
.app-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  box-shadow: 0 10px 25px rgba(109, 94, 252, 0.25);
}
.app-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app-title__h {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-title__sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.8);
  font-size: 12px;
  color: var(--muted);
}
.chip strong { color: var(--text); letter-spacing: 0.08em; }
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 1);
}
.chip.connected .chip-dot { background: rgba(22, 163, 74, 1); }
.chip.disconnected .chip-dot { background: rgba(239, 68, 68, 1); }

/* Card */
.card {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card--pad { padding: 22px; }
.card__h {
  margin: 0 0 14px;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.card__sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Inputs */
.field { display: grid; gap: 8px; }
.label { font-weight: 700; font-size: 13px; color: rgba(15,23,42,0.75); }
.input {
  height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  color: var(--text);
  outline: none;
  transition: box-shadow var(--anim) ease, border-color var(--anim) ease, transform var(--anim) ease;
}
.input:focus {
  border-color: rgba(109, 94, 252, 0.55);
  box-shadow: var(--focus);
}
.input::placeholder { color: rgba(15,23,42,0.35); }

/* Buttons */
.btn {
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-md);
  height: 46px;
  padding: 0 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: transform var(--anim-fast) ease, box-shadow var(--anim) ease, opacity var(--anim) ease;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 14px 30px rgba(109, 94, 252, 0.25);
}
.btn-secondary {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: none;
  box-shadow: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }

/* Answer tiles (player) */
.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.answer-tile {
  border: 1px solid rgba(15,23,42,0.08);
  border-radius: 20px;
  padding: 18px 16px;
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 800;
  color: rgba(15,23,42,0.92);
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.10);
  transition: transform var(--anim-fast) ease, box-shadow var(--anim) ease, border-color var(--anim) ease;
  cursor: pointer;
}
.answer-tile:active { transform: translateY(2px) scale(0.99); }
.answer-tile:hover:not(:disabled) { transform: translateY(-2px); }
.answer-tile:disabled { opacity: 0.6; cursor: not-allowed; }
.answer-badge {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
}
.answer-tile[data-opt="A"] .answer-badge { background: #ff4d6d; }
.answer-tile[data-opt="B"] .answer-badge { background: #3b82f6; }
.answer-tile[data-opt="C"] .answer-badge { background: #f59e0b; }
.answer-tile[data-opt="D"] .answer-badge { background: #22c55e; }
.answer-tile.selected {
  border-color: rgba(109, 94, 252, 0.55);
  box-shadow: 0 24px 55px rgba(109, 94, 252, 0.18);
}
.answer-tile.correct {
  border-color: rgba(22, 163, 74, 0.55);
  box-shadow: 0 24px 55px rgba(22, 163, 74, 0.16);
}

/* Toast */
.toast-stack {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  width: min(560px, 100%);
  margin: 0 auto;
  border-radius: 999px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: kToastIn var(--anim) ease both;
}
.toast__msg { font-weight: 700; color: rgba(15,23,42,0.9); font-size: 13px; }
.toast__meta { font-size: 12px; color: var(--muted); }
.toast.success { border-color: rgba(22, 163, 74, 0.22); }
.toast.error { border-color: rgba(239, 68, 68, 0.22); }
.toast.info { border-color: rgba(109, 94, 252, 0.22); }

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  animation: kFade var(--anim) ease both;
}
.loading-overlay.active { display: flex; }
.loading-card {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.92);
  border-radius: 24px;
  padding: 18px 18px;
  width: min(420px, calc(100% - 48px));
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  justify-items: center;
}
.spinner {
  width: 34px; height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(15,23,42,0.12);
  border-top-color: rgba(109, 94, 252, 0.9);
  animation: kSpin 900ms linear infinite;
}
.loading-title { font-weight: 900; letter-spacing: -0.02em; }
.loading-sub { color: var(--muted); font-size: 13px; text-align: center; }

/* Simple confetti overlay (CSS dots) */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--anim) ease;
  z-index: 1500;
  background:
    radial-gradient(circle at 10% 20%, rgba(255,77,109,.45) 0 6px, transparent 7px) ,
    radial-gradient(circle at 30% 70%, rgba(59,130,246,.45) 0 6px, transparent 7px) ,
    radial-gradient(circle at 70% 30%, rgba(245,158,11,.45) 0 6px, transparent 7px) ,
    radial-gradient(circle at 85% 75%, rgba(34,197,94,.45) 0 6px, transparent 7px);
  background-size: 260px 260px;
  animation: kFloat 900ms ease-in-out infinite;
}
.confetti.active { opacity: 1; }

/* Layout helpers */
.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { height: 14px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Animations */
@keyframes kFadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes kFadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes kFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kSpin { to { transform: rotate(360deg); } }
@keyframes kToastIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes kFloat { 0%,100% { background-position: 0 0; } 50% { background-position: 20px -12px; } }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .container { width: calc(100% - 32px); padding: 18px 0 40px; }
  .answer-grid { grid-template-columns: 1fr; }
}

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

