:root {
  --ink: #f4f1ff;
  --ink-soft: #c9c2e6;
  --brand: #ffcc33;
  --brand-2: #ff5c8a;
  --brand-3: #5ce1e6;
  --home-bg: #1b1240;
  --radius: 20px;

  /* Quiz theme defaults (overridden per theme below) */
  --bg1: #1d3b3a;
  --bg2: #0b1a1f;
  --accent: #9bf6c8;
  --on-accent: #0b1a1f;
  --title: #e9fff4;
  --title-font: "Cinzel", serif;
}

/* ---------- Themes: one block per look ---------- */
.theme-mystic { --bg1: #1d3b3a; --bg2: #0b1a1f; --accent: #9bf6c8; --on-accent: #0b1a1f; --title: #e9fff4; --title-font: "Cinzel", serif; }
.theme-fire   { --bg1: #7a1d12; --bg2: #1f0806; --accent: #ffb347; --on-accent: #2a0a04; --title: #fff1dc; --title-font: "Cinzel", serif; }
.theme-ocean  { --bg1: #0f5c7a; --bg2: #04182b; --accent: #6ff0ff; --on-accent: #04182b; --title: #e6fdff; --title-font: "Nunito", sans-serif; }
.theme-space  { --bg1: #2a1a6e; --bg2: #05031a; --accent: #c8a8ff; --on-accent: #120a33; --title: #f3ecff; --title-font: "Nunito", sans-serif; }
.theme-candy  { --bg1: #ff7eb6; --bg2: #7b3fe4; --accent: #fff36b; --on-accent: #4a1580; --title: #ffffff; --title-font: "Nunito", sans-serif; }
.theme-sunny  { --bg1: #ffb627; --bg2: #e2552b; --accent: #ffffff; --on-accent: #b8361a; --title: #ffffff; --title-font: "Nunito", sans-serif; }
.theme-meadow { --bg1: #5cbf5a; --bg2: #1f6b3a; --accent: #ffe66d; --on-accent: #1f4d2b; --title: #ffffff; --title-font: "Nunito", sans-serif; }
.theme-tropical { --bg1: #18c8c0; --bg2: #ff7a59; --accent: #fff6d6; --on-accent: #0d6b66; --title: #ffffff; --title-font: "Nunito", sans-serif; }
.theme-stage  { --bg1: #3a0d3f; --bg2: #0a0510; --accent: #ffd34d; --on-accent: #2a0a2e; --title: #fff6dc; --title-font: "Nunito", sans-serif; }
.theme-outback { --bg1: #d9662b; --bg2: #5a1e0e; --accent: #ffd27a; --on-accent: #4a1a0a; --title: #fff3e0; --title-font: "Nunito", sans-serif; }
.theme-jungle  { --bg1: #2f7d32; --bg2: #0e2a12; --accent: #d4ff6b; --on-accent: #143316; --title: #f2ffe0; --title-font: "Cinzel", serif; }
.theme-stadium { --bg1: #1565c0; --bg2: #0b2447; --accent: #7cff6b; --on-accent: #0b2447; --title: #ffffff; --title-font: "Nunito", sans-serif; }
.theme-forest  { --bg1: #4f8a4b; --bg2: #1d3a24; --accent: #f6e7b4; --on-accent: #1d3a24; --title: #fbfff4; --title-font: "Nunito", sans-serif; }
.theme-neon   { --bg1: #12124a; --bg2: #050512; --accent: #2bffd5; --on-accent: #050512; --title: #ff6ad5; --title-font: "Nunito", sans-serif; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background: var(--home-bg);
  min-height: 100vh;
  transition: background 0.6s;
}

button { font: inherit; cursor: pointer; border: none; color: inherit; }

.fade-in { animation: fade 0.5s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ================= HOME ================= */
body.home-bg {
  background:
    radial-gradient(circle at 15% 20%, #ff5c8a55, transparent 40%),
    radial-gradient(circle at 85% 10%, #5ce1e655, transparent 40%),
    radial-gradient(circle at 50% 100%, #ffcc3344, transparent 50%),
    var(--home-bg);
  background-attachment: fixed;
}

.home { max-width: 1000px; margin: 0 auto; padding: 24px 16px 32px; }
.home.narrow { max-width: 520px; }

.brand { text-align: center; margin: 16px 0 28px; }
.logo-mark {
  width: 64px; height: 64px; margin: 0 auto 10px;
  border-radius: 50%;
  background: conic-gradient(var(--brand), var(--brand-2), var(--brand-3), var(--brand));
  display: grid; place-items: center;
  font-family: "Cinzel", serif; font-weight: 800; font-size: 36px; color: #1b1240;
  animation: spin 12s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.logo {
  font-weight: 900; font-size: clamp(48px, 10vw, 88px); letter-spacing: -2px; line-height: 1;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tag { color: var(--ink-soft); font-size: 18px; margin-top: 8px; }

.section-title { text-align: center; font-weight: 900; font-size: 26px; margin-bottom: 18px; }
.progress-note { text-align: center; color: var(--ink-soft); margin: -12px 0 20px; }

/* Player bar */
.player-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.me-chip {
  display: flex; align-items: center; gap: 10px;
  background: #ffffff14; border: 2px solid var(--pc); border-radius: 999px;
  padding: 6px 16px 6px 6px; font-size: 16px;
}
.me-chip:hover { background: #ffffff22; }
.me-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--pc);
  display: grid; place-items: center; font-size: 22px;
}
.link { background: none; color: var(--ink-soft); text-decoration: underline; font-size: 15px; }
.link:hover { color: #fff; }
.link.danger { color: #ff9aa9; }

/* Who's playing */
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; max-width: 760px; margin: 0 auto; }
.player-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 12px; border-radius: var(--radius);
  background: #ffffff10; border: 3px solid var(--pc, #ffffff33);
  transition: transform 0.15s, background 0.15s;
}
.player-tile:hover { transform: translateY(-4px); background: #ffffff1c; }
.player-tile .player-avatar {
  width: 76px; height: 76px; border-radius: 50%; background: var(--pc, #ffffff22);
  display: grid; place-items: center; font-size: 44px;
}
.player-tile.new { border-style: dashed; }
.player-tile.new .player-avatar { font-size: 36px; color: var(--ink-soft); }
.player-name { font-weight: 900; font-size: 18px; }
.player-count { font-size: 13px; color: var(--ink-soft); }

/* Profile form */
.profile-form { display: flex; flex-direction: column; gap: 10px; }
.preview {
  width: 110px; height: 110px; margin: 0 auto 6px; border-radius: 50%;
  background: var(--pc); display: grid; place-items: center; font-size: 64px;
  box-shadow: 0 0 40px color-mix(in srgb, var(--pc) 60%, transparent);
  transition: background 0.2s;
}
.field-label { font-weight: 700; color: var(--ink-soft); margin-top: 8px; }
.text-input {
  font: inherit; font-size: 22px; font-weight: 700;
  padding: 14px 18px; border-radius: 14px;
  border: 2px solid #ffffff33; background: #ffffff12; color: var(--ink);
}
.text-input:focus { outline: none; border-color: var(--brand); }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pick-avatar {
  aspect-ratio: 1; font-size: 30px; border-radius: 14px;
  background: #ffffff10; border: 2px solid transparent;
}
.pick-avatar.on { border-color: var(--brand); background: #ffffff22; transform: scale(1.08); }
.colour-row { display: flex; gap: 10px; flex-wrap: wrap; }
.pick-colour { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.pick-colour.on { border-color: #fff; transform: scale(1.12); }
.btn-brand {
  margin-top: 16px; padding: 16px; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #1b1240;
  font-weight: 900; font-size: 20px;
}
.btn-brand:hover { filter: brightness(1.08); }
.form-links { display: flex; justify-content: space-between; margin-top: 6px; }

/* Quiz cards */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.quiz-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 22px; min-height: 200px; text-align: left;
  border-radius: var(--radius); color: #fff;
  background: linear-gradient(140deg, var(--bg1), var(--bg2) 80%);
  border: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 10px 30px #0006;
  transition: transform 0.2s, box-shadow 0.2s;
}
.quiz-card:not(.locked):hover { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 16px 40px #0008; }
.quiz-card-icon { font-size: 52px; line-height: 1; }
.quiz-card-title { font-weight: 900; font-size: 20px; line-height: 1.2; }
.quiz-card-tag { font-size: 14px; opacity: 0.85; margin-top: auto; }
.quiz-card-done {
  position: absolute; top: 14px; right: 14px;
  background: #000a; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 700;
}
.quiz-card.locked { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.6); }
.quiz-card.locked::after { content: "🔒"; position: absolute; top: 14px; right: 16px; font-size: 18px; }

.home-footer { text-align: center; color: var(--ink-soft); opacity: 0.6; margin-top: 48px; font-size: 13px; }

/* ================= QUIZ SCREENS ================= */
body.quiz-bg {
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--bg1) 70%, white 15%) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
}
body.quiz-bg.theme-space::before {
  /* twinkly stars */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 30% 70%, #fff, transparent),
    radial-gradient(2px 2px at 55% 30%, #fff, transparent),
    radial-gradient(1px 1px at 75% 85%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90% 15%, #fff, transparent),
    radial-gradient(1px 1px at 45% 50%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 20% 90%, #fff, transparent),
    radial-gradient(1px 1px at 85% 55%, #fff, transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { to { opacity: 0.4; } }

.screen {
  position: relative; max-width: 640px; margin: 0 auto; min-height: 100vh;
  padding: 72px 16px 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 18px;
}

.back { position: absolute; top: 20px; left: 16px; background: none; color: var(--ink-soft); font-weight: 700; }
.back:hover { color: #fff; }

.mist {
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(ellipse at 20% 80%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 50%),
    radial-gradient(ellipse at 80% 70%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 50%);
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translateX(-6%) scale(1.1); } }

.start-icon, .result-icon {
  font-size: 110px; line-height: 1;
  filter: drop-shadow(0 0 30px var(--accent));
  animation: float 4s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-12px); } }

.quiz-title {
  font-family: var(--title-font); font-weight: 800;
  font-size: clamp(30px, 7vw, 46px); line-height: 1.15;
  color: var(--title); text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 40%, transparent);
}
.intro { color: color-mix(in srgb, var(--title) 80%, transparent); font-size: 18px; line-height: 1.6; max-width: 480px; }
.hint { opacity: 0.6; font-size: 14px; }
.outro { color: var(--accent); font-style: italic; font-size: 17px; max-width: 460px; line-height: 1.5; }

/* Spotlight sweep for the stage theme, light sweep for neon */
body.quiz-bg.theme-stage::before, body.quiz-bg.theme-neon::before {
  content: ""; position: fixed; inset: -20%; pointer-events: none; z-index: -1;
  background: conic-gradient(from 200deg at 50% -10%, transparent 0deg, #ffd34d22 12deg, transparent 24deg, transparent 336deg, #ff6ad522 348deg, transparent 360deg);
  animation: sweep 7s ease-in-out infinite alternate;
}
body.quiz-bg.theme-neon::before {
  background: repeating-linear-gradient(0deg, transparent 0 38px, #2bffd510 38px 40px), repeating-linear-gradient(90deg, transparent 0 38px, #ff6ad510 38px 40px);
  animation: none;
}
@keyframes sweep { to { transform: rotate(18deg); } }

.btn-primary {
  background: var(--accent); color: var(--on-accent);
  font-weight: 900; font-size: 18px; padding: 14px 34px; border-radius: 999px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: scale(1.05); box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-primary.glow { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 34px var(--accent); } }

.btn-ghost {
  background: transparent; color: var(--accent); border: 2px solid var(--accent);
  font-weight: 800; font-size: 18px; padding: 12px 30px; border-radius: 999px;
}
.btn-ghost.small { font-size: 15px; padding: 8px 18px; }

/* Progress */
.progress { width: 100%; height: 8px; background: #ffffff22; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.4s; }
.q-count { color: var(--accent); font-weight: 800; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }
.q-text { font-family: var(--title-font); color: var(--title); font-size: clamp(26px, 6vw, 38px); line-height: 1.2; }

/* Scale */
.scale { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.scale-value { font-family: var(--title-font); font-size: 72px; font-weight: 800; color: var(--accent); text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 50%, transparent); }
.slider { width: 100%; accent-color: var(--accent); height: 28px; }
.scale-labels { width: 100%; display: flex; justify-content: space-between; gap: 12px; font-size: 14px; opacity: 0.85; }

/* Choices */
.choices { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.choice {
  background: #ffffff14; color: var(--title);
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 16px;
  padding: 18px; font-size: 20px; font-weight: 700;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.choice:hover, .choice.on { background: color-mix(in srgb, var(--accent) 20%, transparent); border-color: var(--accent); transform: scale(1.02); }

.back-link { background: none; opacity: 0.7; font-size: 14px; }

/* Thinking */
.orb {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--accent) 40%, transparent 70%);
  box-shadow: 0 0 80px var(--accent);
  animation: orb 1.2s ease-in-out infinite alternate;
}
@keyframes orb { to { transform: scale(1.2); opacity: 0.7; } }

/* Result bars */
.bars { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.bar-row { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 10px; text-align: left; }
.bar-label { font-size: 14px; opacity: 0.85; }
.bar { position: relative; height: 10px; background: #ffffff22; border-radius: 99px; }
.bar-you { height: 100%; background: var(--accent); border-radius: 99px; }
.bar-mark {
  position: absolute; top: 50%; width: 16px; height: 16px; margin-left: -8px;
  transform: translateY(-50%); border-radius: 50%;
  background: var(--brand-2); border: 2px solid #fff;
}
.legend { font-size: 13px; opacity: 0.85; display: flex; align-items: center; gap: 6px; justify-content: center; }
.sw-you, .sw-mark { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.sw-you { background: var(--accent); }
.sw-mark { background: var(--brand-2); margin-left: 10px; }

/* Result photo */
.result-photo { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.photo-frame { position: relative; animation: float 5s ease-in-out infinite; }
.photo-frame img {
  display: block; width: min(300px, 72vw); aspect-ratio: 1; object-fit: cover; object-position: center 30%;
  border-radius: 28px; border: 4px solid var(--accent);
  box-shadow: 0 0 50px color-mix(in srgb, var(--accent) 45%, transparent), 0 20px 40px #0007;
  background: #0003;
}
.photo-badge {
  position: absolute; right: -14px; bottom: -14px;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center; font-size: 34px;
  box-shadow: 0 6px 16px #0006;
}
.result-photo figcaption { font-size: 11px; opacity: 0.6; max-width: 320px; line-height: 1.4; }
.result-photo figcaption a { color: inherit; }

/* Video */
.video-card {
  position: relative; width: 100%; max-width: 480px; aspect-ratio: 16 / 9;
  border-radius: 18px; overflow: hidden; cursor: pointer;
  border: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 14px 34px #0007; background: #000;
}
.video-card img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; transition: opacity 0.2s; }
.video-card:hover img { opacity: 1; }
.video-card .play {
  position: absolute; inset: 0; margin: auto; width: 76px; height: 76px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 30px; padding-left: 6px;
  box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 60%, transparent);
}
.video-title {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 14px 10px; text-align: left;
  font-size: 14px; font-weight: 700; background: linear-gradient(transparent, #000c);
}
.video-card iframe { width: 100%; height: 100%; border: 0; display: block; }

.result-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

/* Music toggle */
.music-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 10;
  width: 44px; height: 44px; border-radius: 50%;
  background: #ffffff22; color: var(--accent); font-size: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.music-toggle.muted { opacity: 0.4; text-decoration: line-through; }
.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
