:root,
[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f3f5f7;
  --page-bg-secondary: #eef3f9;
  --bg: var(--page-bg);
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #f1f5fb;
  --surface-hover: #eef3ff;
  --text: #172033;
  --text-primary: #172033;
  --text-secondary: #667085;
  --text-muted: #8b95a7;
  --muted: #667085;
  --border: #dfe4ea;
  --border-strong: #cbd5e1;
  --primary: #2855d9;
  --primary-dark: #1f43ad;
  --primary-soft: #eef3ff;
  --primary-ring: rgb(40 85 217 / 14%);
  --primary-border: rgb(40 85 217 / 26%);
  --primary-hover-border: #9aabe5;
  --primary-gradient-end: #6f8ff5;
  --success: #18794e;
  --success-bg: #edf9f2;
  --success-border: #70c9a5;
  --success-text: #145c3d;
  --success-ring: rgb(24 121 78 / 10%);
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --danger-border: #ef9292;
  --danger-text: #8f1d14;
  --danger-ring: rgb(180 35 24 / 9%);
  --neutral: #475467;
  --neutral-bg: #f8fafc;
  --neutral-border: #d0d5dd;
  --star: #d99a00;
  --star-border: #f2c94c;
  --star-bg: #fff7d6;
  --star-ring: rgb(217 154 0 / 14%);
  --star-shadow: rgb(217 154 0 / 32%);
  --warning-bg: #fff8e6;
  --warning-accent: rgb(255 193 7 / 9%);
  --shadow: 0 8px 24px rgb(23 32 51 / 7%);
  --shadow-hover: 0 14px 34px rgb(23 32 51 / 11%);
  --shadow-mobile-drawer: 0 -16px 36px rgb(23 32 51 / 18%);
  --header-bg: rgb(255 255 255 / 82%);
  --glass-bg: rgb(255 255 255 / 78%);
  --placeholder: #98a2b3;
  --progress-track: #e8ecf2;
  --button-text: #ffffff;
  --button-shadow: 0 4px 12px rgb(40 85 217 / 18%);
  --button-shadow-hover: 0 7px 16px rgb(40 85 217 / 24%);
  --button-shine: rgb(255 255 255 / 44%);
  --card-glow: rgb(40 85 217 / 13%);
  --card-shine: rgb(255 255 255 / 38%);
  --ambient-cursor: rgb(40 85 217 / 8%);
  --ambient-brand: rgb(40 85 217 / 10%);
  --ambient-success: rgb(24 121 78 / 7%);
  --ambient-page-start: #f6f8fb;
  --ambient-page-end: #f5f7fa;
  --pattern-dot: rgb(40 85 217 / 24%);
  --mask-strong: #000000;
  --ripple-primary: rgb(255 255 255 / 45%);
  --ripple-soft: rgb(40 85 217 / 18%);
  --focus-ring: rgb(40 85 217 / 30%);
  --divider-muted: rgb(102 112 133 / 22%);
  --scrollbar-thumb: #c7d0df;
  --route-tile-border: rgb(255 255 255 / 18%);
  --route-tile-shine: rgb(255 255 255 / 18%);
  --route-tile-start: #1e3a8a;
  --route-tile-end: #8fb1ff;
  --route-tile-shadow: 0 20px 56px rgb(40 85 217 / 24%), inset 0 0 28px rgb(255 255 255 / 12%);
  --cursor-border: rgb(40 85 217 / 45%);
  --cursor-bg: rgb(40 85 217 / 6%);
  --cursor-border-hover: rgb(40 85 217 / 20%);
  --cursor-bg-hover: rgb(40 85 217 / 8%);
  --particle-start: rgb(40 85 217 / 16%);
  --particle-end: rgb(24 121 78 / 8%);
  --drawer-backdrop: rgb(15 23 42 / 24%);
  --radius: 14px;
  --fx-fast: 140ms;
  --fx-normal: 220ms;
  --fx-slow: 380ms;
  --fx-route: 560ms;
  --fx-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --fx-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --fx-spring: cubic-bezier(0.18, 1.35, 0.32, 1);
  --fx-x: 50vw;
  --fx-y: 50vh;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0b1020;
  --page-bg-secondary: #10172a;
  --bg: var(--page-bg);
  --surface: #151d2f;
  --surface-elevated: #192338;
  --surface-soft: #11192a;
  --surface-muted: #1d2940;
  --surface-hover: #22304a;
  --text: #edf2ff;
  --text-primary: #edf2ff;
  --text-secondary: #b2bed2;
  --text-muted: #8491a7;
  --muted: #b2bed2;
  --border: #2b3850;
  --border-strong: #3a4964;
  --primary: #6f95ff;
  --primary-dark: #93b2ff;
  --primary-soft: rgb(95 140 255 / 15%);
  --primary-ring: rgb(95 140 255 / 28%);
  --primary-border: rgb(95 140 255 / 42%);
  --primary-hover-border: #789cf7;
  --primary-gradient-end: #9db8ff;
  --success: #55d69d;
  --success-bg: rgb(28 151 98 / 14%);
  --success-border: rgb(85 214 157 / 55%);
  --success-text: #9ff0c8;
  --success-ring: rgb(85 214 157 / 18%);
  --danger: #ff7676;
  --danger-bg: rgb(210 54 54 / 15%);
  --danger-border: rgb(255 118 118 / 55%);
  --danger-text: #ffb0b0;
  --danger-ring: rgb(255 118 118 / 17%);
  --neutral: #c5cfdf;
  --neutral-bg: #11192a;
  --neutral-border: #3a4964;
  --star: #ffd76a;
  --star-border: #c99d32;
  --star-bg: rgb(247 200 89 / 13%);
  --star-ring: rgb(247 200 89 / 20%);
  --star-shadow: rgb(247 200 89 / 38%);
  --warning-bg: rgb(220 160 30 / 14%);
  --warning-accent: rgb(247 200 89 / 11%);
  --shadow: 0 16px 42px rgb(0 0 0 / 28%);
  --shadow-hover: 0 22px 58px rgb(0 0 0 / 34%);
  --shadow-mobile-drawer: 0 -18px 42px rgb(0 0 0 / 42%);
  --header-bg: rgb(13 20 37 / 82%);
  --glass-bg: rgb(21 29 47 / 78%);
  --placeholder: #8491a7;
  --progress-track: #27344d;
  --button-text: #ffffff;
  --button-shadow: 0 7px 18px rgb(75 115 255 / 22%);
  --button-shadow-hover: 0 10px 24px rgb(75 115 255 / 30%);
  --button-shine: rgb(215 226 255 / 24%);
  --card-glow: rgb(95 140 255 / 18%);
  --card-shine: rgb(185 206 255 / 13%);
  --ambient-cursor: rgb(95 140 255 / 12%);
  --ambient-brand: rgb(95 140 255 / 13%);
  --ambient-success: rgb(85 214 157 / 8%);
  --ambient-page-start: #0f172a;
  --ambient-page-end: #0d1324;
  --pattern-dot: rgb(125 162 255 / 18%);
  --mask-strong: #000000;
  --ripple-primary: rgb(255 255 255 / 24%);
  --ripple-soft: rgb(95 140 255 / 22%);
  --focus-ring: rgb(95 140 255 / 35%);
  --divider-muted: rgb(178 190 210 / 20%);
  --scrollbar-thumb: #53627b;
  --route-tile-border: rgb(173 195 255 / 20%);
  --route-tile-shine: rgb(215 226 255 / 16%);
  --route-tile-start: #15275d;
  --route-tile-end: #6f95ff;
  --route-tile-shadow: 0 22px 62px rgb(0 0 0 / 34%), inset 0 0 28px rgb(215 226 255 / 10%);
  --cursor-border: rgb(125 162 255 / 45%);
  --cursor-bg: rgb(95 140 255 / 9%);
  --cursor-border-hover: rgb(125 162 255 / 26%);
  --cursor-bg-hover: rgb(95 140 255 / 12%);
  --particle-start: rgb(95 140 255 / 14%);
  --particle-end: rgb(85 214 157 / 8%);
  --drawer-backdrop: rgb(0 0 0 / 54%);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

html.theme-transitioning,
html.theme-transitioning * {
  transition:
    background-color 240ms var(--fx-ease-out),
    color 200ms var(--fx-ease-out),
    border-color 220ms var(--fx-ease-out),
    box-shadow 220ms var(--fx-ease-out),
    fill 200ms var(--fx-ease-out),
    stroke 200ms var(--fx-ease-out) !important;
}

::selection {
  background: var(--primary-soft);
  color: var(--text);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  overflow-x: hidden;
  isolation: isolate;
}

body.drawer-open {
  overflow: hidden;
}

/* Hai lớp nền rất nhẹ tạo chiều sâu nhưng vẫn giữ cảm giác tập trung. */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -2;
  pointer-events: none;
}

