@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #14102A;
  --bg-deep: #1B1338;
  --bg-panel: #251A4A;
  --bg-panel-raised: #2E2059;
  --line: #3B2C6B;
  --text: #F6F3FF;
  --muted: #B4A8DA;
  --gold: #FFB93F;
  --gold-dark: #E39C1F;

  --c-triangle: #E8465F;
  --c-diamond: #2E9BE0;
  --c-circle: #FFC93C;
  --c-square: #2FC178;

  --radius: 18px;
  --shadow: 0 12px 30px rgba(10, 6, 30, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
}

body {
  background-color: var(--bg-deep);
  background-image:
    linear-gradient(180deg, rgba(27, 19, 56, 0.88), rgba(20, 16, 42, 0.94)),
    url('/images/bg-texture.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

/* ---------- site header logo (host/play screens) ---------- */
.site-header {
  position: fixed;
  top: 16px;
  left: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.site-header img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.site-header span {
  font-family: 'Fredoka';
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  display: none;
}
@media (min-width: 640px) {
  .site-header span { display: inline; }
}

h1, h2, h3 { font-family: 'Fredoka', 'Inter', sans-serif; font-weight: 600; margin: 0; }

button { font-family: inherit; cursor: pointer; }

a { color: inherit; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #23150A;
  box-shadow: 0 8px 22px rgba(255, 185, 63, 0.35);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(255, 185, 63, 0.5); }
.btn-primary:disabled { opacity: .4; box-shadow: none; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--line);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-large { padding: 18px 36px; font-size: 1.1rem; width: 100%; max-width: 420px; }

/* ---------- landing ---------- */
.landing {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.landing-glow {
  position: absolute;
  width: 900px; height: 900px;
  top: -320px; left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255,185,63,.18), transparent 60%);
  pointer-events: none;
}
.landing-wrap {
  position: relative;
  text-align: center;
  padding: 24px;
  max-width: 640px;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 12px; }
.brand-mark {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 18px;
  background: linear-gradient(135deg, #FFD96A 0%, #FFB93F 30%, #FF7A5E 100%);
  border: 3px solid rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fredoka'; font-size: 2rem; font-weight: 700; color: var(--ink);
  transform: rotate(-6deg);
  box-shadow: 0 16px 32px rgba(255, 169, 64, 0.35);
  text-shadow: 0 2px 0 rgba(255,255,255,0.18);
}
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 3px solid rgba(20, 16, 42, 0.32);
  border-radius: 12px;
}
.brand-mark::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  right: 10px; bottom: 9px;
  border-radius: 50%;
  background: rgba(20, 16, 42, 0.52);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}
.brand h1 { font-size: 2.6rem; letter-spacing: -0.02em; }
.hero-logo {
  width: min(320px, 70vw);
  height: auto;
  border-radius: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.tagline { color: var(--muted); font-size: 1.1rem; margin-bottom: 40px; }
/* ---------- categories section ---------- */
.categories-section { margin-bottom: 40px; }
.categories-section h2 { font-size: 1.4rem; margin-bottom: 20px; color: var(--gold); }
.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 16px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--bg-panel);
  color: var(--text);
  text-decoration: none;
  transition: all .2s ease;
  cursor: pointer;
}
.category-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(255, 185, 63, 0.25);
}
.category-icon {
  font-size: 2.4rem;
  display: block;
}
.category-name {
  font-weight: 600;
  font-size: 1.05rem;
  font-family: 'Fredoka';
}
@media (min-width: 640px) {
  .categories-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}
