:root {
  color-scheme: dark;
  --bg: #111111;
  --spark: 1.8s;
  --text-main: #f0f0f0;
  --text-muted: #999999;
  --timer-color: #f0f0f0;
  --accent: #c8f135;
  --correct: #22c55e;
  --wrong: #ef4444;
  --font-main: "MonoLisa", "MonoLisa Variable", "SF Mono", "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, "Noto Sans TC", monospace;
  --font-code: "MonoLisa", "MonoLisa Variable", "SF Mono", "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 14% 72%, rgba(180, 230, 30, 0.18) 0%, transparent 46%),
    radial-gradient(ellipse at 72% 22%, rgba(200, 241, 53, 0.10) 0%, transparent 46%),
    radial-gradient(ellipse at 88% 78%, rgba(60, 60, 60, 0.35) 0%, transparent 36%),
    radial-gradient(ellipse at 40% 10%, rgba(150, 200, 20, 0.08) 0%, transparent 32%),
    var(--bg);
  color: var(--text-main);
  font-family: var(--font-main);
}

body:has(.start-card) {
  overflow: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    radial-gradient(circle, rgba(200, 241, 53, 0.35) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(180, 220, 30, 0.15) 0 1px, transparent 1.4px);
  background-position: 0 0, 36px 58px;
  background-size: 96px 96px, 132px 132px;
  opacity: 0.2;
}

button {
  font: inherit;
}

.liquid-glass {
  isolation: isolate;
  pointer-events: auto !important;
  transform-style: preserve-3d;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: start center;
  padding: clamp(16px, 2.4vw, 32px);
}

.stage {
  width: min(1180px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.35vw, 18px);
}

.quiz-stage {
  min-height: auto;
  justify-content: flex-start;
}

.result-shell {
  width: min(980px, 100%);
  margin: 0 auto;
}

/* ── Shared glass card style ── */
.start-card,
.timer-card,
.progress-pill,
.question-card,
.result-card {
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
}

.app-shell:has(.start-card) {
  padding: 0;
}

.start-card {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(40px, 8vw, 100px);
  border-radius: 0;
  border: none;
  text-align: center;
}

.start-title {
  position: relative;
  margin: 0 0 18px;
  color: #ffffff;
  font-size: clamp(36px, 5vw, 72px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 18px 42px rgba(200, 241, 53, 0.18);
  animation: titleGlowGreen 0.9s ease-out 1600ms forwards;
}

@keyframes titleGlowGreen {
  from {
    text-shadow: 0 18px 42px rgba(200, 241, 53, 0.18);
  }
  to {
    text-shadow:
      0 0 8px rgba(200, 241, 53, 0.9),
      0 0 24px rgba(200, 241, 53, 0.7),
      0 0 60px rgba(200, 241, 53, 0.45),
      0 0 120px rgba(200, 241, 53, 0.25),
      0 18px 42px rgba(200, 241, 53, 0.2);
  }
}

.start-copy {
  max-width: 760px;
  margin: 0 auto 34px;
  color: var(--text-muted);
  font-size: clamp(19px, 2.2vw, 28px);
  line-height: 1.5;
}

.primary-action,
.secondary-action {
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  color: var(--text-main);
  cursor: pointer;
  font-weight: 850;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 24px rgba(0, 0, 0, 0.3);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.35s ease;
}

.primary-action:hover {
  transform: translateY(-2px);
  border-color: rgba(200, 241, 53, 0.6);
  box-shadow:
    -4px -3px 14px 3px rgba(180, 230, 30, 0.45),
     4px  4px 14px 3px rgba(200, 241, 53, 0.35),
    -3px -2px 30px 8px rgba(160, 210, 20, 0.25),
     5px  5px 30px 8px rgba(200, 241, 53, 0.2);
}

.secondary-action:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 12px 32px rgba(0, 0, 0, 0.4);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 200px;
  padding: 18px 40px;
  background: #c8f135;
  color: #111111;
  font-size: 24px;
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 18px;
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
}