body::before {
  inset: 0;
  background:
    radial-gradient(circle at var(--fx-x) var(--fx-y), var(--ambient-cursor), transparent 18rem),
    radial-gradient(circle at 12% 8%, var(--ambient-brand), transparent 28rem),
    radial-gradient(circle at 88% 78%, var(--ambient-success), transparent 30rem),
    linear-gradient(135deg, var(--ambient-page-start) 0%, var(--bg) 52%, var(--ambient-page-end) 100%);
}

body::after {
  inset: 0;
  z-index: -1;
  opacity: 0.22;
  background-image: radial-gradient(var(--pattern-dot) 0.65px, transparent 0.65px);
  background-size: 18px 18px;
  mask-image: linear-gradient(to bottom, var(--mask-strong), transparent 72%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--primary-dark);
}

a:hover {
  color: var(--primary);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

input,
select,
textarea {
  caret-color: var(--primary);
}

input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 9999s ease-out;
}

.container {
  width: min(100% - 32px, 920px);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.theme-control {
  position: relative;
  z-index: 55;
  flex: 0 0 auto;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    background var(--fx-fast) var(--fx-ease-out),
    border-color var(--fx-fast) var(--fx-ease-out),
    color var(--fx-fast) var(--fx-ease-out),
    box-shadow var(--fx-fast) var(--fx-ease-out),
    transform var(--fx-fast) var(--fx-ease-out);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--primary-border);
  background: var(--surface-hover);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.theme-toggle:active {
  transform: scale(0.97);
}

.theme-toggle-icon,
.theme-option-icon {
  display: inline-grid;
  place-items: center;
  color: currentColor;
}

.theme-toggle-icon svg,
.theme-option-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-control[data-theme-preference="dark"] .theme-toggle-icon {
  animation: theme-icon-moon 260ms var(--fx-ease-out) both;
}

.theme-control[data-theme-preference="light"] .theme-toggle-icon {
  animation: theme-icon-sun 260ms var(--fx-ease-out) both;
}

.theme-menu {
  width: min(220px, calc(100vw - 24px));
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-hover);
  transform-origin: top right;
  animation: theme-menu-enter 160ms var(--fx-ease-out) both;
}

