/* ============ VictoGames Econ Quiz Arena ============ */
:root {
  --bg-1: #0f0a1f;
  --bg-2: #1b1138;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #f4f1ff;
  --text-dim: #b3a9d4;
  --accent-1: #7c3aed;
  --accent-2: #06b6d4;
  --accent-3: #f472b6;
  --good: #22c55e;
  --bad: #ef4444;
  --gold: #fbbf24;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  min-height: 100dvh;
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(124, 58, 237, 0.35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(6, 182, 212, 0.25), transparent 60%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  overflow-x: hidden;
}

#confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* ============ Screens ============ */
.screen {
  display: none;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 18px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ============ Buttons ============ */
.icon-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.icon-btn:active { transform: scale(0.92); }

.btn-primary {
  display: block;
  width: 100%;
  padding: 15px 22px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.btn-primary:active { transform: scale(0.97); filter: brightness(1.15); }

.btn-ghost {
  display: block;
  width: 100%;
  padding: 13px 22px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.btn-ghost:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.12); }

/* ============ HOME ============ */
.home-header { display: flex; justify-content: flex-end; }

.hero { text-align: center; margin: 4vh 0 5vh; }

.hero-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero-title {
  font-size: clamp(2.6rem, 12vw, 4rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: 0.01em;
}

/* first headline line — smaller so it never wraps, white like the original */
.title-fit {
  display: block;
  font-size: clamp(1.2rem, 6.2vw, 2.2rem);
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.gradient-text {
  background: linear-gradient(110deg, var(--accent-2), var(--accent-1) 50%, var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 1rem;
  max-width: 34ch;
  margin-inline: auto;
}

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

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.mode-card:active { transform: scale(0.97); }
.mode-card:hover { border-color: rgba(124, 58, 237, 0.6); background: rgba(255, 255, 255, 0.09); }

.mode-emoji {
  font-size: 1.7rem;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, rgba(124, 58, 237, 0.35), rgba(6, 182, 212, 0.25));
  border-radius: 14px;
  flex-shrink: 0;
}

.mode-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.mode-name { font-size: 1.1rem; font-weight: 700; }
.mode-desc { font-size: 0.83rem; color: var(--text-dim); }

.mode-best {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  text-align: right;
  white-space: nowrap;
}
.mode-best.chevron { color: var(--text-dim); font-size: 1.1rem; transition: transform 0.25s; }
.mode-card[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 0 14px;
  border-left: 2px solid rgba(124, 58, 237, 0.45);
  margin-left: 18px;
  margin-top: -12px; /* cancel the .modes gap while collapsed */
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease,
    margin-top 0.25s ease, visibility 0s 0.25s;
}
.category-list.open {
  padding: 4px 0 4px 14px;
  margin-top: 0;
  max-height: 500px;
  opacity: 1;
  visibility: visible;
  transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease,
    margin-top 0.25s ease, visibility 0s;
}

.category-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s;
}
.category-list button:active { transform: scale(0.97); }
.category-list button:hover { border-color: rgba(6, 182, 212, 0.6); }
.category-list .cat-best { font-size: 0.75rem; color: var(--gold); font-weight: 700; white-space: nowrap; }

.home-footer {
  margin-top: auto;
  padding-top: 26px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ============ QUIZ ============ */
.quiz-header { display: flex; flex-direction: column; gap: 12px; }

.quiz-header .icon-btn { align-self: flex-start; }

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-1));
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.hud b { color: var(--text); font-size: 1rem; }
.hud-score { margin-left: auto; }
.hud-streak {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--gold);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  animation: pulse-streak 1.2s ease-in-out infinite;
}
.hud-streak b { color: var(--gold); }
@keyframes pulse-streak { 50% { transform: scale(1.07); } }

.quiz-body { display: flex; flex-direction: column; flex: 1; padding-top: 22px; }

.category-chip {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.35);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.question-text {
  font-size: clamp(1.25rem, 5.4vw, 1.55rem);
  font-weight: 700;
  line-height: 1.35;
  min-height: 3.6em;
}

.timer-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  margin: 16px 0 18px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good), var(--accent-2));
  transition: width 0.1s linear, background-color 0.3s;
}
.timer-fill.warn { background: linear-gradient(90deg, var(--bad), #f97316); }

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

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  line-height: 1.35;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.2s, background 0.25s, opacity 0.3s;
  animation: option-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) backwards;
}
.option:nth-child(1) { animation-delay: 0.03s; }
.option:nth-child(2) { animation-delay: 0.09s; }
.option:nth-child(3) { animation-delay: 0.15s; }
.option:nth-child(4) { animation-delay: 0.21s; }
@keyframes option-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}