/* ── Quiz header ── */

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.timer-card {
  --timer-progress: 0;
  --timer-progress-angle: 0deg;
  --timer-ring: rgba(205, 245, 82, 0.94);
  --timer-ring-fade: rgba(205, 245, 82, 0.46);
  --timer-ring-soft: rgba(205, 245, 82, 0.14);
  --timer-ring-glow: rgba(205, 245, 82, 0.30);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 210px;
  padding: 14px 18px 16px;
  border-radius: 24px;
  border-color: rgba(178, 210, 96, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 8px 28px rgba(0, 0, 0, 0.35),
    0 0 26px rgba(205, 245, 82, 0.08),
    0 0 52px rgba(205, 245, 82, 0.045);
}

.timer-card::before,
.timer-card::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  content: "";
  pointer-events: none;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.timer-card::before {
  z-index: 0;
  padding: 2px;
  background:
    conic-gradient(
      from -90deg,
      var(--timer-ring) 0 calc(var(--timer-progress-angle) - 10deg),
      var(--timer-ring-fade) calc(var(--timer-progress-angle) - 3deg),
      var(--timer-ring-soft) calc(var(--timer-progress-angle) + 9deg) 1turn
    );
  filter: drop-shadow(0 0 7px var(--timer-ring-glow))
    drop-shadow(0 0 22px rgba(205, 245, 82, 0.20))
    drop-shadow(0 0 42px rgba(205, 245, 82, 0.12));
}

.timer-card::after {
  z-index: 0;
  padding: 6px;
  background:
    conic-gradient(
      from calc(-102deg + var(--timer-progress-angle)),
      transparent 0 330deg,
      rgba(239, 255, 184, 0.18) 342deg,
      rgba(239, 255, 184, 0.38) 350deg,
      rgba(205, 245, 82, 0.62) 356deg,
      transparent 360deg
    );
  filter: blur(18px);
  opacity: 0.54;
}

.timer-card > * {
  position: relative;
  z-index: 1;
}

.timer-label {
  color: var(--text-muted);
  font-size: clamp(13px, 1.35vw, 17px);
  font-weight: 850;
  letter-spacing: 0;
}

.question-count {
  color: #ffffff;
  font-size: clamp(20px, 2.4vw, 32px);
  font-weight: 850;
  letter-spacing: 0;
}

.timer-value {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  transform-origin: center;
}

.flip-digit {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: clamp(36px, 4vw, 52px);
  height: clamp(58px, 6.6vw, 80px);
  font-size: clamp(48px, 5.6vw, 72px);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  color: var(--timer-color);
  line-height: 1;
}

.numeric-digit-current,
.numeric-digit-old,
.numeric-digit-new {
  display: block;
  font: inherit;
  line-height: inherit;
  font-variant-numeric: inherit;
}

.numeric-digit-old,
.numeric-digit-new {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  will-change: transform, opacity, filter;
}

.numeric-digit-old {
  animation: numeric-text-old 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.numeric-digit-new {
  animation: numeric-text-new 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes numeric-text-old {
  0% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(52%) scale(0.96);
  }
}

@keyframes numeric-text-new {
  0% {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(-52%) scale(0.96);
  }

  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

.flip-colon {
  font-size: clamp(40px, 4.8vw, 62px);
  font-weight: 950;
  color: var(--timer-color);
  line-height: 1;
  align-self: center;
  margin-bottom: 2px;
}

.timer-value.is-hot {
  filter: drop-shadow(0 0 16px rgba(255, 218, 145, 0.42));
}

.timer-value.is-faster {
  filter: drop-shadow(0 0 18px rgba(255, 218, 145, 0.52));
}

.timer-value.is-fastest {
  filter: drop-shadow(0 0 20px rgba(255, 218, 145, 0.68));
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 17px 28px;
  border-radius: 24px;
  white-space: nowrap;
}

.progress-pill span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #c8f135;
  box-shadow: 0 0 18px rgba(200, 241, 53, 0.7), 0 0 28px rgba(180, 230, 30, 0.4);
}

/* ── Nav buttons ── */

.nav-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.sparkle-button {
  position: relative;
}

.nav-btn {
  --cut: 0.1em;
  --active: 0;
  --btn-bg:
    radial-gradient(
      40% 50% at center 100%,
      hsl(54 calc(var(--active) * 98%) 75% / var(--active)),
      transparent
    ),
    radial-gradient(
      80% 100% at center 120%,
      hsl(76 calc(var(--active) * 90%) 58% / var(--active)),
      transparent
    ),
    linear-gradient(
      135deg,
      hsl(76 calc(var(--active) * 88%) calc((var(--active) * 42%) + 12%)),
      hsl(54 calc(var(--active) * 96%) calc((var(--active) * 48%) + 12%))
    );
  background: var(--btn-bg);
  min-width: 150px;
  padding: 14px 30px;
  border: 0;
  border-radius: 24px;
  font-size: clamp(15px, 1.5vw, 19px);
  font-weight: 850;
  cursor: pointer;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8em;
  position: relative;
  box-shadow:
    0 0 calc(var(--active) * 5em) calc(var(--active) * 2em) hsl(65 95% 52% / 0.75),
    0 0.05em 0 0 hsl(54 calc(var(--active) * 96%) calc((var(--active) * 55%) + 25%)) inset,
    0 -0.05em 0 0 hsl(76 calc(var(--active) * 88%) calc(var(--active) * 50%)) inset;
  transition: box-shadow 0.25s, scale 0.25s, background 0.25s;
  scale: calc(1 + (var(--active) * 0.05));
}

.nav-btn:active {
  scale: 1;
}

.nav-btn:is(:hover, :focus-visible):not(:disabled) {
  --active: 1;
  --play-state: running;
  outline: none;
}

.nav-btn:is(:hover, :focus-visible):not(:disabled) ~ .nav-particle-pen {
  --active: 1;
  --play-state: running;
}

.nav-btn:before {
  content: "";
  position: absolute;
  inset: -0.25em;
  z-index: -1;
  border: 0.25em solid hsl(65 95% 55% / 0.5);
  border-radius: 28px;
  opacity: var(--active, 0);
  transition: opacity 0.25s;
}

.nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.nav-btn:disabled .nav-spark {
  display: none;
}

/* Spinning spark border */
.nav-spark {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  rotate: 0deg;
  overflow: hidden;
  mask: linear-gradient(white, transparent 50%);
  animation: nav-spark-flip calc(var(--spark) * 2) infinite steps(2, end);
}

@keyframes nav-spark-flip {
  to { rotate: 360deg; }
}

.nav-spark:before {
  content: "";
  position: absolute;
  width: 200%;
  aspect-ratio: 1;
  top: 0%;
  left: 50%;
  z-index: -1;
  translate: -50% -15%;
  transform: rotate(-90deg);
  opacity: calc(var(--active) + 0.4);
  background: conic-gradient(from 0deg, transparent 0 340deg, white 360deg);
  transition: opacity 0.25s;
  animation: nav-spark-rotate var(--spark) linear infinite both;
}

@keyframes nav-spark-rotate {
  to { transform: rotate(90deg); }
}

.nav-spark:after {
  content: "";
  position: absolute;
  inset: var(--cut);
  border-radius: 24px;
}

/* Button interior fill */
.nav-backdrop {
  position: absolute;
  inset: var(--cut);
  background: var(--btn-bg);
  border-radius: 24px;
  transition: background 0.25s;
}

/* Sparkle icon */
.nav-sparkle {
  overflow: visible;
  width: 0.85em;
  height: 0.85em;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.nav-sparkle path {
  color: hsl(0 0% calc(var(--base) - (var(--active, 0) * calc(var(--base) - 12%))));
  transform-box: fill-box;
  transform-origin: center;
  fill: currentColor;
  stroke: currentColor;
  animation-delay: calc(0.375s + (var(--delay) * 1s));
  animation-duration: 0.6s;
  transition: color 0.25s;
}

.nav-btn:is(:hover, :focus-visible) .nav-sparkle path {
  animation-name: nav-sparkle-bounce;
}

@keyframes nav-sparkle-bounce {
  35%, 65% { scale: var(--scale); }
}

.nav-sparkle path:nth-of-type(1) { --scale: 0.5; --delay: 0.1; --base: 72%; }
.nav-sparkle path:nth-of-type(2) { --scale: 1.5; --delay: 0.2; --base: 55%; }
.nav-sparkle path:nth-of-type(3) { --scale: 2.5; --delay: 0.35; --base: 64%; }

/* Button text */
.nav-text {
  letter-spacing: 0.01ch;
  color: hsl(0 0% calc(78% - (var(--active, 0) * 67%)));
  transition: color 0.25s;
  position: relative;
  z-index: 1;
}

/* Floating particles */
.nav-particle-pen {
  position: absolute;
  width: 200%;
  aspect-ratio: 1;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  -webkit-mask: radial-gradient(white, transparent 65%);
  mask: radial-gradient(white, transparent 65%);
  z-index: -1;
  opacity: var(--active, 0);
  transition: opacity 0.25s;
  pointer-events: none;
}

.nav-particle {
  width: calc(var(--size, 0.25) * 1rem);
  aspect-ratio: 1;
  position: absolute;
  top: calc(var(--y) * 1%);
  left: calc(var(--x) * 1%);
  opacity: var(--alpha, 1);
  animation: nav-particle-float calc(var(--duration, 1) * 1s) calc(var(--delay) * -1s) infinite linear;
  transform-origin: var(--origin-x, 1000%) var(--origin-y, 1000%);
  z-index: -1;
  animation-play-state: var(--play-state, paused);
}

.nav-particle:nth-of-type(even) {
  animation-direction: reverse;
}

.nav-particle path {
  fill: hsl(60 80% 88%);
  stroke: none;
}

@keyframes nav-particle-float {
  to { rotate: 360deg; }
}

/* ── Question card ── */

.question-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  display: grid;
  gap: clamp(10px, 1.2vw, 15px);
  align-items: start;
  padding: clamp(20px, 2.8vw, 32px);
  border-radius: 30px;
  text-align: left;
}

.eyebrow {
  width: fit-content;
  justify-self: start;
  display: inline-flex;
  padding: 8px 16px;
  border-radius: 999px;
  border: 0.5px solid rgba(200, 241, 53, 0.4);
  background: linear-gradient(135deg, rgba(200, 241, 53, 0.15), rgba(160, 210, 20, 0.08));
  color: #c8f135;
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0.08em;
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  box-shadow:
    inset 0 1px 0 rgba(200, 241, 53, 0.15),
    0 0 18px rgba(200, 241, 53, 0.12);
}

.question-title {
  max-width: 980px;
  margin: 0;
  color: var(--text-main);
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 950;
  line-height: 1.16;
  letter-spacing: 0;
  text-shadow: 0 0 26px rgba(255, 255, 255, 0.18);
}

.code-block {
  width: 100%;
  max-height: none;
  overflow: visible;
  margin: 0;
  padding: 16px 20px;
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: rgba(10, 6, 20, 0.88);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 20px rgba(0, 0, 0, 0.22);
  font-family: var(--font-code);
  font-size: clamp(15px, 1.45vw, 20px);
  font-weight: 650;
  line-height: 1.62;
  letter-spacing: 0;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.code-keyword { color: #c8f135; font-weight: 800; }
.code-string  { color: #ff8fa3; font-weight: 750; }
.code-type    { color: #79c0ff; font-weight: 750; }
.code-muted   { color: #8b8ba8; }

/* ── Answer choices ── */

.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.choice-tile {
  position: relative;
  overflow: hidden;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  color: var(--text-main);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 28px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  text-align: left;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.choice-tile::before,
.choice-tile::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  border-radius: inherit;
}

.choice-tile::before {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.16), transparent 28%),
    radial-gradient(circle at 88% 10%, rgba(255, 255, 255, 0.1), transparent 30%);
  mix-blend-mode: screen;
  opacity: 0.55;
}

.choice-tile::after {
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -16px 30px rgba(255, 255, 255, 0.04);
}

.choice-tile > * {
  position: relative;
  z-index: 1;
}

.choice-tile:hover,
.choice-tile:focus-visible {
  transform: translateY(-4px);
  background: #c8f135;
  border-color: #c8f135;
  color: #111111;
  box-shadow:
    0 0 20px rgba(200, 241, 53, 0.4),
    0 14px 36px rgba(0, 0, 0, 0.25);
  outline: none;
}

.choice-tile:hover .choice-label,
.choice-tile:focus-visible .choice-label {
  background: rgba(20, 20, 20, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.choice-label {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  font-size: 27px;
  font-weight: 950;
  line-height: 1;
  color: #ffffff;
  background: rgba(20, 20, 20, 0.9);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.choice-text {
  overflow-wrap: anywhere;
  font-size: clamp(18px, 1.65vw, 24px);
  font-weight: 850;
  line-height: 1.28;
}

.choice-state {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.answer.correct {
  background: #c8f135;
  border-color: #c8f135;
  color: #111111;
  box-shadow:
    0 0 20px rgba(200, 241, 53, 0.4),
    0 14px 36px rgba(0, 0, 0, 0.25);
}

.answer.correct .choice-label {
  background: rgba(20, 20, 20, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.answer.wrong {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.12), transparent 30%),
    rgba(120, 31, 58, 0.2);
  border-color: rgba(255, 114, 160, 0.34);
}

/* ── Fill-blank notice ── */

.fill-blank-card {
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 30px;
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.3);
  text-align: center;
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
}

.fill-blank-title {
  margin: 0 0 10px;
  color: var(--text-main);
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 900;
}

.fill-blank-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(18px, 2vw, 26px);
}

/* ── Results ── */

.result-shell {
  width: min(1180px, 100%);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.result-title {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(36px, 4.8vw, 64px);
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow: 0 18px 42px rgba(200, 241, 53, 0.15);
}

.result-list {
  display: grid;
  gap: 16px;
}

.result-card {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 2.6vw, 30px);
  border-radius: 24px;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: clamp(18px, 1.8vw, 24px);
  font-weight: 800;
}

.result-question {
  margin: 0 0 14px;
  color: var(--text-main);
  font-size: clamp(18px, 2vw, 25px);
  font-weight: 850;
  line-height: 1.45;
}

.result-question .code-block {
  margin-top: 12px;
}

.result-answer {
  margin: 0 0 10px;
  color: var(--text-main);
  font-size: clamp(18px, 1.8vw, 23px);
  font-weight: 900;
}

.result-reason {
  margin: 0;
  color: var(--text-muted);
  font-size: clamp(16px, 1.55vw, 20px);
  line-height: 1.6;
}

.reference-panel {
  position: relative;
  margin-top: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.reference-content {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.reference-label {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 900;
}

.result-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 13px;
  border: 0.5px solid rgba(200, 241, 53, 0.2);
  border-radius: 999px;
  background: rgba(200, 241, 53, 0.06);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.2;
  text-decoration: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.result-link:hover,
.result-link:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(200, 241, 53, 0.4);
  background: rgba(200, 241, 53, 0.12);
  outline: none;
}

/* ── Toast ── */

.toast {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 40px;
  max-width: min(860px, calc(100vw - 32px));
  transform: translateX(-50%) translateY(110px);
  opacity: 0;
  padding: 20px 36px;
  border: 0.5px solid rgba(200, 241, 53, 0.25);
  border-radius: 999px;
  background: rgba(20, 22, 16, 0.88);
  font-size: 18px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5), 0 0 30px rgba(200, 241, 53, 0.08);
  backdrop-filter: blur(18px);
  color: var(--text-main);
  font-weight: 850;
  line-height: 1.4;
  pointer-events: none;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Error ── */

.error-card {
  max-width: 760px;
  padding: 28px;
  border: 0.5px solid rgba(255, 80, 80, 0.2);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
}

/* ── Animations ── */

.title-star {
  display: inline-block;
  margin-left: 0.2em;
  color: #FFD000;
  vertical-align: middle;
  opacity: 0;
  animation: letterPullUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) 1100ms forwards;
}

.title-star svg {
  height: 0.7em;
  width: auto;
}

.spark-1 { transform-origin: 24px 26px; animation: starTwinkle 2.8s ease-in-out 1.8s infinite; }
.spark-2 { transform-origin: 40px 54px; animation: starTwinkle 2.8s ease-in-out 2.9s infinite; }
.spark-3 { transform-origin: 72px 40px; animation: starTwinkle 2.8s ease-in-out 1.2s infinite; }

@keyframes starTwinkle {
  0%, 100% { transform: scale(1);    opacity: 1; }
  30%       { transform: scale(0.3);  opacity: 0.1; }
  55%       { transform: scale(1.25); opacity: 1;
              filter: brightness(1.3) drop-shadow(0 0 8px rgba(255, 210, 0, 0.9)); }
  72%       { transform: scale(0.95); opacity: 0.95; }
  84%       { transform: scale(1.06); opacity: 1; }
}

.letter-up {
  display: inline-block;
  opacity: 0;
  animation: letterPullUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes letterPullUp {
  from {
    transform: translateY(60%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .timer-value.is-hot { animation: none; }
  .numeric-digit-old,
  .numeric-digit-new {
    animation: none;
    filter: none;
    transform: none;
  }

  .numeric-digit-old {
    opacity: 0;
  }
}

/* ── Responsive ── */

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    place-items: start center;
    padding: 28px 18px;
  }

  .quiz-stage {
    min-height: auto;
  }

  .choices-grid {
    grid-template-columns: 1fr;
  }

  .choice-tile {
    min-height: 76px;
  }
}

@media (max-width: 560px) {
  .quiz-header,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-buttons {
    justify-content: center;
  }

  .sparkle-button {
    flex: 1;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
  }

  .timer-card {
    min-width: 0;
  }

  .progress-pill {
    width: fit-content;
  }

  .question-card {
    border-radius: 26px;
  }

  .reference-panel {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .choice-tile {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .choice-state {
    grid-column: 2;
  }
}

/* ── Music button ── */

.music-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 10;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  cursor: pointer;
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.music-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

.music-btn svg {
  width: 20px;
  height: 20px;
}

.music-btn .icon-off {
  display: none;
}

.music-btn.is-muted .icon-on {
  display: none;
}

.music-btn.is-muted .icon-off {
  display: block;
  opacity: 0.45;
}