.theme-menu button {
  width: 100%;
  min-height: 40px;
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 24px 1fr 18px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.theme-menu button:hover,
.theme-menu button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
  background: var(--surface-hover);
  color: var(--primary-dark);
}

.theme-menu button[aria-checked="true"] {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.theme-check {
  opacity: 0;
  color: var(--primary-dark);
  font-weight: 900;
}

.theme-menu button[aria-checked="true"] .theme-check {
  opacity: 1;
}

.muted {
  color: var(--muted);
}

main.container {
  flex: 1;
  padding-block: 32px 48px;
  outline: none;
}

main.view-entering {
  animation: view-enter var(--fx-slow) var(--fx-ease-out) both;
}

/* Mỗi màn hình mới xuất hiện nhẹ nhàng khi app thay nội dung. */
main > section,
main > .donate-box {
  animation: view-enter var(--fx-slow) var(--fx-ease-out) both;
}

main > section:nth-child(2) {
  animation-delay: 45ms;
}

main > section:nth-child(3),
main > .donate-box {
  animation-delay: 90ms;
}

.page-heading {
  margin-bottom: 24px;
}

.page-heading h1,
.quiz-card h2,
.question-card h2,
.result-card h2 {
  margin-top: 0;
  line-height: 1.3;
}

.page-heading h1 {
  margin-bottom: 8px;
  font-size: clamp(1.65rem, 5vw, 2.3rem);
}

.page-heading p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
}

.quiz-grid {
  display: grid;
  gap: 16px;
}

.home-tools {
  margin-bottom: 20px;
  padding: 18px;
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.home-tools label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 750;
}

.search-field {
  position: relative;
}

.search-field span {
  position: absolute;
  left: 14px;
  top: 50%;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  transform: translateY(-52%);
  pointer-events: none;
  transition: color var(--fx-fast) var(--fx-ease-out), transform var(--fx-fast) var(--fx-ease-out);
}

.search-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--fx-fast) var(--fx-ease-out), box-shadow var(--fx-fast) var(--fx-ease-out), background var(--fx-fast) var(--fx-ease-out);
}

.search-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.search-field:focus-within span {
  color: var(--primary);
  transform: translateY(-52%) translateX(2px) scale(1.04);
}

.search-field input::placeholder {
  color: var(--placeholder);
}