.landing-actions { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.shape-strip { display: flex; justify-content: center; gap: 18px; margin-top: 48px; }
.shape { width: 30px; height: 30px; display: inline-block; }
.shape-triangle { background: var(--c-triangle); clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.shape-diamond { background: var(--c-diamond); clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.shape-circle { background: var(--c-circle); border-radius: 50%; }
.shape-square { background: var(--c-square); border-radius: 6px; }

/* ---------- screen switching ---------- */
.screen { display: none; min-height: 100vh; padding: 88px 20px 32px; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ---------- panels / forms ---------- */
.panel { width: 100%; max-width: 640px; text-align: center; }
.picker-panel { max-width: 1120px; text-align: left; }
.panel-narrow { max-width: 380px; }
.picker-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 48px; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: .95rem; }
.back-link:hover { color: var(--text); }
.picker-status { color: var(--muted); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--c-square); box-shadow: 0 0 0 4px rgba(47, 193, 120, .14); }
.panel-title { font-size: 1.9rem; margin-bottom: 24px; }
.picker-hero { max-width: 720px; margin-bottom: 46px; }
.picker-eyebrow { color: var(--gold); font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.picker-hero .panel-title { font-size: clamp(2.5rem, 6vw, 4.8rem); line-height: .98; margin: 12px 0 18px; letter-spacing: -.03em; }
.picker-summary { max-width: 520px; color: var(--muted); font-size: 1.05rem; line-height: 1.6; margin: 0 0 22px; }
.picker-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: .86rem; }
.picker-meta span { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(46, 32, 89, .5); }
.picker-meta strong { color: var(--text); }

.pin-input, .name-input {
  width: 100%;
  padding: 16px 20px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  font-family: 'Fredoka';
}
.pin-input:focus, .name-input:focus { outline: none; border-color: var(--gold); }
.error-text { color: var(--c-triangle); min-height: 1.2em; font-size: .9rem; margin-top: 8px; }

/* ---------- quiz picker ---------- */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 38px;
  width: 100%;
}
.quiz-topic { border-top: 1px solid var(--line); padding-top: 20px; }
.topic-heading { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.topic-kicker { color: var(--gold); font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.topic-heading h2 { font-size: 1.45rem; }
.topic-count { color: var(--muted); font-size: .8rem; }
.topic-quizzes { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) {
  .topic-quizzes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.quiz-card {
  width: 100%;
  background: var(--bg-panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: border-color .15s ease, transform .15s ease;
}
.quiz-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.quiz-card:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.quiz-card-copy { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.quiz-card-copy strong { font-family: 'Fredoka'; font-size: 1.05rem; }
.quiz-card-copy small { color: var(--muted); font-size: .82rem; }
.quiz-card-arrow { color: var(--gold); font-size: 1.4rem; transition: transform .15s ease; }
.quiz-card:hover .quiz-card-arrow { transform: translateX(4px); }

/* ---------- host lobby ---------- */
.lobby-top { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }
.pin-card {
  background: var(--bg-panel);
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  padding: 18px 40px;
  text-align: center;
}
.pin-label { display: block; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; }
.pin-value { font-family: 'Fredoka'; font-size: 3rem; font-weight: 700; letter-spacing: .12em; color: var(--gold); }
.join-hint { color: var(--muted); font-size: .95rem; }
.lobby-heading { margin-bottom: 18px; }
.player-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 720px; margin-bottom: 32px; min-height: 46px; }
.player-chip {
  background: var(--bg-panel-raised);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- question (host) ---------- */
.q-topbar { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 900px; margin-bottom: 20px; }
.q-progress, .answer-count { color: var(--muted); font-weight: 600; }
.timer-ring { position: relative; width: 60px; height: 60px; }
.timer-ring svg { width: 60px; height: 60px; transform: rotate(-90deg); }
.timer-ring circle {
  fill: none; stroke: var(--line); stroke-width: 5;
}
#timer-circle {
  stroke: var(--gold);
  stroke-dasharray: 163;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke .3s ease;
}
#timer-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: 'Fredoka';
}
.q-text { font-size: 1.8rem; text-align: center; max-width: 900px; margin-bottom: 30px; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; max-width: 900px; }
.option-btn {
  border: none;
  border-radius: var(--radius);
  padding: 26px 20px;
  color: white;
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform .12s ease, filter .12s ease;
}
.option-btn .opt-shape { width: 24px; height: 24px; flex-shrink: 0; }
.opt-0 { background: var(--c-triangle); }
.opt-1 { background: var(--c-diamond); }
.opt-2 { background: var(--c-circle); color: #2A1E00; }
.opt-3 { background: var(--c-square); }
.opt-0 .opt-shape { background: white; clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
.opt-1 .opt-shape { background: white; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.opt-2 .opt-shape { background: #2A1E00; border-radius: 50%; }
.opt-3 .opt-shape { background: white; border-radius: 5px; }

.player-options .option-btn { cursor: pointer; justify-content: center; font-size: 1.4rem; padding: 40px 20px; }
.player-options .option-btn:active { transform: scale(0.95); }
.player-options .option-btn:disabled { opacity: .5; cursor: default; }

/* ---------- results (host) ---------- */
.results-heading { margin-bottom: 20px; }
.results-bars { width: 100%; max-width: 700px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 34px; }
.result-bar-row { display: flex; align-items: center; gap: 12px; }
.result-bar-shape { width: 20px; height: 20px; flex-shrink: 0; }
.result-bar-track { flex: 1; background: var(--bg-panel); border-radius: 10px; overflow: hidden; height: 30px; }
.result-bar-fill { height: 100%; display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; color: white; font-weight: 700; font-size: .85rem; transition: width .6s ease; }
.result-bar-fill.correct-mark::after { content: ' ✓'; }

.leaderboard-title { margin-bottom: 14px; }
.leaderboard-list { list-style: none; padding: 0; margin: 0 0 30px; width: 100%; max-width: 500px; }
.leaderboard-list li {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-panel);
  padding: 12px 20px;
  border-radius: 12px;
  margin-bottom: 8px;
  font-weight: 600;
}
.leaderboard-list li .rank { color: var(--gold); margin-right: 10px; }
.leaderboard-final li:nth-child(1) { border: 2px solid var(--gold); }
.winner-announcement { color: var(--gold); font-size: 1.35rem; font-weight: 700; margin: -10px 0 20px; text-align: center; }
.flower-burst { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 10; }
.flower { position: absolute; left: var(--x); top: -2rem; font-size: 2rem; animation: flower-fall 3.2s var(--delay) ease-out forwards; }
@keyframes flower-fall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0deg) scale(.6); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin)) scale(1.1); opacity: 0; }
}

/* ---------- player waiting / feedback ---------- */
.waiting-wrap { text-align: center; margin: auto; }
.pulse-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--gold);
  margin: 0 auto 24px;
  animation: pulse 1.2s infinite ease-in-out;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .4; } }

.answer-status { font-size: 1.1rem; color: var(--muted); margin-bottom: 20px; text-align: center; }
.player-options { position: relative; }
.submitted-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(20, 16, 42, 0.92);
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  z-index: 5;
}
.submitted-overlay.active { display: flex; }
.submitted-check { font-size: 3.5rem; color: var(--c-square); margin-bottom: 10px; }

.feedback-icon { font-size: 4rem; margin-bottom: 10px; }
.feedback-title { font-size: 2rem; margin-bottom: 10px; }
.feedback-points { font-size: 1.3rem; color: var(--gold); font-weight: 700; margin-bottom: 6px; }
.feedback-rank { color: var(--muted); }

.final-score-text { font-size: 1.3rem; color: var(--muted); margin-bottom: 24px; }

@media (max-width: 640px) {
  .options-grid { grid-template-columns: 1fr; }
  .pin-value { font-size: 2.2rem; }
  .q-text { font-size: 1.4rem; }
}