.option:not(:disabled):active { transform: scale(0.97); }
.option:not(:disabled):hover { border-color: rgba(124, 58, 237, 0.65); }

.option-letter {
  width: 30px; height: 30px;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 0.82rem;
  font-weight: 800;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-dim);
}

.option.correct {
  border-color: var(--good);
  background: rgba(34, 197, 94, 0.16);
  animation: pop-correct 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.option.correct .option-letter { background: var(--good); color: #06220f; }

.option.wrong {
  border-color: var(--bad);
  background: rgba(239, 68, 68, 0.14);
  animation: shake 0.4s;
}
.option.wrong .option-letter { background: var(--bad); color: #fff; }

.option.dimmed { opacity: 0.4; }
.option.removed { opacity: 0.18; pointer-events: none; text-decoration: line-through; }

@keyframes pop-correct { 35% { transform: scale(1.035); } }
@keyframes shake {
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  90% { transform: translateX(2px); }
}

.lifeline {
  margin-top: 16px;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 999px;
  color: var(--gold);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.3s;
}
.lifeline small { font-weight: 500; color: var(--text-dim); font-size: 0.72rem; }
.lifeline:active { transform: scale(0.95); }
.lifeline:disabled { opacity: 0.3; pointer-events: none; }

/* feedback */
.feedback {
  margin-top: 18px;
  animation: feedback-in 0.4s cubic-bezier(0.34, 1.3, 0.64, 1);
}
@keyframes feedback-in {
  from { opacity: 0; transform: translateY(18px); }
}

.feedback-banner {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.feedback-banner.good { color: var(--good); }
.feedback-banner.bad { color: var(--bad); }

.feedback-explanation {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent-2);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 0.93rem;
  line-height: 1.5;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.feedback-explanation b { color: var(--text); }

/* floating points */
.points-pop {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 3px 14px rgba(251, 191, 36, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
}
.points-pop.show { animation: points-fly 0.9s ease-out; }
@keyframes points-fly {
  0% { opacity: 0; transform: translate(-50%, 18px) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -54px) scale(1); }
}

/* ============ RESULTS ============ */
#screen-results { justify-content: flex-start; gap: 22px; padding-top: 30px; }

.results-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: feedback-in 0.5s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.results-emoji { font-size: 3.2rem; }

.new-best {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #1c1402;
  background: linear-gradient(100deg, var(--gold), #fde68a);
  padding: 6px 16px;
  border-radius: 999px;
  animation: pulse-streak 1s ease-in-out infinite;
}

.results-grade {
  font-size: 1.9rem;
  font-weight: 900;
  margin-top: 10px;
  background: linear-gradient(110deg, var(--accent-2), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.results-quip { color: var(--text-dim); font-size: 0.95rem; margin-top: 6px; }

.score-ring-wrap { position: relative; width: 150px; margin: 22px auto; }
.score-ring { width: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-val { fill: none; stroke-width: 10; }
.ring-bg { stroke: rgba(255, 255, 255, 0.09); }
.ring-val {
  stroke: url(#ring-grad);
  stroke: var(--accent-2);
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1.1s cubic-bezier(0.4, 0, 0.2, 1);
}
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-label span { font-size: 1.7rem; font-weight: 900; }
.ring-label small { color: var(--text-dim); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }

.results-stats {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin-bottom: 24px;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.25rem; font-weight: 800; }
.stat span { font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.06em; text-transform: uppercase; }

.results-actions { display: flex; flex-direction: column; gap: 10px; }

.study-links {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.study-links h3 { font-size: 1rem; margin-bottom: 4px; }
.study-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 11px;
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
}
.study-links a:hover { color: var(--text); border-color: rgba(6, 182, 212, 0.5); }
.study-links a:active { transform: scale(0.98); }

/* ============ misc ============ */
@media (min-width: 640px) {
  .screen { padding-top: 32px; }
  .results-actions { flex-direction: row; }
  .results-actions .btn-primary { flex: 1.4; }
  .results-actions .btn-ghost { flex: 1; }
}

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