.category-filter {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.category-filter-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.category-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-chip {
  min-height: 36px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 750;
  position: relative;
  overflow: hidden;
  transition:
    background var(--fx-fast) var(--fx-ease-out),
    border-color var(--fx-fast) var(--fx-ease-out),
    color var(--fx-fast) var(--fx-ease-out),
    box-shadow var(--fx-fast) var(--fx-ease-out),
    transform var(--fx-fast) var(--fx-ease-out);
}

.category-chip:hover {
  border-color: var(--primary-hover-border);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.category-chip.is-active {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.category-chip strong {
  min-width: 1.7em;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.category-chip.is-active strong {
  background: var(--surface);
  color: var(--primary-dark);
}

.search-summary {
  min-height: 1.4em;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.empty-state {
  grid-column: 1 / -1;
  box-shadow: none;
}

.pagination {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 24px;
}

.pagination[hidden] {
  display: none;
}

.pagination span {
  color: var(--muted);
  white-space: nowrap;
}

.quiz-card,
.panel,
.question-card,
.result-card,
.status-card,
.donate-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.quiz-card,
.donate-box {
  background: var(--surface);
}

.panel,
.question-card,
.result-card,
.status-card {
  background: var(--surface-elevated);
}

.quiz-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  animation: card-enter var(--fx-slow) var(--fx-ease-out) both;
  transform: translateY(0) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transform-style: preserve-3d;
  transition: transform var(--fx-normal) var(--fx-ease-out), box-shadow var(--fx-normal) var(--fx-ease-out), border-color var(--fx-normal) var(--fx-ease-out);
}

.quiz-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  opacity: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary-gradient-end));
  transition: opacity var(--fx-normal) var(--fx-ease-out);
}

.quiz-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--local-x, 50%) var(--local-y, 50%), var(--card-glow), transparent 13rem),
    linear-gradient(115deg, transparent 18%, var(--card-shine), transparent 38%);
  transform: translateX(-20%);
  transition: opacity var(--fx-normal) var(--fx-ease-out), transform 520ms var(--fx-ease-out);
}

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

.quiz-card:nth-child(2) {
  animation-delay: 70ms;
}

.quiz-card:nth-child(3) {
  animation-delay: 140ms;
}

.quiz-card:nth-child(4) {
  animation-delay: 210ms;
}

.quiz-card:hover {
  transform: translateY(-4px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  border-color: var(--primary-hover-border);
  box-shadow: var(--shadow-hover);
}

.quiz-card:hover::before,
.quiz-card:hover::after {
  opacity: 1;
}

.quiz-card:hover::after {
  transform: translateX(0);
}

.quiz-card h2 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.category-badge {
  margin-bottom: 12px;
  padding: 4px 9px;
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
}

.quiz-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.quiz-meta,
.history-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-row {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-soft);
  border-radius: 9px;
}

.quiz-card .button {
  margin-top: auto;
}

.panel,
.question-card,
.result-card {
  padding: clamp(20px, 5vw, 32px);
}

.start-details {
  margin: 20px 0;
  padding: 14px 16px;
  background: var(--surface-soft);
  border-radius: 10px;
  color: var(--muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0;
  cursor: pointer;
  opacity: 0;
  animation: view-enter var(--fx-slow) var(--fx-ease-out) both;
}

.check-row:nth-child(1) {
  animation-delay: 80ms;
}

.check-row:nth-child(2) {
  animation-delay: 130ms;
}

.quiz-settings {
  display: grid;
  gap: 13px;
  margin: 22px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.check-row input {
  width: 19px;
  height: 19px;
  accent-color: var(--primary);
  transition: box-shadow var(--fx-fast) var(--fx-ease-out), transform var(--fx-fast) var(--fx-ease-out);
}

.check-row input:checked {
  transform: scale(1.06);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.button {
  min-height: 44px;
  padding: 10px 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--primary);
  color: var(--button-text);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--button-shadow);
  --mag-x: 0px;
  --mag-y: 0px;
  --press-scale: 1;
  transform: translate3d(var(--mag-x), var(--mag-y), 0) scale(var(--press-scale));
  transition: background var(--fx-fast) var(--fx-ease-out), transform var(--fx-fast) var(--fx-ease-out), box-shadow var(--fx-fast) var(--fx-ease-out), border-color var(--fx-fast) var(--fx-ease-out);
}

.button::before {
  content: "";
  position: absolute;
  inset: -55% -95%;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, var(--button-shine), transparent 60%);
  transform: translateX(-70%) rotate(8deg);
  transition: transform 620ms var(--fx-ease-out);
}

.button:hover {
  background: var(--primary-dark);
  box-shadow: var(--button-shadow-hover);
  --press-scale: 1.015;
}

.button:hover::before {
  transform: translateX(72%) rotate(8deg);
}

.button:active {
  --press-scale: 0.97;
}

.button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
}

.button.secondary:hover {
  background: var(--surface-soft);
}

.button.danger {
  background: var(--danger);
}

.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  --press-scale: 1;
}

.button.fx-pressed {
  animation: button-release 520ms var(--fx-spring);
}

.ripple {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  border-radius: 50%;
  background: var(--ripple-primary);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple-pop 620ms var(--fx-ease-out);
}

.button.secondary .ripple,
.answer-option .ripple,
.filter-chip .ripple,
.category-chip .ripple,
.mark-question-button .ripple {
  background: var(--ripple-soft);
}

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.quiz-topbar strong {
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.question-counter {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}

.mark-question-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  overflow: hidden;
  transition: background var(--fx-fast) var(--fx-ease-out), border-color var(--fx-fast) var(--fx-ease-out), color var(--fx-fast) var(--fx-ease-out), box-shadow var(--fx-fast) var(--fx-ease-out), transform var(--fx-fast) var(--fx-ease-out);
}

.mark-question-button:hover,
.mark-question-button:focus-visible {
  border-color: var(--star-border);
  background: var(--star-bg);
  color: var(--star);
}

.mark-question-button.is-marked {
  border-color: var(--star-border);
  background: var(--star-bg);
  color: var(--star);
  animation: star-pop 360ms var(--fx-spring) both;
  box-shadow: 0 0 0 4px var(--star-ring);
}

.mark-question-button:active {
  transform: scale(0.97);
}

.progress {
  width: 100%;
  height: 9px;
  margin-bottom: 24px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--progress-track);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-gradient-end), var(--primary));
  background-size: 200% 100%;
  animation: progress-glow 2.8s ease-in-out infinite;
  transform-origin: left;
  transition: width var(--fx-normal) var(--fx-ease-out), transform var(--fx-normal) var(--fx-ease-out);
}

.question-text {
  margin-bottom: 20px;
  font-size: clamp(1.08rem, 3vw, 1.3rem);
  animation: question-copy-enter 0.2s 30ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.answers {
  display: grid;
  gap: 11px;
  border: 0;
  padding: 0;
  margin: 0;
}

.answer-option {
  min-height: 54px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: answer-enter var(--fx-normal) var(--fx-ease-out) both;
  transition: border-color var(--fx-fast) var(--fx-ease-out), background var(--fx-fast) var(--fx-ease-out), transform var(--fx-fast) var(--fx-ease-out), box-shadow var(--fx-fast) var(--fx-ease-out), color var(--fx-fast) var(--fx-ease-out);
}

.answer-option:nth-child(1) { animation-delay: 80ms; }
.answer-option:nth-child(2) { animation-delay: 125ms; }
.answer-option:nth-child(3) { animation-delay: 170ms; }
.answer-option:nth-child(4) { animation-delay: 215ms; }

.answer-option:hover {
  border-color: var(--primary-hover-border);
  transform: translateX(2px);
  box-shadow: 0 4px 14px var(--primary-ring);
}

.answer-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-ring);
  animation: answer-selected 320ms var(--fx-ease-out) both;
}

.answer-option:has(input:disabled) {
  cursor: default;
}

.answer-option.correct-answer,
.answer-option.correct-answer:has(input:checked) {
  border-color: var(--success-border);
  background: var(--success-bg);
  box-shadow: 0 0 0 3px var(--success-ring);
}

.answer-option.wrong-answer,
.answer-option.wrong-answer:has(input:checked) {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  box-shadow: 0 0 0 3px var(--danger-ring);
  animation: answer-shake 240ms var(--fx-ease-in-out) both;
}

.answer-copy {
  flex: 1 1 auto;
}

.answer-state-icon {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 900;
  transform-origin: center;
  animation: icon-pop 280ms var(--fx-spring) both;
}

.correct-answer .answer-state-icon {
  background: var(--success-bg);
  color: var(--success);
}

.wrong-answer .answer-state-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.instant-feedback {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  animation: feedback-enter 320ms var(--fx-ease-out) both;
}

.instant-feedback::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: currentColor;
  transform-origin: top;
  animation: accent-draw 320ms var(--fx-ease-out) both;
}

.instant-feedback p {
  margin: 7px 0 0;
}

.instant-feedback.feedback-correct {
  border-left-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.instant-feedback.feedback-incorrect {
  border-left-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.answer-option input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--primary);
}

.answer-letter {
  font-weight: 800;
}

.quiz-layout {
  width: min(1160px, calc(100vw - 32px));
  margin-left: 50%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 22px;
  transform: translateX(-50%);
}

.question-picker {
  width: 100%;
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: sidebar-enter 320ms var(--fx-ease-out) both;
}

.question-picker-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.question-picker-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.question-picker-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.question-picker-close {
  display: none;
}

.picker-progress {
  height: 7px;
  margin-bottom: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--progress-track);
}

.picker-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width var(--fx-normal) var(--fx-ease-out);
}

.question-picker-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.filter-chip {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  transition: background var(--fx-fast) var(--fx-ease-out), border-color var(--fx-fast) var(--fx-ease-out), color var(--fx-fast) var(--fx-ease-out), box-shadow var(--fx-fast) var(--fx-ease-out), transform var(--fx-fast) var(--fx-ease-out);
}

.filter-chip:hover {
  border-color: var(--primary-hover-border);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.filter-chip.is-active {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.question-picker-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.question-picker-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend-dot.answered {
  border: 1px solid var(--success-border);
  background: var(--success-bg);
}

.legend-dot.unanswered {
  border: 1px solid var(--neutral-border);
  background: var(--neutral-bg);
}

.legend-dot.correct {
  border: 1px solid var(--success-border);
  background: var(--success-bg);
}

.legend-dot.incorrect {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
}

.legend-star {
  color: var(--star);
  font-size: 0.9rem;
  line-height: 1;
}

.question-picker-grid {
  min-height: 0;
  padding: 2px 2px 2px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
  display: grid;
  grid-template-columns: repeat(5, minmax(40px, 1fr));
  gap: 8px;
}

.question-picker-grid::-webkit-scrollbar {
  width: 7px;
}

.question-picker-grid::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--scrollbar-thumb);
}

.question-picker-grid::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

.question-picker-empty {
  grid-column: 1 / -1;
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.question-picker-item {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 750;
  cursor: pointer;
  position: relative;
  transition: transform var(--fx-fast) var(--fx-ease-out), box-shadow var(--fx-fast) var(--fx-ease-out), border-color var(--fx-normal) var(--fx-ease-out), background var(--fx-normal) var(--fx-ease-out), color var(--fx-normal) var(--fx-ease-out);
}

.question-picker-item.status-answered {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.question-picker-item.status-unanswered {
  border-color: var(--neutral-border);
  background: var(--neutral-bg);
  color: var(--neutral);
}

.question-picker-item.status-correct {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.question-picker-item.status-incorrect {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.question-picker-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px var(--primary-ring);
}

.question-picker-item.is-current {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--primary);
  animation-name: picker-current-pulse;
  animation-duration: 360ms;
  animation-timing-function: var(--fx-ease-out);
}

.question-picker-item:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.picker-number {
  line-height: 1;
}

.picker-star {
  position: absolute;
  top: 2px;
  right: 4px;
  color: var(--star);
  font-size: 0.68rem;
  line-height: 1;
  text-shadow: 0 1px 1px var(--surface);
  animation: star-pop 360ms var(--fx-spring) both;
}

.question-picker-item.is-marked {
  box-shadow: inset 0 0 0 1px var(--star-ring);
}

.question-picker-item.is-current.is-marked {
  box-shadow:
    inset 0 0 0 1px var(--star-ring),
    0 0 0 2px var(--surface),
    0 0 0 5px var(--primary);
}

.mobile-picker-toggle,
.question-picker-backdrop {
  display: none;
}

.question-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 26px;
  animation: nav-enter 0.2s 120ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.question-card.is-next {
  animation: question-next 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.question-card.is-previous {
  animation: question-previous 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.question-card.is-direct {
  animation: question-direct var(--fx-normal) var(--fx-ease-out) both;
}

.question-card.is-stay {
  animation: feedback-view-enter 0.18s ease-out both;
}

.question-nav .right-actions {
  display: flex;
  gap: 10px;
}

.score-block {
  margin: 18px 0 24px;
  padding: 20px;
  text-align: center;
  border-radius: 12px;
  background: var(--surface-soft);
}

.score-number {
  display: block;
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 800;
  line-height: 1.1;
  animation: score-pop 0.48s 0.12s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.score-percent {
  color: var(--primary);
  font-weight: 800;
}

.result-list {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

.result-item {
  padding: 18px;
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 11px;
  animation: result-enter 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.result-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.result-item:nth-child(2) { animation-delay: 50ms; }
.result-item:nth-child(3) { animation-delay: 100ms; }
.result-item:nth-child(4) { animation-delay: 150ms; }
.result-item:nth-child(5) { animation-delay: 200ms; }
.result-item:nth-child(n + 6) { animation-delay: 250ms; }

.donate-box {
  position: relative;
  overflow: hidden;
}

.donate-box::after {
  content: "";
  position: absolute;
  width: 130px;
  height: 130px;
  right: -55px;
  bottom: -72px;
  border-radius: 50%;
  background: var(--warning-accent);
}

.result-item.correct {
  border-left-color: var(--success);
  background: var(--success-bg);
}

.result-item.incorrect {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.result-item h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.result-item p {
  margin: 6px 0;
}

.result-status {
  font-weight: 800;
}

.correct .result-status {
  color: var(--success);
}

.incorrect .result-status {
  color: var(--danger);
}

.explanation {
  margin-top: 12px !important;
  padding-top: 12px;
  border-top: 1px solid var(--divider-muted);
}

.donate-box {
  margin-top: 26px;
  padding: 20px;
  background: var(--warning-bg);
}

.donate-box p {
  margin: 0 0 12px;
}

.donate-box a {
  color: var(--primary-dark);
  font-weight: 700;
}

.support-links {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: start;
  gap: 9px;
}

.support-links a {
  overflow-wrap: anywhere;
}

.support-links a:hover {
  color: var(--primary);
}

.ad-popup {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(6 10 24 / 62%);
  backdrop-filter: blur(8px);
  animation: ad-popup-enter 180ms ease-out;
}

.ad-popup-panel {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgb(0 0 0 / 34%);
}

.ad-popup-link {
  display: block;
  background: #ffffff;
}

.ad-popup-link img {
  display: block;
  width: 100%;
  max-height: min(72vh, 430px);
  object-fit: contain;
  background: #ffffff;
}

.ad-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgb(15 23 42 / 82%);
  color: #ffffff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 26px rgb(0 0 0 / 26%);
}

.ad-popup-close:hover,
.ad-popup-close:focus-visible {
  background: rgb(15 23 42 / 94%);
  transform: translateY(-1px);
}

.status-card {
  padding: 34px;
  text-align: center;
}

.status-card.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.status-card p {
  margin: 8px 0;
}

.spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto 12px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.site-footer {
  padding: 22px 0;
  border-top: 1px solid var(--border);
  background: var(--header-bg);
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.fx-route-leaving main,
.fx-route-leaving .site-header,
.fx-route-leaving .site-footer {
  pointer-events: none;
  animation: page-depart 280ms var(--fx-ease-in-out) both;
}

.route-curtain {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}

.route-curtain.is-leaving,
.route-curtain.is-entering {
  opacity: 1;
}

.route-tile {
  position: absolute;
  top: var(--tile-top);
  left: -36vmax;
  width: var(--tile-size);
  height: var(--tile-size);
  border: 1px solid var(--route-tile-border);
  border-radius: 18%;
  background:
    linear-gradient(135deg, var(--route-tile-shine), transparent 36%),
    linear-gradient(135deg, var(--route-tile-start) 0%, var(--primary) 48%, var(--route-tile-end) 100%);
  box-shadow: var(--route-tile-shadow);
  opacity: 0;
  transform: translate3d(-12vw, 0, 0) rotate(-10deg) scale(0.92);
}

.route-curtain.is-leaving .route-tile {
  animation: square-sweep-leave var(--fx-route) var(--fx-ease-in-out) both;
  animation-delay: var(--tile-delay);
}

.route-curtain.is-entering .route-tile {
  animation: square-sweep-enter 460ms var(--fx-ease-out) both;
  animation-delay: var(--tile-delay);
}

.cursor-orb {
  position: fixed;
  z-index: 15;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  pointer-events: none;
  border: 1px solid var(--cursor-border);
  border-radius: 999px;
  background: var(--cursor-bg);
  opacity: 0;
  transform: translate3d(-50%, -50%, 0);
  transition: width var(--fx-normal) var(--fx-ease-out), height var(--fx-normal) var(--fx-ease-out), opacity var(--fx-fast) var(--fx-ease-out), border-color var(--fx-fast) var(--fx-ease-out), background var(--fx-fast) var(--fx-ease-out);
}

.cursor-orb.is-active {
  opacity: 1;
}

body:has(.button:hover, .quiz-card:hover) .cursor-orb {
  width: 42px;
  height: 42px;
  border-color: var(--cursor-border-hover);
  background: var(--cursor-bg-hover);
}

.fx-particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.fx-particle {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--particle-start), var(--particle-end));
  opacity: 0;
  animation: particle-float var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.hide-ambient-fx .fx-particles,
.hide-ambient-fx .cursor-orb,
body.is-hidden .fx-particles,
body.is-hidden .cursor-orb {
  display: none;
}

@keyframes theme-menu-enter {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes theme-icon-sun {
  from {
    opacity: 0.75;
    transform: rotate(-18deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

@keyframes theme-icon-moon {
  from {
    opacity: 0.75;
    transform: rotate(14deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes page-depart {
  to {
    opacity: 0.62;
    filter: blur(3px);
    transform: scale(0.985);
  }
}

@keyframes view-enter {
  from {
    opacity: 0;
    filter: blur(3px);
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

@keyframes card-enter {
  from {
    opacity: 0;
    filter: blur(3px);
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes result-enter {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes score-pop {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes progress-glow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes question-next {
  from {
    opacity: 0;
    transform: translateX(16px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes question-previous {
  from {
    opacity: 0;
    transform: translateX(-16px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes question-direct {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes question-copy-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes answer-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes nav-enter {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes feedback-enter {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes feedback-view-enter {
  from { opacity: 0.82; }
  to { opacity: 1; }
}

@keyframes button-release {
  0% { transform: translate3d(var(--mag-x), var(--mag-y), 0) scale(0.97); }
  55% { transform: translate3d(var(--mag-x), var(--mag-y), 0) scale(1.025); }
  100% { transform: translate3d(var(--mag-x), var(--mag-y), 0) scale(var(--press-scale)); }
}

@keyframes ripple-pop {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(18);
  }
}

@keyframes ad-popup-enter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes answer-selected {
  0% { box-shadow: 0 0 0 0 var(--primary-ring); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 3px var(--primary-ring); }
}

@keyframes answer-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  55% { transform: translateX(2px); }
  80% { transform: translateX(-1px); }
}

@keyframes icon-pop {
  from {
    opacity: 0;
    transform: scale(0.62) rotate(-8deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes accent-draw {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

@keyframes sidebar-enter {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes picker-item-enter {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes status-pop {
  0% { transform: scale(1); }
  55% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

@keyframes picker-current-pulse {
  0% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 2px transparent; }
  100% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--primary); }
}

@keyframes star-pop {
  0% {
    filter: drop-shadow(0 0 0 transparent);
    transform: scale(0.72) rotate(-10deg);
  }
  55% {
    filter: drop-shadow(0 0 8px var(--star-shadow));
    transform: scale(1.15) rotate(5deg);
  }
  100% {
    filter: drop-shadow(0 0 0 transparent);
    transform: scale(1) rotate(0);
  }
}

@keyframes square-sweep-leave {
  0% {
    opacity: 0;
    transform: translate3d(-18vw, 0, 0) rotate(-12deg) scale(0.86);
  }
  18%, 62% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate3d(132vw, 0, 0) rotate(14deg) scale(1);
  }
}

@keyframes square-sweep-enter {
  0% {
    opacity: 1;
    transform: translate3d(38vw, 0, 0) rotate(5deg) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translate3d(136vw, 0, 0) rotate(16deg) scale(0.94);
  }
}

@keyframes particle-float {
  0% {
    opacity: 0;
    transform: translate3d(var(--x), 105vh, 0) scale(0.8);
  }
  14%, 72% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--x) + var(--drift)), -10vh, 0) scale(1.1);
  }
}

@media (min-width: 680px) {
  .quiz-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .container {
    width: min(100% - 24px, 920px);
  }

  main.container {
    padding-top: 22px;
  }

  .question-nav,
  .question-nav .right-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .question-nav {
    grid-template-columns: 1fr;
  }

  .question-nav .button,
  .button-row .button {
    flex: 1 1 100%;
  }

  .ad-popup {
    padding: 14px;
  }

  .ad-popup-panel {
    width: min(100%, 420px);
  }

  .ad-popup-close {
    width: 38px;
    height: 38px;
    font-size: 1.5rem;
  }

  .quiz-card:hover {
    transform: none;
  }

  .answer-option:hover {
    transform: none;
  }

  .question-picker-item:hover {
    transform: none;
  }

  .result-item:hover {
    transform: none;
  }

  .home-tools {
    padding: 14px;
  }

  .pagination {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .pagination span {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
  }
}

@media (max-width: 1080px) {
  .quiz-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .question-picker-grid {
    grid-template-columns: repeat(5, minmax(36px, 1fr));
  }
}

@media (max-width: 820px) {
  .quiz-layout {
    width: 100%;
    margin-left: 0;
    grid-template-columns: minmax(0, 1fr);
    transform: none;
    padding-bottom: 72px;
  }

  .question-picker {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 30;
    max-height: min(78vh, 620px);
    width: 100%;
    padding: 18px;
    border-radius: 18px 18px 0 0;
    box-shadow: var(--shadow-mobile-drawer);
    transform: translateY(105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--fx-normal) var(--fx-spring), visibility 0s linear var(--fx-normal);
  }

  .question-picker.is-open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .question-picker-close {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
  }

  .question-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    background: var(--drawer-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--fx-fast) var(--fx-ease-out);
  }

  .question-picker-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .question-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    justify-content: start;
    gap: 8px;
  }

  .mobile-picker-toggle {
    min-height: 44px;
    padding: 10px 14px;
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 14px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--primary-border);
    border-radius: 999px;
    background: var(--primary);
    color: var(--button-text);
    box-shadow: var(--button-shadow-hover);
    cursor: pointer;
    font-weight: 800;
  }

  .mobile-picker-toggle:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
  }
}

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

  body::before {
    background:
      radial-gradient(circle at 12% 8%, var(--ambient-brand), transparent 28rem),
      linear-gradient(135deg, var(--ambient-page-start) 0%, var(--bg) 52%, var(--ambient-page-end) 100%);
  }

  .route-curtain,
  .cursor-orb,
  .fx-particles,
  .ripple {
    display: none !important;
  }

  .question-picker {
    transition: none !important;
  }
}

@media (pointer: coarse) {
  .cursor-orb {
    display: none;
  }

  .quiz-card,
  .quiz-card:hover {
    transform: none;
  }
}
