/* Shared base styles */

/* Register --progress for animation support in conic-gradient */
@property --progress {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

:root {
  /* Colors */
  --color-text: #1c2430;
  --color-text-strong: #101827;
  --color-text-muted: #5d6878;
  --color-bg: #fff8ed;
  --color-brand: #123f7a;
  --color-brand-dark: #092a56;
  --color-brand-soft: #dbeafe;
  --color-accent: #c94236;
  --color-reward: #f2b84b;
  --color-reward-dark: #b7791f;
  --color-reward-deep: #80540e;
  --color-jade: #178f86;
  --color-jade-dark: #0e625c;
  --color-jade-soft: #d9f3ee;
  --color-success: #2e9f6e;
  --color-success-strong: #1f7a54;
  --color-error: #c92f45;
  --color-error-soft: #ffe1e7;

  /* Class Colors */
  --color-class-middle: #2e9f6e;
  --color-class-middle-dark: #1f7a54;
  --color-class-middle-foreground: #101827;
  --color-class-middle-foreground-hover: #ffffff;
  --color-class-high: #f2b84b;
  --color-class-high-dark: #b7791f;
  --color-class-high-foreground: #101827;
  --color-class-high-foreground-hover: #101827;
  --color-class-low: #2f80c9;
  --color-class-low-dark: #1b5f99;
  --color-class-low-foreground: #06111f;
  --color-class-low-foreground-hover: #ffffff;

  /* Surfaces */
  --color-surface: #fffdf8;
  --color-surface-soft: #fff3df;
  --color-surface-light: #fffaf1;
  --color-surface-muted: #eadcc8;
  --color-success-fade: #dff5e9;
  --color-success-mid: #bee8d2;

  /* Derived theme colors kept as plain values for iOS 15 WKWebView support. */
  --color-focus-ring: #a46212;
  --color-surface-card: #fffdf8;
  --color-surface-card-bright: #fffdf9;
  --color-brand-soft-wash: #e5f0fe;
  --color-brand-border: #aebed2;
  --color-brand-border-soft: #b8c5d7;
  --color-brand-muted: #7690b2;
  --color-brand-deep: #10376b;
  --color-brand-deeper: #113a70;
  --color-brand-dark-deep: #072247;
  --color-brand-dark-muted: #70839d;
  --color-brand-reward: #2d4e74;
  --color-brand-reward-soft: #636b69;
  --color-reward-wash: #fcf1db;
  --color-reward-soft: #fbebcd;
  --color-reward-mid: #f9e0b0;
  --color-reward-brand: #867e62;
  --color-reward-brand-strong: #98885e;
  --color-reward-jade: #89a467;
  --color-jade-wash: #edf9f7;
  --color-jade-wash-soft: #f1fbf9;
  --color-jade-muted: #bee0dd;
  --color-jade-mid: #99ceca;

  /* Effects */
  --shadow-soft: 0 12px 28px rgba(18, 63, 122, 0.12);
  --shadow-card: 0 8px 18px rgba(28, 36, 48, 0.1);
  --shadow-button: 0 10px 22px rgba(18, 63, 122, 0.18);
  --shadow-reward: 0 10px 22px rgba(242, 184, 75, 0.24);
  --radius-card: 16px;
  --radius-control: 12px;
  --radius-pill: 999px;
  --border-soft: 1px solid rgba(18, 63, 122, 0.12);

  /* Fonts */
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: var(--font-main);
  --font-thai-sarabun: 'ThaiQuest Sarabun', sans-serif;
  --font-thai-kanit: 'ThaiQuest Kanit', sans-serif;
  --font-thai-prompt: 'ThaiQuest Prompt', sans-serif;
  --font-thai-kodchasan: 'ThaiQuest Kodchasan', sans-serif;
  --font-thai-mitr: 'ThaiQuest Mitr', sans-serif;

  /* Product type scale */
  --type-2xs: 0.68rem;
  --type-xs: 0.75rem;
  --type-sm: 0.875rem;
  --type-md: 1rem;
  --type-lg: 1.125rem;
  --type-xl: 1.35rem;
  --type-2xl: 1.75rem;
  --type-3xl: 2.15rem;
  --type-4xl: 2.75rem;
  --type-micro: var(--type-2xs);
  --type-caption: var(--type-sm);
  --type-body: var(--type-md);
  --type-body-lg: var(--type-lg);
  --type-action-sm: var(--type-sm);
  --type-action: var(--type-md);
  --type-action-lg: var(--type-lg);
  --type-stat-label: var(--type-xs);
  --type-stat-value: var(--type-xl);
  --type-title-sm: var(--type-xl);
  --type-title-md: var(--type-2xl);
  --type-title-lg: var(--type-3xl);
  --type-display: var(--type-4xl);
  --type-overlay-result: clamp(3.5rem, 13vw, 5rem);

  /* Spacing */
  --page-padding: 2em;
  --spacing-xs: 0.25em;
  --spacing-sm: 0.5em;
  --spacing-md: 1em;
  --spacing-lg: 1.5em;
  --spacing-xl: 2em;
}

@font-face {
  font-family: 'ThaiQuest Sarabun';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/asset/fonts/SarabunLoopless.woff2') format('woff2');
}

@font-face {
  font-family: 'ThaiQuest Kanit';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/asset/fonts/KanitRounded.woff2') format('woff2');
}

@font-face {
  font-family: 'ThaiQuest Prompt';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/asset/fonts/PromptModern.woff2') format('woff2');
}

@font-face {
  font-family: 'ThaiQuest Kodchasan';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/asset/fonts/KodchasanCreative.woff2') format('woff2');
}

@font-face {
  font-family: 'ThaiQuest Mitr';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/asset/fonts/MitrSoft.woff2') format('woff2');
}

body {
  --page-padding: var(--spacing-xl);
  font-family: var(--font-main);
  text-align: center;
  background:
    radial-gradient(circle at 18% 8%, rgba(242, 184, 75, 0.13), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(23, 143, 134, 0.12), transparent 24rem),
    linear-gradient(180deg, var(--color-bg) 0%, #fffdf8 58%, #f7ead6 100%);
  padding: calc(var(--page-padding) + env(safe-area-inset-top, 0px))
    calc(var(--page-padding) + env(safe-area-inset-right, 0px))
    calc(var(--page-padding) + env(safe-area-inset-bottom, 0px))
    calc(var(--page-padding) + env(safe-area-inset-left, 0px));
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  color: var(--color-text);
}

/* Legal pages layout */
body.legal {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  text-align: left;
  line-height: 1.7;
  box-sizing: border-box;
}

body.legal main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  box-sizing: border-box;
}

body.legal h1 {
  font-size: clamp(1.8em, 4vw, 2.4em);
  margin-bottom: 0.6em;
}

body.legal h2 {
  margin-top: 1.8em;
  font-size: clamp(1.25em, 3vw, 1.6em);
}

body.legal p,
body.legal li {
  font-size: clamp(1em, 2.6vw, 1.05em);
  color: var(--color-text-strong);
}

@media (max-width: 600px) {
  body.legal {
    padding: var(--spacing-xl) 1.25em 2.5em;
  }
}

/* Lightweight loader */
.loading {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: 600;
  opacity: 0.9;
}

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

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

@keyframes logoPop {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }

  40% {
    transform: scale(1.15) rotate(2deg);
    filter: brightness(1.2);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.tq-logo.tq-logo-animating {
  animation: logoPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

h1 {
  color: var(--color-text);
}

.subtitle {
  opacity: 0.9;
}

/* Modern app header */
.app-header {
  margin: 0 auto 0;
  max-width: 1120px;
  width: 100%;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8em;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0.85em 1.4em;
  background: rgba(255, 253, 248, 0.88);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  box-sizing: border-box;
  position: relative;
  z-index: 2;
}

.lang-fab {
  position: absolute;
  top: 16px;
  left: 16px;
  right: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
}

.account-actions-fab {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
}

.lang-switcher-btn,
.account-actions-toggle {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-bottom: 3px solid rgba(183, 121, 31, 0.44);
  border-radius: 10px !important;
  padding: 0;
  color: var(--color-brand-dark);
  font-size: 1.2rem;
  line-height: 1;
  box-shadow:
    0 12px 22px rgba(128, 84, 14, 0.14),
    inset 0 1px 0 rgba(255, 253, 248, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0) 46%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 243, 223, 0.96));
  box-sizing: border-box;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.lang-switcher-btn:hover,
.lang-switcher-btn:focus-visible,
.lang-switcher-btn[aria-expanded='true'],
.account-actions-toggle:hover,
.account-actions-toggle:focus-visible,
.account-actions-toggle[aria-expanded='true'] {
  border-color: rgba(183, 121, 31, 0.42);
  border-bottom-color: var(--color-reward-deep);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0) 48%),
    linear-gradient(180deg, rgba(255, 248, 237, 0.98), rgba(251, 235, 205, 0.96));
  box-shadow:
    0 15px 28px rgba(128, 84, 14, 0.18),
    inset 0 1px 0 rgba(255, 253, 248, 0.94);
  transform: translateY(-1px);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  left: 0;
  right: auto;
  min-width: 190px;
  padding: 0.55rem;
  display: none;
  gap: 0.45rem;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-bottom: 4px solid rgba(183, 121, 31, 0.4);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(255, 243, 223, 0.97)), var(--color-surface-soft);
  box-shadow:
    0 18px 36px rgba(128, 84, 14, 0.16),
    inset 0 1px 0 rgba(255, 253, 248, 0.92);
  box-sizing: border-box;
  z-index: 1200;
}

.lang-menu.is-open {
  display: flex;
  flex-direction: column;
}

.lang-menu button,
body.home .account-actions-menu .btn-accent {
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 0.62rem 0.72rem;
  border: 1px solid rgba(183, 121, 31, 0.22);
  border-bottom: 3px solid rgba(183, 121, 31, 0.3);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(255, 248, 237, 0.92));
  color: var(--color-brand-dark);
  box-shadow: 0 6px 12px rgba(128, 84, 14, 0.07);
  box-sizing: border-box;
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1.18;
  white-space: nowrap;
  overflow-wrap: normal;
}

.lang-menu-row {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr) 1.15rem;
  align-items: center;
  gap: 0.62rem;
  width: 100%;
}

.account-action-row {
  display: block;
  width: 100%;
  min-width: 0;
}

.lang-menu-mark {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 6px;
  background: rgba(183, 121, 31, 0.13);
  color: var(--color-brand-dark);
  box-shadow: inset 0 0 0 1px rgba(183, 121, 31, 0.12);
  font-size: var(--type-2xs);
  font-weight: 950;
  letter-spacing: 0.03em;
  line-height: 1;
}

.lang-menu-name,
.account-action-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-menu-check {
  justify-self: end;
  color: var(--color-reward-deep);
  font-weight: 950;
}

.lang-menu button:hover,
.lang-menu button:focus-visible,
body.home .account-actions-menu .btn-accent:hover,
body.home .account-actions-menu .btn-accent:focus-visible {
  border-color: rgba(183, 121, 31, 0.34);
  border-bottom-color: var(--color-reward-deep);
  background: linear-gradient(180deg, rgba(255, 248, 237, 0.98), rgba(251, 235, 205, 0.96));
  box-shadow: 0 10px 18px rgba(128, 84, 14, 0.14);
  transform: translateY(-1px);
}

.lang-menu button.is-active {
  border-color: rgba(183, 121, 31, 0.38);
  border-bottom-color: var(--color-reward-deep);
  background: linear-gradient(180deg, rgba(255, 248, 237, 0.99), rgba(251, 235, 205, 0.96)), var(--color-reward-soft);
  color: var(--color-brand-dark);
}

.account-actions-toggle {
  font-size: 1rem;
}

.lang-switcher-glyph {
  display: inline-grid;
  place-items: center;
  min-width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  background: rgba(183, 121, 31, 0.13);
  box-shadow: inset 0 0 0 1px rgba(183, 121, 31, 0.12);
}

.lang-switcher-code {
  color: currentColor;
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  line-height: 1;
}

.account-actions-glyph {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.account-actions-glyph span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.account-actions-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  min-width: 220px;
  padding: 0.55rem;
  display: none;
  gap: 0.45rem;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-bottom: 4px solid rgba(183, 121, 31, 0.4);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(255, 243, 223, 0.97)), var(--color-surface-soft);
  box-shadow:
    0 18px 36px rgba(128, 84, 14, 0.16),
    inset 0 1px 0 rgba(255, 253, 248, 0.92);
  box-sizing: border-box;
  z-index: 1200;
}

.account-actions-menu.is-open {
  display: flex;
  flex-direction: column;
}

.account-actions-menu[hidden],
.account-actions-menu [hidden] {
  display: none !important;
}

@media (max-width: 480px) {
  .lang-fab {
    top: 12px;
    left: 12px;
    right: auto;
  }

  .account-actions-fab {
    top: 12px;
    right: 12px;
  }

  .lang-switcher-btn,
  .account-actions-toggle {
    width: 44px;
    height: 44px;
  }
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  color: var(--color-brand);
}

.brand-logo {
  height: clamp(96px, 20vw, 176px);
  width: auto;
  display: block;
  object-fit: contain;
}

.brand-text {
  display: grid;
  line-height: 1.1;
  text-align: center;
}

.brand-subtitle.subtitle {
  font-family: var(--font-main);
  font-size: var(--type-caption);
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--color-brand);
  opacity: 0.86;
  margin: 0;
}

body.pricing-page .app-header,
body.stats-page .app-header,
body.highscores-page .app-header,
body.achievements-page .app-header,
body.legal .app-header {
  width: 100%;
  display: flex;
  justify-content: center;
}

body.pricing-page .app-bar,
body.stats-page .app-bar,
body.highscores-page .app-bar,
body.achievements-page .app-bar,
body.legal .app-bar {
  justify-content: space-between;
  align-items: center;
}

body.legal .app-bar {
  width: min(1120px, 100%);
}

body.pricing-page .brand,
body.stats-page .brand,
body.highscores-page .brand,
body.achievements-page .brand,
body.legal .brand {
  flex-direction: row;
  align-items: center;
  gap: 0.75em;
  text-decoration: none;
  color: var(--color-brand);
}

body.pricing-page .brand:hover,
body.pricing-page .brand:focus,
body.stats-page .brand:hover,
body.stats-page .brand:focus,
body.highscores-page .brand:hover,
body.highscores-page .brand:focus,
body.achievements-page .brand:hover,
body.achievements-page .brand:focus,
body.legal .brand:hover,
body.legal .brand:focus {
  color: var(--color-brand-dark);
}

body.pricing-page .brand-logo,
body.stats-page .brand-logo,
body.highscores-page .brand-logo,
body.achievements-page .brand-logo,
body.legal .brand-logo {
  height: 56px;
  width: 56px;
  min-width: 56px;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0, 36, 125, 0.18);
}

body.pricing-page .brand-text,
body.stats-page .brand-text,
body.highscores-page .brand-text,
body.achievements-page .brand-text,
body.legal .brand-text {
  text-align: left;
}

body.pricing-page .brand-subtitle.subtitle,
body.stats-page .brand-subtitle.subtitle,
body.highscores-page .brand-subtitle.subtitle,
body.achievements-page .brand-subtitle.subtitle,
body.legal .brand-subtitle.subtitle {
  margin-top: 0.1em;
  font-size: var(--type-caption);
  letter-spacing: 0.02em;
}

body.pricing-page .brand:focus-visible,
body.stats-page .brand:focus-visible,
body.highscores-page .brand:focus-visible,
body.achievements-page .brand:focus-visible,
body.legal .brand:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 6px;
  border-radius: 18px;
}

body.pricing-page .app-bar-link,
body.stats-page .app-bar-link,
body.highscores-page .app-bar-link,
body.achievements-page .app-bar-link,
body.legal .app-bar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.55em 0.85em;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  color: var(--color-brand);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95em;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

body.pricing-page .app-bar-link:hover,
body.pricing-page .app-bar-link:focus,
body.stats-page .app-bar-link:hover,
body.stats-page .app-bar-link:focus,
body.highscores-page .app-bar-link:hover,
body.highscores-page .app-bar-link:focus,
body.achievements-page .app-bar-link:hover,
body.achievements-page .app-bar-link:focus,
body.legal .app-bar-link:hover,
body.legal .app-bar-link:focus {
  color: var(--color-brand-dark);
  background: var(--color-reward-wash);
  border-color: var(--color-reward-mid);
  text-decoration: none;
  transform: translateY(-1px);
}

body.pricing-page .app-bar-link:focus-visible,
body.stats-page .app-bar-link:focus-visible,
body.highscores-page .app-bar-link:focus-visible,
body.achievements-page .app-bar-link:focus-visible,
body.legal .app-bar-link:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-pill);
}

@media (max-width: 480px) {
  .app-bar {
    padding: 0.65em 0.8em;
  }

  .brand-logo {
    height: 176px;
  }

  body.pricing-page .app-bar,
  body.stats-page .app-bar,
  body.highscores-page .app-bar,
  body.achievements-page .app-bar,
  body.legal .app-bar {
    width: 100%;
    margin: 0.8em auto 1.6em;
    padding: 0.75em 1.1em;
    gap: var(--spacing-md);
  }

  body.pricing-page .brand-logo,
  body.stats-page .brand-logo,
  body.highscores-page .brand-logo,
  body.achievements-page .brand-logo,
  body.legal .brand-logo {
    height: 56px;
    width: 56px;
    min-width: 56px;
  }

  body.pricing-page .app-bar-link,
  body.stats-page .app-bar-link,
  body.highscores-page .app-bar-link,
  body.achievements-page .app-bar-link,
  body.legal .app-bar-link {
    font-size: 0.9em;
  }
}

/* Accessibility utility */
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* Hero header */
.hero {
  margin: 0 auto 2.5em;
  max-width: 780px;
}

.hero .subtitle {
  margin-bottom: var(--spacing-lg);
}

.options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin: 0 auto;
}

/* Ensure a consistent minimum answer button width across all quizzes (using vowels as default) */
body.quiz-page .options button {
  min-width: 240px;
}

.options button {
  user-select: none;
  -webkit-user-select: none;
}

button {
  box-sizing: border-box;
  font: inherit;
  font-family: var(--font-main);
  cursor: pointer;
  position: relative;
}

button:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
}

/* Answer feedback animations */
@keyframes correctPulse {
  0% {
    transform: scale(1);
    background-color: var(--color-surface-light);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }

  20% {
    transform: scale(1.04);
    background-color: var(--color-success-fade);
    box-shadow: 0 8px 18px rgba(40, 167, 69, 0.25);
  }

  50% {
    transform: scale(1.02);
    background-color: var(--color-success-mid);
  }

  100% {
    transform: scale(1);
    background-color: var(--color-surface-light);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
}

@keyframes wrongShake {
  0% {
    transform: translateX(0);
  }

  15% {
    transform: translateX(-6px) rotate(-1deg);
  }

  30% {
    transform: translateX(6px) rotate(1deg);
  }

  45% {
    transform: translateX(-5px) rotate(-1deg);
  }

  60% {
    transform: translateX(5px) rotate(1deg);
  }

  75% {
    transform: translateX(-3px) rotate(-0.5deg);
  }

  90% {
    transform: translateX(3px) rotate(0.5deg);
  }

  100% {
    transform: translateX(0);
  }
}

button.answer-correct {
  animation: correctPulse 500ms ease;
  background-color: var(--color-success-fade) !important;
  border-color: rgba(40, 167, 69, 0.6) !important;
  box-shadow: 0 8px 18px rgba(40, 167, 69, 0.25);
}

button.answer-wrong {
  animation: wrongShake 500ms ease;
  background-color: var(--color-error-soft) !important;
  border-color: rgba(220, 53, 69, 0.6) !important;
}

@media (hover: hover) and (pointer: fine) {
  button.answer-wrong:hover {
    background-color: var(--color-error-soft) !important;
    border-color: rgba(220, 53, 69, 0.6) !important;
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(220, 53, 69, 0.25);
  }
}

/* button:active handled in base rule */

.options:focus {
  outline: none;
}

#feedback {
  margin-top: var(--spacing-md);
  font-size: 1.3em;
  font-weight: bold;
  min-height: 1.5em;
  color: var(--color-text);
}

#nextBtn {
  display: none;
  margin: var(--spacing-xl) auto 0;
}

.stats {
  font-size: 0.9em;
  color: rgba(17, 17, 17, 0.7);
}

.stats-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4em;
}

.stats-summary {
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 480px) {
  body.quiz-page .stats {
    font-size: 0.75em;
    letter-spacing: -0.02em;
  }

  body.quiz-page .stats-line {
    gap: 0.2em;
    justify-content: center;
  }

  body.quiz-page .stats .star-rating {
    font-size: 1.1em;
    margin-top: 0;
  }
}

.quiz-progress {
  margin-top: 0.45em;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
}

.quiz-progress-bar {
  width: var(--progress, 0%);
  max-width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-brand) 100%);
  transition: width 0.35s ease;
}

body.quiz-page.boss-mode .quiz-hero {
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: 0;
  overflow: visible;
}

body.quiz-page.boss-mode .stats,
body.quiz-page.boss-mode .quiz-progress {
  display: none !important;
}

body.quiz-page.boss-mode #feedback {
  display: none !important;
}

body.quiz-page.boss-mode {
  padding-bottom: calc(var(--page-padding) + 3rem);
  touch-action: pan-y;
}

body.quiz-page.boss-mode .back-btn,
body.quiz-page.boss-mode .footer {
  display: none !important;
}

body.quiz-page.boss-damage-shake {
  animation: bossScreenShake 0.4s ease;
}

body.quiz-page .boss-hud-inline {
  width: 100%;
  margin-top: clamp(0.6em, 2vw, 1em);
  box-sizing: border-box;
}

body.quiz-page .prompt-card .boss-hud-inline {
  margin: 0 auto;
}

body.quiz-page .boss-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4em;
}

body.quiz-page .boss-hero-image-wrap {
  position: relative;
  display: inline-block;
  overflow: visible;
  animation: bossPulse 2.6s ease-in-out infinite;
}

body.quiz-page .boss-hero-image {
  width: min(270px, 58vw);
  height: auto;
  max-height: 31vh;
  object-fit: contain;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

body.quiz-page .boss-hero-image-wrap.is-hit {
  animation: bossShake 0.35s ease;
}

body.quiz-page .boss-hit-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -40%);
  font-size: clamp(2.6rem, 7vw, 4rem);
  font-weight: 900;
  color: #ff2b2b;
  text-shadow:
    0 0 6px rgba(255, 43, 43, 0.6),
    0 8px 18px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.04em;
  animation: bossHitFloat 0.85s ease-out forwards;
  pointer-events: none;
}

@keyframes bossShake {
  0% {
    transform: translate3d(0, 0, 0);
  }

  20% {
    transform: translate3d(-6px, 0, 0);
  }

  40% {
    transform: translate3d(6px, 0, 0);
  }

  60% {
    transform: translate3d(-4px, 0, 0);
  }

  80% {
    transform: translate3d(4px, 0, 0);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes bossScreenShake {
  0% {
    transform: translate3d(0, 0, 0);
  }

  15% {
    transform: translate3d(-6px, 0, 0);
  }

  30% {
    transform: translate3d(6px, 0, 0);
  }

  50% {
    transform: translate3d(-4px, 0, 0);
  }

  70% {
    transform: translate3d(4px, 0, 0);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes bossPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.quiz-page .boss-hero-image-wrap {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.quiz-page.boss-damage-shake {
    animation: none;
  }
}

/* Boss Special Attack */
body.quiz-page.boss-mode .streak-indicator:not(.hidden) {
  pointer-events: auto;
  cursor: pointer;
}

body.quiz-page.boss-mode .streak-indicator:not(.hidden):hover .streak-flame,
body.quiz-page.boss-mode .streak-indicator:not(.hidden):focus-visible .streak-flame {
  filter: drop-shadow(0 0 10px #ff9800) drop-shadow(0 0 20px #ff6d00);
}

body.quiz-page.boss-mode .streak-indicator:not(.hidden) .streak-flame {
  animation: bossSpecialGlow 1.5s infinite ease-in-out;
}

body.quiz-page.boss-mode .streak-indicator:not(.hidden)::after {
  content: attr(data-boss-attack-label);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.1em;
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 800;
  color: #ff9800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: normal;
  width: max-content;
  max-width: 6em;
  text-align: center;
  line-height: 1.3;
  animation: bossAttackLabelPulse 2s infinite ease-in-out;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@keyframes bossSpecialGlow {
  0% {
    transform: scale(1);
    opacity: 0.9;
    filter: drop-shadow(0 0 4px #e65100);
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
    filter: drop-shadow(0 0 8px #ff9800) drop-shadow(0 0 16px #ff6d00);
  }

  100% {
    transform: scale(1);
    opacity: 0.9;
    filter: drop-shadow(0 0 4px #e65100);
  }
}

@keyframes bossAttackLabelPulse {
  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 1;
  }
}

body.quiz-page .boss-special-hit-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -40%) scale(0.5);
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-weight: 900;
  color: #ff9800;
  text-shadow:
    0 0 8px rgba(255, 152, 0, 0.7),
    0 0 20px rgba(255, 152, 0, 0.4),
    0 8px 18px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.04em;
  animation: bossSpecialHitFloat 1.2s ease-out forwards;
  pointer-events: none;
}

@keyframes bossSpecialHitFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.5);
  }

  12% {
    opacity: 1;
    transform: translate(-50%, -45%) scale(1.15);
  }

  25% {
    transform: translate(-50%, -45%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, 60%) scale(0.8);
  }
}

.boss-special-flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 152, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  z-index: 23000;
  transition: opacity 0.4s ease;
}

.boss-special-flash.is-active {
  opacity: 1;
}

body.quiz-page .boss-hero-image-wrap.is-special-hit {
  animation: bossSpecialShake 0.5s ease;
}

@keyframes bossSpecialShake {
  0% {
    transform: translate3d(0, 0, 0);
  }

  15% {
    transform: translate3d(-10px, -4px, 0);
  }

  30% {
    transform: translate3d(10px, 4px, 0);
  }

  45% {
    transform: translate3d(-8px, -2px, 0);
  }

  60% {
    transform: translate3d(8px, 2px, 0);
  }

  80% {
    transform: translate3d(-4px, 0, 0);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.quiz-page.boss-mode .streak-indicator:not(.hidden) .streak-flame {
    animation: none;
  }

  body.quiz-page.boss-mode .streak-indicator:not(.hidden)::after {
    animation: none;
  }

  body.quiz-page .boss-special-hit-indicator {
    animation: none;
  }

  body.quiz-page .boss-hero-image-wrap.is-special-hit {
    animation: none;
  }
}

@keyframes bossHitFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, -45%);
  }

  15% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, 70%);
  }
}

body.quiz-page .boss-hero-name {
  font-size: 1.45em;
  font-weight: 800;
  color: #b8872b;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

body.quiz-page .boss-hero-panel {
  width: clamp(320px, 72vw, 760px);
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 0.35em;
  padding: 0.5em 0.7em;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #111;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.5),
    inset -2px -2px 0 rgba(0, 0, 0, 0.15),
    8px 8px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45em;
}

body.quiz-page .boss-hero-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5em;
  min-width: 0;
}

body.quiz-page .boss-hero-panel .boss-hero-name {
  margin: 0;
  text-align: left;
  white-space: nowrap;
  flex-shrink: 0;
}

body.quiz-page .boss-hero-desc {
  font-family: var(--font-heading);
  font-size: 0.46em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.55;
  color: var(--color-text);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

body.quiz-page .boss-hero-hp-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  width: 100%;
}

body.quiz-page .boss-hero-hp .boss-bar-track {
  height: 8px;
  background: rgba(0, 0, 0, 0.14);
  flex: 1;
}

body.quiz-page.boss-ended .options {
  pointer-events: none;
  opacity: 0.55;
  filter: grayscale(0.15);
}

body.quiz-page.boss-ended #nextBtn {
  display: none !important;
}

body.quiz-page .boss-hud {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  width: 100%;
}

body.quiz-page .boss-bars {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  padding: 0.7em 1em;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #111;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.5),
    inset -2px -2px 0 rgba(0, 0, 0, 0.15),
    8px 8px 0 rgba(0, 0, 0, 0.12);
}

body.quiz-page .boss-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

body.quiz-page .boss-bar-label {
  font-family: var(--font-heading);
  font-size: 0.7em;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  width: 3.8em;
  text-align: right;
}

body.quiz-page .boss-bar-track {
  width: 100%;
  height: 12px;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.08);
  border: 3px solid #111;
  flex: 1;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.35),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

body.quiz-page .boss-bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.6s ease;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.35),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2);
}

body.quiz-page .boss-bar-fill-boss {
  background: linear-gradient(90deg, rgba(200, 60, 60, 0.9), rgba(150, 20, 20, 0.95));
}

body.quiz-page .boss-bar-fill-player {
  background: linear-gradient(90deg, rgba(36, 133, 204, 0.9), rgba(12, 86, 148, 0.95));
}

body.quiz-page .boss-bar-fill-timer {
  background: linear-gradient(90deg, rgba(245, 197, 66, 0.95), rgba(214, 136, 22, 0.95));
}

.boss-result-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 45%), rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  z-index: 24000;
  padding: 1.4em;
  box-sizing: border-box;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.boss-result-card {
  max-width: min(480px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  margin: auto;
  width: 100%;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: clamp(var(--spacing-md), 4vw, 1.4em) clamp(1.1em, 5vw, 1.6em);
  text-align: center;
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  transform: scale(0.96);
  animation: cardPopIn 200ms ease forwards;
}

.boss-result-title {
  font-family: var(--font-heading);
  font-size: 1.4em;
  color: var(--color-brand);
  text-transform: uppercase;
  margin-bottom: 0.3em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.boss-result-body {
  font-family: var(--font-heading);
  font-size: 0.75em;
  line-height: 1.6;
  margin-bottom: 1.2em;
  opacity: 0.85;
}

.boss-result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  margin-top: 0.8em;
}

.boss-result-card .btn-accent {
  width: 100%;
  padding: 1em 1.4em;
  box-sizing: border-box;
  min-height: 54px;
}

.boss-result-card .btn-accent:not(.boss-result-back):hover {
  transform: translateY(-2px);
}

.boss-result-back {
  background: rgba(0, 36, 125, 0.12);
  border-color: rgba(0, 36, 125, 0.24);
  color: var(--color-brand);
}

.boss-result-back:hover,
.boss-result-back:focus {
  background: rgba(0, 36, 125, 0.18);
  transform: translateY(-1px);
}

.boss-result-lore-btn {
  background: rgba(0, 36, 125, 0.16) !important;
  color: var(--color-brand) !important;
}

.boss-result-lore-btn:hover,
.boss-result-lore-btn:focus {
  background: rgba(0, 36, 125, 0.24) !important;
}

.boss-lore-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 42, 86, 0.42);
  display: grid;
  place-items: center;
  z-index: 24500;
  padding: 1.4em;
  box-sizing: border-box;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
}

.boss-lore-card-overlay {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade), var(--color-brand), var(--color-reward-dark));
  --overlay-top-accent-height: 6px;
  width: min(720px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  position: relative;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height, 6px) no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.96)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height, 6px),
    auto,
    36px 36px,
    36px 36px,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box, padding-box;
  color: var(--color-text);
  border: 1px solid rgba(18, 63, 122, 0.16);
  border-top-color: transparent;
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: var(--radius-card);
  padding: clamp(0.7rem, 2vw, 1rem) clamp(1rem, 3vw, 1.45rem) clamp(1rem, 3vw, 1.45rem);
  text-align: left;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: clamp(0.85rem, 2.2vw, 1.15rem);
  overscroll-behavior: contain;
  box-shadow: 0 24px 58px rgba(9, 42, 86, 0.24);
  animation: cardPopIn 200ms ease forwards;
}

.boss-lore-card-overlay::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}

.boss-lore-hero {
  display: grid;
  grid-template-columns: clamp(112px, 20vw, 170px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(0.9rem, 3vw, 1.4rem);
  padding-bottom: clamp(0.8rem, 2vw, 1rem);
  border-bottom: 1px solid rgba(18, 63, 122, 0.12);
}

.boss-lore-image-frame {
  display: grid;
  align-self: start;
  place-items: center;
  min-width: 0;
}

.boss-lore-image-overlay {
  width: clamp(112px, 20vw, 170px);
  height: clamp(112px, 20vw, 170px);
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 12px 18px rgba(18, 63, 122, 0.16));
  transform: translateY(-14%);
}

.boss-lore-heading {
  min-width: 0;
}

.boss-lore-title {
  font-family: var(--font-main);
  font-size: var(--type-xs);
  font-weight: 900;
  color: var(--color-jade-dark);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0 0 0.28rem;
  display: inline-block;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.boss-lore-overlay-name {
  font-family: var(--font-main);
  font-size: var(--type-title-md);
  font-weight: 950;
  line-height: 1.12;
  margin: 0;
  color: var(--color-brand-dark);
  letter-spacing: 0;
  text-shadow: none;
}

.boss-lore-overlay-body {
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: min(42dvh, 360px);
  padding-right: 0.35rem;
  scrollbar-gutter: stable;
  color: var(--color-text);
  font-family: var(--font-main);
}

.boss-lore-overlay-paragraph {
  margin: 0;
  font-size: var(--type-body);
  line-height: 1.58;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.boss-lore-overlay-paragraph + .boss-lore-overlay-paragraph {
  margin-top: 0.85em;
}

.boss-lore-card-overlay .btn-accent {
  width: 100%;
  box-sizing: border-box;
  min-height: 56px;
  letter-spacing: 0;
  text-transform: none;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .boss-lore-overlay {
    padding: 0.5em;
  }

  .boss-lore-card-overlay {
    width: min(100%, calc(100vw - 1rem));
    max-width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: 0.95rem;
    gap: 0.85rem;
  }

  .boss-lore-hero {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 0.8rem;
  }

  .boss-lore-image-overlay {
    width: 88px;
    height: 88px;
  }

  .boss-lore-overlay-name {
    font-size: var(--type-title-sm);
  }

  .boss-lore-overlay-body {
    max-height: calc(100dvh - 14rem);
  }

  .boss-lore-overlay-paragraph {
    font-size: var(--type-sm);
    line-height: 1.5;
  }
}

.boss-damage-flash {
  position: fixed;
  inset: 0;
  background: rgba(200, 30, 30, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 23000;
  transition: opacity 0.4s ease;
}

.boss-damage-flash.is-active {
  opacity: 1;
}

.boss-locked-message {
  font-weight: 700;
  text-align: center;
  margin: 1.6em auto 1em;
}

.streak-toast,
.srs-toast {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade) 0, var(--color-brand) 100%);
  --overlay-top-accent-height: 4px;
  position: fixed;
  top: max(0.9rem, calc(env(safe-area-inset-top, 0px) + 0.75rem));
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: min(
    30rem,
    calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - clamp(1rem, 5vw, 2.5rem))
  );
  padding: 0.72rem clamp(0.9rem, 3vw, 1.35rem);
  border: 1px solid rgba(183, 121, 31, 0.32);
  border-top-color: transparent;
  border-bottom: 4px solid rgba(183, 121, 31, 0.46);
  border-radius: 10px;
  overflow: hidden;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height, 4px) no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.96)),
    var(--color-surface-card);
  background-origin: border-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box;
  box-shadow: 0 18px 42px rgba(9, 42, 86, 0.24);
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-sm);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: 0;
  text-transform: none;
  text-align: center;
  text-wrap: balance;
  pointer-events: none;
  transition:
    transform 0.5s ease-out,
    opacity 0.4s ease-out;
  box-sizing: border-box;
  z-index: 21000;
}

.streak-toast::before,
.srs-toast::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 4px) + 1px);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  pointer-events: none;
  z-index: 0;
}

.streak-toast-icon {
  display: inline-block;
  width: 1.7em;
  height: 1.7em;
  flex: 0 0 1.7em;
  background: url('/asset/metric-icons/streak.webp') center / contain no-repeat;
  filter: drop-shadow(0 3px 6px rgba(183, 121, 31, 0.2));
  animation: streakFirePulse 1s ease-in-out infinite;
}

.streak-toast-text {
  font-size: 1.1em;
}

.streak-toast.is-visible,
.srs-toast.is-visible {
  animation: streakPopIn 0.6s ease-out forwards;
}

@keyframes streakPopIn {
  from {
    transform: translateX(-50%) scale(0.8);
    opacity: 0;
  }

  50% {
    transform: translateX(-50%) scale(1.08);
    opacity: 1;
  }

  to {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .streak-toast,
  .srs-toast {
    top: max(0.75rem, calc(env(safe-area-inset-top, 0px) + 0.65rem));
    gap: 0.45rem;
    padding: 0.64rem 0.8rem;
    font-size: var(--type-xs);
  }

  .streak-toast-icon {
    width: 1.55em;
    height: 1.55em;
    flex-basis: 1.55em;
  }

  .streak-toast-text {
    font-size: 1em;
  }
}

/* Larger star visuals for completion rating */
.star-rating {
  font-size: 1.4em;
  line-height: 1;
  margin-top: var(--spacing-xs);
}

/* Ensure fullscreen overlays also cover iOS safe-area/notch region. */
.example-overlay,
.star-celebration-overlay,
.quiz-completed-overlay,
.level-up-overlay,
.streak-milestone-overlay,
.daily-goal-overlay,
.achievement-unlock-overlay,
.boss-result-overlay,
.boss-lore-overlay {
  top: calc(env(safe-area-inset-top, 0px) * -1) !important;
  right: calc(env(safe-area-inset-right, 0px) * -1) !important;
  bottom: calc(env(safe-area-inset-bottom, 0px) * -1) !important;
  left: calc(env(safe-area-inset-left, 0px) * -1) !important;
  z-index: 30000 !important;
}

/* Keep celebration overlays self-contained to reduce layout/style invalidation. */
.star-celebration-overlay,
.level-up-overlay,
.streak-milestone-overlay,
.daily-goal-overlay,
.achievement-unlock-overlay {
  contain: layout style;
}

/* Stars appended inside stats line on quiz page */
body.quiz-page .stats {
  line-height: 1.4;
}

/* Shared example card styling */
.example {
  margin-top: var(--spacing-sm);
  font-size: 0.78em;
  font-weight: 600;
  background: var(--color-surface-soft);
  border: 1px solid rgba(0, 36, 125, 0.2);
  display: inline-block;
  padding: var(--spacing-sm) 0.7em;
  border-radius: 10px;
}

/* Full-screen example overlay shown after correct answers */
.example-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 45%), rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 9999;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.example-overlay .overlay-card {
  max-width: min(820px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  width: min(820px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  margin: clamp(0.75em, 4vw, var(--spacing-lg)) auto;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  box-sizing: border-box;
  padding: clamp(var(--spacing-md), 4vw, 1.4em) clamp(1.1em, 5vw, 1.6em);
  box-shadow: var(--shadow-card);
  transform: scale(0.96);
  animation: cardPopIn 200ms ease forwards;
  position: relative;
  z-index: 1;
}

.example-overlay .overlay-card .heading {
  font-family: var(--font-heading);
  font-size: 3em;
  color: var(--color-brand);
  text-transform: uppercase;
  margin-bottom: 0.5em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.example-overlay .overlay-card .label {
  display: inline-block;
  opacity: 0.95;
  font-size: clamp(0.9em, 1.8vw, 1em);
  padding: 0;
  margin-right: 0.6em;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand);
  border: none;
  font-weight: 600;
}

.example-overlay .overlay-card .text {
  display: block;
  margin-top: 0.6em;
  font-weight: 800;
  font-size: clamp(1.25em, 4.2vw, 2.2em);
  line-height: 1.25;
}

.example-overlay .overlay-card .text.is-multiline {
  display: flex;
  flex-direction: column;
  gap: clamp(0.45em, 2vw, 0.7em);
  font-weight: 400;
  font-size: clamp(1.05em, 3.4vw, 1.85em);
  line-height: 1.3;
}

.example-overlay .overlay-card .text.is-multiline .example-line {
  display: flex;
  flex-direction: column;
  gap: clamp(0.12em, 1.4vw, 0.22em);
}

.example-overlay .overlay-card .text.is-multiline .example-line-label {
  font-size: clamp(0.68em, 1.8vw, 0.85em);
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(17, 17, 17, 0.62);
}

.example-overlay .overlay-card .text.is-multiline .example-line-value {
  font-size: clamp(1.15em, 3.8vw, 2em);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.28;
  word-break: break-word;
}

/* Highlight for the selected word across languages */
.example-overlay .overlay-card .text .sel {
  background: none;
  color: var(--color-brand);
  font-weight: 900;
  padding: 0 0.02em;
  border-radius: 2px;
}

/* Optional subtle variations per language (currently same color) */

/* Countdown timer */
.example-overlay > .timer {
  position: absolute;
  left: clamp(1rem, 6vw, 3rem);
  right: clamp(1rem, 6vw, 3rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  height: 10px;
  background: rgba(0, 36, 125, 0.1);
  border: 3px solid #111;
  border-radius: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.example-overlay > .timer .timer-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-brand) 100%);
  transform: translateX(0%);
  animation: timerDrain var(--overlay-duration, 2600ms) linear forwards;
}

.example-overlay > .timer .timer-fill.is-paused {
  animation-play-state: paused;
}

@keyframes timerDrain {
  from {
    transform: translateX(0%);
  }

  to {
    transform: translateX(100%);
  }
}

/* Falling flags layer behind the card */
.example-overlay .flags-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.flag {
  position: absolute;
  top: -12px;
  opacity: 0;
  transform: translateY(-10px) rotate(0deg);
  animation: flagFall 3200ms cubic-bezier(0.23, 1, 0.32, 1) forwards;
  will-change: transform, opacity;
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes cardPopIn {
  from {
    transform: scale(0.96);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes flagFall {
  0% {
    opacity: 0;
    transform: translateY(-10px) rotate(0deg);
  }

  10% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translateY(120vh) rotate(var(--flag-rotate, 320deg));
  }
}

/* Tutorial onboarding overlay */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 42, 86, 0.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.5s ease;
  animation: overlayFadeIn 200ms ease;
}

.onboarding-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.onboarding-content {
  text-align: center;
  display: grid;
  gap: 1rem;
  animation: cardPopIn 200ms ease forwards;
  max-width: 90vw;
  width: auto;
}

.onboarding-title {
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  color: var(--color-brand-dark);
  letter-spacing: 0;
  text-transform: none;
  text-shadow: none;
  margin: 0;
  line-height: 1.2;
}

.onboarding-button {
  font-family: var(--font-main);
  font-size: var(--type-action);
  padding: 0.8rem 1rem;
  text-transform: none;
  animation: none;
  text-shadow: none;
  margin-top: var(--spacing-sm);
}

.onboarding-button:hover,
.onboarding-button:focus-visible {
  transform: translateY(-1px);
  filter: none;
  animation: none;
  text-shadow: none;
}

.onboarding-button:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.onboarding-button:active {
  transform: translateY(1px);
}

/* Quiz Completed Overlay - shown when returning to a capped quiz */
.star-celebration-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(34, 197, 94, 0.12) 0%, rgba(255, 255, 255, 0) 45%), rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 10000;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.star-celebration-overlay .flags-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.star-celebration-card {
  max-width: min(480px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  margin: 10px;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: clamp(var(--spacing-md), 4vw, 1.4em) clamp(1.1em, 5vw, 1.6em);
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  text-align: center;
  transform: scale(0.96);
  animation: cardPopIn 200ms ease forwards;
}

.star-celebration-card .celebrate-heading {
  font-family: var(--font-heading);
  font-size: 1.5em;
  color: var(--color-brand);
  text-transform: uppercase;
  margin-bottom: 0.3em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.star-celebration-card .celebrate-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0.1em 0 0.3em;
  color: var(--color-brand);
  text-shadow: none;
}

.star-celebration-card .celebrate-star-icon {
  display: inline-block;
  width: clamp(3.15rem, 12vw, 4.4rem);
  height: clamp(3.15rem, 12vw, 4.4rem);
  background-image: url('/asset/metric-icons/star-rating.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 7px 12px rgba(183, 121, 31, 0.18));
}

.star-celebration-card--no-stars .celebrate-stars,
.star-celebration-card .celebrate-stars--empty {
  color: var(--color-error);
  text-shadow: none;
}

.star-celebration-card .celebrate-star-icon[data-star-state='empty'] {
  background-image: url('/asset/metric-icons/star-rating-empty.webp');
  filter: drop-shadow(0 5px 9px rgba(18, 63, 122, 0.12));
}

.star-celebration-card .celebrate-message {
  font-family: var(--font-heading);
  font-size: 0.7em;
  line-height: 1.6;
  margin-bottom: 0.8em;
  opacity: 0.9;
}

.star-celebration-card .celebrate-message--no-stars {
  color: var(--color-error);
  font-weight: 700;
  opacity: 1;
}

.star-celebration-card .celebrate-retry {
  font-family: var(--font-heading);
  font-size: 0.6em;
  margin-bottom: 0.9em;
  opacity: 0.85;
}

.star-celebration-card .celebrate-meta {
  font-family: var(--font-heading);
  font-size: 0.55em;
  opacity: 0.7;
  margin-bottom: 2em;
}

.star-celebration-card .celebrate-review-mistakes {
  width: 100%;
  font-size: 0.75em;
  padding: 0.9em 1em;
  margin-bottom: 0.7em;
}

.star-celebration-card .celebrate-review-mistakes:hover {
  transform: translateY(-2px);
}

.star-celebration-card .celebrate-close {
  width: 100%;
  font-size: 0.8em;
  padding: 1em;
}

.star-celebration-card .celebrate-close:hover {
  transform: translateY(-2px);
}

.star-celebration-card .celebrate-review-mistakes:focus-visible,
.star-celebration-card .celebrate-close:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.missed-items-review-wrapper {
  width: 100%;
  min-height: 100vh;
}

.star-celebration-card .timer {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border: 2px solid #111;
  border-radius: 0;
  overflow: hidden;
  margin-top: 1.5em;
}

.star-celebration-card .timer-fill {
  height: 100%;
  background: var(--color-brand);
  width: 100%;
  transform-origin: left;
  animation: timerShrink var(--overlay-duration, 7000ms) linear forwards;
}

.quiz-completed-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 45%), rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  padding: 1.4em;
  box-sizing: border-box;
  z-index: 10000;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.quiz-completed-card {
  max-width: min(480px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  margin: 10px;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: clamp(var(--spacing-md), 4vw, 1.4em) clamp(1.1em, 5vw, 1.6em);
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  text-align: center;
  transform: scale(0.96);
  animation: cardPopIn 200ms ease forwards;
}

.quiz-completed-card .completed-heading {
  font-family: var(--font-heading);
  font-size: 1.5em;
  color: var(--color-brand);
  text-transform: uppercase;
  margin-bottom: 0.3em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.quiz-completed-card .completed-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0.35em 0 0.45em;
  color: var(--color-brand);
  text-shadow: none;
}

.quiz-completed-card .completed-star-icon {
  display: inline-block;
  width: 4rem;
  height: 4rem;
  background-image: url('/asset/metric-icons/star-rating.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 7px 12px rgba(183, 121, 31, 0.18));
}

.quiz-completed-card .completed-star-icon[data-star-state='earned'] {
  opacity: 1;
}

.quiz-completed-card .completed-star-icon[data-star-state='empty'] {
  background-image: url('/asset/metric-icons/star-rating-empty.webp');
  filter: drop-shadow(0 5px 9px rgba(18, 63, 122, 0.12));
}

.quiz-completed-card .completed-stats {
  font-family: var(--font-heading);
  font-size: 0.7em;
  line-height: 1.6;
  margin-bottom: 1.5em;
  opacity: 0.9;
}

.quiz-completed-card .completed-buttons {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.2em;
}

.quiz-completed-card .completed-btn {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--color-brand-dark);
  font-family: var(--font-heading);
  font-size: 0.85em;
  padding: 1em;
  border-radius: var(--radius-pill);
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
  text-transform: uppercase;
  box-shadow: 0 12px 24px rgba(18, 63, 122, 0.2);
}

.quiz-completed-card .completed-btn-restart:hover {
  transform: translateY(-2px);
}

.quiz-completed-card .completed-btn-practice {
  background: var(--color-reward-wash);
  color: var(--color-brand);
  border-color: var(--color-reward-brand);
}

.quiz-completed-card .completed-btn-practice:hover {
  background: var(--color-reward-soft);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(242, 184, 75, 0.24);
}

.quiz-completed-card .completed-leaderboard-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0;
  padding: 1em;
  min-height: 56px;
  font-family: var(--font-heading);
  font-size: 0.85em;
  font-weight: 700;
  text-decoration: none;
  color: var(--color-brand);
  background: var(--color-surface-card);
  border: 1px solid var(--color-brand-border-soft);
  border-radius: var(--radius-pill);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
  text-transform: uppercase;
  box-shadow: 0 12px 24px rgba(18, 63, 122, 0.12);
}

.quiz-completed-card .completed-leaderboard-icon {
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
  flex: 0 0 1.75rem;
  background-image: url('/asset/achievements/quest-master-gold.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 4px 8px rgba(18, 63, 122, 0.14));
}

.quiz-completed-card .completed-leaderboard-link:hover {
  background: var(--color-reward-wash);
  border-color: var(--color-reward-brand);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(242, 184, 75, 0.2);
}

.quiz-completed-card .completed-btn:focus-visible,
.quiz-completed-card .completed-leaderboard-link:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

@media (max-width: 420px) {
  .quiz-completed-card {
    padding: 1.25em 1.4em 1.7em;
  }

  .quiz-completed-card .completed-stars {
    gap: 0.35rem;
  }

  .quiz-completed-card .completed-star-icon {
    width: 3.2rem;
    height: 3.2rem;
  }

  .quiz-completed-card .completed-buttons {
    gap: 0.6em;
  }
}

/* ===================== Sentence Ordering Quiz ===================== */

/* Prompt styling */
.sentence-prompt {
  font-size: 1.4em;
  font-weight: 600;
  color: var(--color-text-strong);
  line-height: 1.4;
}

.sentence-thai-hint {
  font-size: 1.15em;
  color: var(--color-text);
  opacity: 0.65;
}

/* Answer Area - where placed words go */
.sentence-answer-area {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  min-height: 56px;
  padding: var(--spacing-md);
  border: 2px dashed rgba(0, 36, 125, 0.35);
  border-radius: 12px;
  background: var(--color-surface-soft, rgba(0, 36, 125, 0.03));
  justify-content: center;
  align-items: center;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.sentence-answer-area .word-btn {
  flex: 0 0 auto;
  /* Don't grow or shrink, auto width */
  min-width: auto !important;
}

.sentence-answer-area.answer-correct {
  border-color: var(--color-success, #22c55e);
  background: rgba(34, 197, 94, 0.08);
  animation: flashCorrect 0.35s ease-out;
}

.sentence-answer-area.answer-incorrect {
  border-color: var(--color-error, #ef4444);
  background: rgba(239, 68, 68, 0.08);
  animation: shakeIncorrect 0.4s ease-out;
}

@keyframes flashCorrect {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.015);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shakeIncorrect {
  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-5px);
  }

  40%,
  80% {
    transform: translateX(5px);
  }
}

.answer-placeholder {
  color: rgba(0, 36, 125, 0.45);
  font-style: italic;
  font-size: 0.95em;
}

/* Word Bank - shuffled words */
.sentence-word-bank {
  display: flex;
  flex-direction: row !important;
  /* Override .options column direction */
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  justify-content: center;
  align-items: flex-start;
  padding: var(--spacing-md) 0;
  margin-bottom: 5em;
}

.sentence-word-bank .word-btn {
  flex: 0 0 auto;
  /* Don't grow or shrink, auto width */
  min-width: auto !important;
}

/* Word buttons - matching quiz button style but smaller */
.word-btn {
  padding: 0.5em 0.9em;
  font-size: 2em;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-bottom-width: 3px;
  background: var(--color-surface-light);
  color: var(--color-text);
  border-radius: 12px;
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  font-family: inherit;
  position: relative;
  top: 0;
  min-width: auto;
  /* Override .options button min-width */
  width: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .word-btn:active {
    border-bottom-width: 1px;
    top: 2px;
    transform: none;
  }
}

.word-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .word-btn:hover {
    filter: brightness(0.98);
    transform: translateY(-1px);
  }
}

/* Bank words (not yet placed) */
.word-bank {
  background: var(--color-surface-light);
  color: var(--color-text);
}

/* Feedback styling for sentence ordering */
.feedback-correct {
  color: var(--color-success, #22c55e);
  font-weight: 600;
}

.feedback-incorrect {
  color: var(--color-error, #ef4444);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 480px) {
  .word-btn {
    padding: 0.4em 0.7em;
    font-size: 1.5em;
  }

  .sentence-answer-area {
    min-height: 44px;
    padding: var(--spacing-sm);
  }

  .sentence-prompt {
    font-size: 1.15em;
  }

  .sentence-thai-hint {
    font-size: 1em;
  }
}

/* ===================== End Sentence Ordering ===================== */

/* ===================== Audio Dictation ===================== */
.audio-dictation-symbol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
}

.audio-dictation-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}

.audio-dictation-play-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.audio-dictation-play:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 8px 16px rgba(18, 63, 122, 0.16));
}

.audio-dictation-play:active,
.audio-dictation-play.playing {
  transform: scale(0.95);
}

.audio-dictation-hint {
  font-size: 0.45em;
  color: rgba(0, 0, 0, 0.4);
  margin-top: -0.3em;
  font-weight: 400;
  font-style: italic;
}

/* Display mode toggle (view-toggle style) */
.audio-dictation-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125em;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  gap: 0.06em;
}

.dictation-chip {
  border: none;
  background: transparent;
  color: var(--color-text);
  border-radius: 999px;
  padding: 0.14em 0.34em;
  font-size: 0.49em;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
  box-shadow: none;
}

.dictation-chip:active {
  transform: none;
  box-shadow: none;
}

.dictation-chip:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--color-text);
  box-shadow: none;
  transform: none;
}

.dictation-chip.active {
  background: var(--color-brand);
  color: var(--color-bg);
  box-shadow: none;
}

.dictation-chip.active:hover {
  background: var(--color-brand);
  color: var(--color-bg);
  transform: none;
  box-shadow: none;
}

.dictation-chip:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

/* Audio dictation choice buttons */
.audio-dictation-choice {
  font-size: 1.1em;
  padding: 0.8em 1em;
  text-align: center;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .audio-dictation-play {
    padding: 0;
  }

  .dictation-chip {
    padding: 0.11em 0.3em;
    font-size: 0.45em;
  }

  .audio-dictation-choice {
    font-size: 1em;
    padding: 0.7em 0.9em;
  }
}

/* ===================== End Audio Dictation ===================== */

/* Level Up Celebration */
.level-up-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 45%), rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 10000;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.level-up-card {
  max-width: min(480px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  margin: 10px;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: clamp(var(--spacing-md), 4vw, 1.4em) clamp(1.1em, 5vw, 1.6em);
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  text-align: center;
  transform: scale(0.96);
  animation: cardPopIn 200ms ease forwards;
}

.level-up-heading {
  font-family: var(--font-heading);
  font-size: 1.5em;
  color: var(--color-accent);
  text-transform: uppercase;
  margin-bottom: 0.5em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.level-up-number {
  font-family: var(--font-heading);
  font-size: 5em;
  line-height: 1;
  color: var(--color-brand);
  margin: 0.2em 0;
  text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
  background: -webkit-linear-gradient(45deg, var(--color-brand), var(--color-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.level-up-card .timer {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border: 2px solid #111;
  border-radius: 0;
  overflow: hidden;
  margin-top: 2em;
}

.level-up-card .timer-fill {
  height: 100%;
  background: var(--color-brand);
  width: 100%;
  transform-origin: left;
  animation: timerShrink var(--overlay-duration, 5000ms) linear forwards;
}

@keyframes timerShrink {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

/* Streak Milestone Celebration */
.streak-milestone-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(255, 140, 50, 0.12) 0%, rgba(255, 255, 255, 0) 45%), rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 10000;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.streak-milestone-card {
  max-width: min(480px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  margin: 10px;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: clamp(var(--spacing-md), 4vw, 1.4em) clamp(1.1em, 5vw, 1.6em);
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  text-align: center;
  transform: scale(0.96);
  animation: cardPopIn 200ms ease forwards;
}

.streak-milestone-heading {
  font-family: var(--font-heading);
  font-size: 1.5em;
  color: #d35400;
  text-transform: uppercase;
  margin-bottom: 0.3em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.streak-milestone-icon {
  width: 5rem;
  height: 5rem;
  margin: 0.2em auto;
  background: url('/asset/metric-icons/streak.webp') center / contain no-repeat;
  filter: drop-shadow(0 8px 14px rgba(183, 121, 31, 0.2));
  animation: streakFirePulse 1s ease-in-out infinite;
}

@keyframes streakFirePulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

.streak-milestone-days {
  font-family: var(--font-heading);
  font-size: 4em;
  line-height: 1;
  color: #d35400;
  margin: 0.1em 0 0;
  text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
  background: linear-gradient(135deg, #ff6b35, #f7931e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.streak-milestone-label {
  font-family: var(--font-heading);
  font-size: 0.8em;
  font-weight: 700;
  color: #d35400;
  text-transform: uppercase;
  margin-bottom: 0.8em;
}

.streak-milestone-message {
  font-family: var(--font-heading);
  font-size: 0.7em;
  line-height: 1.6;
  margin-bottom: 1.5em;
  opacity: 0.9;
}

.streak-milestone-card .timer {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border: 2px solid #111;
  border-radius: 0;
  overflow: hidden;
  margin-top: 1em;
}

.streak-milestone-card .timer-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b35, #f7931e);
  width: 100%;
  transform-origin: left;
  animation: timerShrink var(--overlay-duration, 5000ms) linear forwards;
}

/* Daily Goal Celebration */
.daily-goal-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(52, 152, 219, 0.12) 0%, rgba(255, 255, 255, 0) 45%), rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 10000;
  animation: overlayFadeIn 200ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.daily-goal-card {
  max-width: min(480px, calc(100vw - clamp(1rem, 5vw, 2.5rem)));
  margin: 10px;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: clamp(var(--spacing-md), 4vw, 1.4em) clamp(1.1em, 5vw, 1.6em);
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 1;
  text-align: center;
  transform: scale(0.96);
  animation: cardPopIn 200ms ease forwards;
}

.daily-goal-heading {
  font-family: var(--font-heading);
  font-size: 1.5em;
  color: #2980b9;
  text-transform: uppercase;
  margin-bottom: 0.3em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.daily-goal-icon {
  width: 5.4rem;
  height: 5.4rem;
  margin: 0.2em auto;
  background: url('/asset/metric-icons/goal-celebration.webp') 44% center / 76% auto no-repeat;
  filter: drop-shadow(0 8px 14px rgba(18, 63, 122, 0.16));
  animation: streakFirePulse 1s ease-in-out infinite;
}

.daily-goal-number {
  font-family: var(--font-heading);
  font-size: 4em;
  line-height: 1;
  color: #2980b9;
  margin: 0.1em 0 0;
  text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
  background: linear-gradient(135deg, #3498db, #2980b9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.daily-goal-label {
  font-family: var(--font-heading);
  font-size: 0.8em;
  font-weight: 700;
  color: #2980b9;
  text-transform: uppercase;
  margin-bottom: 0.8em;
}

.daily-goal-message {
  font-family: var(--font-heading);
  font-size: 0.7em;
  line-height: 1.6;
  margin-bottom: 1.5em;
  opacity: 0.9;
}

.daily-goal-card .timer {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border: 2px solid #111;
  border-radius: 0;
  overflow: hidden;
  margin-top: 1em;
}

.daily-goal-card .timer-fill {
  height: 100%;
  background: linear-gradient(90deg, #3498db, #2980b9);
  width: 100%;
  transform-origin: left;
  animation: timerShrink var(--overlay-duration, 5000ms) linear forwards;
}

/* Confetti */
.confetti-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.confetti-particle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: #fff;
  opacity: 0;
  transform: translate(0, 0) scale(0) rotate(var(--rotate, 0deg));
  animation: fireworkExplosion 3s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
  will-change: transform, opacity;
}

.overlay-visual-burst-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.overlay-visual-particle {
  --particle-size: 52px;
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--particle-size);
  height: var(--particle-size);
  background: var(--overlay-particle-visual) center / contain no-repeat;
  opacity: 0;
  filter: saturate(1.12) contrast(1.06) drop-shadow(0 12px 18px rgba(9, 42, 86, 0.28));
  transform: translate(-50%, -50%) scale(0.46) rotate(0deg);
  animation: overlayVisualBurst 2400ms cubic-bezier(0.16, 0.84, 0.28, 1) forwards;
  will-change: transform, opacity;
}

@keyframes overlayVisualBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.42) rotate(0deg);
  }

  14% {
    opacity: 0.68;
  }

  44% {
    opacity: 0.46;
  }

  72% {
    opacity: 0.22;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, -120px))) scale(var(--end-scale, 1))
      rotate(var(--rotate, 0deg));
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-visual-burst-wrap {
    display: none;
  }
}

@keyframes fireworkExplosion {
  0% {
    transform: translate(0, 0) scale(0) rotate(0deg);
    opacity: 0;
  }

  /* Rapid burst phase */
  5% {
    opacity: 1;
  }

  20% {
    transform: translate(var(--tx), var(--ty)) scale(var(--scale, 1)) rotate(calc(var(--rotate, 0deg) + 90deg));
    opacity: 1;
  }

  /* Slow drifting/floating phase */
  60% {
    transform: translate(calc(var(--tx) * 1.1), calc(var(--ty) * 1.1 + 60px)) scale(var(--scale, 1))
      rotate(calc(var(--rotate, 0deg) + 360deg));
    opacity: 1;
  }

  /* Gravity-driven fall and fade phase */
  100% {
    transform: translate(calc(var(--tx) * 1.15), calc(var(--ty) * 1.1 + 400px)) scale(0)
      rotate(calc(var(--rotate, 0deg) + 720deg));
    opacity: 0;
  }
}

.example .label {
  display: inline-block;
  opacity: 0.95;
  font-size: 0.9em;
  padding: 0;
  margin-right: 0.45em;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand);
  border: none;
  font-weight: 600;
}

.example .text {
  display: block;
  margin-top: 0.35em;
  font-weight: 600;
}

.footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25em;
  padding: 2.5em 0;
  font-size: 0.95em;
  color: rgba(17, 17, 17, 0.72);
}

.footer-legal {
  margin-top: 1.4em;
  font-size: var(--type-caption);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  justify-content: center;
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-transform: none;
}

.footer-legal a {
  color: var(--color-brand);
  text-decoration: none;
  font-family: inherit;
  font-weight: inherit;
}

.footer-legal a:hover,
.footer-legal a:focus {
  text-decoration: underline;
  color: var(--color-brand-dark);
}

.footer-legal a:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 6px;
}

.footer-legal .footer-delimiter {
  color: rgba(17, 17, 17, 0.5);
  text-transform: none;
  user-select: none;
}

.back-to-top {
  position: fixed;
  top: auto;
  /* Reset generic button top:0 to prevent stretching */
  right: clamp(0.8rem, 4vw, 1.6rem);
  bottom: clamp(1rem, 6vw, 2.2rem);
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.55em 1.1em;
  border-radius: 999px;
  border: none;
  background: var(--color-brand);
  color: var(--color-bg);
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 1200;
}

.back-to-top:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.back-to-top:hover {
  background: var(--color-brand-deep);
  color: var(--color-bg);
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-6px);
}

body.home.flashcard-mode:has(.review-mode-container) .back-to-top {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0);
}

.back-to-top:active {
  top: auto;
  border: none;
  transform: translateY(-4px);
  box-shadow: var(--shadow-button);
}

@media (max-width: 640px) {
  .back-to-top {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.85rem, calc(env(safe-area-inset-bottom) + 0.75rem));
    max-width: calc(100vw - 1.5rem);
    padding: var(--spacing-sm) 0.95em;
    font-size: 0.85em;
    box-shadow: var(--shadow-button);
  }
}

/* Auth overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  overflow-y: auto;
  box-sizing: border-box;
}

.auth-overlay::after {
  content: '';
  display: block;
  flex: 0 0 auto;
  width: 0;
  height: env(safe-area-inset-bottom, 0px);
}

.auth-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.auth-dialog {
  position: relative;
  z-index: 1;
  width: min(440px, 92vw);
  overflow: visible;
  background: var(--color-surface-card);
  color: var(--color-text);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.4em 1.6em 1.4em;
  text-align: left;
  box-sizing: border-box;
  max-width: min(440px, calc(100vw - 3.5em));
}

@media (max-height: 640px) {
  .auth-dialog {
    overflow-y: auto;
  }
}

.auth-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: 0;
  background: transparent;
  font-size: 1.25em;
  cursor: pointer;
  color: rgba(17, 17, 17, 0.7);
  transition: none;
  padding: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.auth-close:hover,
.auth-close:focus {
  color: var(--color-brand);
  background-color: var(--color-brand-soft-wash);
  transform: none;
  filter: none;
}

.auth-close:active {
  top: 16px;
  border: 0;
  box-shadow: none;
  transform: none;
  background-color: rgba(0, 0, 0, 0.08);
}

.auth-dialog h2 {
  margin: 0;
  font-size: 1.4em;
}

.auth-description {
  margin: 0.6em 0 0;
  font-size: 0.95em;
  opacity: 0.8;
}

.auth-box {
  margin: 1.2em auto 0;
  padding: var(--spacing-md) 1.25em;
  border: var(--border-soft);
  border-radius: var(--radius-card);
  max-width: 360px;
  background: var(--color-surface-card);
  color: var(--color-text);
  text-align: left;
  box-shadow: var(--shadow-card);
}

.auth-box.is-busy {
  opacity: 0.65;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.auth-overlay.is-busy .auth-dialog {
  filter: saturate(0.9);
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  margin-top: 0.75em;
}

.auth-label {
  font-size: 0.85em;
  font-weight: 600;
  color: rgba(17, 17, 17, 0.85);
}

.auth-label .auth-required,
.auth-label .auth-optional {
  font-weight: 400;
  color: rgba(17, 17, 17, 0.6);
}

.auth-box input {
  width: 100%;
  padding: 0.6em 0.75em;
  margin: 0;
  border: 0;
  border-radius: 10px;
  font-size: 0.95em;
  box-sizing: border-box;
  background: transparent;
}

.auth-box input:focus,
.auth-box input:focus-visible {
  box-shadow: none;
}

.auth-box input:focus {
  outline: none;
}

.auth-box input:focus-visible {
  outline: none;
  outline-offset: 0;
}

.auth-box input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-field {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 0em 0.85em;
  margin: 0.35em 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.auth-field:focus-within {
  border-color: rgba(18, 63, 122, 0.16);
  box-shadow: none;
}

.auth-field-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(17, 17, 17, 0.6);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.auth-error {
  font-size: 0.8em;
  color: var(--color-accent);
  min-height: 1em;
}

.auth-feedback {
  margin-top: 0.75em;
  font-size: 0.85em;
  min-height: 1.2em;
}

.auth-feedback.is-error {
  color: var(--color-accent);
}

.auth-feedback.is-success {
  color: var(--color-success-strong);
}

.auth-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65em;
  color: rgba(17, 17, 17, 0.5);
  font-size: 0.7em;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0.35em 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(17, 17, 17, 0.12);
}

.auth-divider span {
  flex: 0 0 auto;
}

.auth-actions .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  width: 100%;
  position: relative;
  min-height: 44px;
  padding: 0 1.4em;
  border: 1px solid var(--color-brand-dark);
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(18, 63, 122, 0.2);
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.auth-action-icon {
  display: inline-block;
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 1.35rem;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 3px 5px rgba(9, 42, 86, 0.18));
  pointer-events: none;
}

.auth-action-icon[data-auth-icon='signup'] {
  background-image: url('/asset/metric-icons/stars.webp');
}

.auth-action-icon[data-auth-icon='login'] {
  background-image: url('/asset/metric-icons/focus.webp');
}

.auth-action-icon[data-auth-icon='magic'] {
  background-image: url('/asset/sprites/lantern-1.webp');
}

.auth-title-icon {
  display: inline-block;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.35rem;
  vertical-align: -0.25rem;
  background: url('/asset/metric-icons/focus.webp') center / contain no-repeat;
  filter: drop-shadow(0 3px 6px rgba(9, 42, 86, 0.16));
}

.chip.is-busy,
.auth-inline-action.is-busy {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

.auth-note {
  font-size: 0.85em;
  opacity: 0.78;
  margin-top: 0.75em;
}

.auth-session {
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

@media (max-width: 600px) {
  .auth-overlay {
    align-items: flex-start;
    padding: clamp(var(--spacing-sm), 4vw, 1.15em) clamp(0.75em, 5vw, 1.2em);
    overflow-x: hidden;
  }

  .auth-dialog {
    width: min(420px, calc(85vw));
    margin: clamp(0.6em, 6vw, 1.8em) auto 0;
    padding: clamp(0.85em, 4.2vw, 1.2em) clamp(0.8em, 4.2vw, 1.1em);
    border-radius: var(--radius-card);
    max-width: min(420px, calc(85vw));
    max-height: none;
    box-shadow: var(--shadow-card);
  }

  .auth-close {
    top: 0.85em;
    right: 0.9em;
  }

  .auth-box {
    max-width: calc(100% - 1.4em);
    margin: clamp(0.7em, 4vw, var(--spacing-md)) auto 0;
    padding: clamp(0.8em, 4vw, var(--spacing-md)) clamp(0.65em, 3.8vw, 0.95em);
    border-radius: 18px;
  }

  .auth-box input {
    padding: 0.7em 0.9em;
    border-radius: 14px;
    font-size: 1em;
  }

  .auth-actions {
    gap: var(--spacing-sm);
  }

  .auth-actions .chip {
    box-shadow: 0 14px 26px rgba(18, 63, 122, 0.16);
  }
}

/* Quiz footer overlay with compact controls */
body.quiz-page .footer {
  position: fixed;
  left: 50%;
  bottom: clamp(0.9em, 4vw, 1.8em);
  transform: translateX(-50%);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  justify-content: center;
  justify-items: center;
  gap: 0.65em;
  padding: 0.55em 0.75em;
  border-radius: 999px;
  z-index: 80;
  backdrop-filter: blur(2px) saturate(2%);
  -webkit-backdrop-filter: blur(2px) saturate(2%);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 36, 125, 0.2) transparent;
}

body.quiz-page .footer::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  pointer-events: none;
}

body.quiz-page .footer::-webkit-scrollbar {
  height: 6px;
}

body.quiz-page .footer::-webkit-scrollbar-thumb {
  background: rgba(0, 36, 125, 0.2);
  border-radius: 999px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-size: 0.95em;
  font-weight: 700;
  text-decoration: none;
  color: var(--color-bg);
}

.back-btn:hover,
.back-btn:focus {
  text-decoration: none;
}

body.quiz-page .footer .btn-accent {
  flex: 0 0 auto;
  min-width: 0;
}

body.quiz-page .footer .quiz-preferences {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.92em;
  color: rgba(17, 17, 17, 0.78);
}

body.quiz-page .footer .quiz-preferences label {
  font-weight: 600;
  font-size: 1.1em;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(0, 36, 125, 0.85);
}

body.quiz-page .footer .quiz-preferences select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0.45em 1.1em 0.45em 0.75em;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  letter-spacing: 0.02em;
  min-width: auto;
  width: auto;
  cursor: pointer;
}

body.quiz-page .footer .quiz-preferences select:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.quiz-page .footer .sound-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  margin-left: auto;
}

body.quiz-page .footer .sound-controls .chip,
body.quiz-page .footer .sound-help {
  flex: 0 0 auto;
}

body.quiz-page .footer .sound-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4em;
  padding: 0.6em 1.1em;
  border-radius: 999px;
  background: rgba(0, 36, 125, 0.08);
  color: var(--color-brand);
  font-weight: 600;
  font-size: 0.9em;
  text-decoration: none;
  border: 0;
  cursor: pointer;
}

body.quiz-page .footer .sound-help:hover,
body.quiz-page .footer .sound-help:focus {
  background: var(--color-brand-soft-wash);
  color: var(--color-brand);
}

body.quiz-page .footer .pro-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  padding: 0.6em 1.1em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 600;
  font-size: 0.9em;
  color: rgba(17, 17, 17, 0.8);
}

body.quiz-page .footer .pro-tip small {
  display: inline;
}

/* Page-specific overrides using body classes */

/* Shared quiz-page utilities and deduped rules */
/* Base quiz defaults via CSS variables */
body.quiz-page {
  --symbol-font-size: clamp(2.3em, 4.4vw, 3.4em);
  --symbol-margin: 0.6em 0 0.6em 0;
  --symbol-font-weight: 800;
  --symbol-color: var(--color-text);
  --symbol-text-shadow: none;
  --symbol-line-height: 1.2;
  --options-max-width: 620px;
  padding-bottom: calc(var(--page-padding) + 160px);
}

@media (max-width: 640px) {
  body.quiz-page {
    --symbol-font-size: clamp(1.55em, 6.8vw, 2.8em);
    --symbol-line-height: 1.28;
  }

  body.quiz-page.long-question #symbol {
    text-align: left;
    text-wrap: balance;
    hyphens: auto;
    letter-spacing: -0.01em;
    line-height: 1.34;
    padding: clamp(0.9em, 4vw, 1.2em);
    border-radius: 18px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.92);
    max-width: min(780px, calc(var(--options-max-width, 620px) + 220px));
  }

  body.quiz-page.long-question #symbol .secondary {
    font-size: 0.72em;
    color: rgba(17, 17, 17, 0.8);
  }
}

body.quiz-page .quiz-hero {
  padding: clamp(1.6em, 4vw, 2.4em) clamp(1.8em, 4.8vw, 2.8em);
  border-radius: 26px;
  background:
    linear-gradient(
      135deg,
      rgba(165, 25, 49, 0.16) 0%,
      rgba(255, 255, 255, 0.94) 28%,
      rgba(0, 36, 125, 0.18) 62%,
      rgba(165, 25, 49, 0.14) 100%
    ),
    rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
  text-align: left;
  width: 100%;
  max-width: min(780px, calc(var(--options-max-width, 620px) + 220px));
  box-sizing: border-box;
}

body.quiz-page .quiz-hero::before {
  content: '';
  position: absolute;
  inset: -30% -10% auto 35%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 65%);
  opacity: 0.9;
  pointer-events: none;
  transform: rotate(8deg);
}

body.quiz-page .quiz-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  pointer-events: none;
}

body.quiz-page .quiz-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65em;
  color: var(--color-text);
}

body.quiz-page .quiz-hero-label {
  margin: 0;
  font-size: 0.78em;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(0, 36, 125, 0.75);
}

body.quiz-page .quiz-hero-title {
  margin: 0;
  font-size: clamp(2.1em, 4.6vw, 3em);
  line-height: 1.1;
  font-weight: 900;
  color: var(--color-brand);
  text-shadow: 0 12px 26px rgba(0, 36, 125, 0.18);
}

body.quiz-page .quiz-hero-subtitle {
  margin: 0;
  max-width: 560px;
  font-size: 1.05em;
  opacity: 0.92;
  color: rgba(17, 17, 17, 0.86);
}

body.quiz-page .quiz-hero-subtitle:empty {
  display: none;
}

body.quiz-page .quiz-hero-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.65em var(--spacing-md);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 10px 24px rgba(0, 36, 125, 0.1);
  color: rgba(17, 17, 17, 0.9);
  font-weight: 600;
}

body.quiz-page .quiz-hero-tip small {
  font-size: 0.95em;
}

body.quiz-page .quiz-hero-protip:empty {
  display: none;
}

body.quiz-page .quiz-hero-protip small {
  display: inline;
  margin: 0;
}

@media (max-width: 640px) {
  body.quiz-page .quiz-hero {
    padding: clamp(1.3em, 5vw, 1.8em) clamp(1.1em, 6vw, 1.6em);
    border-radius: 22px;
  }

  body.quiz-page .quiz-hero-label {
    font-size: 0.7em;
    letter-spacing: 0.26em;
  }

  body.quiz-page .quiz-hero-title {
    font-size: clamp(1.8em, 7vw, 2.4em);
  }

  body.quiz-page .quiz-hero-subtitle {
    font-size: 1em;
  }

  body.quiz-page .quiz-hero-tip {
    flex-wrap: wrap;
    gap: 0.4em;
    padding: 0.6em 0.85em;
  }

  body.quiz-page .quiz-hero-tip {
    display: none;
  }
}

body.quiz-page #symbol {
  font-size: var(--symbol-font-size);
  margin: var(--symbol-margin);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  max-width: min(720px, calc(var(--options-max-width, 620px) + 160px));
  box-sizing: border-box;
  font-weight: var(--symbol-font-weight);
  color: var(--symbol-color);
  text-shadow: var(--symbol-text-shadow);
  line-height: var(--symbol-line-height);
  overflow-wrap: anywhere;
  word-break: break-word;
}

body.quiz-page .prompt-card {
  margin: clamp(0.8em, 3vw, 1.4em) auto clamp(1.2em, 3.5vw, 1.8em);
  padding: clamp(var(--spacing-md), 3.2vw, 1.6em) clamp(1.1em, 3.6vw, 1.9em);
  background: var(--color-surface-card);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  max-width: min(780px, calc(var(--options-max-width, 620px) + 220px));
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}

body.quiz-page .prompt-label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.3em 0.7em;
  border-radius: 999px;
  background: rgba(0, 36, 125, 0.08);
  color: rgba(17, 17, 17, 0.7);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8em;
  width: fit-content;
}

@media (max-width: 640px) {
  body.quiz-page .prompt-card {
    margin: clamp(0.6em, 3vw, var(--spacing-md)) auto clamp(var(--spacing-md), 4vw, 1.4em);
    padding: clamp(0.9em, 4vw, 1.2em) clamp(0.95em, 4.8vw, 1.35em);
    border-radius: 16px;
    gap: 0.3em;
  }

  body.quiz-page .prompt-label {
    font-size: 0.76em;
    letter-spacing: 0.12em;
  }
}

body.quiz-page .options {
  max-width: var(--options-max-width);
}

body.quiz-page .options button {
  background: var(--color-surface-card);
  border: 1px solid var(--color-brand-border-soft);
  border-bottom: 4px solid var(--color-brand-reward-soft);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
  color: var(--color-text-strong);
}

@media (hover: hover) and (pointer: fine) {
  body.quiz-page .options button:hover {
    background: var(--color-jade-wash);
    border-color: var(--color-jade-mid);
    box-shadow: var(--shadow-soft);
  }
}

body.quiz-page h1 {
  margin-bottom: 0.2em;
}

body.quiz-page #symbol .secondary {
  display: block;
  font-size: 0.8em;
  opacity: 0.95;
  margin-top: 0.15em;
  font-weight: 600;
}

body.quiz-page #symbol .emoji-line {
  font-size: 0.9em;
  opacity: 0.95;
  margin-bottom: 0.1em;
}

/* Cloze question layout: sentences prominent, hints smaller */
body.quiz-page #symbol .cloze-sentence {
  display: block;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.2em;
}

body.quiz-page #symbol .cloze-phonetic {
  color: var(--color-text);
}

body.quiz-page #symbol .cloze-thai {
  font-size: 0.85em;
  font-weight: 600;
  color: rgba(17, 17, 17, 0.7);
}

body.quiz-page #symbol .cloze-hints {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.18em;
  margin-top: 0.6em;
  font-size: 0.46em;
  font-weight: 600;
  color: rgba(17, 17, 17, 0.6);
}

body.quiz-page #symbol .cloze-hint-label {
  color: rgba(17, 17, 17, 0.58);
}

body.quiz-page #symbol .cloze-hint-word {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-reward-deep);
  font-weight: 800;
}

/* Cloze placeholder: explicit inline blank */
body.quiz-page #symbol .cloze-placeholder {
  display: inline-block;
  margin: 0 0.08em;
  color: var(--color-reward-deep);
  font-weight: 900;
  line-height: 1;
  vertical-align: baseline;
}

/* Consolidated options widths via variables */
body.numbers-quiz,
body.classifiers-quiz {
  --options-max-width: 600px;
}

body.color-quiz {
  --options-max-width: 500px;
}

body.vowel-quiz,
body.consonant-quiz,
body.consonant-clusters-quiz,
body.thai-modern-fonts-quiz {
  --options-max-width: 300px;
}

body.thai-modern-fonts-quiz {
  --symbol-font-weight: 500;
}

body.thai-modern-fonts-quiz #symbol {
  margin: 0;
  letter-spacing: 0.02em;
  transition:
    font-family 0.3s ease,
    letter-spacing 0.3s ease;
}

body.thai-modern-fonts-quiz #symbol .font-style-label {
  font-size: 0.1em;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
}

body.thai-modern-fonts-quiz #symbol[data-font-id='loopless'] {
  font-family: var(--font-thai-sarabun);
  font-weight: 400;
  letter-spacing: 0.015em;
}

body.thai-modern-fonts-quiz #symbol[data-font-id='rounded'] {
  font-family: var(--font-thai-kanit);
  font-weight: 500;
  letter-spacing: 0.01em;
}

body.thai-modern-fonts-quiz #symbol[data-font-id='modern'] {
  font-family: var(--font-thai-prompt);
  font-weight: 500;
  letter-spacing: 0.012em;
}

body.thai-modern-fonts-quiz #symbol[data-font-id='creative'] {
  font-family: var(--font-thai-kodchasan);
  font-weight: 500;
  letter-spacing: 0.005em;
}

body.thai-modern-fonts-quiz #symbol[data-font-id='soft'] {
  font-family: var(--font-thai-mitr);
  font-weight: 500;
  letter-spacing: 0.008em;
}

body.quiz-page.premium-locked .pro-tip,
body.quiz-page.premium-locked .prompt-card,
body.quiz-page.premium-locked #symbol,
body.quiz-page.premium-locked .options,
body.quiz-page.premium-locked #nextBtn,
body.quiz-page.premium-locked .stats {
  display: none !important;
}

body.quiz-page .quiz-premium-message {
  max-width: 520px;
  margin: 2.6em auto;
  padding: 1.8em 2.1em;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.08);
  text-align: center;
}

body.quiz-page .quiz-premium-message h2 {
  margin: 0 0 0.65em;
  font-size: 1.4em;
  color: var(--color-brand);
}

body.quiz-page .quiz-premium-message p {
  margin: 0;
  font-size: 1em;
  line-height: 1.55;
  opacity: 0.9;
}

body.quiz-page .quiz-premium-actions {
  margin-top: 1.4em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em;
  justify-content: center;
}

body.quiz-page .quiz-premium-actions .btn-accent {
  min-width: 150px;
}

/* Home (index) */
body.home h1 {
  margin-bottom: var(--spacing-md);
  font-size: 2.5em;
}

body.home .subtitle {
  font-size: 1.2em;
  margin-bottom: 3em;
}

body.home .brand-text .subtitle {
  margin-bottom: 0;
}

body.pricing-page .brand-text .brand-subtitle {
  font-size: var(--type-caption);
}

body.home .quiz-container {
  display: flex;
  justify-content: center;
  gap: var(--spacing-xl);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-xl);
  width: 100%;
}

body.home .quiz-spotlight-slot[hidden] {
  display: none;
}

body.home .quiz-spotlight-slot {
  width: min(720px, 100%);
  margin: var(--spacing-sm) auto 0;
  overflow: visible;
}

body.home .quiz-spotlight-card {
  --quiz-spotlight-background: none;
  display: grid;
  grid-template-columns: clamp(112px, 15vw, 156px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(1rem, 2.6vw, 1.65rem);
  min-height: clamp(144px, 17vw, 184px);
  padding: clamp(1rem, 2vw, 1.35rem);
  border: 1px solid rgba(23, 143, 134, 0.28);
  border-radius: var(--radius-card);
  position: relative;
  overflow: visible;
  isolation: isolate;
  background: var(--color-surface-card);
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  box-shadow:
    0 12px 32px rgba(18, 63, 122, 0.12),
    inset 0 0 0 1px rgba(183, 121, 31, 0.16);
  box-sizing: border-box;
}

body.home .quiz-spotlight-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  clip-path: inset(0 round var(--radius-card));
  background:
    linear-gradient(90deg, rgba(255, 248, 237, 0.76) 0%, rgba(237, 249, 247, 0.62) 58%, rgba(255, 241, 213, 0.78) 100%),
    radial-gradient(circle at 17% 50%, rgba(23, 143, 134, 0.22) 0%, rgba(183, 121, 31, 0.1) 36%, transparent 60%),
    var(--quiz-spotlight-background), var(--color-surface-card);
  background-position: center;
  background-repeat: no-repeat;
  background-size: auto, auto, cover, auto;
  pointer-events: none;
}

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

body.home .quiz-spotlight-ornament {
  position: absolute;
  z-index: 0;
  width: clamp(116px, 14vw, 190px);
  aspect-ratio: 1;
  background: url('/asset/ui/spotlight-corner-ornament.webp') center / contain no-repeat;
  opacity: 1;
  filter: saturate(0.92) brightness(1.04);
  pointer-events: none;
}

body.home .quiz-spotlight-ornament-start {
  top: clamp(-2rem, -2.8vw, -1.25rem);
  left: clamp(-2rem, -2.8vw, -1.25rem);
  transform: none;
}

body.home .quiz-spotlight-ornament-end {
  right: clamp(-2rem, -2.8vw, -1.25rem);
  bottom: clamp(-2rem, -2.8vw, -1.25rem);
  transform: rotate(180deg);
}

body.home .quiz-spotlight-card:hover,
body.home .quiz-spotlight-card:focus {
  color: var(--color-text);
  text-decoration: none;
}

body.home .quiz-spotlight-card:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .quiz-spotlight-visual {
  width: clamp(112px, 15vw, 156px);
  height: clamp(112px, 15vw, 156px);
  flex: 0 0 clamp(112px, 15vw, 156px);
  object-fit: contain;
}

body.home .quiz-spotlight-copy {
  min-width: 0;
}

body.home .quiz-spotlight-eyebrow {
  margin-bottom: 0.18rem;
  color: var(--color-jade-dark);
  font-size: var(--type-xs);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

body.home .quiz-spotlight-title {
  margin: 0;
  color: var(--color-brand-dark);
  font-size: var(--type-xl);
  line-height: 1.16;
  overflow-wrap: anywhere;
}

body.home .quiz-spotlight-message {
  margin: 0.28rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--type-sm);
  line-height: 1.42;
}

@media (max-width: 640px) {
  body.home .quiz-spotlight-card {
    grid-template-columns: clamp(88px, 25vw, 116px) minmax(0, 1fr);
    align-items: center;
  }

  body.home .quiz-spotlight-visual {
    width: clamp(88px, 25vw, 116px);
    height: clamp(88px, 25vw, 116px);
    flex-basis: clamp(88px, 25vw, 116px);
  }

  body.home .quiz-spotlight-ornament {
    width: clamp(92px, 26vw, 124px);
    opacity: 1;
  }
}

body.home .quest-loading-skeleton {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--spacing-lg);
  width: 100%;
}

body.home .quest-skeleton-card {
  display: grid;
  grid-template-columns: clamp(126px, 12vw, 174px) minmax(0, 1fr) clamp(96px, 11vw, 138px);
  align-items: center;
  gap: clamp(1em, 2.4vw, 1.65em);
  width: 100%;
  max-width: 640px;
  min-height: 174px;
  margin: 0 auto;
  padding: 1.8em;
  box-sizing: border-box;
  border: 1px solid rgba(18, 63, 122, 0.1);
  border-radius: 16px;
  background: var(--color-bg);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.06);
}

body.home .quest-skeleton-icon,
body.home .quest-skeleton-status,
body.home .quest-skeleton-line {
  position: relative;
  overflow: hidden;
  background: rgba(18, 63, 122, 0.09);
}

body.home .quest-skeleton-icon,
body.home .quest-skeleton-status {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
}

body.home .quest-skeleton-copy {
  display: flex;
  flex-direction: column;
  gap: 0.72em;
  min-width: 0;
}

body.home .quest-skeleton-line {
  width: 100%;
  height: 0.82rem;
  border-radius: 999px;
}

body.home .quest-skeleton-title {
  width: min(72%, 18rem);
  height: 1.35rem;
}

body.home .quest-skeleton-short {
  width: min(48%, 12rem);
}

body.home .quest-skeleton-icon::after,
body.home .quest-skeleton-status::after,
body.home .quest-skeleton-line::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.62), transparent);
  animation: questSkeletonShimmer 1.35s ease-in-out infinite;
}

@keyframes questSkeletonShimmer {
  to {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.home .quest-skeleton-icon::after,
  body.home .quest-skeleton-status::after,
  body.home .quest-skeleton-line::after {
    animation: none;
  }
}

body.home .quiz-container.flashcard-mode {
  display: block;
  gap: 0;
  align-self: stretch;
  width: 100%;
  max-width: min(1100px, 92vw);
  margin-left: auto;
  margin-right: auto;
}

body.home .flashcard-section {
  --study-row-background: none;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96) 0%, rgba(255, 248, 237, 0.96) 100%), var(--color-surface-card);
  border-radius: var(--radius-card);
  border: var(--border-soft);
  margin-bottom: var(--spacing-lg);
  overflow: visible;
  box-shadow: var(--shadow-card);
  max-width: 100%;
}

body.home .flashcard-section.premium-locked {
  border-color: rgba(183, 121, 31, 0.34);
  background: var(--color-reward-wash);
}

body.home .flashcard-section.premium-locked .flashcard-lock-badge {
  font-size: 0.55em;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
  color: var(--color-brand-dark);
  background: var(--color-reward-wash);
  border: 1px solid rgba(183, 121, 31, 0.35);
  padding: 0.32em 0.6em;
  border-radius: 999px;
  white-space: nowrap;
}

body.home .flashcard-section.premium-locked .flashcard-lock {
  margin-top: var(--spacing-md);
  padding: 1.1em 1.2em;
  border-radius: var(--radius-control);
  background: var(--color-surface-card);
  border: 1px dashed rgba(183, 121, 31, 0.42);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  align-items: center;
  box-shadow: inset 0 0 0 3px rgba(252, 241, 219, 0.72);
}

body.home .flashcard-section.premium-locked .flashcard-lock-message {
  font-weight: 700;
  color: var(--color-text);
}

body.home .flashcard-section.premium-locked .flashcard-lock-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55em 1.35em;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
  color: var(--color-bg);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-button);
}

body.home .flashcard-section.premium-locked .flashcard-lock-cta:hover,
body.home .flashcard-section.premium-locked .flashcard-lock-cta:focus {
  text-decoration: none;
  color: var(--color-bg);
  box-shadow: 0 16px 32px rgba(0, 36, 125, 0.3);
}

body.home .flashcard-section.premium-locked .flashcard-lock-cta:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .flashcard-section.is-ongoing::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 0.45rem;
  height: 100%;
  background: linear-gradient(180deg, var(--color-jade) 0%, var(--color-brand) 100%);
  box-shadow:
    inset -1px 0 0 rgba(255, 253, 248, 0.46),
    0 0 16px rgba(23, 143, 134, 0.28);
  pointer-events: none;
  z-index: 2;
}

body.home .flashcard-section.is-ongoing {
  border-color: rgba(23, 143, 134, 0.34);
  box-shadow:
    var(--shadow-card),
    inset 0 0 0 1px rgba(23, 143, 134, 0.12);
  padding-left: 0;
}

body.home .flashcard-section summary {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1em;
  list-style: none;
  padding: 0.5em var(--spacing-lg);
  cursor: pointer;
  user-select: none;
  min-height: 112px;
  overflow: hidden;
  border-radius: var(--radius-card);
  isolation: isolate;
}

body.home .flashcard-section summary::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  clip-path: inset(0 round var(--radius-card));
  background:
    linear-gradient(90deg, rgba(255, 253, 248, 0.74) 0%, rgba(255, 248, 237, 0.62) 42%, rgba(255, 253, 248, 0.78) 100%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.14), rgba(255, 248, 237, 0.46)), var(--study-row-background);
  background-position:
    center,
    center,
    left center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.9;
  filter: saturate(0.92);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    filter 0.2s ease;
}

body.home .flashcard-section summary > * {
  z-index: 1;
}

body.home .flashcard-section-visual {
  width: clamp(86px, 9vw, 104px);
  height: clamp(86px, 9vw, 104px);
  flex: 0 0 clamp(86px, 9vw, 104px);
  object-fit: contain;
  aspect-ratio: 1;
}

body.home .flashcard-section summary:hover {
  background: rgba(252, 241, 219, 0.64);
}

body.home .flashcard-section summary:hover::before {
  opacity: 1;
  filter: saturate(1);
}

body.home .flashcard-section summary::-webkit-details-marker {
  display: none;
}

body.home .flashcard-section summary::marker {
  content: '';
}

body.home .flashcard-section h3 {
  margin: 0;
  font-size: clamp(1.15em, 2.6vw, 1.4em);
  flex: 1;
  min-width: 0;
  line-height: 1.14;
  color: var(--color-brand-dark);
  overflow-wrap: anywhere;
  hyphens: auto;
  text-align: left;
}

body.home .flashcard-section .flashcard-summary-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
  margin-left: auto;
  flex-shrink: 0;
}

body.home .flashcard-section .flashcard-ongoing-tag {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  padding: 0;
  font-size: 0.6em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-reward-deep);
  background: transparent;
  border: 0;
  box-shadow: none;
  text-shadow: 0 1px 0 rgba(255, 253, 248, 0.72);
  pointer-events: none;
  z-index: 3;
}

body.home .flashcard-match {
  background: var(--color-reward-wash);
  padding: 0 0.08em;
  border-radius: 4px;
  box-shadow: inset 0 -0.3em 0 rgba(242, 184, 75, 0.3);
}

body.home .flashcard-content {
  padding: 0 var(--spacing-lg) var(--spacing-lg);
  border-top: var(--border-soft);
}

body.home .flashcard-section.flashcard-section-animated.is-expanding .flashcard-content,
body.home .flashcard-section.flashcard-section-animated.is-collapsing .flashcard-content {
  transition:
    max-height 0.24s ease,
    opacity 0.18s ease,
    transform 0.24s ease;
  will-change: max-height, opacity, transform;
}

body.home .flashcard-loading-placeholder {
  padding: var(--spacing-lg);
  color: var(--color-text-muted);
  text-align: center;
  font-style: italic;
}

body.home .flashcard-section summary:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 12px;
}

body.home .flashcard-table-wrapper {
  overflow-x: auto;
  margin-top: var(--spacing-md);
}

body.home .flashcard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 320px;
  border: var(--border-soft);
  background: var(--color-surface-card);
  border-radius: var(--radius-control);
  overflow: hidden;
}

body.home .flashcard-table th,
body.home .flashcard-table td {
  padding: 0.75em var(--spacing-md);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body.home .flashcard-table thead th {
  background: var(--color-jade-soft);
  color: var(--color-jade-dark);
  font-weight: 600;
}

body.home .flashcard-table tbody tr:nth-child(even) {
  background: rgba(252, 241, 219, 0.48);
}

body.home .flashcard-table tbody tr:last-child td {
  border-bottom: none;
}

body.home .flashcard-table td.flashcard-cell-phonetic {
  font-style: italic;
  color: rgba(17, 17, 17, 0.75);
}

@media (max-width: 640px) {
  body.home .flashcard-section summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'visual'
      'title'
      'actions';
    justify-items: center;
    align-items: start;
    gap: 0.65rem;
    min-height: clamp(318px, 84vw, 372px);
    padding: clamp(1rem, 4vw, 1.25rem);
    text-align: center;
  }

  body.home .flashcard-section-visual {
    grid-area: visual;
    width: clamp(150px, 48vw, 184px);
    height: clamp(150px, 48vw, 184px);
    align-self: center;
    justify-self: center;
    margin-top: 0.2rem;
  }

  body.home .flashcard-section h3 {
    grid-area: title;
    width: min(100%, 20rem);
    flex: initial;
    align-self: center;
    font-size: var(--type-title-md);
    line-height: 1.08;
    text-align: center;
    text-wrap: balance;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
  }

  body.home .flashcard-section .flashcard-summary-actions {
    grid-area: actions;
    width: 100%;
    margin-left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6em;
    align-self: start;
  }

  body.home .flashcard-section .flashcard-ongoing-tag {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
    writing-mode: vertical-rl;
    margin-right: 0;
    font-size: 0.56rem;
    letter-spacing: 0.13em;
  }

  body.home .flashcard-section .flashcard-lock-badge {
    margin: 0 auto;
  }

  body.home .flashcard-section .flashcard-summary-actions .flashcard-ongoing-tag {
    position: absolute;
  }

  body.home .flashcard-section .flashcard-summary-actions .quiz-chip-review-btn {
    width: auto;
    min-width: 0;
    max-width: none;
    padding-left: 1.15em;
    padding-right: 1.15em;
  }

  body.home .flashcard-section .flashcard-summary-actions .flashcard-favorite-btn {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    transform: none;
    justify-self: auto;
    margin-left: 0;
  }

  body.home .flashcard-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    border: 0;
  }

  body.home .flashcard-table,
  body.home .flashcard-table tbody,
  body.home .flashcard-table tr,
  body.home .flashcard-table td {
    display: block;
    width: auto;
  }

  body.home .flashcard-table {
    border: none;
    min-width: 0;
  }

  body.home .flashcard-table tbody tr {
    margin-bottom: 0.9em;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.02);
  }

  body.home .flashcard-table td {
    border: none;
    padding: 0.95em 1.4em 0.95em 6.4em;
    position: relative;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  body.home .flashcard-table td:last-child {
    border-bottom: none;
  }

  body.home .flashcard-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 5.4em;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 1.3em;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.5);
    line-height: 1.2;
  }
}

body.home .home-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  padding: 0.25em 0 1em;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  max-width: 720px;
  width: 100%;
  box-sizing: border-box;
}

body.home .home-controls .controls-primary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

body.home:not(.quest-mode) .home-controls .controls-primary {
  gap: 0.4em;
  align-items: stretch;
}

body.home .home-controls .search-wrapper {
  display: flex;
  transition:
    max-height 0.28s ease,
    opacity 0.24s ease,
    margin 0.24s ease;
  max-height: 74px;
  opacity: 1;
}

body.home .home-controls .search-wrapper input {
  width: 100%;
}

body.home .home-controls .chip-group {
  justify-content: flex-start;
}

body.home .home-controls .controls-primary + .filters {
  margin-top: 0.3em;
}

body.home .home-controls .filters {
  transition:
    max-height 0.32s ease,
    opacity 0.26s ease,
    margin 0.24s ease;
  max-height: 360px;
  opacity: 1;
}

body.home .view-toggle {
  --switch-index: 0;
  --switch-gap: 0.18em;
  --switch-padding: 0.35em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--switch-gap);
  padding: var(--switch-padding);
  background: var(--color-reward-wash);
  border-radius: 999px;
  border: 1px solid rgba(183, 121, 31, 0.24);
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

body.home .view-toggle::before {
  content: '';
  position: absolute;
  top: var(--switch-padding);
  bottom: var(--switch-padding);
  left: var(--switch-padding);
  width: calc((100% - (var(--switch-padding) * 2) - (var(--switch-gap) * 2)) / 3);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  box-shadow: var(--shadow-button);
  transform: translateX(calc(var(--switch-index) * (100% + var(--switch-gap))));
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.22s ease,
    opacity 0.18s ease;
  z-index: 0;
}

body.home .view-toggle .view-chip + .view-chip {
  margin-left: 0;
}

body.home .view-chip {
  border: none;
  background: transparent;
  color: var(--color-brand-dark);
  border-radius: 999px;
  padding: 0.45em 1.2em;
  font-size: var(--type-action-lg);
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  z-index: 1;
  top: 0;
  border-bottom-width: 0;
}

body.home .view-chip:active {
  top: 0;
  transform: none;
  border-bottom-width: 0;
  box-shadow: none;
}

body.home .view-chip:hover {
  background: rgba(255, 255, 255, 0.72);
  color: var(--color-brand-dark);
  box-shadow: none;
  transform: none;
}

body.home .view-chip.active {
  background: transparent;
  color: var(--color-bg);
  box-shadow: none;
}

body.home .view-chip.active:hover {
  background: transparent;
  color: var(--color-bg);
  transform: none;
  box-shadow: none;
}

body.home .view-chip.is-locked {
  color: var(--color-text-muted);
  cursor: not-allowed;
  background: transparent;
  box-shadow: none;
}

body.home .view-chip.is-locked:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.home .view-chip:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.learning-mode-segment {
  --switch-index: 0;
  --switch-gap: 0.15rem;
  --switch-padding: 0.22rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--switch-gap);
  padding: var(--switch-padding);
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.72);
  position: relative;
  isolation: isolate;
}

.learning-mode-segment::before {
  content: '';
  position: absolute;
  top: var(--switch-padding);
  bottom: var(--switch-padding);
  left: var(--switch-padding);
  width: calc((100% - (var(--switch-padding) * 2) - var(--switch-gap)) / 2);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  box-shadow: var(--shadow-button);
  transform: translateX(calc(var(--switch-index) * (100% + var(--switch-gap))));
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.22s ease,
    opacity 0.18s ease;
  z-index: 0;
}

.learning-mode-button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-brand-dark);
  min-width: 5.4rem;
  padding: 0.42rem 0.78rem;
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition:
    color 0.2s ease,
    transform 0.18s ease;
}

.learning-mode-button:hover,
.learning-mode-button:focus-visible {
  background: rgba(255, 255, 255, 0.72);
  transform: none;
}

.learning-mode-button.is-active {
  background: transparent;
  color: var(--color-bg);
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  body.home .view-toggle::before,
  .learning-mode-segment::before,
  .learning-mode-button {
    transition: none;
  }
}

.flashcard-lock-overlay {
  position: absolute;
  bottom: calc(100% + 0.6em);
  left: 50%;
  transform: translate3d(-50%, 6px, 0);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 14px;
  box-shadow:
    0 16px 32px rgba(0, 0, 0, 0.2),
    0 6px 12px rgba(0, 0, 0, 0.12);
  padding: 0.85em 1.1em;
  max-width: min(320px, 80vw);
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  align-items: center;
  text-align: center;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 25;
}

.flashcard-lock-overlay::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 8px;
  border-style: solid;
  border-color: var(--color-bg) transparent transparent transparent;
}

.flashcard-lock-overlay strong {
  font-size: 0.78em;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(0, 36, 125, 0.9);
}

.flashcard-lock-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(-50%, 0, 0);
}

.flashcard-lock-overlay[hidden] {
  display: none;
}

body.home.quest-mode .filters,
body.home.quest-mode .home-controls .filters,
body.home.flashcard-mode .filters,
body.home.flashcard-mode .home-controls .filters {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Pricing */
body.pricing-page {
  background:
    radial-gradient(circle at 18% 8%, rgba(242, 184, 75, 0.13), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(23, 143, 134, 0.12), transparent 24rem),
    linear-gradient(180deg, var(--color-bg) 0%, #fffdf8 58%, #f7ead6 100%);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

body.stats-page {
  background:
    radial-gradient(circle at 18% 8%, rgba(242, 184, 75, 0.13), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(23, 143, 134, 0.12), transparent 24rem),
    linear-gradient(180deg, var(--color-bg) 0%, #fffdf8 58%, #f7ead6 100%);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

body.pricing-page::before {
  content: '';
  position: absolute;
  top: 4rem;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(220px, 32vw, 340px);
  height: clamp(220px, 32vw, 340px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(0, 36, 125, 0.28) 0%, rgba(0, 36, 125, 0.08) 55%, rgba(0, 36, 125, 0) 100%),
    repeating-linear-gradient(
      135deg,
      rgba(0, 36, 125, 0.08) 0 16px,
      rgba(165, 25, 49, 0.06) 16px 32px,
      transparent 32px 48px
    );
  filter: blur(0.2px);
}

body.stats-page::before {
  content: none;
}

.pricing-content {
  width: 100%;
  max-width: 960px;
  margin: 0 auto var(--spacing-xl);
  padding: 0em var(--spacing-lg) 0;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.stats-content {
  width: 100%;
  max-width: 960px;
  margin: 0 auto 2.5em;
  padding: 0 var(--spacing-lg);
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.pricing-hero {
  text-align: center;
  margin-bottom: 2.5em;
}

.stats-hero {
  text-align: center;
  margin: 2.8em auto 2.2em;
  max-width: 720px;
}

.stats-hero h2 {
  font-size: clamp(1.4em, 4.5vw, 3em);
  margin-bottom: 0.25em;
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-brand);
  text-shadow: 0 4px 12px rgba(0, 36, 125, 0.1);
  line-height: 1.3;
}

.stats-lead {
  font-size: 1.05em;
  opacity: 0.85;
  margin-bottom: 0.8em;
}

.stats-updated {
  font-weight: 600;
  color: rgba(0, 36, 125, 0.75);
}

.stats-feedback {
  margin: 0 auto 1.2em;
  padding: 0.9em 1.1em;
  max-width: 640px;
  border-radius: 14px;
  background: rgba(0, 36, 125, 0.08);
  color: rgba(0, 36, 125, 0.85);
  font-weight: 600;
}

.stats-feedback:empty {
  display: none;
}

.stats-feedback-info {
  background: rgba(0, 36, 125, 0.1);
  color: rgba(0, 36, 125, 0.9);
}

.stats-feedback-error {
  background: rgba(165, 25, 49, 0.08);
  color: rgba(165, 25, 49, 0.9);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.6em;
}

.stats-card {
  background: var(--color-surface-card);
  border-radius: var(--radius-card);
  padding: 1.6em 1.4em;
  box-shadow: var(--shadow-card);
  border: var(--border-soft);
  position: relative;
  overflow: hidden;
}

.stats-card h3 {
  margin-top: 0;
  margin-bottom: 0.9em;
  font-size: 1.35em;
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.8em;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-md);
  align-items: baseline;
}

.stats-row dt {
  font-weight: 600;
  color: rgba(0, 0, 0, 0.66);
}

.stats-row dd {
  margin: 0;
  font-weight: 700;
  font-size: 1.15em;
  color: rgba(0, 36, 125, 0.9);
}

.stats-highlight {
  margin-top: 1.1em;
  font-size: 0.95em;
  font-weight: 600;
  color: rgba(0, 36, 125, 0.85);
}

.stats-note {
  margin-top: 1.1em;
  font-size: 0.9em;
  color: rgba(0, 0, 0, 0.6);
}

@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-card {
    padding: 1.4em 1.2em;
  }

  .stats-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-row dd {
    font-size: 1.1em;
  }
}

/* ============================================================================
   Progress Dashboard Styles
   ============================================================================ */

.stats-section {
  margin-bottom: 2.5em;
}

.stats-section-title {
  font-size: clamp(1.1em, 3.5vw, 1.5em);
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.6em;
  color: var(--color-brand);
  line-height: 1.4;
}

.stats-section-lead {
  font-size: 0.95em;
  opacity: 0.75;
  margin: 0 0 1.2em;
}

.personal-bests-grid.achievements-summary-grid {
  grid-template-columns: repeat(4, 1fr);
}

.achievements-summary-actions {
  margin-top: 1.2em;
  display: flex;
  justify-content: center;
}

/* Personal Bests Grid */
.personal-bests-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1em;
}

.personal-best-card,
.settings-group {
  background: var(--color-surface-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: var(--border-soft);
}

.personal-best-card {
  padding: 1.4em 1.2em;
  text-align: center;
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease,
    background 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.personal-best-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--color-brand);
  opacity: 0.15;
}

.personal-best-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.personal-best-icon {
  font-size: 1.8em;
  margin-bottom: 0.2em;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.personal-best-value {
  font-size: 2.4em;
  font-weight: 800;
  color: var(--color-brand);
  line-height: 1;
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.personal-best-label {
  font-size: 0.72em;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 0.6em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.personal-best-sublabel {
  font-size: 0.85em;
  color: rgba(0, 36, 125, 0.75);
  margin-top: 0.25em;
  font-weight: 600;
}

@media (max-width: 768px) {
  .personal-bests-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .personal-bests-grid.achievements-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .personal-bests-grid {
    grid-template-columns: 1fr;
  }

  .personal-bests-grid.achievements-summary-grid {
    grid-template-columns: 1fr;
  }

  .personal-best-card {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      'icon'
      'value'
      'label'
      'sublabel';
    align-items: center;
    gap: 0.35em;
    text-align: center;
    padding: 1em;
  }

  .personal-best-icon {
    grid-area: icon;
    margin-bottom: 0.2em;
    width: 1.6em;
    height: 1.6em;
    justify-self: center;
  }

  .personal-best-value {
    grid-area: value;
    font-size: 1.8em;
    min-width: 0;
  }

  .personal-best-label {
    grid-area: label;
    margin-top: 0;
  }

  .personal-best-sublabel {
    grid-area: sublabel;
  }
}

/* Activity Graph (GitHub-style) */
.activity-graph-container {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 1.4em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}

.activity-graph {
  display: flex;
  gap: 3px;
  min-height: 100px;
}

.activity-loading,
.activity-error {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100px;
  color: rgba(0, 0, 0, 0.5);
  font-size: 0.9em;
}

.activity-day-labels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 6px;
}

.activity-day-label {
  height: 12px;
  font-size: 9px;
  color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
}

.activity-weeks-grid {
  display: flex;
  gap: 3px;
}

.activity-week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.activity-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.06);
  transition: transform 0.1s ease;
}

.activity-cell:hover {
  transform: scale(1.3);
}

.activity-cell[data-level='0'] {
  background: rgba(0, 0, 0, 0.06);
}

.activity-cell[data-level='1'] {
  background: rgba(0, 36, 125, 0.12);
}

.activity-cell[data-level='2'] {
  background: rgba(0, 36, 125, 0.35);
}

.activity-cell[data-level='3'] {
  background: rgba(0, 36, 125, 0.65);
}

.activity-cell[data-level='4'] {
  background: var(--color-brand);
  box-shadow: 0 0 10px rgba(0, 36, 125, 0.4);
}

.activity-cell-today {
  box-shadow: 0 0 0 2px var(--color-brand);
}

.activity-cell-future {
  opacity: 0.3;
  pointer-events: none;
}

.activity-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 0.8em;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.5);
}

.activity-legend-label {
  padding: 0 4px;
}

.activity-legend-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.activity-legend-cell[data-level='0'] {
  background: rgba(0, 0, 0, 0.06);
}

.activity-legend-cell[data-level='1'] {
  background: rgba(0, 36, 125, 0.12);
}

.activity-legend-cell[data-level='2'] {
  background: rgba(0, 36, 125, 0.35);
}

.activity-legend-cell[data-level='3'] {
  background: rgba(0, 36, 125, 0.65);
}

.activity-legend-cell[data-level='4'] {
  background: var(--color-brand);
}

.activity-summary {
  display: flex;
  gap: 2em;
  margin-top: 1.2em;
  justify-content: center;
}

.activity-stat {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
}

.activity-stat-value {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--color-brand);
}

.activity-stat-label {
  font-size: 0.9em;
  color: rgba(0, 0, 0, 0.6);
}

/* ============================================================================
   Review Analytics Dashboard
   ============================================================================ */

.analytics-maturity,
.analytics-accuracy,
.analytics-heatmap {
  margin-bottom: 2em;
}

.analytics-subtitle {
  font-size: 1em;
  font-weight: 600;
  margin: 0 0 0.75em;
  color: rgba(0, 0, 0, 0.8);
}

/* Maturity Card — matches personal-best-card glass style */
.analytics-maturity-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 18px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.04),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1.6em 1.4em;
  position: relative;
  overflow: hidden;
}

.analytics-maturity-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--color-brand);
  opacity: 0.15;
}

.analytics-maturity-row {
  display: flex;
  align-items: center;
  gap: 2em;
  justify-content: center;
  flex-wrap: wrap;
}

/* Maturity Donut */
.maturity-donut {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: conic-gradient(
    var(--maturity-known-color, #28a745) 0deg calc(var(--known-pct, 0) * 3.6deg),
    var(--maturity-learning-color, #3498db) calc(var(--known-pct, 0) * 3.6deg)
      calc((var(--known-pct, 0) + var(--learning-pct, 0)) * 3.6deg),
    var(--maturity-unseen-color, #d5dbe5) calc((var(--known-pct, 0) + var(--learning-pct, 0)) * 3.6deg) 360deg
  );
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 4px 16px rgba(0, 36, 125, 0.1),
    inset 0 0 0 3px rgba(255, 255, 255, 0.5);
}

.maturity-donut::after {
  content: '';
  position: absolute;
  inset: 28%;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.06);
}

.maturity-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
}

.maturity-donut-total {
  font-size: 1.6em;
  font-weight: 800;
  line-height: 1;
  color: var(--color-brand);
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.maturity-donut-label {
  font-size: 0.65em;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.2em;
}

/* Maturity Legend */
.maturity-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  min-width: 140px;
}

.maturity-legend-item {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: 0.88em;
  font-weight: 500;
}

.maturity-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.maturity-legend-dot.known {
  background: var(--maturity-known-color, #28a745);
}

.maturity-legend-dot.learning {
  background: var(--maturity-learning-color, #3498db);
}

.maturity-legend-dot.unseen {
  background: var(--maturity-unseen-color, #d5dbe5);
}

.maturity-legend-label {
  color: rgba(0, 0, 0, 0.6);
}

.maturity-legend-count {
  font-weight: 700;
  color: var(--color-brand);
  margin-left: auto;
  padding-left: 1em;
  font-family: var(--font-heading);
  font-size: 0.85em;
}

/* Accuracy Trend Chart */
.accuracy-trend-chart {
  display: flex;
  align-items: flex-end;
  height: 120px;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.accuracy-bar {
  flex: 1;
  min-width: 4px;
  border-radius: 2px 2px 0 0;
  background: var(--color-class-low, #3498db);
  cursor: pointer;
  position: relative;
  transition: opacity 0.15s;
}

.accuracy-bar:hover {
  opacity: 0.8;
}

.accuracy-bar[data-reviewed='0'] {
  height: 4px !important;
  background: var(--border-color, #e2e8f0);
  border-radius: 50%;
  align-self: flex-end;
  cursor: default;
}

.accuracy-bar-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 0.7em;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

.accuracy-bar:hover .accuracy-bar-tooltip {
  display: block;
}

/* Review Replay Button */
.review-replay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
  font-size: 1.2em;
  margin-top: 0.5em;
  transition: background 0.15s;
}

.review-replay-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* Review Direction Mode Select */
.review-settings-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5em 0;
}

.review-settings-select {
  padding: 0.45em 0.75em;
  border-radius: var(--radius-control);
  border: var(--border-soft);
  background: var(--color-surface-card);
  color: var(--color-text);
  font-size: 0.85em;
  max-width: 220px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.review-settings-select:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .analytics-maturity-card {
    padding: 1.2em 1em;
  }

  .analytics-maturity-row {
    flex-direction: column;
    gap: 1.2em;
  }

  .maturity-donut {
    width: 110px;
    height: 110px;
  }

  .maturity-donut-total {
    font-size: 1.3em;
  }

  .maturity-legend {
    flex-direction: row;
    gap: 1.5em;
    min-width: 0;
  }

  .maturity-legend-count {
    margin-left: 0.4em;
    padding-left: 0;
  }

  .accuracy-trend-chart {
    height: 100px;
  }
}

/* Category Mastery Grid */
.category-mastery-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25em;
}

.category-loading,
.category-empty,
.category-error {
  padding: 2em;
  text-align: center;
  color: rgba(0, 0, 0, 0.5);
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
}

.category-mastery-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 1.8em 1em;
  text-align: center;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.03),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2em;
}

.category-mastery-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

.category-mastery-circle {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--color-brand) var(--progress), rgba(0, 36, 125, 0.08) 0deg);
  transition: --progress 0.5s ease;
}

/* Inner circle for the "bar" look */
.category-mastery-circle::after {
  content: '';
  position: absolute;
  width: 70px;
  height: 70px;
  background: #f8f9fa;
  /* Match the subtle card background or transparency */
  border-radius: 50%;
  z-index: 1;
}

.category-mastery-circle-label {
  position: relative;
  z-index: 2;
  font-weight: 800;
  font-size: 0.95em;
  color: var(--color-brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.category-mastery-star-icon {
  font-size: 0.8em;
  opacity: 0.8;
}

.category-mastery-info {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}

.category-mastery-name {
  font-weight: 700;
  font-size: 0.9em;
  color: rgba(0, 0, 0, 0.85);
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  word-wrap: break-word;
  max-width: 100%;
}

.category-mastery-count {
  font-size: 0.78em;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.boss-lore-list {
  display: grid;
  gap: 1em;
}

.boss-lore-card {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 1em;
  align-items: start;
  padding: 1em;
  border-radius: 0;
  border: 3px solid #111;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(245, 247, 255, 0.94) 100%), rgba(255, 255, 255, 0.85);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.45),
    inset -2px -2px 0 rgba(0, 0, 0, 0.12),
    8px 8px 0 rgba(0, 0, 0, 0.1);
}

.boss-lore-media {
  width: 108px;
  height: 108px;
  border-radius: 0;
  overflow: hidden;
  border: 3px solid #111;
  background: #fff;
}

.boss-lore-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}

.boss-lore-body {
  min-width: 0;
}

.boss-lore-name {
  margin: 0;
  font-size: 1.02em;
  font-family: var(--font-heading);
  color: var(--color-brand);
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.boss-lore-quest {
  margin-top: 0.5em;
  font-size: 0.68em;
  color: rgba(0, 36, 125, 0.9);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: inline-block;
  padding: 0.2em 0.5em;
  border: 2px solid #111;
  background: rgba(0, 36, 125, 0.09);
}

.boss-lore-text {
  margin: 0.75em 0 0;
}

.boss-lore-text-paragraph {
  margin: 0;
  font-size: 0.9em;
  line-height: 1.5;
}

.boss-lore-text-paragraph + .boss-lore-text-paragraph {
  margin-top: 0.8em;
}

@media (max-width: 640px) {
  .boss-lore-card {
    grid-template-columns: 1fr;
  }

  .boss-lore-media {
    width: 100%;
    height: 170px;
  }
}

/* ============================================================================
   Settings Section Styles
   ============================================================================ */

.settings-section {
  margin-top: 2em;
}

.settings-grid {
  display: grid;
  gap: 1em;
  width: min(100%, 920px);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: stretch;
  margin: 0 auto;
}

.settings-container {
  max-width: none;
  width: 100%;
  display: flex;
}

.settings-container .settings-group {
  flex: 1;
}

.settings-group {
  padding: 1.6em;
  display: flex;
  flex-direction: column;
}

.settings-group-title {
  font-size: 1em;
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.4em;
  color: var(--color-brand);
}

.settings-description {
  font-size: 0.9em;
  opacity: 0.7;
  margin: 0 0 1.2em;
  line-height: 1.4;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.8em 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  gap: 0.8em;
}

.settings-row.settings-row-stack {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.settings-row.settings-row-stack .settings-label {
  text-align: center;
}

.settings-row.settings-row-stack .settings-action-btn,
.settings-row.settings-row-stack .settings-action-link {
  align-self: center;
}

.settings-row:last-of-type {
  border-bottom: none;
}

.settings-label {
  font-size: 0.95em;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.8);
  flex: 1;
}

.settings-helper {
  font-size: 0.85em;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.5);
  margin-top: 0.35em;
  line-height: 1.3;
}

.settings-warning {
  font-size: 0.85em;
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
  padding: 0.8em 1em;
  border-radius: 8px;
  margin-top: 1em;
  line-height: 1.4;
}

.settings-action-btn {
  border-radius: 999px;
  border: 1px solid rgba(0, 36, 125, 0.2);
  background: rgba(0, 36, 125, 0.08);
  color: var(--color-brand);
  font-weight: 700;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  white-space: nowrap;
}

.settings-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 36, 125, 0.15);
}

.settings-action-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.settings-action-btn-danger {
  border-color: rgba(146, 35, 48, 0.3);
  background: rgba(146, 35, 48, 0.08);
  color: #8b1f2c;
}

.settings-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 36, 125, 0.2);
  text-decoration: none;
  color: var(--color-brand);
  font-weight: 700;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  background: #fff;
  white-space: nowrap;
}

.settings-action-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 36, 125, 0.15);
}

.settings-action-link:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6em;
  }

  .settings-action-btn,
  .settings-action-link {
    width: 100%;
    justify-content: center;
    white-space: normal;
  }
}

/* Time input */
.settings-time-input {
  font-family: inherit;
  font-size: 0.95em;
  padding: 0.5em 0.8em;
  border: var(--border-soft);
  border-radius: var(--radius-control);
  background: var(--color-surface-card);
  color: var(--color-text);
  min-width: 110px;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.settings-time-input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(0, 36, 125, 0.1);
}

.settings-time-input:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

/* Toggle Switch (iOS style) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch .toggle-input {
  opacity: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
  z-index: 2;
  margin: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.15);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 28px;
}

.toggle-slider::before {
  position: absolute;
  content: '';
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.toggle-input:checked + .toggle-slider {
  background-color: var(--color-brand);
}

.toggle-input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.toggle-input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(0, 36, 125, 0.15);
}

.toggle-input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   Focus Sessions
   ============================================================================ */

.session-timer-overlay {
  --session-progress: 360deg;
  --session-ring-color: var(--color-jade);
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    'display controls'
    'stats stats';
  gap: 0.5rem 0.65rem;
  align-items: center;
  width: max-content;
  min-width: 0;
  max-width: min(26rem, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 0.58rem 0.68rem 0.62rem;
  border: 1px solid rgba(183, 121, 31, 0.26);
  border-bottom-color: rgba(183, 121, 31, 0.38);
  border-radius: 1.6rem;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 16% 18%, rgba(242, 184, 75, 0.2), transparent 4.5rem),
    radial-gradient(circle at 84% 18%, rgba(23, 143, 134, 0.16), transparent 4.8rem),
    linear-gradient(135deg, rgba(255, 253, 248, 0.96), rgba(255, 244, 224, 0.91));
  box-shadow: 0 18px 44px rgba(79, 45, 19, 0.16);
  color: var(--color-brand-dark);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.session-timer-overlay::before,
.session-timer-overlay::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.session-timer-overlay::before {
  top: -2.9rem;
  left: -2.25rem;
  width: 8.2rem;
  aspect-ratio: 1;
  transform: rotate(2deg);
  background-image: url('/asset/ui/boss-card-corner-ornament.webp');
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.14;
  filter: saturate(0.95) brightness(1.04);
}

.session-timer-overlay::after {
  right: 1.25rem;
  bottom: 0.34rem;
  left: 1.25rem;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(23, 143, 134, 0.88), rgba(242, 184, 75, 0.92), rgba(183, 121, 31, 0.32));
  opacity: 0.86;
}

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

.session-timer-overlay.is-paused {
  --session-ring-color: var(--color-reward);
  background: linear-gradient(135deg, rgba(255, 248, 237, 0.98), rgba(252, 241, 219, 0.94));
}

.session-timer-display {
  grid-area: display;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.session-timer-progress {
  width: 4.15rem;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--session-ring-color) 0deg,
    var(--session-ring-color) var(--session-progress),
    rgba(183, 121, 31, 0.16) var(--session-progress),
    rgba(183, 121, 31, 0.16) 360deg
  );
  position: relative;
  box-shadow:
    0 0 0 3px rgba(255, 253, 248, 0.72),
    0 12px 22px rgba(79, 45, 19, 0.14),
    inset 0 0 0 1px rgba(183, 121, 31, 0.18);
  transition:
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.session-timer-display:focus-visible .session-timer-progress {
  box-shadow:
    0 0 0 3px rgba(255, 253, 248, 0.86),
    0 0 0 6px rgba(23, 143, 134, 0.24),
    0 12px 22px rgba(79, 45, 19, 0.14),
    inset 0 0 0 1px rgba(183, 121, 31, 0.18);
  transform: translateY(-1px);
}

.session-timer-display:focus-visible {
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  .session-timer-display:hover .session-timer-progress {
    box-shadow:
      0 0 0 3px rgba(255, 253, 248, 0.86),
      0 0 0 6px rgba(23, 143, 134, 0.24),
      0 12px 22px rgba(79, 45, 19, 0.14),
      inset 0 0 0 1px rgba(183, 121, 31, 0.18);
    transform: translateY(-1px);
  }
}

.session-timer-progress::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(23, 143, 134, 0.11), transparent 42%),
    linear-gradient(180deg, #fffdf8, #fff3df);
  box-shadow: inset 0 0 0 1px rgba(183, 121, 31, 0.14);
}

.session-timer-time {
  position: relative;
  z-index: 1;
  font-variant-numeric: tabular-nums;
  font-size: 1.08rem;
  font-weight: 900;
  color: var(--color-brand-dark);
  line-height: 1;
}

.session-timer-controls {
  grid-area: controls;
  display: flex;
  gap: 0.42rem;
}

.session-timer-controls button {
  width: 2.85rem;
  height: 2.85rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(183, 121, 31, 0.22);
  border-bottom-color: rgba(183, 121, 31, 0.34);
  background: rgba(255, 253, 248, 0.72);
  box-shadow: 0 10px 18px rgba(79, 45, 19, 0.12);
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: none;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.session-timer-controls button:hover,
.session-timer-controls button:focus-visible {
  border-color: rgba(183, 121, 31, 0.38);
  background: rgba(255, 253, 248, 0.9);
}

.session-timer-controls button:active {
  transform: translateY(1px);
}

.session-timer-controls .session-timer-pause {
  border-color: rgba(190, 224, 221, 0.55);
  background: linear-gradient(180deg, var(--color-jade), var(--color-jade-dark));
  color: #fffdf8;
  box-shadow: 0 12px 22px rgba(23, 143, 134, 0.28);
}

.session-timer-controls .session-timer-cancel {
  position: relative;
  color: var(--color-brand-dark);
  font-size: 0;
}

.session-timer-controls .session-timer-cancel::before,
.session-timer-controls .session-timer-cancel::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1rem;
  height: 0.18rem;
  border-radius: 999px;
  background: currentColor;
}

.session-timer-controls .session-timer-cancel::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.session-timer-controls .session-timer-cancel::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.session-timer-stats {
  grid-area: stats;
  padding: 0 0.35rem 0.18rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-muted);
  line-height: 1.2;
  min-height: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-timer-stats:empty {
  display: none;
}

.session-timer-overlay.compact {
  grid-template-columns: auto;
  grid-template-areas: 'display';
  padding: 0.45rem;
  border-radius: 1.8rem;
}

.session-timer-overlay.compact .session-timer-progress {
  width: 3.65rem;
}

.session-timer-overlay.compact .session-timer-display {
  padding: 0;
}

.session-timer-overlay.compact .session-timer-controls,
.session-timer-overlay.compact .session-timer-stats {
  display: none;
}

.session-complete-overlay,
.break-reminder-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1.25em + env(safe-area-inset-top, 0px)) calc(1.25em + env(safe-area-inset-right, 0px))
    calc(1.25em + env(safe-area-inset-bottom, 0px)) calc(1.25em + env(safe-area-inset-left, 0px));
  background: rgba(0, 0, 0, 0.36);
}

.session-complete-card,
.break-reminder-card {
  width: min(100%, 420px);
  border-radius: var(--radius-card);
  background: var(--color-surface-card);
  border: var(--border-soft);
  box-shadow: var(--shadow-card);
  padding: 1.6em;
  text-align: center;
}

.session-complete-card {
  position: relative;
  overflow: hidden;
  display: grid;
  justify-items: center;
  gap: 1rem;
  width: min(100%, 430px);
  padding: clamp(1rem, 4.8vw, 1.45rem);
  animation: session-complete-rise 220ms ease-out both;
}

.session-complete-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 8.8rem;
  background:
    radial-gradient(circle at 18% 22%, rgba(242, 184, 75, 0.24), transparent 4.5rem),
    radial-gradient(circle at 78% 18%, rgba(23, 143, 134, 0.18), transparent 5.5rem),
    linear-gradient(180deg, rgba(255, 232, 178, 0.48), rgba(255, 253, 248, 0));
  pointer-events: none;
}

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

.session-complete-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(7.2rem, 33vw, 9.2rem);
  aspect-ratio: 1;
  margin-top: -0.15rem;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.94), rgba(255, 248, 237, 0.88)), var(--color-jade-wash);
  border: 1px solid rgba(23, 143, 134, 0.18);
  box-shadow:
    0 18px 34px rgba(9, 42, 86, 0.16),
    inset 0 0 0 8px rgba(255, 255, 255, 0.58);
  animation: session-complete-visual-pop 360ms cubic-bezier(0.2, 0.8, 0.2, 1) 80ms both;
}

.session-complete-quest-visual {
  width: 72%;
  height: 72%;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(9, 42, 86, 0.18));
}

.session-complete-award-visual {
  position: absolute;
  right: -0.25rem;
  bottom: 0.1rem;
  width: clamp(2.75rem, 13vw, 3.45rem);
  height: clamp(2.75rem, 13vw, 3.45rem);
  object-fit: contain;
  filter: drop-shadow(0 9px 12px rgba(123, 80, 12, 0.24));
}

.session-complete-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.75em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(40, 167, 69, 0.12);
  color: var(--color-success-strong);
  font-size: 1.8em;
  font-weight: 900;
}

.session-complete-title,
.break-reminder-title {
  margin: 0 0 0.8em;
  font-family: var(--font-heading);
  font-size: 1em;
  line-height: 1.45;
  color: var(--color-brand);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.session-complete-title {
  margin: -0.1rem 0 0;
  font-size: clamp(1.15rem, 5vw, 1.45rem);
  line-height: 1.12;
  text-wrap: balance;
}

.session-complete-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  width: 100%;
  margin: 0;
}

.session-complete-stat,
.break-reminder-message {
  color: rgba(17, 17, 17, 0.72);
  font-weight: 700;
}

.session-complete-stat {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 0.25rem;
  min-width: 0;
  min-height: 6.35rem;
  padding: 0.65rem 0.45rem;
  border: 1px solid rgba(23, 143, 134, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
}

.session-complete-stat-icon {
  width: 2.1rem;
  height: 2.1rem;
  object-fit: contain;
  margin-bottom: 0.1rem;
}

.session-complete-stat-value {
  color: var(--color-brand-dark);
  font-size: clamp(1rem, 4.8vw, 1.3rem);
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.session-complete-stat-label {
  color: rgba(17, 17, 17, 0.62);
  font-size: 0.74rem;
  line-height: 1.12;
  font-weight: 800;
}

.break-reminder-timer {
  font-variant-numeric: tabular-nums;
  font-size: 2.1em;
  font-weight: 900;
  color: var(--color-brand);
  margin-bottom: 0.35em;
}

.session-complete-actions,
.break-reminder-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65em;
}

.session-complete-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 0.65rem;
}

.session-complete-actions button,
.break-reminder-actions button {
  border-radius: var(--radius-pill);
  padding: 0.7em 1.1em;
  font-size: 0.92em;
}

.session-complete-actions button {
  min-height: 3.05rem;
  padding: 0.72rem 0.9rem;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.session-complete-break,
.session-complete-done {
  border: 1px solid rgba(18, 63, 122, 0.18);
  border-bottom: 3px solid rgba(18, 63, 122, 0.28);
  background: rgba(255, 253, 248, 0.9);
  color: var(--color-brand-dark);
  box-shadow: 0 10px 18px rgba(18, 63, 122, 0.08);
}

.session-complete-start {
  box-shadow: 0 14px 24px rgba(18, 63, 122, 0.24);
}

.session-complete-actions button:hover,
.session-complete-actions button:focus-visible {
  transform: translateY(-1px);
}

.session-complete-done {
  grid-column: 1 / -1;
  justify-self: center;
  min-width: 8.6rem;
}

@keyframes session-complete-rise {
  from {
    opacity: 0;
    transform: translateY(0.7rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes session-complete-visual-pop {
  from {
    opacity: 0;
    transform: translateY(0.3rem) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .session-complete-card,
  .session-complete-visual {
    animation: none;
  }
}

.session-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1em;
}

.session-stat-card {
  padding: 1.35em 1.1em;
  text-align: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 36, 125, 0.08);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.04),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.session-stat-icon {
  font-size: 1.6em;
  line-height: 1;
  margin-bottom: 0.35em;
}

.session-stat-value {
  font-size: 1.95em;
  font-weight: 900;
  color: var(--color-brand);
  font-family: var(--font-heading);
  line-height: 1.2;
}

.session-stat-label {
  margin-top: 0.55em;
  font-size: 0.72em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(17, 17, 17, 0.52);
}

.session-settings {
  margin-top: 1em;
  padding: 1.25em;
  border-radius: 18px;
  background: rgba(0, 36, 125, 0.04);
  border: 1px solid rgba(0, 36, 125, 0.08);
  text-align: left;
}

.session-settings-title {
  margin: 0 0 0.85em;
  font-size: 0.92em;
  color: var(--color-brand);
  font-family: var(--font-heading);
  text-transform: uppercase;
  line-height: 1.5;
}

.session-settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1em;
  padding: 0.75em 0;
  border-top: 1px solid rgba(0, 36, 125, 0.08);
}

.session-settings-label {
  font-weight: 800;
  color: rgba(17, 17, 17, 0.72);
}

.session-duration-options,
.break-duration-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em;
  justify-content: flex-end;
}

.session-duration-options button,
.break-duration-options button {
  padding: 0.5em 0.8em;
  border-radius: 999px;
  font-size: 0.85em;
  border: 1px solid rgba(0, 36, 125, 0.14);
  border-bottom-width: 3px;
  background: #fff;
}

.session-duration-options button.active,
.break-duration-options button.active {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}

@media (max-width: 640px) {
  body.has-session-timer {
    padding-bottom: calc(var(--page-padding) + 8.75rem + env(safe-area-inset-bottom, 0px));
  }

  body.quiz-page.has-session-timer {
    padding-bottom: calc(var(--page-padding) + 260px + env(safe-area-inset-bottom, 0px));
  }

  body.quiz-page.has-session-timer .footer {
    bottom: calc(7.35rem + env(safe-area-inset-bottom, 0px));
  }

  .session-timer-overlay {
    left: 50%;
    right: auto;
    bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    grid-template-columns: auto auto;
    grid-template-areas: 'display controls' 'stats stats';
    justify-content: space-between;
    gap: 0.46rem 0.54rem;
    width: min(29rem, calc(100vw - 1rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    min-width: 0;
    max-width: none;
    padding: 0.62rem 0.68rem 0.68rem;
    border-radius: 2rem;
  }

  .session-timer-display {
    justify-content: flex-start;
    min-width: 0;
    padding-right: 0;
  }

  .session-timer-progress {
    width: 4.55rem;
  }

  .session-timer-progress::after {
    inset: 6px;
  }

  .session-timer-time {
    font-size: 1.06rem;
  }

  .session-timer-controls {
    gap: 0.42rem;
  }

  .session-timer-controls button {
    width: 2.95rem;
    height: 2.95rem;
    font-size: 1.08rem;
  }

  .session-timer-stats {
    display: block;
    padding: 0 0.3rem;
    font-size: 0.78rem;
  }

  .session-timer-overlay.compact {
    grid-template-columns: auto;
    grid-template-areas: 'display';
    width: max-content;
    max-width: calc(100vw - 1rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    padding: 0.5rem;
  }

  .session-timer-overlay.compact .session-timer-progress {
    width: 4.05rem;
  }
}

@media (max-width: 360px) {
  .session-timer-overlay {
    gap: 0.42rem;
    padding: 0.54rem 0.56rem 0.6rem;
  }

  .session-timer-progress {
    width: 4.1rem;
  }

  .session-timer-controls button {
    width: 2.72rem;
    height: 2.72rem;
  }
}

@media (max-width: 520px) {
  .session-timer-overlay {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .session-settings-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .session-duration-options,
  .break-duration-options {
    justify-content: flex-start;
    width: 100%;
  }
}

/* Time row visibility transition */
.time-row {
  transition:
    opacity 0.2s ease,
    max-height 0.2s ease;
  overflow: hidden;
}

.time-row[style*='display: none'] {
  opacity: 0;
  max-height: 0;
  padding: 0;
  margin: 0;
  border: none;
}

.pricing-hero h2 {
  font-size: clamp(2.1em, 4vw, 2.6em);
  margin-bottom: 0.4em;
  font-family: var(--font-heading);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pricing-lead {
  font-size: 1.1em;
  opacity: 0.85;
  margin: 0 auto;
  max-width: 620px;
}

.pricing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.4em;
  margin: 0 0 2.6em;
}

.pricing-feature-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 1.3em var(--spacing-lg);
  box-shadow: 0 18px 32px rgba(0, 36, 125, 0.08);
  text-align: left;
}

.pricing-feature-card h3 {
  margin: 0 0 0.45em;
  font-size: 1.05em;
  color: var(--color-brand);
  text-transform: none;
  letter-spacing: 0.02em;
}

.pricing-feature-card p {
  margin: 0;
  font-size: 0.95em;
  line-height: 1.5;
  opacity: 0.85;
}

.pricing-plans {
  display: grid;
  gap: 1.8em;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-bottom: 2.5em;
}

.pricing-card {
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: 1.8em;
  box-shadow: var(--shadow-card);
  background: var(--color-surface-card);
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  position: relative;
  align-items: flex-start;
  text-align: left;
}

.pricing-card.is-active {
  border-color: var(--color-reward-brand-strong);
  box-shadow: var(--shadow-reward);
}

.pricing-card.is-active .pricing-current {
  display: inline-block;
}

.pricing-card header {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}

.pricing-card h3 {
  font-size: 1.4em;
  margin: 0;
}

.pricing-amount {
  font-size: 1.6em;
  font-weight: 800;
  margin: 0;
}

.pricing-frequency {
  font-size: 0.6em;
  font-weight: 600;
  opacity: 0.7;
}

.pricing-save {
  font-size: 0.95em;
  color: var(--color-brand);
  font-weight: 700;
  margin: 0;
}

.pricing-current {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  background: var(--color-reward-wash);
  color: var(--color-brand-dark);
  font-size: 0.85em;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.35em 0.7em;
  border-radius: 999px;
  text-transform: uppercase;
}

.pricing-current::before {
  content: '★';
}

.pricing-current[hidden] {
  display: none !important;
}

.pricing-benefits {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  font-size: 0.98em;
}

.pricing-benefits li {
  display: flex;
  align-items: flex-start;
  gap: 0.55em;
  line-height: 1.4;
}

.pricing-benefits li::before {
  content: '✔';
  flex: 0 0 auto;
  margin-top: 0.05em;
  color: var(--color-brand);
}

.pricing-card .btn-accent {
  align-self: flex-start;
  min-width: auto;
  padding-inline: 2.2em;
  margin-top: 0;
}

.pricing-cta {
  margin-top: auto;
  width: 100%;
  padding-top: 0.9em;
}

.pricing-plan-disclosure {
  margin-top: 0.9em;
  font-size: 0.92em;
  color: rgba(0, 0, 0, 0.72);
}

.pricing-plan-disclosure-text {
  margin: 0.55em 0 0;
  line-height: 1.35;
}

.pricing-plan-disclosure-text:first-child {
  margin-top: 0;
}

.pricing-plan-disclosure-links {
  margin: 0.75em 0 0;
  line-height: 1.35;
}

.pricing-restore,
.pricing-manage {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.8em;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 1.6em;
  background: rgba(255, 255, 255, 0.85);
  max-width: 680px;
  margin: 0 auto 0;
}

.pricing-restore {
  margin: 0 auto 2.2em;
}

.pricing-restore[hidden] {
  display: none !important;
}

.pricing-restore .btn-accent,
.pricing-manage .btn-accent {
  align-self: flex-start;
}

body.home .quest-details {
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  transition:
    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease,
    margin 0.4s ease;
}

body.home .quest-details.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
}

.pricing-restore h3,
.pricing-manage h3 {
  margin-top: 0;
  margin-bottom: 0.4em;
}

.pricing-feedback {
  min-height: 1.4em;
  text-align: center;
  font-weight: 600;
  transition: opacity 0.2s ease;
  padding: 0.6em var(--spacing-md);
  border-radius: 12px;
  margin: 0 auto 1.6em;
  max-width: 720px;
}

.pricing-feedback-info {
  background: rgba(0, 36, 125, 0.08);
  color: rgba(0, 36, 125, 0.8);
}

.pricing-feedback-error {
  background: rgba(165, 25, 49, 0.12);
  color: rgba(165, 25, 49, 0.95);
}

.pricing-feedback-success {
  background: rgba(43, 160, 91, 0.12);
  color: rgba(43, 160, 91, 0.95);
}

.pricing-feedback:empty {
  padding: 0;
  min-height: 0;
  margin: 0;
}

@media (max-width: 640px) {
  .pricing-content {
    padding: 0em var(--spacing-md) 0;
  }

  .pricing-card {
    padding: 1.4em;
  }
}

body.home.quest-mode .home-controls .search-wrapper {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
  overflow: hidden;
}

body.home.flashcard-mode .home-controls .filters,
body.home.flashcard-mode .filters {
  display: none;
}

body.home.quest-mode .home-controls,
body.home.flashcard-mode .home-controls {
  gap: 0.4em;
}

body.home.quest-mode .home-controls {
  gap: 0;
}

body.home.quest-mode .quiz-container {
  flex-direction: column;
  align-items: stretch;
  gap: var(--spacing-lg);
}

body.home .quest-card {
  background: var(--color-bg);
  border-radius: 16px;
  padding: 1.8em;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease;
  cursor: default;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

body.home .quest-card:hover {
  transform: translateY(-4px);
}

body.home .quest-card > * {
  position: relative;
  z-index: 1;
}

body.home .quest-header {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  margin-bottom: 0.8em;
}

body.home .quest-title {
  font-size: var(--type-title-md);
  font-weight: 800;
  color: var(--color-text);
}

body.home .quest-tagline {
  font-weight: 600;
  opacity: 0.75;
  font-size: var(--type-body-lg);
}

body.home .quest-goal {
  margin: 0;
  line-height: 1.6;
  opacity: 0.9;
}

body.home .quest-progress {
  margin-top: var(--spacing-md);
  font-weight: 700;
}

body.home .quest-card.preview {
  border-style: dashed;
  position: relative;
}

body.home .quest-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin: 1.4em 0 1.6em;
  justify-content: center;
}

body.home .quest-lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  text-align: center;
}

body.home .quest-lock-overlay[data-lock-type='premium'] {
  background: rgba(255, 255, 255, 0.96);
  border: 2px dashed rgba(0, 36, 125, 0.2);
  flex-direction: column;
  gap: 0.8em;
  padding: 1.8em;
}

body.home .quest-lock-message {
  max-width: min(72rem, 100%);
  font-weight: 700;
  font-size: var(--type-body-lg);
  color: var(--color-text);
}

body.home .quest-lock-overlay .quest-lock-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55em 1.35em;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
  color: var(--color-bg);
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0, 36, 125, 0.28);
  border: none;
  cursor: pointer;
  font-family: inherit;
}

body.home .quest-lock-overlay .quest-lock-cta:hover,
body.home .quest-lock-overlay .quest-lock-cta:focus {
  text-decoration: none;
  color: var(--color-bg);
  box-shadow: 0 16px 32px rgba(0, 36, 125, 0.32);
}

body.home .quest-lock-overlay .quest-lock-cta:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .quest-preview-topics {
  margin: 1.2em 0 0;
  padding-left: 1.4em;
  list-style: disc;
  font-weight: 600;
  opacity: 0.85;
  text-align: left;
}

body.home .quest-preview-topics li {
  margin: 0.3em 0;
}

body.home .quest-quiz {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.6em;
  padding: 0.45em 0.9em;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.95em;
  position: relative;
  overflow: hidden;
}

body.home .quest-quiz-text {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  position: relative;
  z-index: 1;
}

body.home .quest-quiz-title {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  flex-wrap: wrap;
}

body.home .quest-quiz-meta {
  font-size: 0.85em;
  opacity: 0.75;
  font-weight: 500;
}

body.home .quest-quiz.premium-step {
  background: linear-gradient(135deg, rgba(255, 248, 242, 0.94), rgba(255, 255, 255, 0.92));
  border-color: rgba(143, 19, 40, 0.18);
}

body.home .quest-quiz-premium-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12em 0.52em;
  border-radius: 999px;
  background: rgba(143, 19, 40, 0.08);
  color: rgba(115, 14, 31, 0.88);
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

body.home .quest-quiz.locked {
  background: rgba(0, 0, 0, 0.07);
  border-color: rgba(0, 0, 0, 0.12);
  pointer-events: none;
  cursor: not-allowed;
}

body.home .quest-quiz.complete {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), rgba(41, 128, 185, 0.08));
  border-color: rgba(41, 128, 185, 0.3);
}

body.home .quest-quiz:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .quest-actions {
  display: flex;
  justify-content: center;
  margin-top: var(--spacing-md);
}

body.home .quest-action-btn {
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

body.home .quest-finished {
  display: inline-flex;
  align-items: center;
  padding: 0.6em 1.2em;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), rgba(41, 128, 185, 0.08));
  border: 1px solid rgba(41, 128, 185, 0.3);
  font-weight: 700;
  color: var(--color-text);
}

body.home .quest-boss {
  margin-top: var(--spacing-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
  text-align: center;
}

body.home .quest-boss-collapsed {
  display: none;
  justify-content: center;
  margin: 0.6em 0 0.2em;
}

body.home .quest-card.collapsed .quest-boss-collapsed {
  display: flex;
}

body.home .quest-boss-card {
  display: flex;
  align-items: center;
  gap: 0.9em;
  padding: 0.25em 0.35em;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(165, 25, 49, 0.14), rgba(15, 23, 42, 0.02));
  border: 2px solid rgba(165, 25, 49, 0.2);
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
  width: min(420px, 90%);
}

body.home .quest-boss:not(.is-defeated):not(.is-locked) .quest-boss-card {
  animation: boss-pulse-no-shadow 2s ease-in-out infinite;
}

body.home .quest-boss-collapsed .quest-boss-card {
  animation: boss-pulse 2s ease-in-out infinite;
}

@keyframes boss-pulse-no-shadow {
  0%,
  100% {
    border-color: rgba(165, 25, 49, 0.15);
  }

  50% {
    border-color: rgba(165, 25, 49, 0.7);
  }
}

@keyframes boss-pulse {
  0%,
  100% {
    border-color: rgba(165, 25, 49, 0.2);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 24px 6px rgba(165, 25, 49, 0.45);
    border-color: rgba(165, 25, 49, 0.6);
    transform: scale(1.03);
  }
}

body.home .quest-boss:not(.is-locked) .quest-boss-card:hover,
body.home .quest-boss:not(.is-locked) .quest-boss-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(165, 25, 49, 0.38);
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .quest-boss.is-locked .quest-boss-card {
  cursor: default;
  pointer-events: none;
}

body.home .quest-boss.is-locked .quest-boss-image {
  filter: grayscale(0.82) saturate(0.72);
  opacity: 0.56;
}

body.home .quest-boss.is-locked .quest-boss-title {
  opacity: 0.6;
}

body.home .quest-boss-card {
  position: relative;
}

body.home .quest-boss.is-defeated .quest-boss-image {
  filter: grayscale(1);
  opacity: 0.82;
}

body.home .quest-boss-text {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  align-items: center;
  text-align: center;
}

body.home .quest-boss-image-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  flex-shrink: 0;
}

body.home .quest-boss-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  transform: none;
}

body.home .quest-boss-title {
  font-weight: 800;
  font-size: 1.1em;
}

body.home .quest-boss-subtitle {
  font-weight: 600;
  font-size: 0.85em;
  opacity: 0.7;
}

body.home .quiz-card {
  background: var(--color-surface-card);
  border-radius: var(--radius-card);
  padding: var(--spacing-xl);
  min-width: 300px;
  max-width: 400px;
  border: var(--border-soft);
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.home .quiz-card-favorite-btn,
body.home .flashcard-favorite-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.6;
  transition:
    opacity 0.2s,
    transform 0.15s;
  z-index: 4;
}

body.home .flashcard-section summary .flashcard-favorite-btn {
  position: relative;
  top: auto;
  right: auto;
  z-index: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

body.home .quiz-card-favorite-btn:hover,
body.home .flashcard-favorite-btn:hover {
  opacity: 1;
  transform: scale(1.08);
}

body.home .quiz-card-favorite-btn:focus-visible,
body.home .flashcard-favorite-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 8px;
}

body.home .quiz-card-favorite-btn::before,
body.home .flashcard-favorite-btn::before {
  content: '';
  display: block;
  width: 2.7rem;
  height: 2.7rem;
  background-image: url('/asset/ui/favorite-off.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

body.home .quiz-card-favorite-btn.is-favorited::before,
body.home .flashcard-favorite-btn.is-favorited::before {
  background-image: url('/asset/ui/favorite-on.webp');
}

/* Retro Card Favorite Animation */
@keyframes retroCardPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(165, 25, 49, 0);
    transform: scale(1);
    border-color: rgba(0, 0, 0, 0.08);
  }

  30% {
    box-shadow: 0 0 20px 5px rgba(165, 25, 49, 0.4);
    transform: scale(1.02);
    border-color: var(--color-accent);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(165, 25, 49, 0);
    transform: scale(1);
    border-color: rgba(0, 0, 0, 0.08);
  }
}

.quiz-card.just-favorited,
.flashcard-section.just-favorited {
  animation: retroCardPulse 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards !important;
  z-index: 10;
}

body.home .quiz-card:hover {
  transform: translateY(-4px);
  background: var(--color-surface-card-bright);
  box-shadow: var(--shadow-soft);
}

body.home .quiz-card.premium-locked {
  cursor: default;
  box-shadow: none;
}

body.home .quiz-card.premium-locked:hover {
  transform: none;
  box-shadow: none;
}

body.home .quiz-card.premium-locked .quiz-card-lock {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9em;
  padding: 1.6em;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  z-index: 3;
}

body.home .quiz-card.premium-locked .quiz-card-lock-message {
  font-weight: 700;
  font-size: 1.05em;
  color: var(--color-text);
}

body.home .quiz-card.premium-locked .quiz-card-lock-title {
  font-weight: 800;
  font-size: 1.2em;
  color: var(--color-text);
  text-transform: none;
  letter-spacing: 0.01em;
}

body.home .quiz-card.premium-locked .quiz-card-lock-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55em 1.35em;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%);
  color: var(--color-bg);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0, 36, 125, 0.28);
}

body.home .quiz-card.premium-locked .quiz-card-lock-cta:hover,
body.home .quiz-card.premium-locked .quiz-card-lock-cta:focus {
  text-decoration: none;
  color: var(--color-bg);
  box-shadow: 0 16px 32px rgba(0, 36, 125, 0.32);
}

body.home .quiz-card.premium-locked .quiz-card-lock-cta:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .quiz-card[data-emoji]::before {
  content: attr(data-emoji);
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(9em, 32vw, 11.25em);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
  line-height: 1;
}

body.home
  .quiz-card
  > :not(.quiz-card-lock):not(.quiz-card-favorite-btn):not(.quiz-card-bg):not(.home-surface-ornament) {
  position: relative;
  z-index: 1;
}

body.home .quiz-card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.1;
  filter: saturate(0.95) contrast(0.95);
  pointer-events: none;
  transform: scale(1.04);
}

body.home .quiz-card > .quiz-card-favorite-btn {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

body.home .quiz-card h2 {
  margin: 0 0 var(--spacing-md) 0;
  font-size: 1.8em;
  color: var(--color-text);
}

body.home .quiz-card p {
  margin: 0 0 0 0;
  opacity: 0.9;
  line-height: 1.6;
}

body.home .quiz-card .features {
  text-align: left;
  margin-bottom: var(--spacing-lg);
  list-style: none;
  padding-left: 0;
}

/* Larger stars on quiz cards */
body.home .quiz-card .star-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 3.45rem;
  width: 100%;
  font-size: 0;
}

body.home .quiz-card .star-rating .star {
  display: inline-block;
  width: clamp(2.35rem, 5vw, 3.1rem);
  height: clamp(2.35rem, 5vw, 3.1rem);
  margin: 0;
  background-image: url('/asset/metric-icons/star-rating.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  line-height: 0;
  color: transparent;
  filter: drop-shadow(0 4px 7px rgba(183, 121, 31, 0.15));
  transform-origin: center bottom;
}

body.home .quiz-card .star-rating .star--accent {
  transform: translateY(-0.08rem) scale(1.08);
}

body.home .quiz-card .star-rating .star[data-star-state='empty'] {
  background-image: url('/asset/metric-icons/star-rating-empty.webp');
  filter: drop-shadow(0 3px 6px rgba(18, 63, 122, 0.1));
}

body.home .quiz-card .features li {
  margin-bottom: var(--spacing-sm);
  font-weight: inherit;
}

body.home .quiz-card .features li::before {
  content: '✔';
  margin-right: 0.3em;
  color: var(--color-text-strong);
}

.start-btn {
  min-width: 140px;
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  border: 1px solid var(--color-brand-dark);
  border-bottom: 4px solid var(--color-brand-dark-deep);
  border-radius: var(--radius-pill);
  color: #fff;
  box-shadow: 0 14px 26px rgba(18, 63, 122, 0.2);
}

body.home .quiz-card .start-btn {
  margin-top: auto;
  align-self: center;
}

.start-btn:hover,
.start-btn:focus {
  background: linear-gradient(135deg, var(--color-brand-reward), var(--color-brand-dark));
  box-shadow: 0 16px 30px rgba(18, 63, 122, 0.24);
  color: #fff;
}

.start-btn[aria-disabled='true'],
.start-btn.is-disabled {
  opacity: 0.6;
  box-shadow: none;
}

/* Player card */
.player-card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  background: var(--color-bg);
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.player-command-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.player-profile-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: var(--spacing-sm);
}

.player-character-card {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(0, 36, 125, 0.12);
  border-radius: 18px;
  background: #ffffff;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  text-align: left;
  box-shadow: 0 4px 0 rgba(0, 36, 125, 0.05);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.player-character-card:hover {
  border-color: rgba(23, 143, 134, 0.32);
  box-shadow: 0 8px 18px rgba(18, 63, 122, 0.12);
  transform: translateY(-2px);
}

.player-character-card:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.player-character-frame {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  display: block;
  border: 2px solid rgba(230, 181, 74, 0.68);
  background: var(--color-reward-wash);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.68);
}

.player-character-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.player-avatar-stage {
  position: relative;
  width: 216px;
  height: 216px;
  margin: var(--spacing-md) auto 0;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.avatar-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.avatar-overlay-sprite {
  --avatar-sprite-entry-delay: 0s;
  position: absolute;
  display: block;
  height: auto;
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  animation: avatar-sprite-in 0.56s cubic-bezier(0.19, 1, 0.22, 1) var(--avatar-sprite-entry-delay) forwards;
  will-change: transform, opacity;
}

.avatar-overlay-sprite--top {
  --avatar-lantern-drift-x: 5px;
  --avatar-lantern-drift-y: 10px;
  --avatar-lantern-mid-y: -6.5px;
  --avatar-lantern-rise-y: -10px;
  --avatar-lantern-sway: 4deg;
  --avatar-lantern-drift-duration: 4.2s;
  animation:
    avatar-sprite-pulse-in 0.62s cubic-bezier(0.19, 1, 0.22, 1) var(--avatar-sprite-entry-delay) forwards,
    avatar-lantern-drift var(--avatar-lantern-drift-duration) ease-in-out calc(var(--avatar-sprite-entry-delay) + 0.62s)
      infinite alternate;
  filter: drop-shadow(0 7px 10px rgba(177, 112, 23, 0.28)) brightness(1.08);
  transform-origin: 50% 18%;
  will-change: transform, opacity, filter;
}

@keyframes avatar-sprite-in {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }

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

@keyframes avatar-sprite-pulse-in {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.82);
  }

  70% {
    opacity: 1;
    transform: translateY(0) scale(1.08);
  }

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

@keyframes avatar-lantern-drift {
  0% {
    transform: translateX(0) translateY(0) rotate(0deg) scale(1);
    filter: drop-shadow(0 6px 9px rgba(177, 112, 23, 0.24)) brightness(1.04);
  }

  48% {
    transform: translateX(0) translateY(var(--avatar-lantern-mid-y)) rotate(var(--avatar-lantern-sway)) scale(1.09);
    filter: drop-shadow(0 10px 16px rgba(177, 112, 23, 0.42)) brightness(1.18);
  }

  100% {
    transform: translateX(var(--avatar-lantern-drift-x)) translateY(var(--avatar-lantern-rise-y))
      rotate(var(--avatar-lantern-sway)) scale(1.04);
    filter: drop-shadow(0 9px 14px rgba(177, 112, 23, 0.34)) brightness(1.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-overlay-sprite {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .avatar-overlay-sprite--top {
    animation: none;
  }
}

.player-identity {
  padding: 0.2em 1.6em 0.1em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  width: 100%;
}

.player-name-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  position: relative;
  gap: 0;
}

.player-name {
  font-weight: 800;
  font-size: 1.35em;
  color: var(--color-text);
  transition: color 0.2s ease;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 0;
  text-align: center;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  position: relative;
  padding: 0 0.15em;
  margin: 0;
}

.player-name:hover {
  color: var(--color-brand);
}

.player-name-row:hover .player-name,
.player-name-row:focus-within .player-name {
  color: var(--color-brand);
}

.player-name-icon {
  background: none;
  border: none;
  appearance: none;
  padding: 0;
  line-height: 1;
  font-family: inherit;
  display: inline-flex;
  font-size: 1.05em;
  color: rgba(17, 17, 17, 0.5);
  transition: color 0.2s ease;
  cursor: pointer;
  margin-left: 0.2em;
  align-self: baseline;
}

.player-name-icon[hidden] {
  display: none !important;
}

.player-name-icon:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.player-name-row:hover .player-name-icon {
  color: var(--color-brand);
}

.player-name-edit {
  font-weight: 800;
  font-size: 1.35em;
  color: var(--color-text);
  background: var(--color-surface-card);
  border: 2px solid var(--color-brand-border);
  border-radius: 12px;
  padding: 4px 12px;
  outline: none;
  font-family: inherit;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  text-align: center;
  display: block;
  margin: 0 auto;
}

.player-name-edit:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(0, 36, 125, 0.18);
}

.player-name-edit:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.player-level {
  font-weight: 700;
  font-size: 0.95em;
  color: var(--color-brand);
  letter-spacing: 0.04em;
}

@keyframes streak-pulse {
  0%,
  100% {
    box-shadow:
      0 4px 0 rgba(0, 36, 125, 0.05),
      inset 0 0 0 rgba(255, 107, 53, 0);
    border-color: rgba(0, 36, 125, 0.08);
  }

  50% {
    box-shadow:
      0 4px 0 rgba(0, 36, 125, 0.05),
      inset 0 0 20px 2px rgba(255, 107, 53, 0.3);
    border-color: rgba(255, 107, 53, 0.4);
  }
}

/* Streak metric at-risk state */
.metric.streak-at-risk {
  animation: streak-pulse 2s ease-in-out infinite;
  position: relative;
  overflow: hidden;
  background: white;
  /* Ensure it stands out */
}

.metric.streak-at-risk::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4rem;
  height: 4rem;
  background: url('/asset/metric-icons/streak.webp') center / contain no-repeat;
  transform: translate(-50%, -50%);
  opacity: 0.08;
  z-index: 0;
  pointer-events: none;
  animation: streak-flame-pulse 2s ease-in-out infinite;
  filter: blur(2px);
}

@keyframes streak-flame-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.9) rotate(-5deg);
    opacity: 0.06;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
    opacity: 0.15;
  }
}

.metric.streak-at-risk .metric-value {
  color: #000000;
  position: relative;
  z-index: 1;
}

.metric.streak-at-risk .metric-label {
  position: relative;
  z-index: 1;
}

.player-metrics {
  width: 100%;
  padding: 1.4em 1.8em 0.3em;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1em;
}

.metric {
  flex: 1 1 60px;
  background: #ffffff;
  border: 1px solid rgba(0, 36, 125, 0.08);
  border-radius: 20px;
  padding: 1em 0.8em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
  text-align: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 0 rgba(0, 36, 125, 0.05);
}

.metric:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 36, 125, 0.08);
  border-color: rgba(0, 36, 125, 0.15);
}

.metric-label {
  font-size: 0.65em;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(17, 17, 17, 0.5);
  margin-bottom: 2px;
}

.metric-value {
  font-size: 1.15em;
  font-weight: 900;
  color: var(--color-text);
  line-height: 1;
}

/* SRS Due Today metric */
.metric.metric-srs-due {
  position: relative;
}

.metric.metric-srs-due.has-due-cards {
  background: linear-gradient(135deg, #fff8f0 0%, #fff1e6 100%);
  box-shadow: 0 8px 18px rgba(255, 130, 0, 0.18);
  border-color: rgba(255, 130, 0, 0.45);
}

.metric.metric-srs-due.has-due-cards::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff7a00;
  box-shadow: 0 0 0 4px rgba(255, 122, 0, 0.15);
}

.metric.metric-srs-due.is-loading .metric-label {
  position: relative;
}

.metric.metric-srs-due.is-loading .metric-label::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: rgba(255, 122, 0, 0.7);
  animation: srsDuePulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}

.metric.metric-srs-due.is-empty .metric-value {
  opacity: 1;
  color: #111;
}

.metric.metric-srs-due.is-empty {
  justify-content: center;
  gap: 0.2em;
}

.metric.metric-srs-due.is-empty .metric-label {
  display: none;
}

@keyframes srsDuePulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.9);
  }

  50% {
    opacity: 0.9;
    transform: scale(1.1);
  }
}

/* Daily goal progress circular bar (border style) */
.metric.metric-daily-goal {
  --goal-progress: 0deg;
  position: relative;
  background: conic-gradient(
    from -90deg,
    var(--color-class-low) 0deg,
    var(--color-class-low) var(--goal-progress),
    rgba(0, 0, 0, 0.05) var(--goal-progress),
    rgba(0, 0, 0, 0.05) 360deg
  );
  padding: 1.25em 0.8em;
  z-index: 1;
  overflow: hidden;
  border: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.05);
}

.metric.metric-daily-goal:hover,
.metric.metric-daily-goal:focus {
  border-color: transparent;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.metric.metric-daily-goal::after {
  content: '';
  position: absolute;
  inset: 6px;
  background: #ffffff;
  border-radius: 15px;
  /* Matches 20px outer radius minus 6px inset roughly */
  z-index: -1;
  box-shadow: inset 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.metric.metric-daily-goal.goal-complete {
  background: conic-gradient(
    from -90deg,
    #1a5fb4 0deg,
    #1a5fb4 var(--goal-progress),
    rgba(0, 0, 0, 0.05) var(--goal-progress),
    rgba(0, 0, 0, 0.05) 360deg
  );
  border-color: rgba(41, 128, 185, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(41, 128, 185, 0.15);
}

.metric.metric-daily-goal.goal-complete .metric-value {
  color: #1a5e9a;
}

.session-launcher[hidden],
body.has-session-timer .session-launcher {
  display: none;
}

.metric.metric-focus-session {
  appearance: none;
  -webkit-appearance: none;
  min-height: 92px;
  border-color: rgba(0, 36, 125, 0.14);
  font: inherit;
  cursor: pointer;
}

.metric.metric-focus-session:hover,
.metric.metric-focus-session:focus {
  filter: none;
  background: rgba(0, 36, 125, 0.04);
  border-color: rgba(0, 36, 125, 0.24);
}

.metric.metric-focus-session:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.metric.metric-focus-session .metric-value {
  color: var(--color-brand);
}

.session-info {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  color: rgba(17, 17, 17, 0.65);
  font-size: 0.7em;
  font-weight: 700;
  line-height: 1.2;
}

.session-info-value {
  min-width: 1.2em;
  color: var(--color-brand);
  font-weight: 900;
}

.player-character-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 196, 77, 0.2), transparent 34rem),
    radial-gradient(circle at 12% 100%, rgba(23, 143, 134, 0.18), transparent 26rem), rgba(9, 42, 86, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.player-character-modal {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade), var(--color-brand), var(--color-reward-dark));
  --overlay-top-accent-height: 6px;
  position: relative;
  width: min(880px, calc(100vw - 2rem));
  max-height: min(760px, calc(100vh - 2rem));
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-top-color: transparent;
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 16px;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height, 6px) no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(255, 248, 237, 0.97)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height, 6px),
    auto,
    36px 36px,
    36px 36px,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box, padding-box;
  box-shadow: 0 24px 68px rgba(4, 21, 48, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-character-modal::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: var(--overlay-top-accent);
  pointer-events: none;
  z-index: 2;
}

.player-character-modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.1rem, 3vw, 1.45rem) clamp(1rem, 3vw, 1.45rem) 0.95rem;
  border-bottom: 1px solid rgba(18, 63, 122, 0.1);
}

.player-character-modal-title {
  margin: 0;
  color: var(--color-brand-dark);
  font-size: var(--type-title-sm);
  font-weight: 950;
  line-height: 1.05;
}

.player-character-modal-close {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand-dark);
  cursor: pointer;
  font: inherit;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
  opacity: 0.78;
  transition:
    color 0.16s ease,
    opacity 0.16s ease,
    transform 0.16s ease;
}

.player-character-modal-close:hover,
.player-character-modal-close:focus-visible {
  color: var(--color-jade-dark);
  opacity: 1;
  transform: scale(1.04);
}

.player-character-modal-close:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.daily-goal-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 196, 77, 0.2), transparent 34rem),
    radial-gradient(circle at 12% 100%, rgba(23, 143, 134, 0.18), transparent 26rem), rgba(9, 42, 86, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.daily-goal-settings-modal {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade), var(--color-brand), var(--color-reward-dark));
  --overlay-top-accent-height: 6px;
  position: relative;
  width: min(520px, calc(100vw - 2rem));
  max-height: min(640px, calc(100vh - 2rem));
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-top-color: transparent;
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 16px;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height, 6px) no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(255, 248, 237, 0.97)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height, 6px),
    auto,
    36px 36px,
    36px 36px,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box, padding-box;
  box-shadow: 0 24px 68px rgba(4, 21, 48, 0.32);
  overflow: auto;
}

.daily-goal-settings-modal::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: var(--overlay-top-accent);
  pointer-events: none;
  z-index: 2;
}

.daily-goal-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.1rem, 3vw, 1.45rem) clamp(1rem, 3vw, 1.45rem) 0.95rem;
  border-bottom: 1px solid rgba(18, 63, 122, 0.1);
}

.daily-goal-settings-title {
  margin: 0;
  color: var(--color-brand-dark);
  font-size: var(--type-title-sm);
  font-weight: 950;
  line-height: 1.05;
}

.daily-goal-settings-close {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand-dark);
  cursor: pointer;
  font: inherit;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: none;
  opacity: 0.78;
}

.daily-goal-settings-close:hover,
.daily-goal-settings-close:focus-visible {
  color: var(--color-jade-dark);
  opacity: 1;
}

.daily-goal-settings-close:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.daily-goal-settings-body {
  padding: clamp(1rem, 3vw, 1.35rem) clamp(1rem, 3vw, 1.45rem) 0;
  text-align: center;
}

.daily-goal-settings-copy {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--type-body);
  font-weight: 800;
  line-height: 1.35;
}

.daily-goal-settings-progress {
  margin: 0.65rem 0 0;
  color: var(--color-brand-dark);
  font-size: var(--type-action-sm);
  font-weight: 900;
}

.daily-goal-settings-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
  padding: clamp(1rem, 3vw, 1.45rem);
}

.daily-goal-settings-option {
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
  min-height: 78px;
  border: 1px solid rgba(18, 63, 122, 0.12);
  border-bottom: 3px solid rgba(183, 121, 31, 0.18);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.9), rgba(255, 248, 237, 0.78));
  color: var(--color-brand-dark);
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 0.1rem;
  padding: 0.55rem 0.35rem;
  font: inherit;
  box-shadow: 0 10px 24px rgba(9, 42, 86, 0.08);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.daily-goal-settings-option:hover,
.daily-goal-settings-option:focus-visible {
  border-color: rgba(23, 143, 134, 0.34);
  box-shadow: 0 14px 28px rgba(9, 42, 86, 0.14);
  transform: translateY(-1px);
}

.daily-goal-settings-option:active {
  transform: translateY(1px) scale(0.98);
}

.daily-goal-settings-option:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.daily-goal-settings-option.is-selected {
  border-color: rgba(183, 121, 31, 0.58);
  border-bottom-color: var(--color-reward-dark);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 196, 77, 0.22), transparent 5rem),
    linear-gradient(180deg, rgba(237, 249, 247, 0.96), rgba(255, 248, 237, 0.94));
  box-shadow:
    0 18px 34px rgba(9, 42, 86, 0.16),
    inset 0 0 0 1px rgba(255, 253, 248, 0.55);
}

.daily-goal-settings-option-value {
  font-size: var(--type-title-sm);
  font-weight: 950;
  line-height: 1;
}

.daily-goal-settings-option-label {
  color: var(--color-text-muted);
  font-size: var(--type-caption);
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.daily-goal-settings-toast {
  z-index: 2300;
}

@media (max-width: 520px) {
  .daily-goal-settings-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.player-character-options {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.85rem, 2vw, 1.1rem);
  min-height: 0;
  padding: clamp(1rem, 3vw, 1.45rem);
  overflow-x: hidden;
  overflow-y: auto;
}

.player-character-option {
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
  border: 1px solid rgba(18, 63, 122, 0.1);
  border-bottom: 3px solid rgba(183, 121, 31, 0.18);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 14%, rgba(23, 143, 134, 0.11), transparent 6.8rem),
    linear-gradient(180deg, rgba(255, 253, 248, 0.88), rgba(255, 248, 237, 0.76));
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.65rem 0.8rem;
  font: inherit;
  box-shadow: 0 10px 24px rgba(9, 42, 86, 0.08);
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.player-character-option:hover {
  border-color: rgba(23, 143, 134, 0.32);
  box-shadow: 0 14px 28px rgba(9, 42, 86, 0.14);
  transform: translateY(-2px);
}

.player-character-option.is-selected {
  border-color: rgba(183, 121, 31, 0.58);
  border-bottom-color: var(--color-reward-dark);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 196, 77, 0.2), transparent 7rem),
    linear-gradient(180deg, rgba(237, 249, 247, 0.96), rgba(255, 248, 237, 0.94));
  box-shadow:
    0 18px 34px rgba(9, 42, 86, 0.16),
    inset 0 0 0 1px rgba(255, 253, 248, 0.55);
  transform: translateY(-2px);
}

.player-character-option.is-locked {
  cursor: pointer;
  border-color: rgba(18, 63, 122, 0.08);
  border-bottom-color: rgba(18, 63, 122, 0.12);
  background:
    radial-gradient(circle at 50% 14%, rgba(18, 63, 122, 0.08), transparent 6.8rem),
    linear-gradient(180deg, rgba(255, 253, 248, 0.72), rgba(246, 239, 229, 0.72));
  box-shadow: 0 8px 18px rgba(9, 42, 86, 0.07);
}

.player-character-option.is-locked:hover {
  border-color: rgba(183, 121, 31, 0.28);
  box-shadow: 0 12px 24px rgba(9, 42, 86, 0.12);
  transform: translateY(-1px);
}

.player-character-option.is-locked .player-character-option-image {
  filter: grayscale(0.35) saturate(0.72) opacity(0.72) drop-shadow(0 10px 14px rgba(9, 42, 86, 0.12));
}

.player-character-option:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.player-character-option-image {
  width: min(100%, 13.2rem);
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 14px 18px rgba(9, 42, 86, 0.16));
}

.player-character-option-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--color-brand-dark);
  font-size: var(--type-action-sm);
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-character-option-unlock {
  max-width: 100%;
  color: var(--color-reward-dark);
  font-size: var(--type-caption);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.player-character-lock-toast {
  z-index: 2300;
}

/* Player action row */
.player-actions {
  width: 100%;
  max-width: 420px;
  margin: 0.75em auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  flex-wrap: wrap;
}

.player-actions.is-hidden {
  display: none;
}

.player-actions .player-premium-link {
  border: none;
}

.player-actions .player-premium-link.is-disabled,
.player-actions .player-premium-link[aria-disabled='true'] {
  cursor: not-allowed;
  opacity: 0.6;
}

.billing-banner {
  width: 100%;
  max-width: 460px;
  margin: 0.6em auto 1.2em;
  padding: 0.85em 1.1em;
  border-radius: 14px;
  font-size: 0.95em;
  font-weight: 600;
  text-align: center;
  box-sizing: border-box;
  letter-spacing: 0.01em;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.billing-banner.is-fading {
  opacity: 0;
}

@media (max-width: 560px) {
  .player-card {
    max-width: 100%;
    border-radius: 20px;
  }

  .player-actions {
    margin: 0.6em auto 0;
    gap: var(--spacing-sm);
  }

  .player-name,
  .player-name-edit {
    font-size: 1.25em;
  }

  .player-metrics {
    padding: 1.1em 1.6em 0.3em;
    gap: 0.7em;
  }

  .metric {
    flex: 1 1 60px;
    padding: 0.65em var(--spacing-sm);
  }
}

/* Consonant + vowel quiz heading spacing */
body.consonant-quiz h1,
body.consonant-clusters-quiz h1,
body.thai-modern-fonts-quiz h1,
body.final-consonants-quiz h1,
body.vowel-quiz h1 {
  margin-bottom: var(--spacing-sm);
}

/* Centralized symbol sizing: large characters (Thai consonants, vowels) */
body.quiz-page.symbol-size-character {
  --symbol-font-size: 10em;
  --symbol-margin: 0;
  --symbol-font-weight: bold;
}

/* Legacy body classes for quiz-specific styling (non-font-size) */
body.consonant-quiz,
body.vowel-quiz {
  --symbol-margin: 0;
  --symbol-font-weight: bold;
}

button .emoji {
  font-size: 1.5em;
  margin-right: 0.3em;
}

.middle-class {
  border-color: var(--color-class-middle) !important;
  background-color: var(--color-class-middle) !important;
  color: var(--color-class-middle-foreground) !important;
}

.class-chip.middle-class:hover {
  background-color: var(--color-class-middle-dark) !important;
  color: var(--color-class-middle-foreground-hover) !important;
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(39, 174, 96, 0.3);
}

.high-class {
  border-color: var(--color-class-high) !important;
  background-color: var(--color-class-high) !important;
  color: var(--color-class-high-foreground) !important;
}

.class-chip.high-class:hover {
  background-color: var(--color-class-high-dark) !important;
  color: var(--color-class-high-foreground-hover) !important;
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(243, 156, 18, 0.3);
}

.low-class {
  border-color: var(--color-class-low) !important;
  background-color: var(--color-class-low) !important;
  color: var(--color-class-low-foreground) !important;
}

.class-chip.low-class:hover {
  background-color: var(--color-class-low-dark) !important;
  color: var(--color-class-low-foreground-hover) !important;
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(52, 152, 219, 0.3);
}

.legend {
  display: flex;
  justify-content: center;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
  font-size: 0.9em;
  color: var(--color-text);
}

/* Consonant legend chips styled like answer buttons */
.legend-chips {
  gap: 0.8em;
  flex-wrap: wrap;
  margin-top: 0.6em;
}

.class-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35em 0.7em;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.95em;
  border: 2px solid transparent;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.class-chip.middle-class:hover,
.class-chip.high-class:hover,
.class-chip.low-class:hover {
  transform: none;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
}

/* Color quiz - text shadow for readability on colored backgrounds */
body.color-quiz {
  --symbol-text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6), 0 0 4px rgba(0, 0, 0, 0.45);
}

/* Numbers quiz */
.pro-tip {
  font-size: 0.95em;
  opacity: 0.95;
}

.pro-tip small {
  opacity: 0.9;
}

/* Light placeholder base for vowels (ko kai) */
/* Removed wrapper for shaping compatibility */
body.vowel-quiz .options {
  min-width: 240px;
}

/* Filters */
.filters {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  width: 100%;
}

.quiz-preferences select {
  padding: 0.45em 0.75em;
  border-radius: var(--radius-control);
  border: var(--border-soft);
  background: var(--color-surface-card);
  color: var(--color-text);
  font-size: 0.95em;
  min-width: 160px;
}

.quiz-preferences select:focus {
  outline: none;
  border-color: rgba(0, 36, 125, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 36, 125, 0.15);
}

.quiz-preferences select:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

#quiz-search {
  padding: 0.9em var(--spacing-md);
  font-size: 1em;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: all 0.2s ease;
  backdrop-filter: none;
}

#quiz-search::placeholder {
  color: rgba(17, 17, 17, 0.5);
}

#quiz-search:focus {
  border-color: rgba(0, 36, 125, 0.5);
  background: var(--color-surface-soft);
}

#quiz-search:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.chip-group {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  justify-content: center;
}

.chip {
  padding: var(--spacing-sm) 0.9em;
  font-size: 0.95em;
  font-weight: 700;
  /* Reset from generic button bold */
  border-radius: var(--radius-pill);
  border: var(--border-soft);
  background: var(--color-surface-card);
  color: var(--color-brand);
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
  backdrop-filter: none;
}

.chip:hover {
  background: var(--color-reward-wash);
  border-color: var(--color-reward-mid);
  transform: translateY(-1px);
}

.chip.active {
  background: var(--color-brand-deeper);
  border-color: var(--color-brand-dark);
  color: #fff;
  box-shadow: 0 10px 20px rgba(18, 63, 122, 0.18);
}

.chip[role='tab'][aria-selected='true'] {
  font-weight: 700;
  background: var(--color-brand-deeper);
  border-color: var(--color-brand-dark);
  color: #fff;
  box-shadow: 0 10px 20px rgba(18, 63, 122, 0.18);
}

.chip:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.empty {
  opacity: 0.9;
  background: var(--color-surface-soft);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: var(--spacing-md) 1.2em;
}

.quiz-preferences {
  margin: 0.8em auto 0.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  font-size: 0.95em;
}

.quiz-preferences:empty {
  display: none;
}

.quiz-preferences label {
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  body.home {
    --page-padding: var(--spacing-md);
  }

  body.home h1 {
    font-size: 2em;
  }

  body.home .home-controls {
    padding: var(--spacing-md) 1.1em;
    gap: 0.75em;
  }

  body.home .view-toggle {
    --switch-gap: 0.2em;
    --switch-padding: var(--spacing-xs);
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: center;
    padding: var(--switch-padding);
    gap: var(--switch-gap);
  }

  body.home .view-toggle .view-chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.55em 0.7em;
    border-radius: 18px;
    font-size: var(--type-action-sm);
    white-space: normal;
  }

  body.home .view-toggle .view-chip + .view-chip {
    margin-left: 0;
  }

  body.home .quiz-container {
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
  }

  body.home .quest-skeleton-card {
    grid-template-columns: 72px minmax(0, 1fr);
    min-height: 128px;
    padding: 1.1em;
  }

  body.home .quest-skeleton-status {
    display: none;
  }

  body.home .quiz-card {
    min-width: 280px;
    padding: var(--spacing-lg);
  }
}

@media (max-width: 600px) {
  body {
    --page-padding: 0.8em;
  }

  /* Centralized: large character display on mobile */
  body.quiz-page.symbol-size-character {
    --symbol-font-size: 7em;
  }

  button {
    font-size: 1.05em;
    padding: 0.8em;
  }

  #keyboard-tip {
    display: none;
  }

  body.consonant-quiz h1,
  body.consonant-clusters-quiz h1 {
    font-size: 1.5em;
    margin-bottom: 0.3em;
  }

  body.consonant-quiz .legend,
  body.consonant-clusters-quiz .legend {
    gap: var(--spacing-md);
    margin-bottom: 0.3em;
    font-size: 0.8em;
    flex-wrap: wrap;
    justify-content: center;
  }

  body.consonant-quiz .options,
  body.consonant-clusters-quiz .options {
    gap: 0.8em;
  }

  body.consonant-quiz button,
  body.consonant-clusters-quiz button {
    font-size: 1em;
    padding: 0.7em;
    min-height: 3em;
  }

  body.consonant-quiz button .emoji,
  body.consonant-clusters-quiz button .emoji {
    font-size: 1.3em;
  }

  body.consonant-quiz #feedback,
  body.consonant-clusters-quiz #feedback {
    font-size: 1.2em;
    margin-top: 0.8em;
  }

  body.consonant-quiz #nextBtn,
  body.consonant-clusters-quiz #nextBtn {
    margin-top: var(--spacing-lg);
  }

  body.consonant-quiz .stats,
  body.consonant-clusters-quiz .stats {
    font-size: 0.8em;
  }

  .quiz-preferences {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-preferences select {
    width: 100%;
  }
}

@media (max-width: 400px) {
  /* Centralized: smaller character display on tiny screens */
  body.quiz-page.symbol-size-character {
    --symbol-font-size: 6em;
  }

  body.consonant-quiz .legend,
  body.consonant-clusters-quiz .legend {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  body.consonant-quiz button,
  body.consonant-clusters-quiz button {
    font-size: 0.9em;
    padding: 0.6em;
  }

  .player-card {
    padding: 0;
  }

  .player-metrics {
    padding: 0.9em 1.3em 0.2em;
    gap: 0.6em;
  }

  .metric {
    flex: 1 1 60px;
    padding: var(--spacing-sm) var(--spacing-sm);
  }
}

body.auth-overlay-open {
  overflow: hidden;
}

body.modal-overlay-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.btn-accent,
.onboarding-button,
.review-action-restart,
.quiz-chip-review-btn,
.star-celebration-card .celebrate-close,
.star-celebration-card .celebrate-review-mistakes,
body.quiz-page .quiz-completed-card .completed-btn-restart {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-width: 120px;
  min-height: 44px;
  padding: 0 1.4em;
  border: 1px solid var(--color-brand-dark);
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  color: #fff;
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(18, 63, 122, 0.2);
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.btn-accent:hover,
.btn-accent:focus,
.onboarding-button:hover,
.onboarding-button:focus-visible,
.review-action-restart:hover,
.review-action-restart:focus-visible,
.quiz-chip-review-btn:hover,
.quiz-chip-review-btn:focus-visible,
.star-celebration-card .celebrate-close:hover,
.star-celebration-card .celebrate-close:focus-visible,
.star-celebration-card .celebrate-review-mistakes:hover,
.star-celebration-card .celebrate-review-mistakes:focus-visible,
body.quiz-page .quiz-completed-card .completed-btn-restart:hover,
body.quiz-page .quiz-completed-card .completed-btn-restart:focus-visible,
.auth-actions .chip:hover,
.auth-actions .chip:focus {
  background: linear-gradient(135deg, var(--color-brand-reward), var(--color-brand-dark));
  box-shadow: 0 18px 32px rgba(18, 63, 122, 0.26);
  color: #fff;
  transform: translateY(-1px);
}

.btn-accent:focus-visible,
.auth-actions .chip:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

html:not([data-tq-focus-source='keyboard']) :focus-visible {
  outline: none !important;
  outline-offset: 0 !important;
}

.btn-accent[disabled],
.btn-accent.is-disabled,
.btn-accent[aria-disabled='true'],
.auth-actions .chip[disabled],
.auth-actions .chip.is-busy {
  background: linear-gradient(135deg, var(--color-brand-muted), var(--color-brand-dark-muted));
  transform: translateY(0);
  box-shadow: none;
  cursor: not-allowed;
}

/* Google OAuth button */
.auth-actions .chip-apple {
  background: #000;
  color: #fff;
  border: 1px solid #000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
}

.auth-actions .chip-apple:hover,
.auth-actions .chip-apple:focus {
  background: #1a1a1a;
  color: #fff;
}

.auth-actions .chip-apple[disabled] {
  background: #2f2f2f;
  color: #c8c8c8;
  border-color: #2f2f2f;
  box-shadow: none;
}

.auth-actions .chip-apple .apple-icon {
  font-size: 1.2em;
  line-height: 1;
  transform: translateY(-0.02em);
}

.auth-actions .chip-google {
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
}

.auth-actions .chip-google:hover,
.auth-actions .chip-google:focus {
  background: #f8f9fa;
  box-shadow: 0 2px 6px rgba(60, 64, 67, 0.2);
  color: #3c4043;
}

.auth-actions .chip-google[disabled] {
  background: #f1f3f4;
  color: #80868b;
  border-color: #dadce0;
  box-shadow: none;
}

.auth-actions .chip-google .google-icon {
  flex-shrink: 0;
}

button .answer-result {
  display: block;
  margin-top: 0.35em;
  font-size: 0.85em;
  font-weight: 600;
  opacity: 0.95;
}

button .answer-result[data-result='correct'] {
  color: var(--color-success-strong);
}

button .answer-result[data-result='incorrect'] {
  color: #a51931;
}

/* Fixed Streak Indicator */
.streak-indicator {
  position: fixed;
  bottom: 80px;
  /* Moved up to avoid footer overlap */
  right: 24px;
  /* Removed container box styles */
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
  z-index: 1000;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  /* Fixed width to center content */
  height: 80px;
  /* Fixed height to center content */
}

body.quiz-page.boss-mode .streak-indicator {
  bottom: 150px;
}

.streak-indicator.hidden {
  opacity: 0;
  transform: translateY(10px);
}

.streak-flame {
  display: inline-block;
  width: 5rem;
  height: 5rem;
  background: url('/asset/metric-icons/streak.webp') center / contain no-repeat;
  filter: drop-shadow(0 10px 16px rgba(183, 121, 31, 0.2));
  animation: flamePulse 1.5s infinite ease-in-out;
  line-height: 1;
}

@keyframes flamePulse {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
    filter: drop-shadow(0 0 4px #e65100);
  }

  100% {
    transform: scale(1);
    opacity: 0.9;
  }
}

/* Rising fire layer for streak celebration */
.fire-streak-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 20000;
}

.fire-particle {
  position: absolute;
  bottom: -50px;
  opacity: 0;
  transform: translateY(0) scale(1);
  background: url('/asset/metric-icons/streak.webp') center / contain no-repeat;
  filter: drop-shadow(0 8px 12px rgba(183, 121, 31, 0.18));
  animation: fireRise 3000ms ease-out forwards;
  will-change: transform, opacity;
  line-height: 1;
}

@keyframes fireRise {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5) rotate(0deg);
  }

  5% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-120vh) scale(1.5) rotate(var(--fire-rotate, 0deg));
  }
}

/* Rising star layer for quest completion */
.star-streak-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 20001;
  /* Above the overlay */
}

.star-particle {
  position: absolute;
  bottom: -50px;
  opacity: 0;
  transform: translateY(0) scale(1);
  animation: starRise 4000ms ease-out forwards;
  will-change: transform, opacity;
  font-size: 2rem;
  line-height: 1;
}

@keyframes starRise {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5) rotate(0deg);
  }

  10% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-120vh) scale(1.5) rotate(var(--star-rotate, 0deg));
  }
}

/* ThaiQuest 2.0 home quest experience */
body.home .app-bar,
body.home .player-card,
body.home .home-controls {
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.home .app-bar {
  padding: 0.35em 1.4em 0.65em;
}

body.home .brand {
  gap: 0.55em;
}

body.home .brand-logo {
  width: clamp(320px, 32vw, 500px);
  max-width: min(88vw, 500px);
  height: auto;
  filter: drop-shadow(0 16px 20px rgba(18, 63, 122, 0.14));
}

body.home .home-controls {
  overflow: visible;
}

body.home .player-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  clip-path: inset(0 round 24px);
  background:
    linear-gradient(180deg, rgba(255, 248, 237, 0.12), rgba(255, 248, 237, 0.42) 78%, rgba(255, 248, 237, 0.76)),
    var(--avatar-band-background, linear-gradient(180deg, rgba(255, 253, 248, 0), rgba(255, 253, 248, 0)));
  background-position: center;
  background-size: cover;
  opacity: 0;
  filter: saturate(0.92);
  pointer-events: none;
  transition: opacity 0.36s ease;
}

body.home .player-card[data-avatar-background='true']::before {
  opacity: 0.86;
}

body.home .player-card::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  height: 5px;
  background: linear-gradient(90deg, var(--color-jade) 0, var(--color-brand) 52%, var(--color-reward-dark) 100%);
  pointer-events: none;
}

body.home .quest-card,
body.home .quiz-card,
body.home .flashcard-section {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 237, 0.9)), var(--color-surface-card);
  border: var(--border-soft);
  box-shadow: var(--shadow-card);
}

body.home .player-card {
  max-width: min(760px, 100%);
  border: 1px solid rgba(23, 143, 134, 0.24);
  border-radius: 24px;
  position: relative;
  overflow: visible;
  isolation: isolate;
  padding-top: clamp(176px, 16vw, 208px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 248, 237, 0.86)), var(--color-surface-card);
  box-shadow:
    0 4px 0 rgba(18, 63, 122, 0.05),
    0 18px 38px rgba(18, 63, 122, 0.08),
    inset 0 0 0 1px rgba(183, 121, 31, 0.14);
}

body.home .player-card > * {
  position: relative;
  z-index: 1;
}

body.home .player-avatar-stage {
  --home-avatar-ground-offset: clamp(3.75rem, 6vw, 4.5rem);
  position: absolute;
  top: 0;
  left: 50%;
  width: 236px;
  height: 236px;
  margin: 0;
  transform: translate(-50%, var(--home-avatar-ground-offset));
  overflow: visible;
  isolation: isolate;
  background: transparent;
  box-shadow: none;
}

body.home .avatar-overlay {
  left: 50%;
  right: auto;
  width: min(calc(100vw - 2rem), 700px);
  transform: translateX(-50%);
}

body.home .home-surface-ornament {
  position: absolute;
  z-index: 0;
  aspect-ratio: 1;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 1;
  filter: saturate(0.94) brightness(1.03);
  pointer-events: none;
}

body.home .player-card > .home-surface-ornament,
body.home .quest-card > .home-surface-ornament,
body.home .quiz-card > .home-surface-ornament {
  z-index: 0;
}

body.home .player-card-ornament {
  --player-card-ornament-size: clamp(140px, 17vw, 230px);
  width: var(--player-card-ornament-size);
  background-image: url('/asset/ui/player-card-corner-ornament.webp');
}

body.home .player-card-ornament-start {
  top: calc(var(--player-card-ornament-size) * -0.197);
  left: calc(var(--player-card-ornament-size) * -0.136);
}

body.home .player-card-ornament-end {
  top: calc(var(--player-card-ornament-size) * -0.197);
  right: calc(var(--player-card-ornament-size) * -0.136);
  transform: scaleX(-1);
}

body.home .quest-card-ornament {
  --quest-card-ornament-size: clamp(122px, 12vw, 180px);
  top: calc(var(--quest-card-ornament-size) * -0.189);
  right: calc(var(--quest-card-ornament-size) * -0.144);
  width: var(--quest-card-ornament-size);
  background-image: url('/asset/ui/quest-card-corner-ornament.webp');
}

body.home .quiz-card-ornament {
  left: clamp(-1.05rem, -1.25vw, -0.65rem);
  bottom: clamp(-1.05rem, -1.25vw, -0.65rem);
  width: clamp(92px, 9vw, 132px);
  background-image: url('/asset/ui/quiz-card-corner-ornament.webp');
}

body.home .study-card-ornament {
  --study-card-ornament-size: clamp(92px, 10vw, 138px);
  top: calc(var(--study-card-ornament-size) * -0.184);
  left: calc(var(--study-card-ornament-size) * -0.131);
  z-index: 1;
  width: var(--study-card-ornament-size);
  background-image: url('/asset/ui/study-card-corner-ornament.webp');
}

body.home .player-command-panel {
  width: min(720px, calc(100% - 1.6rem));
  margin: 0 auto;
  padding: 0.95rem;
  box-sizing: border-box;
  position: relative;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

body.home .player-command-panel::before {
  display: none;
  content: none;
}

body.home .player-profile-row {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

body.home .player-profile-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 86px;
  align-items: center;
  gap: 0.8rem;
}

body.home .player-identity {
  min-width: 0;
  padding: 0;
  align-items: flex-start;
  box-sizing: border-box;
}

body.home .player-name-row {
  min-width: 0;
  justify-content: flex-start;
}

body.home .player-name,
body.home .player-name-edit {
  font-size: var(--type-title-md);
  line-height: 1.12;
}

body.home .player-name-icon {
  flex: 0 0 auto;
  font-size: var(--type-body);
}

body.home .player-name {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  justify-content: flex-start;
}

body.home .player-character-card {
  width: 96px;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  grid-template-columns: 96px;
  gap: 0;
  padding: 0;
  transform: none;
}

body.home .player-character-card:hover {
  border-color: transparent;
  box-shadow: none;
}

body.home .player-character-frame {
  width: 90px;
  height: 90px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  filter: drop-shadow(0 12px 18px rgba(18, 63, 122, 0.2)) drop-shadow(0 3px 5px rgba(183, 121, 31, 0.16));
}

body.home .player-character-image {
  width: 100%;
  height: 100%;
  border-radius: 0;
  object-fit: contain;
  transform: none;
}

body.home .player-level {
  display: block;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand-dark);
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body.home .account-actions-menu {
  right: 0;
  display: none;
  flex-direction: column;
  align-items: stretch;
  width: min(240px, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  margin: 0;
  gap: 0.45rem;
  padding: 0.55rem;
  box-sizing: border-box;
}

body.home .account-actions-menu.is-open {
  display: flex;
}

body.home .account-actions-menu [hidden] {
  display: none !important;
}

body.home .account-actions-menu .btn-accent {
  align-self: stretch;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 48px;
  padding: 0.62rem 0.72rem;
  border: 1px solid rgba(183, 121, 31, 0.22);
  border-bottom: 3px solid rgba(183, 121, 31, 0.3);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(255, 248, 237, 0.92));
  color: var(--color-brand-dark);
  box-shadow: 0 6px 12px rgba(128, 84, 14, 0.07);
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1.18;
  text-align: left;
  white-space: nowrap;
  overflow-wrap: normal;
  box-sizing: border-box;
}

body.home .account-actions-menu .btn-accent:hover,
body.home .account-actions-menu .btn-accent:focus-visible {
  border-color: rgba(183, 121, 31, 0.34);
  border-bottom-color: var(--color-reward-deep);
  background: linear-gradient(180deg, rgba(255, 248, 237, 0.98), rgba(251, 235, 205, 0.96));
  box-shadow: 0 10px 18px rgba(128, 84, 14, 0.14);
  transform: translateY(-1px);
}

body.home .player-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  gap: 0.55rem;
  padding: 0.9rem 0 0;
  border-top: 1px solid rgba(18, 63, 122, 0.1);
  margin-top: 0.8rem;
}

body.home .metric {
  min-width: 0;
  min-height: 108px;
  padding: 0.1rem 0.1rem;
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 72px auto auto;
  align-items: start;
  align-content: start;
  justify-items: center;
  row-gap: 0.25rem;
  text-align: center;
}

body.home .metric:hover,
body.home .metric:focus-visible {
  border-color: transparent;
  box-shadow: none;
  transform: none;
  background: transparent;
  filter: none;
  outline: none;
}

body.home .metric:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 12px;
}

body.home .metric.metric-focus-session:hover,
body.home .metric.metric-focus-session:focus {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  filter: none;
}

body.home .metric.metric-xp,
body.home .metric.metric-daily-goal {
  overflow: visible;
  z-index: auto;
  background: transparent;
  box-shadow: none;
}

body.home .metric.metric-xp::after,
body.home .metric.metric-daily-goal::after {
  display: none;
  content: none;
}

body.home .metric:not(.metric-badge)::before {
  content: '';
  width: 72px;
  height: 72px;
  grid-row: 1;
  grid-column: 1;
  border-radius: 16px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 10px 14px rgba(18, 63, 122, 0.18)) drop-shadow(0 3px 5px rgba(183, 121, 31, 0.14));
  transition:
    box-shadow 180ms ease,
    filter 180ms ease,
    transform 180ms ease;
}

body.home .metric-xp::before {
  background-image: url('/asset/metric-icons/xp.webp');
}

body.home .metric-streak::before {
  background-image: url('/asset/metric-icons/streak.webp');
}

body.home .metric.metric-streak.streak-at-risk {
  animation: none;
  overflow: visible;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body.home .metric.metric-streak.streak-at-risk::before {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  opacity: 1;
  z-index: 1;
  animation: none;
  filter: drop-shadow(0 7px 12px rgba(255, 107, 53, 0.24)) drop-shadow(0 10px 14px rgba(18, 63, 122, 0.18));
}

body.home .metric-stars::before {
  background-image: url('/asset/metric-icons/stars.webp');
}

body.home .metric-daily-goal::before {
  background-image: url('/asset/metric-icons/goal.webp');
}

body.home .metric-srs-due::before {
  background-image: url('/asset/metric-icons/due.webp');
}

body.home .metric-focus-session::before {
  background-image: url('/asset/metric-icons/focus.webp');
}

body.home .metric-badge::before {
  content: '';
  width: 72px;
  height: 72px;
  grid-row: 1;
  grid-column: 1;
  border-radius: 16px;
  background: url('/asset/achievements/badge-placeholder.png') center / contain no-repeat;
  filter: drop-shadow(0 10px 14px rgba(18, 63, 122, 0.18)) drop-shadow(0 3px 5px rgba(183, 121, 31, 0.14));
  transition: transform 180ms ease;
}

body.home .metric-badge:has(.badge-icon-img)::before {
  display: none;
}

body.home .metric-badge:has(.badge-icon-img) .badge-value {
  grid-column: 1;
  grid-row: 1;
  justify-content: center;
  z-index: 1;
}

body.home .metric-label {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

body.home .metric-value {
  color: var(--color-text-strong);
  font-size: var(--type-action-lg);
  font-weight: 950;
  line-height: 1.05;
  white-space: nowrap;
  grid-column: 1;
  grid-row: 2;
  text-align: center;
}

body.home .metric-focus-session {
  min-height: 108px;
}

body.home .metric-badge .badge-icon-img {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 10px 14px rgba(18, 63, 122, 0.18)) drop-shadow(0 3px 5px rgba(183, 121, 31, 0.14));
  transition:
    filter 180ms ease,
    transform 180ms ease;
}

body.home .metric:focus-visible:not(.metric-badge)::before,
body.home .metric.metric-badge:focus-visible::before {
  transform: scale(1.06);
}

body.home .metric.metric-badge:focus-visible .badge-icon-img {
  transform: scale(1.06);
}

@media (hover: hover) and (pointer: fine) {
  body.home .metric:hover:not(.metric-badge)::before,
  body.home .metric.metric-badge:hover::before {
    transform: scale(1.06);
  }

  body.home .metric.metric-badge:hover .badge-icon-img {
    transform: scale(1.06);
  }
}

body.home .metric-focus-session .session-info {
  grid-column: 1;
  grid-row: 3;
  justify-content: center;
  margin-top: 0.18rem;
}

body.home .metric.metric-srs-due.is-empty .metric-value {
  min-width: 0;
  max-width: 100%;
  line-height: 1.08;
  overflow-wrap: anywhere;
  white-space: normal;
}

body.home .session-info {
  font-size: var(--type-caption);
}

body.home .player-profile-main .metric-badge {
  width: 86px;
  min-height: 86px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  grid-template-rows: 1fr;
  place-items: center;
}

body.home .player-profile-main .metric-badge::before {
  width: 78px;
  height: 78px;
}

body.home .player-profile-main .metric-badge .badge-value {
  grid-column: 1;
  grid-row: 1;
  justify-content: center;
  align-items: center;
}

body.home .player-profile-main .metric-badge .badge-icon-img {
  width: 78px;
  height: 78px;
}

body.home .player-profile-main .metric-badge .badge-icon-none {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

body.home .metric.metric-srs-due.has-due-cards {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body.home .metric.metric-srs-due.has-due-cards::after {
  top: 4px;
  right: calc(50% - 33px);
}

body.home .home-controls {
  max-width: min(720px, 100%);
  border-radius: 0;
  margin: clamp(0.75rem, 2.2vw, 1rem) auto;
  padding: 0;
}

body.home .home-controls .search-wrapper input {
  border-color: rgba(18, 63, 122, 0.16);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

body.home .view-toggle {
  --switch-padding: 0.28em;
  padding: var(--switch-padding);
  background: var(--color-surface-soft);
  border: 1px solid rgba(18, 63, 122, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

body.home .view-chip {
  min-width: 118px;
  color: var(--color-brand-dark);
  font-size: var(--type-action-lg);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.01em;
}

body.home .view-chip:hover {
  background: var(--color-jade-wash);
  color: var(--color-jade-dark);
}

body.home .view-chip.active,
body.home .view-chip.active:hover {
  background: transparent;
  color: #ffffff;
  box-shadow: none;
}

body.home .chip-group .chip {
  background: var(--color-surface-soft);
  border-color: rgba(183, 121, 31, 0.24);
  color: var(--color-brand-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

body.home .chip-group .chip:hover {
  background: var(--color-reward-wash);
  border-color: rgba(183, 121, 31, 0.34);
  color: var(--color-brand-dark);
}

body.home .chip-group .chip.active,
body.home .chip-group .chip[aria-selected='true'] {
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  border-color: var(--color-brand-dark);
  color: #ffffff;
  box-shadow: var(--shadow-button);
}

body.home .chip-group .chip.active:hover,
body.home .chip-group .chip[aria-selected='true']:hover {
  color: #ffffff;
}

body.home.quest-mode .quiz-container {
  width: min(1180px, 100%);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

body.home .quest-card {
  --quest-card-background: none;
  --quest-card-background-mobile: var(--quest-card-background);
  --quest-card-background-active: var(--quest-card-background);
  --quest-card-map-height: clamp(172px, 15vw, 214px);
  max-width: min(1160px, 100%);
  border-radius: var(--radius-card);
  padding: clamp(1.05em, 2.4vw, 1.65em);
  border-color: rgba(23, 143, 134, 0.22);
  cursor: default;
  overflow: visible;
  isolation: isolate;
}

body.home .quest-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: var(--quest-card-map-height);
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(255, 248, 237, 0.82), rgba(255, 248, 237, 0.52) 46%, rgba(255, 248, 237, 0.88)),
    linear-gradient(180deg, rgba(15, 76, 129, 0.08), rgba(255, 196, 77, 0.04) 64%, rgba(255, 248, 237, 0.92)),
    var(--quest-card-background-active);
  background-position: center top;
  background-repeat: no-repeat;
  background-size: 100% auto;
  border-radius: inherit;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 16px), transparent 100%);
  opacity: 0.92;
  filter: saturate(0.94);
  transform: none;
  transform-origin: center;
  pointer-events: none;
}

body.home .quest-card.preview::before,
body.home .quest-card.premium-locked::before,
body.home .quest-card.premium-checking::before {
  opacity: 0.82;
  filter: blur(5px) saturate(0.72);
  transform: scale(1.02);
}

body.home .quest-card.complete.collapsed::before {
  opacity: 0.96;
}

body.home .quest-card.collapsed::before {
  height: 100%;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 4px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 4px), transparent 100%);
}

body.home .quest-card.collapsed:has(> .quest-boss-collapsed) {
  --quest-card-boss-overlap: clamp(1.5rem, 3vw, 2.75rem);
}

body.home .quest-card.collapsed:has(> .quest-boss-collapsed)::before {
  background-position: center center;
  background-size: cover;
}

body.home .quest-card.collapsed:has(> .quest-boss-collapsed) .quest-boss-collapsed {
  margin-top: calc(var(--quest-card-boss-overlap) * -1);
  margin-bottom: 0;
}

body.home .quest-card.collapsed.is-collapsing::before {
  height: var(--quest-card-map-height);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 16px), transparent 100%);
}

body.home .quest-card.collapsed.is-collapsing:has(> .quest-boss-collapsed)::before {
  height: 100%;
  background-position: center center;
  background-size: cover;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 4px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 4px), transparent 100%);
}

body.home .quest-card:not(.collapsed):not(.preview):not(.premium-locked):not(.premium-checking) {
  background: url('/asset/quest-backgrounds/quest-body-pattern.webp'), var(--color-bg);
  background-position:
    center top,
    center;
  background-repeat: repeat, no-repeat;
  background-size:
    clamp(300px, 36vw, 560px) auto,
    auto;
}

body.home .quest-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 32px rgba(18, 63, 122, 0.13);
}

body.home .quest-card.activation-recap-target {
  outline: 3px solid #e55f2d;
  outline-offset: 4px;
  box-shadow: 0 18px 36px rgba(229, 95, 45, 0.2);
}

body.home .quest-card::after,
body.home .quiz-card::after,
body.home .flashcard-section::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--color-jade) 0%, var(--color-brand) 52%, var(--color-reward) 100%);
  pointer-events: none;
  z-index: 2;
}

body.home .quest-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  grid-template-areas: 'header controls';
  gap: clamp(1em, 2.4vw, 1.65em);
  align-items: start;
  padding: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
}

body.home .quest-summary:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 5px;
}

body.home .quest-card.complete .quest-summary {
  align-items: stretch;
}

body.home .quest-header {
  grid-area: header;
  flex-direction: row;
  align-items: flex-start;
  gap: clamp(1em, 2.4vw, 1.55em);
  margin-bottom: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  text-align: left;
}

body.home .quest-header-text {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.45em;
}

body.home .quest-visual-icon {
  display: inline-block;
  aspect-ratio: 1;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 7px 10px rgba(18, 63, 122, 0.16));
}

body.home .quest-card-icon {
  width: clamp(126px, 12vw, 174px);
  height: clamp(126px, 12vw, 174px);
  align-self: flex-start;
}

body.home .quest-title {
  color: var(--color-brand-dark);
  line-height: 1.12;
  text-wrap: balance;
}

body.home .quest-tagline {
  color: var(--color-jade-dark);
  opacity: 1;
}

body.home .quest-goal {
  max-width: 76ch;
  margin: 0;
  line-height: 1.45;
  text-align: left;
  color: var(--color-text-muted);
  opacity: 1;
}

body.home .quest-controls {
  grid-area: controls;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.8em;
}

body.home .quest-card:not(.preview) .quest-controls {
  align-self: stretch;
  justify-content: center;
}

body.home .quest-card.complete .quest-controls {
  justify-content: center;
  min-width: clamp(132px, 13vw, 178px);
}

body.home .quest-progress {
  display: block;
  align-self: flex-start;
  margin-top: 0;
  padding: 0;
  color: var(--color-brand-dark);
  font-size: var(--type-body);
  font-weight: 850;
  line-height: 1.35;
  text-align: right;
}

body.home .quest-steps {
  justify-content: flex-start;
  gap: 0.7em;
}

body.home .quest-quiz {
  --quest-quiz-background: none;
  align-items: center;
  gap: 1em;
  min-height: 6.45em;
  padding: 0.72em 0.86em;
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(18, 63, 122, 0.13);
  border-radius: var(--radius-control);
  box-shadow: 0 5px 12px rgba(18, 63, 122, 0.07);
  color: var(--color-text);
  font-size: var(--type-body);
  isolation: isolate;
  text-align: left;
}

body.home .quest-quiz::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.78), rgba(255, 248, 237, 0.68)),
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.5), transparent 44%), var(--quest-quiz-background),
    var(--color-surface-card);
  background-position: center, center, center, center;
  background-repeat: no-repeat;
  background-size: auto, auto, cover, auto;
  opacity: 0.78;
  pointer-events: none;
}

body.home .quest-quiz > * {
  position: relative;
  z-index: 1;
}

body.home .quest-quiz-icon {
  width: clamp(78px, 7vw, 96px);
  height: clamp(78px, 7vw, 96px);
}

body.home .quest-quiz-text {
  display: flex;
  align-items: flex-start;
  gap: 0.34em;
  min-width: 0;
  text-align: left;
}

body.home .quest-quiz-title {
  justify-content: flex-start;
  gap: 0.4em;
  font-size: var(--type-body-lg);
  line-height: 1.12;
  text-align: left;
}

body.home .quest-quiz-meta {
  font-size: var(--type-caption);
  line-height: 1.22;
  text-align: left;
}

body.home .quest-quiz-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  min-height: 1.25rem;
}

body.home .quest-quiz-stars .star {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  background-image: url('/asset/metric-icons/star-rating.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 3px 5px rgba(183, 121, 31, 0.12));
}

body.home .quest-quiz-stars .star--accent {
  transform: translateY(-0.03rem) scale(1.08);
}

body.home .quest-quiz-stars .star[data-star-state='empty'] {
  background-image: url('/asset/metric-icons/star-rating-empty.webp');
  filter: drop-shadow(0 2px 4px rgba(18, 63, 122, 0.08));
}

body.home .quest-quiz:hover {
  border-color: rgba(23, 143, 134, 0.32);
  box-shadow: 0 8px 16px rgba(18, 63, 122, 0.11);
}

body.home .quest-quiz.complete {
  background: linear-gradient(135deg, rgba(217, 243, 238, 0.95), rgba(255, 255, 255, 0.92));
  border-color: rgba(23, 143, 134, 0.32);
}

body.home .quest-quiz.premium-step {
  background: linear-gradient(135deg, var(--color-reward-wash), rgba(255, 255, 255, 0.92));
  border-color: rgba(183, 121, 31, 0.35);
}

body.home .quest-quiz.in-progress {
  background: linear-gradient(135deg, rgba(255, 244, 238, 0.96), rgba(255, 255, 255, 0.92));
  border-color: rgba(255, 107, 74, 0.42);
  box-shadow: 0 8px 18px rgba(255, 107, 74, 0.1);
}

body.home .quest-quiz-premium-badge {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-reward-deep);
  box-shadow: none;
  font-size: var(--type-micro);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.home .quest-state-seal {
  width: clamp(128px, 13vw, 176px);
  height: clamp(128px, 13vw, 176px);
  margin-bottom: 0.1em;
}

body.home .quest-lock-controls {
  justify-content: center;
  min-width: clamp(132px, 13vw, 178px);
}

body.home .quest-lock-controls .quest-state-seal {
  width: clamp(112px, 10vw, 148px);
  height: clamp(112px, 10vw, 148px);
  margin: 0;
}

body.home .quest-finished,
body.home .quest-completion-indicator {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28em;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--color-jade-dark);
  font-size: var(--type-action-sm);
  font-weight: 900;
  line-height: 1.1;
  text-align: right;
}

body.home .quest-completion-icon {
  width: clamp(112px, 10vw, 148px);
  height: clamp(112px, 10vw, 148px);
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(183, 121, 31, 0.16));
}

body.home .quest-completion-text {
  display: inline-block;
}

body.home .quest-card.preview {
  min-height: var(--quest-card-map-height);
  border-style: solid;
  border-color: rgba(183, 121, 31, 0.34);
}

body.home .quest-card.preview .quest-header,
body.home .quest-card.premium-locked .quest-header,
body.home .quest-card.premium-checking .quest-header {
  filter: blur(3px) saturate(0.78);
  opacity: 0.76;
}

body.home .quest-lock-overlay,
body.home .quest-lock-overlay[data-lock-type='premium'],
body.home .quest-lock-overlay[data-lock-type='checking'] {
  position: absolute;
  inset: auto clamp(9rem, 13vw, 13.5rem) auto clamp(9rem, 13vw, 13.5rem);
  top: 50%;
  width: auto;
  max-width: min(72rem, calc(100% - clamp(18rem, 26vw, 27rem)));
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  align-items: center;
  flex-direction: column;
  gap: 0.85em;
  text-align: center;
  backdrop-filter: none;
  transform: translateY(-50%);
  z-index: 2;
}

body.home .quest-lock-overlay {
  inset: auto clamp(9rem, 13vw, 13.5rem) auto clamp(9rem, 13vw, 13.5rem);
  top: 50%;
}

body.home .quest-card.premium-checking {
  cursor: progress;
}

body.home .quest-lock-message {
  max-width: min(72rem, 100%);
  color: var(--color-brand-dark);
}

body.home .quest-lock-overlay .quest-lock-cta,
body.home .quest-lock-overlay .quest-lock-signin,
body.home .quiz-card.premium-locked .quiz-card-lock-cta,
body.home .flashcard-section.premium-locked .flashcard-lock-cta {
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-jade-dark) 100%);
  color: #ffffff;
  border: 1px solid rgba(18, 63, 122, 0.18);
  box-shadow: var(--shadow-button);
}

body.home .quest-preview-topics {
  color: var(--color-brand-dark);
  opacity: 0.9;
}

body.home .boss-rush-card {
  position: relative;
  isolation: isolate;
  overflow: visible;
  width: min(760px, calc(100% - 1rem));
  margin: 0 auto clamp(0.8rem, 2vw, 1.15rem);
  display: grid;
  grid-template-columns: minmax(178px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.85rem, 2vw, 1.35rem);
  padding: clamp(0.58rem, 1.4vw, 0.82rem) clamp(0.85rem, 2vw, 1.1rem);
  border: 1px solid rgba(198, 113, 24, 0.22);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 248, 237, 0.92), rgba(255, 255, 255, 0.7)),
    radial-gradient(circle at 12% 10%, rgba(225, 95, 42, 0.16), transparent 38%),
    radial-gradient(circle at 88% 72%, rgba(18, 120, 100, 0.13), transparent 36%);
  color: var(--color-brand-dark);
  text-decoration: none;
  box-shadow: 0 18px 42px rgba(79, 45, 19, 0.12);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

body.home .boss-rush-card::before,
body.home .boss-rush-card::after {
  --boss-rush-ornament-size: clamp(118px, 18vw, 172px);
  content: '';
  position: absolute;
  width: var(--boss-rush-ornament-size);
  aspect-ratio: 1;
  background-image: url('/asset/ui/boss-card-corner-ornament.webp');
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 1;
  pointer-events: none;
  z-index: 0;
  filter: saturate(1.05) brightness(1.02) drop-shadow(0 10px 12px rgba(79, 45, 19, 0.13));
}

body.home .boss-rush-card::before {
  left: calc(var(--boss-rush-ornament-size) * -0.136);
  top: calc(var(--boss-rush-ornament-size) * -0.145);
}

body.home .boss-rush-card::after {
  right: calc(var(--boss-rush-ornament-size) * -0.136);
  bottom: calc(var(--boss-rush-ornament-size) * -0.145);
  transform: rotate(180deg);
}

body.home .boss-rush-card > * {
  position: relative;
  z-index: 1;
}

body.home .boss-rush-card:hover,
body.home .boss-rush-card:focus-visible {
  border-color: rgba(198, 113, 24, 0.38);
  box-shadow: 0 22px 48px rgba(79, 45, 19, 0.16);
  transform: translateY(-2px);
}

body.home .boss-rush-card:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .boss-rush-media {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(178px, 28vw, 264px);
  min-height: clamp(98px, 13vw, 124px);
}

body.home .boss-rush-banner-image {
  width: min(100%, 264px);
  height: clamp(98px, 13vw, 124px);
  object-fit: contain;
  object-position: center center;
  filter: drop-shadow(0 12px 18px rgba(31, 21, 10, 0.18));
  transform: translateY(-2%);
}

body.home .boss-rush-body {
  min-width: 0;
  display: grid;
  gap: 0.18rem;
}

body.home .boss-rush-kicker {
  color: var(--color-text-muted);
  font-size: var(--type-caption);
  font-weight: 900;
  text-transform: uppercase;
}

body.home .boss-rush-title {
  color: var(--color-brand-dark);
  font-size: var(--type-title-sm);
  font-weight: 950;
  line-height: 1.04;
}

body.home .boss-rush-subtitle {
  color: var(--color-text-muted);
  font-weight: 700;
}

body.home .boss-rush-cta {
  align-self: center;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-jade-dark) 100%);
  color: #ffffff;
  font-weight: 900;
  box-shadow: var(--shadow-button);
}

@media (max-width: 640px) {
  body.home .boss-rush-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  body.home .boss-rush-media {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  body.home .boss-rush-banner-image {
    width: min(100%, 290px);
  }

  body.home .boss-rush-cta {
    width: min(100%, 220px);
    text-align: center;
  }
}

body.home .quest-boss-card {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: start;
  gap: clamp(0.55em, 1.2vw, 0.8em);
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

body.home .quest-boss:not(.is-defeated):not(.is-locked) .quest-boss-card,
body.home .quest-boss-collapsed .quest-boss-card {
  animation: none;
}

body.home .quest-boss:not(.is-locked) .quest-boss-card:hover {
  border: 0;
  box-shadow: none;
  outline: none;
  transform: none;
}

body.home .quest-boss:not(.is-locked) .quest-boss-card:focus-visible {
  border: 0;
  box-shadow: none;
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

body.home .quest-boss-image-wrap {
  width: clamp(164px, 22vw, 220px);
  height: clamp(164px, 22vw, 220px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

body.home .quest-boss-title {
  color: var(--color-brand-dark);
  font-size: var(--type-title-sm);
}

body.home .quest-boss-subtitle {
  color: var(--color-text-muted);
  opacity: 1;
}

@media (min-width: 900px) {
  body.home .quest-card:not(.collapsed) {
    display: block;
  }

  body.home .quest-card:not(.collapsed) .quest-details:not(.collapsed) {
    display: grid;
    grid-template-columns: minmax(420px, 1fr) minmax(320px, 0.78fr);
    grid-template-areas:
      'steps boss'
      'actions boss';
    gap: 1.05em clamp(1.15em, 2.4vw, 1.75em);
    align-items: start;
    margin-top: clamp(0.55rem, 1vw, 0.85rem);
    padding-top: 0;
    border-top: 0;
  }

  body.home .quest-card:not(.collapsed) .quest-steps {
    grid-area: steps;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7em;
    justify-content: stretch;
    margin: 0;
  }

  body.home .quest-card:not(.collapsed) .quest-quiz {
    width: 100%;
    min-height: 100%;
    box-sizing: border-box;
  }

  body.home .quest-card:not(.collapsed) .quest-actions {
    grid-area: actions;
    justify-content: flex-start;
    margin-top: 0;
  }

  body.home .quest-card:not(.collapsed) .quest-action-btn {
    min-width: min(220px, 100%);
  }

  body.home .quest-card:not(.collapsed) .quest-boss {
    grid-area: boss;
    align-self: stretch;
    align-items: stretch;
    justify-content: center;
    margin-top: 0;
    text-align: left;
  }

  body.home .quest-card:not(.collapsed) .quest-boss-card {
    width: 100%;
    min-height: 100%;
    align-content: center;
    justify-content: center;
    box-sizing: border-box;
  }
}

body.home .quiz-card {
  min-width: 288px;
  border-radius: var(--radius-card);
  border-color: rgba(18, 63, 122, 0.16);
  overflow: visible;
  text-align: left;
}

body.home .quiz-card-heading {
  display: flex;
  align-items: center;
  gap: 0.75em;
  min-width: 0;
  margin-bottom: 0.55em;
  padding-right: 1.8em;
}

body.home .quiz-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 30px rgba(18, 63, 122, 0.13);
}

body.home .quiz-card[data-emoji]::before {
  top: 0.28em;
  left: auto;
  right: -0.16em;
  transform: none;
  font-size: clamp(6.5em, 25vw, 9.5em);
  opacity: 0.11;
}

body.home .quiz-card h2 {
  color: var(--color-brand-dark);
  line-height: 1.12;
  min-width: 0;
  margin: 0;
  padding-right: 0;
  text-wrap: balance;
}

body.home .quiz-card p {
  color: var(--color-text-muted);
  opacity: 1;
}

body.home .quiz-card .features {
  margin-top: 1em;
  color: var(--color-text);
}

body.home .quiz-card .features li::before {
  color: var(--color-jade);
}

body.home .quiz-card .star-rating {
  color: var(--color-reward-deep);
  text-align: center;
  text-shadow: none;
}

body.home .quiz-card-favorite-btn,
body.home .flashcard-favorite-btn {
  top: 0.78rem;
  right: 0.78rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  opacity: 1;
}

body.home .quiz-card-favorite-btn:hover,
body.home .flashcard-favorite-btn:hover {
  background: transparent;
  border-color: transparent;
  transform: translateY(-1px) scale(1.06);
}

body.home .quiz-card-favorite-btn::before,
body.home .flashcard-favorite-btn::before {
  width: 2.7rem;
  height: 2.7rem;
}

body.home .quiz-card-favorite-btn.is-favorited::before,
body.home .flashcard-favorite-btn.is-favorited::before {
  background-image: url('/asset/ui/favorite-on.webp');
}

body.home .start-btn {
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(18, 63, 122, 0.18);
  border-bottom: 3px solid var(--color-brand-dark-deep);
  background: linear-gradient(135deg, var(--color-brand) 0%, var(--color-jade-dark) 100%);
  box-shadow: var(--shadow-button);
}

body.home .start-btn:hover,
body.home .start-btn:focus {
  background: linear-gradient(135deg, var(--color-jade) 0%, var(--color-brand-dark) 100%);
  box-shadow: 0 14px 28px rgba(18, 63, 122, 0.22);
}

body.home .quiz-card {
  --quiz-card-background: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    'visual'
    'heading'
    'stars'
    'description';
  justify-items: center;
  align-content: start;
  align-self: flex-start;
  row-gap: 0.7rem;
  flex: 1 1 320px;
  width: min(100%, 360px);
  max-width: 360px;
  min-width: min(100%, 260px);
  height: clamp(424px, 28vw, 468px);
  box-sizing: border-box;
  padding: clamp(0.95rem, 2vw, 1.15rem);
  overflow: visible;
  isolation: isolate;
  background: var(--color-surface-card);
  text-align: center;
}

body.home .quiz-card::before {
  content: '';
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  clip-path: inset(0 round var(--radius-card));
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.78), rgba(255, 248, 237, 0.68)),
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.42), transparent 42%), var(--quiz-card-background),
    var(--color-surface-card);
  background-position: center, center, center, center;
  background-repeat: no-repeat;
  background-size: auto, auto, cover, auto;
  pointer-events: none;
}

body.home .quiz-card-bg {
  grid-area: visual;
  position: relative;
  z-index: 1;
  align-self: center;
  justify-self: center;
  width: clamp(180px, 17vw, 222px);
  height: clamp(180px, 17vw, 222px);
  margin: 0.1rem 0 0.25rem;
  object-fit: contain;
  object-position: center;
  opacity: 1;
  filter: drop-shadow(0 9px 14px rgba(18, 63, 122, 0.18));
  pointer-events: none;
  transform: none;
}

body.home .quiz-card-heading {
  grid-area: heading;
  align-self: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  margin-bottom: 0;
  padding-right: 0.55rem;
  padding-left: 0.55rem;
  text-align: center;
}

body.home .quiz-card > p {
  grid-area: description;
  display: -webkit-box;
  max-width: 19.5rem;
  margin-top: 0.1rem;
  overflow: hidden;
  text-align: center;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

body.home .quiz-card .star-rating {
  grid-area: stars;
  justify-content: center;
  min-height: 2.1rem;
  width: auto;
}

body.home .quiz-card .star-rating .star {
  width: clamp(1.45rem, 3vw, 1.85rem);
  height: clamp(1.45rem, 3vw, 1.85rem);
}

body.home .quiz-card .features {
  display: none;
}

body.home .quiz-card .features li {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0.28rem 0.58rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid rgba(18, 63, 122, 0.08);
  color: var(--color-text-muted);
  font-size: var(--type-caption);
  line-height: 1.2;
}

body.home .quiz-card .features li::before {
  margin-right: 0;
}

body.home .quiz-card .start-btn {
  display: none;
}

body.home .quiz-card.premium-locked {
  border-color: rgba(183, 121, 31, 0.34);
  box-shadow: var(--shadow-card);
}

body.home .quiz-card.premium-locked .quiz-card-lock {
  inset: 0;
  border: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.74), rgba(255, 248, 237, 0.88));
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

body.home .quiz-card.premium-locked .quiz-card-lock-title {
  color: var(--color-brand-dark);
}

body.home .quiz-card.premium-locked .quiz-card-lock-message {
  color: var(--color-text-muted);
}

body.home .quiz-card.premium-checking {
  cursor: progress;
  border-color: rgba(18, 63, 122, 0.18);
  box-shadow: var(--shadow-card);
}

body.home .quiz-card.premium-checking .quiz-card-access-check {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  padding: clamp(5rem, 18vw, 7rem) 1.4rem 1.4rem;
  background: transparent;
  box-shadow: none;
  text-align: center;
  z-index: 3;
}

body.home .quiz-card.premium-locked > .quiz-card-ornament,
body.home .quiz-card.premium-checking > .quiz-card-ornament {
  display: none;
}

body.home .quiz-card.premium-locked > :not(.quiz-card-lock):not(.quiz-card-favorite-btn):not(.home-surface-ornament),
body.home
  .quiz-card.premium-checking
  > :not(.quiz-card-access-check):not(.quiz-card-favorite-btn):not(.home-surface-ornament) {
  filter: blur(1.8px) saturate(0.86);
  opacity: 0.44;
}

body.home .quiz-card-access-check-title,
body.home .quiz-card-access-check-message,
body.home .flashcard-access-check-message {
  color: var(--color-brand-dark);
}

body.home .quiz-card-access-check-title {
  font-weight: 800;
  font-size: var(--type-body-lg);
}

body.home .quiz-card-access-check-message {
  max-width: 24rem;
  font-weight: 650;
  color: var(--color-text-muted);
}

body.home .quiz-card.premium-checking .quiz-card-access-check::before,
body.home .quest-lock-overlay[data-lock-type='checking']::before,
body.home .flashcard-access-check::before {
  width: 1.75rem;
  height: 1.75rem;
  content: '';
  border: 3px solid rgba(18, 63, 122, 0.14);
  border-top-color: var(--color-jade);
  border-radius: 50%;
  animation: premiumAccessCheckSpin 0.9s linear infinite;
}

body.home .flashcard-section {
  border-radius: var(--radius-card);
  border-color: rgba(23, 143, 134, 0.2);
}

body.home .flashcard-section summary {
  padding-top: 0.55em;
  padding-bottom: 0.55em;
  text-align: left;
  overflow: visible;
}

body.home .flashcard-section[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

body.home .flashcard-section[open] summary::before {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  clip-path: inset(0 round var(--radius-card) var(--radius-card) 0 0);
}

body.home .flashcard-section summary:hover {
  background: var(--color-jade-wash-soft);
}

body.home .flashcard-section h3 {
  color: var(--color-brand-dark);
}

body.home .flashcard-section.premium-locked .flashcard-lock-badge {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-reward-deep);
  box-shadow: none;
}

body.home .flashcard-section.premium-locked {
  border-color: rgba(183, 121, 31, 0.34);
}

body.home .flashcard-section.premium-checking {
  cursor: progress;
  border-color: rgba(18, 63, 122, 0.18);
}

body.home .flashcard-section.premium-locked .flashcard-lock {
  padding: 0.75rem 0 0;
  border: 0;
  border-top: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.home .flashcard-access-check {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem 0 0;
  font-weight: 750;
}

body.home .flashcard-content {
  border-top-color: rgba(18, 63, 122, 0.1);
}

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

@media (prefers-reduced-motion: reduce) {
  body.home .quiz-card.premium-checking .quiz-card-access-check::before,
  body.home .quest-lock-overlay[data-lock-type='checking']::before,
  body.home .flashcard-access-check::before {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.home .flashcard-section.flashcard-section-animated .flashcard-content {
    transition: none;
  }
}

body.home .flashcard-table-wrapper {
  overflow-x: auto;
  margin-top: clamp(0.85rem, 2vw, 1.05rem);
  border-radius: var(--radius-control);
  border: 1px solid rgba(18, 63, 122, 0.1);
  background: rgba(255, 253, 248, 0.74);
}

body.home .flashcard-table {
  width: 100%;
  min-width: 320px;
  border-collapse: separate;
  border-spacing: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.home .flashcard-table th,
body.home .flashcard-table td {
  padding: clamp(0.75rem, 1.7vw, 0.95rem) clamp(0.85rem, 2.4vw, 1.25rem);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(18, 63, 122, 0.08);
}

body.home .flashcard-table thead th {
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(247, 238, 223, 0.82));
  color: var(--color-brand-dark);
  font-size: var(--type-xs);
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom-color: rgba(18, 63, 122, 0.12);
}

body.home .flashcard-table tbody tr {
  background: rgba(255, 253, 248, 0.68);
}

body.home .flashcard-table tbody tr:nth-child(even) {
  background: rgba(255, 248, 237, 0.64);
}

body.home .flashcard-table tbody tr:last-child td {
  border-bottom: none;
}

body.home .flashcard-table td:first-child {
  color: var(--color-text);
  font-weight: 700;
}

body.home .flashcard-table td.flashcard-cell-phonetic {
  color: var(--color-text-muted);
  font-style: italic;
  font-weight: 650;
}

body.home .flashcard-table td:last-child {
  color: var(--color-brand-dark);
  font-size: var(--type-body-lg);
  font-weight: 800;
  line-height: 1.35;
}

@media (hover: hover) and (pointer: fine) {
  body.home .flashcard-table tbody tr:hover {
    background: rgba(255, 237, 220, 0.72);
  }
}

@media (max-width: 640px) {
  body.home .flashcard-table-wrapper {
    margin-top: 0.9rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body.home .flashcard-table {
    background: transparent;
  }

  body.home .flashcard-table tbody tr {
    margin-bottom: 0.8em;
    border: 1px solid rgba(18, 63, 122, 0.1);
    border-radius: 12px;
    background: rgba(255, 253, 248, 0.82);
  }

  body.home .flashcard-table tbody tr:nth-child(even) {
    background: rgba(255, 248, 237, 0.74);
  }

  body.home .flashcard-table td {
    padding: 0.85rem 1rem 0.85rem 7.5rem;
    border-bottom: 1px solid rgba(18, 63, 122, 0.08);
  }

  body.home .flashcard-table td::before {
    box-sizing: border-box;
    width: 6.55rem;
    padding-left: 0.85rem;
    padding-right: 0.5rem;
    background: rgba(18, 63, 122, 0.045);
    color: var(--color-brand-dark);
    font-size: var(--type-xs);
    font-weight: 800;
    letter-spacing: 0.05em;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.home .quest-boss:not(.is-defeated):not(.is-locked) .quest-boss-card,
  body.home .quest-boss-collapsed .quest-boss-card {
    animation: none;
  }
}

@media (max-width: 768px) {
  body.home .player-card-ornament {
    --player-card-ornament-size: clamp(96px, 27vw, 150px);
  }

  body.home .quest-card-ornament {
    --quest-card-ornament-size: clamp(86px, 24vw, 120px);
  }

  body.home .quest-card:not(.collapsed) > .quest-card-ornament {
    z-index: 3;
  }

  body.home .quiz-card-ornament {
    width: clamp(76px, 22vw, 108px);
  }

  body.home .quiz-card-ornament {
    left: clamp(-0.9rem, -3vw, -0.55rem);
  }

  body.home .quiz-card-ornament {
    bottom: clamp(-0.9rem, -3vw, -0.55rem);
  }

  body.home .study-card-ornament {
    --study-card-ornament-size: clamp(76px, 22vw, 108px);
  }

  body.home .home-controls {
    max-width: 100%;
    margin: clamp(0.75rem, 2.2vw, 1rem) auto;
    padding: 0;
  }

  body.home .quest-card {
    --quest-card-background-active: var(--quest-card-background-mobile, var(--quest-card-background));
    --quest-card-map-height: 172px;
    padding: 1.1em;
  }

  body.home .quest-card::before {
    background-position: center center;
    background-size: cover;
  }

  body.home .quest-card.collapsed::before,
  body.home .quest-card.preview::before,
  body.home .quest-card.premium-locked::before,
  body.home .quest-card.premium-checking::before {
    height: 100%;
    background-position: center center;
    background-size: cover;
  }

  body.home .quest-card.collapsed.is-collapsing::before {
    display: none;
  }

  body.home .quest-card.collapsed:has(> .quest-boss-collapsed) {
    --quest-card-boss-overlap: 0rem;
  }

  body.home .quest-card.collapsed:has(> .quest-boss-collapsed) .quest-boss-collapsed {
    margin-top: 0.6em;
    margin-bottom: 0.2em;
  }

  body.home .quest-card:not(.collapsed):not(.preview):not(.premium-locked):not(.premium-checking)::before {
    display: none;
  }

  body.home .quest-summary {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'header'
      'goal'
      'controls';
    gap: 0.8em;
    padding: 0;
  }

  body.home .quest-card:not(.preview):not(.premium-locked):not(.premium-checking) .quest-summary {
    position: relative;
    isolation: isolate;
  }

  body.home .quest-card:not(.preview):not(.premium-locked):not(.premium-checking) .quest-summary::before {
    content: '';
    position: absolute;
    inset: -1.1em -1.1em -0.95em;
    z-index: 0;
    background:
      linear-gradient(90deg, rgba(255, 248, 237, 0.82), rgba(255, 248, 237, 0.52) 46%, rgba(255, 248, 237, 0.88)),
      linear-gradient(180deg, rgba(15, 76, 129, 0.08), rgba(255, 196, 77, 0.04) 64%, rgba(255, 248, 237, 0.92)),
      var(--quest-card-background-active);
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    border-radius: var(--radius-card);
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 16px), transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 16px), transparent 100%);
    opacity: 0.92;
    filter: saturate(0.94);
    pointer-events: none;
  }

  body.home
    .quest-card.collapsed:not(.is-collapsing):not(.preview):not(.premium-locked):not(.premium-checking)
    .quest-summary::before {
    display: none;
  }

  body.home .quest-card:not(.preview):not(.premium-locked):not(.premium-checking) .quest-summary > * {
    position: relative;
    z-index: 1;
  }

  body.home .quest-header {
    padding: 0;
  }

  body.home .quest-card.preview .quest-summary {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'header'
      'controls';
    align-items: start;
    justify-items: center;
    text-align: center;
  }

  body.home .quest-card-icon {
    width: clamp(68px, 18vw, 88px);
    height: clamp(68px, 18vw, 88px);
  }

  body.home .quest-controls {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  body.home .quest-card:not(.preview) .quest-controls {
    align-self: auto;
    justify-content: space-between;
  }

  body.home .quest-lock-controls {
    align-self: start;
    justify-content: flex-end;
    min-width: 0;
  }

  body.home .quest-card.complete .quest-controls,
  body.home .quest-card.preview .quest-lock-controls,
  body.home .quest-card.premium-locked .quest-lock-controls,
  body.home .quest-card.premium-checking .quest-lock-controls {
    width: 100%;
    align-self: center;
    justify-content: center;
    text-align: center;
  }

  body.home .quest-lock-controls .quest-state-seal {
    width: clamp(88px, 24vw, 112px);
    height: clamp(88px, 24vw, 112px);
  }

  body.home .quest-card.preview .quest-lock-overlay {
    inset: auto clamp(118px, 32vw, 142px) auto clamp(1.1em, 2.4vw, 1.65em);
    top: 50%;
    max-width: none;
  }

  body.home .quest-progress {
    align-self: auto;
    text-align: left;
  }

  body.home .quest-state-seal {
    width: clamp(104px, 30vw, 136px);
    height: clamp(104px, 30vw, 136px);
  }

  body.home .quest-title {
    font-size: var(--type-title-sm);
  }

  body.home .quest-steps {
    justify-content: center;
  }

  body.home .quest-quiz {
    width: 100%;
    box-sizing: border-box;
  }

  body.home .quest-boss-card {
    width: min(100%, 320px);
    grid-template-columns: 1fr;
  }

  body.home .quest-boss-image-wrap {
    width: clamp(144px, 42vw, 192px);
    height: clamp(144px, 42vw, 192px);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body.home .quiz-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'visual'
      'heading'
      'stars'
      'description';
    flex: 0 1 auto;
    min-width: 0;
    width: min(100%, 420px);
    max-width: 420px;
    height: clamp(380px, 58vw, 440px);
    box-sizing: border-box;
    text-align: center;
  }

  body.home .quiz-card::before {
    opacity: 0.88;
  }

  body.home .quiz-card-bg {
    width: clamp(164px, 34vw, 206px);
    height: clamp(164px, 34vw, 206px);
  }

  body.home .quiz-card-heading {
    align-self: center;
    padding-right: 0.55rem;
    padding-left: 0.55rem;
  }

  body.home .quiz-card h2 {
    padding-right: 0;
    text-align: center;
  }

  body.home .quiz-card > p {
    text-align: center;
  }
}

@media (max-width: 480px) {
  body.home .quiz-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'visual'
      'heading'
      'stars'
      'description';
    justify-items: center;
    min-width: 0;
    width: min(100%, 420px);
    height: clamp(360px, 96vw, 420px);
    box-sizing: border-box;
  }

  body.home .quiz-card::before {
    opacity: 0.9;
  }

  body.home .quiz-card-bg {
    width: clamp(152px, 48vw, 188px);
    height: clamp(152px, 48vw, 188px);
  }

  body.home .quiz-card-heading {
    padding-right: 0.55rem;
    padding-left: 0.55rem;
  }

  body.home .quiz-card-heading,
  body.home .quiz-card > p {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 720px) {
  body.home .player-command-panel {
    width: 100%;
    max-width: calc(100% - 1rem);
    margin-inline: auto;
    padding: 0.85rem;
  }

  body.home .player-profile-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  body.home .player-profile-main {
    grid-template-columns: 78px minmax(0, 1fr) 72px;
    gap: 0.55rem;
  }

  body.home .player-character-card {
    width: 78px;
    grid-template-columns: 78px;
    min-height: 0;
    padding: 0;
  }

  body.home .player-character-frame {
    width: 76px;
    height: 76px;
  }

  body.home .player-profile-main .metric-badge {
    width: 72px;
    min-height: 72px;
    border-radius: 17px;
  }

  body.home .player-profile-main .metric-badge::before,
  body.home .player-profile-main .metric-badge::after,
  body.home .player-profile-main .metric-badge .badge-icon-img {
    width: 64px;
    height: 64px;
  }

  body.home .account-actions-menu {
    width: min(240px, calc(100vw - 1.5rem));
  }

  body.home .player-metrics {
    box-sizing: border-box;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.home .metric-srs-due {
    grid-column: auto;
  }

  body.home .metric-focus-session {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  body.home .player-avatar-stage {
    --home-avatar-ground-offset: clamp(3.1rem, 13vw, 4.25rem);
    width: min(132px, 36vw);
    height: min(132px, 36vw);
  }

  body.home .view-toggle {
    width: 100%;
  }

  body.home .view-chip {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 0.65em;
    font-size: var(--type-action);
  }

  body.home .player-metrics {
    padding-left: 1em;
    padding-right: 1em;
    gap: 0.55rem;
  }

  body.home .metric {
    min-width: 0;
    min-height: 96px;
    padding: 0.18rem 0;
    grid-template-rows: 62px auto auto;
    row-gap: 0.18rem;
  }

  body.home .metric:not(.metric-badge)::before {
    width: 62px;
    height: 62px;
  }

  body.home .account-actions-menu .btn-accent {
    font-size: var(--type-action-sm);
  }

  .player-character-modal {
    border-radius: 18px;
  }

  .player-character-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: calc(100vh - 8.5rem);
    gap: 0.7rem;
    padding: 0.85rem;
  }

  .player-character-option {
    padding: 0.65rem 0.5rem 0.72rem;
  }

  .player-character-option-image {
    width: min(100%, 9.2rem);
  }

  body.home .quest-card.preview .quest-lock-overlay,
  body.home .quest-card.preview .quest-lock-overlay[data-lock-type='premium'],
  body.home .quest-card.preview .quest-lock-overlay[data-lock-type='checking'] {
    inset: auto clamp(1rem, 5vw, 1.25rem) auto;
    top: clamp(7.4rem, 32vw, 8.8rem);
    max-width: none;
    transform: none;
    text-align: center;
  }

  body.home .quest-card.preview .quest-lock-controls {
    margin-top: clamp(6.5rem, 28vw, 7.25rem);
  }

  body.home .flashcard-section summary {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'visual'
      'title'
      'actions';
    justify-items: center;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    text-align: center;
  }

  body.home .flashcard-section h3 {
    text-align: center;
    font-size: var(--type-title-md);
  }

  body.home .flashcard-section .flashcard-summary-actions {
    justify-content: center;
  }
}

/* ==========================================================================
   HIGH SCORES / LEADERBOARD PAGE
   Clean styling matching stats page
   ========================================================================== */

body.highscores-page {
  background:
    radial-gradient(circle at 18% 8%, rgba(242, 184, 75, 0.13), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(23, 143, 134, 0.12), transparent 24rem),
    linear-gradient(180deg, var(--color-bg) 0%, #fffdf8 58%, #f7ead6 100%);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Main Content */
.highscores-content {
  width: 100%;
  max-width: 720px;
  margin: 0 auto 2.5em;
  padding: 0 var(--spacing-lg);
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.highscores-hero {
  text-align: center;
  margin: 2.8em auto 2.2em;
  max-width: 600px;
}

.highscores-hero h2 {
  font-size: var(--type-title-lg);
  margin-bottom: 0.3em;
  font-family: var(--font-heading);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.highscores-lead {
  font-size: var(--type-body-lg);
  opacity: 0.85;
  margin-bottom: 0.8em;
}

/* User Rank Card */
.user-rank-card {
  background: linear-gradient(135deg, rgba(0, 36, 125, 0.08) 0%, rgba(165, 25, 49, 0.06) 100%);
  border: 1px solid rgba(0, 36, 125, 0.15);
  border-radius: 16px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.user-rank-header {
  font-size: var(--type-caption);
  font-weight: 600;
  color: rgba(0, 36, 125, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
}

.user-rank-position {
  font-family: var(--font-heading);
  font-size: var(--type-display);
  color: var(--color-brand);
  font-weight: 700;
}

.user-rank-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 0.5rem;
  font-size: var(--type-caption);
  font-weight: 600;
  color: rgba(0, 0, 0, 0.6);
}

.nearby-players {
  margin-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 1rem;
}

.nearby-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.8rem;
  font-size: var(--type-caption);
  color: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
}

.nearby-row.is-you {
  background: rgba(0, 36, 125, 0.08);
  color: var(--color-brand);
  font-weight: 600;
}

/* Period Tabs */
.leaderboard-tabs-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.leaderboard-tabs-container {
  margin-bottom: 0;
}

.leaderboard-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.leaderboard-tab {
  font-size: var(--type-caption);
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  background: transparent;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaderboard-tab:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.leaderboard-tab.active {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
}

/* Leaderboard Card */
.leaderboard-card {
  background: var(--color-surface-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: var(--border-soft);
  overflow: hidden;
}

/* Leaderboard Table */
.leaderboard-table {
  width: 100%;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 60px 1fr 50px 80px 70px;
  gap: 0.5rem;
  padding: 0.85rem 1.2rem;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font-size: var(--type-caption);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-header {
  background: rgba(0, 36, 125, 0.04);
  font-size: var(--type-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(0, 0, 0, 0.5);
}

/* Column alignment */
.lb-rank {
  text-align: center;
  font-weight: 700;
}

.lb-name {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.lb-name-link {
  color: inherit;
  text-decoration: none;
}

.lb-name-link:hover,
.lb-name-link:focus {
  text-decoration: underline;
}

.lb-name-link:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 6px;
}

.nearby-name-link {
  color: inherit;
  text-decoration: none;
}

.nearby-name-link:hover,
.nearby-name-link:focus {
  text-decoration: underline;
}

.nearby-name-link:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 6px;
}

.lb-level {
  text-align: center;
  color: var(--color-brand);
  font-weight: 600;
}

.lb-xp {
  text-align: right;
  color: rgba(0, 0, 0, 0.7);
  font-weight: 600;
}

.lb-quests {
  text-align: right;
  color: var(--color-success);
  font-weight: 600;
}

/* Rank highlighting */
.leaderboard-row.rank-gold {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.12) 0%, transparent 100%);
}

.leaderboard-row.rank-gold .lb-rank {
  color: #b8860b;
}

.leaderboard-row.rank-silver {
  background: linear-gradient(90deg, rgba(192, 192, 192, 0.12) 0%, transparent 100%);
}

.leaderboard-row.rank-silver .lb-rank {
  color: #708090;
}

.leaderboard-row.rank-bronze {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.12) 0%, transparent 100%);
}

.leaderboard-row.rank-bronze .lb-rank {
  color: #cd7f32;
}

/* Current user highlight */
.leaderboard-row.current-user {
  background: rgba(0, 36, 125, 0.08);
  border-left: 3px solid var(--color-brand);
}

/* Loading indicator */
.leaderboard-loading {
  text-align: center;
  padding: 3rem;
  color: rgba(0, 0, 0, 0.5);
}

/* Error message */
.leaderboard-error {
  color: var(--color-error);
  text-align: center;
  padding: 2rem;
  background: rgba(220, 53, 69, 0.08);
  border-radius: 12px;
  margin: 1rem;
}

/* Empty state */
.leaderboard-empty {
  color: rgba(0, 0, 0, 0.5);
  text-align: center;
  padding: 3rem;
  font-size: var(--type-body);
}

/* Metadata footer */
.leaderboard-meta-container {
  padding: 0.8rem 1.2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.leaderboard-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--type-caption);
  color: rgba(0, 0, 0, 0.45);
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .leaderboard-row {
    grid-template-columns: 45px 1fr 40px 65px;
    padding: 0.75rem 1rem;
    font-size: var(--type-caption);
  }

  .lb-quests {
    display: none;
  }

  .leaderboard-header .lb-quests {
    display: none;
  }

  .user-rank-stats {
    gap: 1rem;
    flex-wrap: wrap;
  }

  .highscores-content {
    padding: 0 var(--spacing-md);
  }
}

/* ==========================================
   Interactive Review Mode
   ========================================== */

.review-mode-container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

/* Review Header - matches flashcard section style */
.review-header {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  background: var(--color-surface-card);
  border-radius: var(--radius-card);
  border: var(--border-soft);
  box-shadow: var(--shadow-card);
  padding: 1.25em var(--spacing-lg);
}

.review-title-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: 'back title actions';
  align-items: center;
  gap: var(--spacing-sm);
}

.review-header-actions {
  grid-area: actions;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  justify-self: end;
}

.review-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(0, 36, 125, 0.2);
  background: rgba(0, 36, 125, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}

.review-settings-btn:hover {
  background: rgba(0, 36, 125, 0.12);
  border-color: rgba(0, 36, 125, 0.35);
}

.review-settings-btn.active {
  background: rgba(0, 36, 125, 0.18);
}

.review-settings-icon::before {
  content: '\2699';
  font-size: var(--type-body);
  color: var(--color-brand);
}

.review-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  justify-content: center;
}

.review-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.35em 0.9em;
  border-radius: var(--radius-pill);
  border: var(--border-soft);
  background: var(--color-surface-card);
  color: var(--color-brand);
  font-weight: 700;
  font-size: var(--type-caption);
  cursor: pointer;
  transition: all 0.2s ease;
}

.review-filter-chip.active {
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  color: #fff;
  border-color: var(--color-brand-dark);
  box-shadow: 0 10px 20px rgba(18, 63, 122, 0.18);
}

.review-filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0.1em 0.45em;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: var(--type-xs);
  white-space: nowrap;
}

.review-filter-chip.active .review-filter-badge {
  background: rgba(255, 255, 255, 0.2);
}

.review-settings-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  transition:
    max-height 0.3s ease,
    opacity 0.2s ease,
    transform 0.2s ease;
  background: var(--color-surface-card);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: 0 var(--spacing-md);
}

.review-settings-panel.is-open {
  max-height: 220px;
  opacity: 1;
  transform: translateY(0);
  padding: var(--spacing-sm) var(--spacing-md);
}

.review-settings-title {
  font-size: var(--type-caption);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.6em;
}

.review-settings-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: 0.35em 0;
}

.review-settings-label {
  font-size: var(--type-caption);
  color: rgba(0, 0, 0, 0.65);
}

.review-settings-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-width: 110px;
  justify-content: flex-end;
}

.review-settings-reset-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.6rem;
}

.review-settings-reset-btn {
  border-radius: 999px;
  border: 1px solid rgba(146, 35, 48, 0.25);
  background: rgba(146, 35, 48, 0.08);
  color: #8b1f2c;
  font-weight: 700;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.review-settings-reset-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(146, 35, 48, 0.18);
}

.review-settings-reset-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.review-settings-stepper-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(0, 36, 125, 0.2);
  background: rgba(0, 36, 125, 0.08);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.review-settings-value {
  min-width: 32px;
  text-align: center;
  font-weight: 700;
}

@media (max-width: 520px) {
  .review-filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5em 0.75em;
    justify-items: stretch;
  }

  .review-filter-chip {
    width: 100%;
    justify-content: center;
  }
}

/* Back button */
.review-back-btn {
  grid-area: back;
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  padding: 0.4em 1em;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  border: 1px solid var(--color-brand-dark);
  color: #fff;
  font-weight: 600;
  font-size: var(--type-caption);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(18, 63, 122, 0.18);
  justify-self: start;
}

.review-back-btn:hover {
  background: linear-gradient(135deg, var(--color-brand-reward), var(--color-brand-dark));
  box-shadow: 0 6px 16px rgba(18, 63, 122, 0.24);
  transform: translateY(-1px);
}

.review-back-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.review-title {
  grid-area: title;
  margin: 0;
  font-size: var(--type-title-sm);
  font-weight: 800;
  color: var(--color-text);
  text-align: center;
  justify-self: center;
}

.review-shuffle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  padding: 0.4em 0.8em;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-jade-muted);
  background: var(--color-jade-wash-soft);
  color: var(--color-jade-dark);
  font-weight: 600;
  font-size: var(--type-caption);
  cursor: pointer;
  transition: all 0.2s ease;
}

.review-shuffle-btn:hover {
  background: var(--color-reward-wash);
  border-color: var(--color-reward-jade);
}

.review-shuffle-btn.active {
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  border-color: var(--color-brand-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(18, 63, 122, 0.18);
}

.review-shuffle-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

/* Progress indicator */
.review-progress {
  position: relative;
  text-align: center;
  font-weight: 700;
  font-size: var(--type-body-lg);
  color: var(--color-brand);
  padding: 0.6em 0;
}

.review-progress::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  width: var(--review-progress, 0%);
  background: linear-gradient(90deg, var(--color-brand), var(--color-accent));
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Card container */
.review-card-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md) 0;
}

/* Flashcard */
.review-card {
  --study-card-front-background: url('/asset/study-backgrounds/study-card-front-bg.webp');
  --study-card-back-background: url('/asset/study-backgrounds/study-card-back-bg.webp');
  --study-card-background: var(--study-card-front-background);
  --study-pointer-x: 50%;
  --study-pointer-y: 50%;
  --study-rotate-x: 0deg;
  --study-rotate-y: 0deg;
  --study-card-lift: 0px;
  --study-card-scale: 1;
  --study-sheen-opacity: 0;
  width: 100%;
  max-width: 400px;
  height: 280px;
  position: relative;
  cursor: pointer;
  outline: none;
  contain: layout paint;
  perspective: 900px;
  transform: translate3d(0, var(--study-card-lift), 0) rotateX(var(--study-rotate-x)) rotateY(var(--study-rotate-y))
    scale(var(--study-card-scale));
  transform-style: preserve-3d;
  transition:
    transform 160ms ease-out,
    filter 160ms ease-out;
}

.review-card:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 4px;
  border-radius: var(--radius-card);
}

.review-card:hover:not(.is-flipped):not(.is-revealing) {
  --study-card-lift: -2px;
}

.review-card.is-revealing {
  --study-card-lift: -1px;
  --study-card-scale: 0.998;
}

.review-card.is-revealing .review-card-face {
  will-change: opacity, transform;
}

.review-card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  padding: var(--spacing-xl);
  border-radius: var(--radius-card);
  border: var(--border-soft);
  box-shadow: var(--shadow-card);
  box-sizing: border-box;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition:
    opacity 180ms ease-out,
    transform 340ms cubic-bezier(0.2, 0.72, 0.2, 1);
}

.review-card-front {
  --study-card-background: var(--study-card-front-background);
  background: var(--color-surface-card);
  opacity: 1;
  transform: rotateY(0deg) translateZ(1px);
}

.review-card-back {
  --study-card-background: var(--study-card-back-background);
  background: var(--color-surface-card);
  opacity: 0;
  pointer-events: none;
  transform: rotateY(180deg) translateZ(1px);
}

.review-card.is-flipped .review-card-front {
  opacity: 0;
  pointer-events: none;
  transform: rotateY(-180deg) translateZ(1px);
}

.review-card.is-flipped .review-card-back {
  opacity: 1;
  pointer-events: auto;
  transform: rotateY(0deg) translateZ(1px);
}

@media (prefers-reduced-motion: reduce) {
  .review-card,
  .review-card-face {
    transition: none;
  }

  .review-card:hover:not(.is-flipped):not(.is-revealing),
  .review-card.is-revealing {
    --study-card-lift: 0px;
    --study-card-scale: 1;
  }

  .review-card {
    --study-rotate-x: 0deg !important;
    --study-rotate-y: 0deg !important;
    --study-sheen-opacity: 0 !important;
    transform: translateZ(0);
  }
}

.review-card-visual {
  width: clamp(72px, 18vw, 112px);
  height: clamp(72px, 18vw, 112px);
  object-fit: contain;
  aspect-ratio: 1;
}

.review-card-thai {
  font-size: var(--type-display);
  font-weight: 700;
  color: var(--color-brand);
  text-align: center;
  line-height: 1.2;
}

.review-card-phonetic-hint {
  font-size: var(--type-body-lg);
  font-style: italic;
  color: rgba(0, 0, 0, 0.5);
  text-align: center;
  margin-top: 0.5em;
}

.review-card-phonetic {
  font-size: var(--type-body-lg);
  font-style: italic;
  color: rgba(0, 0, 0, 0.6);
  text-align: center;
}

.review-card-translation {
  font-size: var(--type-title-md);
  font-weight: 700;
  color: var(--color-brand);
  text-align: center;
}

.review-card-thai-ref {
  font-size: var(--type-body);
  color: rgba(0, 0, 0, 0.5);
  margin-top: var(--spacing-sm);
}

/* Production mode (English on front) */
.review-card-meaning {
  font-size: var(--type-title-md);
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
}

.review-card-meaning-ref {
  font-size: var(--type-body);
  color: rgba(0, 0, 0, 0.5);
  margin-top: var(--spacing-sm);
}

/* Rating buttons */
.review-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.review-buttons-simple {
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

.review-buttons-hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.review-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  padding: 0.8em 0.5em;
  border-radius: 12px;
  border: 2px solid transparent;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.review-btn:focus-visible,
.review-filter-chip:focus-visible,
.review-settings-btn:focus-visible,
.review-settings-stepper-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.review-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.review-btn:active {
  transform: translateY(0);
}

.review-btn-label {
  font-size: var(--type-caption);
}

.review-btn-key {
  font-size: var(--type-xs);
  opacity: 0.6;
  padding: 0.15em 0.4em;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
}

/* Button colors */
.review-btn-again {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.review-btn-again:hover {
  background: #fecaca;
  border-color: #f87171;
}

.review-btn-good {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.review-btn-good:hover {
  background: #bfdbfe;
  border-color: #60a5fa;
}

/* Keyboard hint */
.review-hint {
  text-align: center;
  font-size: var(--type-caption);
  color: rgba(0, 0, 0, 0.5);
  padding: var(--spacing-sm);
}

/* Session Summary */
.review-summary {
  max-width: 500px;
  margin: 0 auto;
  padding: var(--spacing-xl);
  text-align: center;
}

.review-summary-heading {
  font-size: var(--type-title-lg);
  font-weight: 900;
  color: var(--color-brand);
  margin: 0 0 var(--spacing-xl);
}

.review-summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.review-stat-item {
  padding: var(--spacing-md);
  background: var(--color-surface-soft);
  border-radius: 12px;
}

.review-stat-value {
  font-size: var(--type-title-md);
  font-weight: 800;
  color: var(--color-brand);
}

.review-stat-label {
  font-size: var(--type-caption);
  color: rgba(0, 0, 0, 0.6);
  margin-top: 0.3em;
}

.review-breakdown {
  margin-bottom: var(--spacing-xl);
  text-align: left;
}

.review-breakdown-title {
  font-size: var(--type-body-lg);
  font-weight: 700;
  margin: 0 0 var(--spacing-md);
  color: var(--color-text);
}

.review-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.review-breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6em 1em;
  border-radius: 8px;
  font-weight: 600;
}

.review-breakdown-count {
  font-weight: 800;
}

.review-color-again {
  background: #fee2e2;
  color: #991b1b;
}

.review-color-good {
  background: #d1fae5;
  color: #065f46;
}

.review-srs-summary {
  margin-bottom: var(--spacing-xl);
  text-align: left;
  background: rgba(0, 36, 125, 0.04);
  border-radius: 14px;
  padding: var(--spacing-md);
  border: 1px solid rgba(0, 36, 125, 0.08);
}

.review-srs-title {
  margin: 0 0 var(--spacing-sm);
  font-size: var(--type-body);
  font-weight: 700;
  color: var(--color-text);
}

.review-srs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.review-srs-stat {
  background: #fff;
  border-radius: 10px;
  padding: 0.6em 0.75em;
  border: 1px solid rgba(0, 36, 125, 0.08);
}

.review-srs-value {
  font-weight: 800;
  color: var(--color-brand);
}

.review-srs-label {
  font-size: var(--type-xs);
  color: rgba(0, 0, 0, 0.55);
  margin-top: 0.2em;
}

.review-srs-next {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
}

.review-srs-next-label {
  font-weight: 700;
  color: var(--color-text);
}

.review-srs-next-line {
  font-size: var(--type-caption);
  color: rgba(0, 0, 0, 0.6);
}

.review-summary-actions {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  flex-wrap: wrap;
}

.review-action-btn {
  padding: 0.8em 1.6em;
  border-radius: var(--radius-pill);
  font-weight: 900;
  font-size: var(--type-action);
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.review-action-restart:hover {
  transform: translateY(-2px);
}

.review-action-exit {
  background: var(--color-surface-card);
  color: var(--color-brand);
  border: 2px solid var(--color-brand-border-soft);
}

.review-action-exit:hover {
  background: var(--color-reward-wash);
  border-color: var(--color-reward-brand);
  transform: translateY(-2px);
}

.review-action-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

/* Review button on quiz cards - matches btn-accent style */
.quiz-chip-review-btn {
  min-height: 40px;
  padding: 0 1.2em;
  font-size: var(--type-action-sm);
  font-weight: 900;
  flex-shrink: 0;
}

.quiz-chip-review-btn:hover {
  transform: translateY(-1px);
}

.quiz-chip-review-btn:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .review-mode-container {
    padding: var(--spacing-md);
    gap: var(--spacing-md);
  }

  .review-header {
    padding: 1em var(--spacing-md);
  }

  .review-title {
    font-size: var(--type-body-lg);
  }

  .review-shuffle-btn {
    font-size: var(--type-xs);
    padding: 0.35em 0.6em;
  }

  .review-card {
    height: 240px;
  }

  .review-card-thai {
    font-size: var(--type-title-lg);
  }

  .review-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
  }

  .review-summary-stats {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }

  .review-stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .review-stat-value {
    font-size: var(--type-title-sm);
  }

  .review-stat-label {
    margin-top: 0;
  }

  .review-hint {
    display: none;
  }
}

/* ============================================================================
   Offline Indicator
   ============================================================================ */

.offline-indicator {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em 1em;
  background: rgba(17, 17, 17, 0.9);
  color: #fff;
  border-radius: 999px;
  font-size: var(--type-caption);
  font-weight: 600;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease,
    transform 0.25s ease;
}

.offline-indicator[hidden] {
  display: none;
}

.offline-indicator:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

.offline-indicator-icon {
  font-size: var(--type-body-lg);
  line-height: 1;
}

.offline-indicator-text {
  white-space: nowrap;
}

/* State variants */
.offline-indicator.is-offline {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.95), rgba(165, 25, 49, 0.95));
}

.offline-indicator.is-syncing {
  background: linear-gradient(135deg, rgba(0, 36, 125, 0.95), rgba(40, 167, 69, 0.95));
}

.offline-indicator.is-syncing .offline-indicator-icon {
  animation: syncSpin 1s linear infinite;
}

.offline-indicator.has-pending {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.95), rgba(230, 126, 34, 0.95));
}

@keyframes syncSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .offline-indicator {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    font-size: var(--type-caption);
    padding: 0.45em 0.9em;
  }
}

/* ==========================================================================
   ACHIEVEMENTS / BADGES SYSTEM
   ========================================================================== */

/* Badge Metric in Player Card */
.metric-badge {
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.metric-badge:hover,
.metric-badge:focus {
  background: rgba(0, 36, 125, 0.06);
  transform: translateY(-2px);
}

.badge-value {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.badge-icon {
  font-size: var(--type-display);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 56px;
}

.badge-icon-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 4px;
}

.badge-icon-none {
  font-size: var(--type-caption);
  min-width: auto;
  min-height: auto;
}

/* ==========================================================================
   Achievements Modal
   ========================================================================== */

.achievements-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  z-index: 10000;
  animation: achievementsOverlayFadeIn 200ms ease;
  padding: var(--spacing-md);
}

.achievements-modal-overlay--closing {
  animation: achievementsOverlayFadeOut 180ms ease forwards;
}

.achievements-modal-overlay--closing .achievements-modal {
  animation: achievementsModalSlideOut 180ms ease forwards;
}

@keyframes achievementsOverlayFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes achievementsOverlayFadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.achievements-modal {
  background: var(--color-surface-card);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  max-width: min(640px, 95vw);
  max-height: 85vh;
  width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  animation: achievementsModalSlideIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

@keyframes achievementsModalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes achievementsModalSlideOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  to {
    opacity: 0;
    transform: scale(0.96) translateY(14px);
  }
}

.achievements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25em 1.5em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(135deg, rgba(0, 36, 125, 0.04) 0%, rgba(165, 25, 49, 0.02) 100%);
}

.achievements-title {
  margin: 0;
  font-size: var(--type-title-sm);
  font-weight: 800;
  color: var(--color-brand);
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.achievements-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.5);
  font-size: var(--type-title-sm);
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.achievements-close-btn:hover {
  background: var(--color-brand-soft-wash);
  color: var(--color-brand);
}

.achievements-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25em;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

/* Achievement Card */
.achievement-card {
  background: var(--color-surface-soft);
  border-radius: 14px;
  padding: 1.1em;
  text-align: center;
  border: 2px solid transparent;
  transition: all 0.25s ease;
  position: relative;
}

.achievement-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.achievement-card.locked {
  opacity: 0.55;
  filter: grayscale(0.7);
}

.achievement-card.has-unlock {
  border-color: rgba(0, 36, 125, 0.2);
}

.achievement-card.tier-bronze {
  border-color: rgba(205, 127, 50, 0.35);
}

.achievement-card.tier-silver {
  border-color: rgba(112, 128, 144, 0.35);
}

.achievement-card.tier-gold {
  border-color: rgba(184, 134, 11, 0.35);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08) 0%, var(--color-surface-soft) 100%);
}

.achievement-image-container {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.achievement-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.achievement-icon-fallback {
  font-size: var(--type-display);
  line-height: 1;
}

.achievement-name {
  font-size: var(--type-caption);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5em;
  line-height: 1.2;
}

.achievement-description {
  font-size: var(--type-xs);
  color: rgba(0, 0, 0, 0.6);
  line-height: 1.3;
  margin-bottom: 0.6em;
}

.tier-badges {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.6em;
}

.tier-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--type-2xs);
  font-weight: 700;
  color: #fff;
  position: relative;
}

.tier-badge.bronze {
  background: linear-gradient(135deg, #cd7f32, #a0522d);
  box-shadow: 0 2px 6px rgba(205, 127, 50, 0.4);
}

.tier-badge.silver {
  background: linear-gradient(135deg, #c0c0c0, #708090);
  box-shadow: 0 2px 6px rgba(192, 192, 192, 0.4);
}

.tier-badge.gold {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  box-shadow: 0 2px 6px rgba(255, 215, 0, 0.4);
}

.tier-badge.locked {
  background: var(--color-muted, #d1d5db);
  box-shadow: none;
  opacity: 0.6;
}

.tier-badge.unlocked::after {
  content: '✓';
  position: absolute;
  font-size: var(--type-caption);
}

/* Progress Bar */
.achievement-progress {
  margin-top: 0.5em;
}

.progress-bar {
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-brand), var(--color-accent));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: var(--type-xs);
  color: rgba(0, 0, 0, 0.5);
  margin-top: 0.3em;
  font-weight: 600;
}

/* ==========================================================================
   Achievement Unlock Celebration
   ========================================================================== */

.achievement-unlock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: grid;
  place-items: center;
  z-index: 10001;
  animation: achievementUnlockFadeIn 300ms ease;
  padding: var(--spacing-lg);
}

@keyframes achievementUnlockFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.achievement-unlock-card {
  background: var(--color-surface-card);
  border: var(--border-soft);
  border-radius: var(--radius-card);
  padding: 2em 2.5em;
  text-align: center;
  max-width: min(380px, 90vw);
  box-shadow: var(--shadow-card);
  animation: achievementCardPop 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

@keyframes achievementCardPop {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(40px);
  }

  50% {
    transform: scale(1.05) translateY(-10px);
  }

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

.achievement-unlock-heading {
  font-family: var(--font-heading);
  font-size: var(--type-caption);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 1.5em;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.achievement-unlock-image-container {
  width: 300px;
  height: 300px;
  margin: 0 auto 1em;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: achievementIconBounce 600ms ease 200ms both;
}

@keyframes achievementIconBounce {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.achievement-unlock-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.achievement-unlock-icon {
  font-size: var(--type-display);
  line-height: 1;
}

.achievement-unlock-name {
  font-family: var(--font-heading);
  font-size: var(--type-body-lg);
  font-weight: 800;
  color: var(--color-brand);
  margin-bottom: 0.8em;
  line-height: 1.4;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.achievement-unlock-name.tier-bronze {
  color: #cd7f32;
}

.achievement-unlock-name.tier-silver {
  color: #708090;
}

.achievement-unlock-name.tier-gold {
  color: #b8860b;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.achievement-unlock-tier {
  display: inline-block;
  padding: 0.5em 1.2em;
  border-radius: 0;
  border: 3px solid #111;
  font-family: var(--font-heading);
  font-size: var(--type-2xs);
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.achievement-unlock-tier.bronze {
  background: linear-gradient(135deg, #cd7f32, #a0522d);
  color: #fff;
}

.achievement-unlock-tier.silver {
  background: linear-gradient(135deg, #c0c0c0, #708090);
  color: #fff;
}

.achievement-unlock-tier.gold {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  color: #4a3500;
}

/* Timer bar for auto-dismiss */
.achievement-unlock-overlay .timer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 2px solid #111;
}

.achievement-unlock-overlay .timer-fill {
  height: 100%;
  background: var(--color-accent);
  animation: timerCountdown var(--overlay-duration, 5000ms) linear forwards;
}

@keyframes timerCountdown {
  from {
    width: 100%;
  }

  to {
    width: 0%;
  }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .achievement-card {
    padding: 0.9em;
  }

  .achievement-image-container {
    width: 52px;
    height: 52px;
  }

  .achievement-name {
    font-size: var(--type-caption);
  }

  .tier-badge {
    width: 20px;
    height: 20px;
    font-size: var(--type-2xs);
  }

  .achievement-unlock-card {
    padding: 1.5em 1.8em;
  }

  .achievement-unlock-image-container {
    width: 250px;
    height: 250px;
  }

  .achievement-unlock-name {
    font-size: var(--type-title-sm);
  }
}

/* ==========================================================================
   Achievements Page
   ========================================================================== */

body.achievements-page {
  background:
    radial-gradient(circle at 18% 8%, rgba(242, 184, 75, 0.13), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(23, 143, 134, 0.12), transparent 24rem),
    linear-gradient(180deg, var(--color-bg) 0%, #fffdf8 58%, #f7ead6 100%);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.achievements-content {
  width: 100%;
  max-width: 960px;
  margin: 0 auto 2.5em;
  padding: 0 var(--spacing-lg);
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  flex: 1;
}

.achievements-hero {
  text-align: center;
  margin: 2.8em auto 2.2em;
  max-width: 720px;
}

.achievements-hero h2 {
  font-size: var(--type-title-lg);
  margin-bottom: 0.25em;
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-brand);
  text-shadow: 0 4px 12px rgba(0, 36, 125, 0.1);
  line-height: 1.3;
}

.achievements-lead {
  font-size: var(--type-body-lg);
  opacity: 0.85;
  margin-bottom: 0.8em;
}

/* Achievement Summary Stats */
.achievements-summary {
  display: flex;
  justify-content: center;
  gap: 1.5em;
  flex-wrap: wrap;
  margin-bottom: 2.5em;
  padding: 1.5em;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.summary-stat {
  text-align: center;
  padding: 0.5em 1.5em;
}

.summary-stat-value {
  display: block;
  font-size: var(--type-title-lg);
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--color-brand);
  line-height: 1.2;
}

.summary-stat-label {
  display: block;
  font-size: var(--type-caption);
  font-weight: 600;
  color: rgba(0, 0, 0, 0.6);
  margin-top: 0.25em;
}

.summary-stat.summary-bronze .summary-stat-value {
  color: #cd7f32;
}

.summary-stat.summary-silver .summary-stat-value {
  color: #708090;
}

.summary-stat.summary-gold .summary-stat-value {
  color: #b8860b;
}

/* Achievements Section */
.achievements-section {
  margin-bottom: 2em;
}

.achievements-section-title {
  font-size: var(--type-title-sm);
  font-weight: 700;
  color: var(--color-brand);
  margin-bottom: 1em;
  padding-bottom: 0.5em;
  border-bottom: 2px solid rgba(0, 36, 125, 0.1);
}

/* Achievements Page Grid */
.achievements-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

.achievements-loading,
.achievements-error {
  text-align: center;
  padding: 3em 1em;
  color: rgba(0, 0, 0, 0.5);
  font-weight: 600;
  grid-column: 1 / -1;
}

.achievements-error {
  color: var(--color-accent);
}

/* Achievement Page Card */
.achievement-page-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface-card);
  border-radius: var(--radius-card);
  padding: 1.25em;
  text-align: center;
  border: var(--border-soft);
  transition: all 0.25s ease;
  position: relative;
  box-shadow: var(--shadow-card);
}

.achievement-page-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-soft);
}

.achievement-page-card.locked {
  opacity: 0.55;
  filter: grayscale(0.7);
}

.achievement-page-card.tier-bronze {
  border-color: rgba(205, 127, 50, 0.35);
}

.achievement-page-card.tier-silver {
  border-color: rgba(112, 128, 144, 0.35);
}

.achievement-page-card.tier-gold {
  border-color: rgba(184, 134, 11, 0.35);
  background:
    linear-gradient(135deg, rgba(242, 184, 75, 0.12) 0%, rgba(255, 255, 255, 0) 100%), var(--color-surface-card);
}

.achievement-page-image-container {
  width: 144px;
  height: 144px;
  margin: 0 auto 0.75em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.achievement-page-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.achievement-page-icon-fallback {
  font-size: var(--type-display);
  line-height: 1;
}

.achievement-page-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.5em;
}

.achievement-page-title {
  font-size: var(--type-body);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.achievement-page-description {
  font-size: var(--type-caption);
  color: rgba(0, 0, 0, 0.55);
  line-height: 1.4;
}

/* Achievement Page Tier Badges */
.achievement-page-tier-badges {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: auto 0 0.25em;
}

.achievement-page-tier-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--type-xs);
  font-weight: 700;
  color: #fff;
  transition: transform 0.2s ease;
}

.achievement-page-tier-badge:hover {
  transform: scale(1.1);
}

.achievement-page-tier-badge.bronze {
  background: linear-gradient(135deg, #cd7f32, #a0522d);
  box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

.achievement-page-tier-badge.silver {
  background: linear-gradient(135deg, #c0c0c0, #708090);
  box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.achievement-page-tier-badge.gold {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.achievement-page-tier-badge.locked {
  background: var(--color-muted, #d1d5db);
  box-shadow: none;
  opacity: 0.5;
}

.achievement-page-tier-badge.unlocked {
  width: clamp(34px, 3vw, 42px);
  height: clamp(34px, 3vw, 42px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: transparent;
  flex: 0 0 auto;
  font-size: 0;
}

.achievement-page-tier-badge.bronze.unlocked {
  background: url('/asset/achievements/achievement-check-bronze.webp') center / contain no-repeat;
}

.achievement-page-tier-badge.silver.unlocked {
  background: url('/asset/achievements/achievement-check-silver.webp') center / contain no-repeat;
}

.achievement-page-tier-badge.gold.unlocked {
  background: url('/asset/achievements/achievement-check-gold.webp') center / contain no-repeat;
}

/* Achievement Page Progress */
.achievement-page-progress {
  margin-top: 0.5em;
}

.achievement-page-progress-bar {
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.achievement-page-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-brand), var(--color-accent));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.achievement-page-progress-text {
  font-size: var(--type-xs);
  color: rgba(0, 0, 0, 0.5);
  margin-top: 0.35em;
  font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .achievements-page-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }

  .achievement-page-card {
    padding: 1em;
  }

  .achievement-page-image-container {
    width: 120px;
    height: 120px;
  }

  .achievement-page-title {
    font-size: var(--type-caption);
  }

  .achievements-summary {
    gap: 1em;
    padding: 1em;
  }

  .summary-stat {
    padding: 0.5em 1em;
  }

  .summary-stat-value {
    font-size: var(--type-title-md);
  }

  body.achievements-page .app-bar {
    padding: 0.5em 1em;
  }

  body.achievements-page .brand-logo {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  .achievements-page-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .achievement-page-card {
    padding: 0.85em;
  }

  .achievement-page-image-container {
    width: 96px;
    height: 96px;
  }

  .achievement-page-title {
    font-size: var(--type-caption);
  }

  .achievement-page-tier-badge {
    width: 22px;
    height: 22px;
    font-size: var(--type-2xs);
  }

  .achievements-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75em;
    justify-items: center;
  }

  .summary-stat {
    width: 100%;
    padding: 0.5em 0.25em;
  }

  .summary-stat-value {
    font-size: var(--type-title-sm);
  }

  .summary-stat-label {
    font-size: var(--type-xs);
  }
}

@media (min-width: 1024px) {
  .app-bar,
  .achievements-content,
  .stats-content,
  .pricing-content,
  .highscores-content {
    max-width: 1120px;
    margin-inline: auto;
  }

  body.legal main {
    max-width: 960px;
    margin-inline: auto;
  }
}

@media (max-width: 480px) {
  body.pricing-page .app-bar,
  body.stats-page .app-bar,
  body.highscores-page .app-bar,
  body.achievements-page .app-bar,
  body.legal .app-bar {
    padding: 0.75em 1.1em;
  }

  body.pricing-page .brand-logo,
  body.stats-page .brand-logo,
  body.highscores-page .brand-logo,
  body.achievements-page .brand-logo,
  body.legal .brand-logo {
    width: 56px;
    height: 56px;
    min-width: 56px;
  }
}

/* ThaiQuest 2.0 quiz and boss experience */
body.quiz-page {
  --quiz-shell-width: min(860px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  --quiz-options-width: min(680px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  --options-max-width: 680px;
  --symbol-font-size: clamp(2.2rem, 5.2vw, 3.45rem);
  --symbol-margin: 0.18em 0 0.08em;
  --symbol-color: var(--color-text-strong);
  --symbol-line-height: 1.12;
  --quiz-card-border: 1px solid rgba(18, 63, 122, 0.14);
  --quiz-card-shadow: 0 18px 42px rgba(18, 63, 122, 0.14);
  --quiz-control-shadow: 0 10px 22px rgba(18, 63, 122, 0.12);
  --quiz-answer-border: #b8c5d7;
  --quiz-answer-border-strong: #70839d;
  background:
    linear-gradient(180deg, rgba(255, 248, 237, 0.94) 0%, rgba(255, 253, 248, 0.98) 56%, #f7ead6 100%), var(--color-bg);
  align-items: center;
  gap: 0;
  padding-bottom: calc(var(--page-padding) + 8.5rem + env(safe-area-inset-bottom, 0px));
}

body.quiz-page .quiz-hero,
body.quiz-page .prompt-card,
body.quiz-page .options,
body.quiz-page #feedback,
body.quiz-page #nextBtn,
body.quiz-page .stats {
  width: var(--quiz-shell-width);
}

body.quiz-page .quiz-hero {
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.45rem) clamp(1rem, 3.5vw, 1.6rem);
  border-radius: var(--radius-card);
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.98) 0%, rgba(229, 240, 254, 0.9) 52%, rgba(252, 241, 219, 0.9) 100%),
    var(--color-surface-card);
  border: var(--quiz-card-border);
  box-shadow: var(--quiz-card-shadow);
}

body.quiz-page .quiz-hero::before {
  inset: auto 0 0;
  height: 5px;
  background: linear-gradient(90deg, var(--color-jade) 0%, var(--color-brand) 52%, var(--color-reward-dark) 100%);
  opacity: 1;
  transform: none;
}

body.quiz-page .quiz-hero::after {
  background:
    linear-gradient(90deg, rgba(18, 63, 122, 0.08) 0, rgba(18, 63, 122, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(18, 63, 122, 0.06) 0, rgba(18, 63, 122, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.28;
}

body.quiz-page .quiz-hero-content {
  gap: 0.42rem;
}

body.quiz-page .quiz-hero-label {
  font-family: var(--font-main);
  font-size: var(--type-xs);
  letter-spacing: 0.16em;
  color: var(--color-jade-dark);
}

body.quiz-page .quiz-hero-title {
  font-family: var(--font-main);
  font-size: var(--type-title-lg);
  color: var(--color-brand-dark);
  letter-spacing: 0;
  text-shadow: none;
}

body.quiz-page .quiz-hero-subtitle {
  max-width: 640px;
  font-size: var(--type-body);
  color: var(--color-text-muted);
  opacity: 1;
}

body.quiz-page .quiz-hero-tip {
  width: fit-content;
  max-width: 100%;
  padding: 0.48rem 0.72rem;
  border-radius: var(--radius-pill);
  background: var(--color-jade-wash);
  border: 1px solid var(--color-jade-mid);
  box-shadow: none;
  color: var(--color-jade-dark);
}

body.quiz-page .quiz-hero-tip small {
  font-size: var(--type-caption);
  line-height: 1.35;
}

body.quiz-page .prompt-card {
  position: relative;
  margin: clamp(0.9rem, 2.8vw, 1.45rem) auto clamp(1rem, 3vw, 1.55rem);
  padding: clamp(0.95rem, 2.6vw, 1.25rem);
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 250, 241, 0.96)), var(--color-surface-card);
  border: var(--quiz-card-border);
  box-shadow: var(--quiz-card-shadow);
  overflow: hidden;
}

body.quiz-page .prompt-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--color-brand), var(--color-jade));
}

body.quiz-page #symbol {
  position: relative;
  z-index: 1;
  max-width: 100%;
  font-family: var(--font-main);
  letter-spacing: 0;
}

body.quiz-page #symbol .secondary,
body.quiz-page #symbol .cloze-phonetic,
body.quiz-page #symbol .cloze-thai {
  font-family: var(--font-main);
  color: var(--color-text-muted);
  opacity: 1;
}

body.quiz-page #symbol .cloze-sentence {
  color: var(--color-text-strong);
}

body.quiz-page #symbol .cloze-hints {
  color: var(--color-text-muted);
}

body.quiz-page #symbol .cloze-hint-label {
  color: var(--color-text-muted);
}

body.quiz-page #symbol .cloze-hint-word {
  color: var(--color-reward-deep);
}

body.quiz-page #symbol .cloze-placeholder {
  color: var(--color-reward-deep);
}

body.quiz-page .options {
  max-width: var(--quiz-options-width);
  gap: clamp(0.7rem, 2vw, 0.9rem);
}

body.quiz-page .options button,
body.quiz-page .word-btn,
body.quiz-page .audio-dictation-choice {
  min-height: 58px;
  padding: 0.82rem 1rem;
  border: 1px solid var(--quiz-answer-border);
  border-bottom: 4px solid var(--quiz-answer-border-strong);
  border-radius: var(--radius-control);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 250, 241, 0.96)), var(--color-surface-card);
  color: var(--color-text-strong);
  box-shadow: var(--quiz-control-shadow);
  font-family: var(--font-main);
  font-size: var(--type-body-lg);
  line-height: 1.32;
  letter-spacing: 0;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

body.quiz-page .options button:focus-visible,
body.quiz-page .word-btn:focus-visible,
body.quiz-page .audio-dictation-choice:focus-visible {
  background: var(--color-jade-wash);
  border-color: var(--color-jade-mid);
  border-bottom-color: var(--color-jade-dark);
  box-shadow: 0 14px 28px rgba(23, 143, 134, 0.16);
  color: var(--color-text-strong);
}

@media (hover: hover) and (pointer: fine) {
  body.quiz-page .options button:hover,
  body.quiz-page .word-btn:hover,
  body.quiz-page .audio-dictation-choice:hover {
    background: var(--color-jade-wash);
    border-color: var(--color-jade-mid);
    border-bottom-color: var(--color-jade-dark);
    box-shadow: 0 14px 28px rgba(23, 143, 134, 0.16);
    color: var(--color-text-strong);
  }
}

body.quiz-page .options button[disabled],
body.quiz-page .options button[aria-disabled='true'] {
  opacity: 0.6;
  filter: grayscale(0.08);
  transform: none;
}

body.quiz-page .options button.answer-correct,
body.quiz-page .options button.answer-wrong {
  opacity: 1;
  filter: none;
}

body.quiz-page button.answer-correct,
body.quiz-page .sentence-answer-area.answer-correct {
  background: var(--color-success-fade) !important;
  border-color: var(--color-success-mid) !important;
  border-bottom-color: var(--color-success-strong) !important;
  color: var(--color-text-strong);
  box-shadow: 0 14px 28px rgba(46, 159, 110, 0.18);
}

body.quiz-page button.answer-wrong,
body.quiz-page .sentence-answer-area.answer-incorrect {
  background: var(--color-error-soft) !important;
  border-color: rgba(201, 47, 69, 0.42) !important;
  border-bottom-color: var(--color-error) !important;
  color: var(--color-text-strong);
  box-shadow: 0 14px 28px rgba(201, 47, 69, 0.16);
}

body.quiz-page button .answer-result {
  display: block;
  margin-top: 0.42rem;
  font-size: var(--type-caption);
  line-height: 1.3;
  font-weight: 800;
}

body.quiz-page button .answer-result[data-result='correct'] {
  color: var(--color-success-strong);
}

body.quiz-page button .answer-result[data-result='incorrect'] {
  color: #a51931;
}

body.quiz-page #feedback {
  min-height: 1.4rem;
  margin: 0.7rem auto 0;
  color: var(--color-text-muted);
  font-size: var(--type-body);
  font-weight: 700;
}

body.quiz-page #nextBtn {
  max-width: 320px;
  min-height: 52px;
  margin-top: 1rem;
  border: 1px solid var(--color-brand-dark);
  border-bottom: 4px solid var(--color-brand-dark-deep);
  box-shadow: var(--shadow-button);
}

body.quiz-page .stats {
  margin: 1rem auto 0;
  padding: 0.7rem 0.85rem 0.85rem;
  border-radius: var(--radius-control);
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid rgba(18, 63, 122, 0.12);
  box-shadow: 0 8px 18px rgba(18, 63, 122, 0.08);
  color: var(--color-text-muted);
  box-sizing: border-box;
}

body.quiz-page .stats-line {
  justify-content: center;
  gap: 0.45rem;
  font-size: var(--type-caption);
  line-height: 1.35;
}

body.quiz-page .stats-summary {
  white-space: normal;
  font-weight: 750;
}

body.quiz-page .stats-stars {
  color: var(--color-reward-deep);
  font-weight: 900;
  letter-spacing: 0.03em;
}

body.quiz-page .quiz-progress {
  height: 9px;
  margin-top: 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--color-brand-soft-wash);
  border: 1px solid rgba(18, 63, 122, 0.12);
}

body.quiz-page .quiz-progress-bar {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-jade) 0%, var(--color-brand) 58%, var(--color-reward-dark) 100%);
}

body.quiz-page .footer {
  bottom: max(0.85rem, calc(env(safe-area-inset-bottom, 0px) + 0.85rem));
  max-width: calc(100vw - 1rem);
  padding: 0.2rem 0;
  gap: 0.45rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  background-color: transparent;
  background-image: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.quiz-page .footer::after {
  content: none;
  box-shadow: none;
}

body.quiz-page .footer .btn-accent,
body.quiz-page .footer .sound-toggle,
body.quiz-page .footer .sound-help,
body.quiz-page .footer .quiz-preferences select,
body.quiz-page .footer .pro-tip {
  min-height: 42px;
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: var(--type-action-sm);
  letter-spacing: 0;
}

body.quiz-page .footer .sound-toggle {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand-dark);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.quiz-page .footer .sound-toggle-icon {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

body.quiz-page .footer .sound-toggle[aria-pressed='false'] .sound-toggle-icon {
  opacity: 0.82;
}

body.quiz-page .footer .btn-accent {
  min-width: 112px;
  min-height: 44px;
  box-shadow: none;
}

body.quiz-page .footer .sound-toggle:hover,
body.quiz-page .footer .sound-toggle:focus-visible {
  background: transparent;
  color: var(--color-brand-dark);
  box-shadow: none;
}

body.quiz-page .footer .sound-toggle:hover .sound-toggle-icon,
body.quiz-page .footer .sound-toggle:focus-visible .sound-toggle-icon {
  transform: translateY(-1px);
}

body.quiz-page .footer .sound-toggle[aria-pressed='true'] {
  background: transparent;
  border-color: transparent;
  color: var(--color-jade-dark);
}

body.quiz-page .footer .quiz-preferences label,
body.quiz-page .footer .pro-tip,
body.quiz-page .footer .sound-help {
  color: var(--color-text-muted);
}

body.quiz-page .sentence-answer-area {
  width: min(100%, var(--quiz-options-width));
  min-height: 76px;
  margin: 0 auto;
  border: 1px dashed var(--color-brand-border-soft);
  border-radius: var(--radius-control);
  background: var(--color-brand-soft-wash);
  box-sizing: border-box;
}

body.quiz-page .sentence-word-bank {
  width: min(100%, var(--quiz-options-width));
  margin: 0 auto 4.5rem;
  padding: 0;
  box-sizing: border-box;
}

body.quiz-page .word-btn {
  min-width: auto !important;
  width: auto;
  min-height: 50px;
  padding: 0.64rem 0.86rem;
  font-size: var(--type-title-sm);
}

body.quiz-page .answer-placeholder {
  color: var(--color-brand-deep);
  font-style: normal;
  font-weight: 700;
}

body.quiz-page .audio-dictation-symbol {
  gap: 0.65rem;
}

body.quiz-page .audio-dictation-play {
  width: 74px;
  height: 74px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

body.quiz-page .audio-dictation-play-icon {
  width: 100%;
  height: 100%;
}

body.quiz-page .audio-dictation-hint {
  margin: 0;
  font-family: var(--font-main);
  font-size: var(--type-caption);
  color: var(--color-text-muted);
  font-style: normal;
}

body.quiz-page .audio-dictation-toggle {
  padding: 0.18rem;
  background: var(--color-surface-soft);
  border: 1px solid rgba(18, 63, 122, 0.12);
}

body.quiz-page .dictation-chip {
  min-height: 34px;
  padding: 0.35rem 0.72rem;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-caption);
  font-weight: 800;
}

body.quiz-page .dictation-chip.active {
  background: var(--color-brand);
  color: #fff;
}

body.quiz-page.boss-mode {
  --quiz-shell-width: min(900px, calc(100vw - clamp(1rem, 5vw, 3rem)));
  --quiz-options-width: min(720px, calc(100vw - clamp(1rem, 5vw, 3rem)));
  background:
    linear-gradient(
      180deg,
      rgba(255, 248, 237, 0.96) 0%,
      rgba(255, 253, 248, 0.98) 54%,
      rgba(252, 241, 219, 0.88) 100%
    ),
    var(--color-bg);
  padding-bottom: calc(var(--page-padding) + 3rem + env(safe-area-inset-bottom, 0px));
}

body.quiz-page.boss-mode .quiz-hero {
  width: var(--quiz-shell-width);
  max-width: var(--quiz-shell-width);
  margin: 0 auto;
  padding: clamp(0.85rem, 2.8vw, 1.25rem);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.92)), var(--color-surface-card);
  border: var(--quiz-card-border);
  box-shadow: var(--quiz-card-shadow);
}

body.quiz-page.boss-mode .quiz-hero::before,
body.quiz-page.boss-mode .quiz-hero::after {
  content: '';
}

body.quiz-page.boss-mode .boss-hero {
  gap: 0.7rem;
}

body.quiz-page.boss-mode .boss-hero-image {
  width: min(360px, 72vw);
  max-height: 34vh;
  filter: drop-shadow(0 18px 24px rgba(18, 63, 122, 0.18));
}

body.quiz-page.boss-mode .boss-hero-panel,
body.quiz-page.boss-mode .boss-bars {
  border-radius: var(--radius-control);
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid rgba(18, 63, 122, 0.14);
  box-shadow: 0 10px 22px rgba(18, 63, 122, 0.1);
}

body.quiz-page.boss-mode .boss-hero-panel {
  width: min(680px, 100%);
  padding: 0.72rem 0.85rem;
}

body.quiz-page.boss-mode .boss-hero-name {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  letter-spacing: 0;
  text-shadow: none;
}

body.quiz-page.boss-mode .boss-hero-desc {
  font-family: var(--font-main);
  font-size: var(--type-caption);
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  opacity: 1;
}

body.quiz-page.boss-mode .prompt-card {
  margin-top: clamp(0.75rem, 2vw, 1.05rem);
}

body.quiz-page.boss-mode .boss-bars {
  padding: 0.72rem 0.85rem;
  gap: 0.55rem;
}

body.quiz-page.boss-mode .boss-bar-row {
  gap: 0.65rem;
}

body.quiz-page.boss-mode .boss-bar-label {
  width: 3.2rem;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-xs);
  letter-spacing: 0.08em;
  opacity: 1;
}

body.quiz-page.boss-mode .boss-bar-track {
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--color-brand-soft-wash);
  border: 1px solid rgba(18, 63, 122, 0.14);
  box-shadow: inset 0 1px 3px rgba(18, 63, 122, 0.1);
}

body.quiz-page.boss-mode .boss-hero-hp .boss-bar-track {
  height: 12px;
}

body.quiz-page.boss-mode .boss-bar-fill {
  border-radius: inherit;
  box-shadow: none;
}

body.quiz-page.boss-mode .boss-bar-fill-boss {
  background: linear-gradient(90deg, var(--color-error) 0%, var(--color-accent) 100%);
}

body.quiz-page.boss-mode .boss-bar-fill-player {
  background: linear-gradient(90deg, var(--color-brand) 0%, var(--color-jade) 100%);
}

body.quiz-page.boss-mode .boss-bar-fill-timer {
  background: linear-gradient(90deg, var(--color-reward-dark) 0%, var(--color-reward) 100%);
}

body.quiz-page.boss-mode .streak-indicator {
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, calc(env(safe-area-inset-bottom, 0px) + 1rem));
}

body.quiz-page.boss-mode .streak-flame {
  width: clamp(3.6rem, 12vw, 5rem);
  height: clamp(3.6rem, 12vw, 5rem);
  filter: drop-shadow(0 12px 18px rgba(183, 121, 31, 0.2));
}

body.quiz-page .boss-result-overlay,
body.quiz-page .boss-lore-overlay,
body.quiz-page .star-celebration-overlay,
body.quiz-page .quiz-completed-overlay,
body.quiz-page .level-up-overlay,
body.quiz-page .streak-milestone-overlay,
body.quiz-page .daily-goal-overlay,
body.quiz-page .achievement-unlock-overlay,
body.quiz-page .example-overlay {
  background: rgba(9, 42, 86, 0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body.quiz-page .boss-result-card,
body.quiz-page .boss-lore-card-overlay,
body.quiz-page .star-celebration-card,
body.quiz-page .quiz-completed-card,
body.quiz-page .level-up-card,
body.quiz-page .streak-milestone-card,
body.quiz-page .daily-goal-card,
body.quiz-page .achievement-unlock-card,
body.quiz-page .example-overlay .overlay-card {
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.96)), var(--color-surface-card);
  border: 1px solid rgba(18, 63, 122, 0.16);
  box-shadow: 0 24px 58px rgba(9, 42, 86, 0.24);
}

body.quiz-page .boss-lore-card-overlay {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade), var(--color-brand), var(--color-reward-dark));
  --overlay-top-accent-height: 6px;
  position: relative;
  border-top-color: transparent;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height, 6px) no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.96)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height, 6px),
    auto,
    36px 36px,
    36px 36px,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box, padding-box;
}

body.quiz-page .boss-result-title,
body.quiz-page .boss-lore-title,
body.quiz-page .star-celebration-card .celebrate-heading,
body.quiz-page .quiz-completed-card .completed-heading,
body.quiz-page .level-up-heading,
body.quiz-page .streak-milestone-heading,
body.quiz-page .daily-goal-heading,
body.quiz-page .example-overlay .overlay-card .heading {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  letter-spacing: 0.02em;
  text-shadow: none;
}

body.quiz-page .boss-result-body,
body.quiz-page .boss-lore-overlay-body,
body.quiz-page .star-celebration-card .celebrate-message,
body.quiz-page .star-celebration-card .celebrate-retry,
body.quiz-page .star-celebration-card .celebrate-meta,
body.quiz-page .quiz-completed-card .completed-stats,
body.quiz-page .streak-milestone-message,
body.quiz-page .daily-goal-message {
  color: var(--color-text-muted);
  font-family: var(--font-main);
  opacity: 1;
}

body.quiz-page .star-celebration-card .celebrate-stars,
body.quiz-page .quiz-completed-card .completed-stars {
  color: var(--color-reward-deep);
  text-shadow: none;
}

body.quiz-page .quiz-completed-card {
  padding: clamp(1.15rem, 4vw, 1.65rem);
}

body.quiz-page .quiz-completed-card:focus {
  outline: none;
}

body.quiz-page .quiz-completed-card .completed-star-icon {
  width: clamp(3.35rem, 11vw, 4.45rem);
  height: clamp(3.35rem, 11vw, 4.45rem);
}

body.quiz-page .quiz-completed-card .completed-buttons {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

body.quiz-page .quiz-completed-card .completed-btn,
body.quiz-page .quiz-completed-card .completed-leaderboard-link {
  box-sizing: border-box;
  width: 100%;
  min-height: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
}

body.quiz-page .quiz-completed-card .completed-leaderboard-link {
  margin-top: 0;
}

body.quiz-page .quiz-completed-card .completed-leaderboard-icon {
  width: 1.5rem;
  height: 1.5rem;
  flex-basis: 1.5rem;
}

body.quiz-page .star-celebration-card .celebrate-close,
body.quiz-page .star-celebration-card .celebrate-review-mistakes,
body.quiz-page .quiz-completed-card .completed-btn,
body.quiz-page .quiz-completed-card .completed-leaderboard-link,
body.quiz-page .boss-result-card .btn-accent,
body.quiz-page .boss-lore-card-overlay .btn-accent {
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  border-radius: var(--radius-pill);
}

body.quiz-page .quiz-completed-card .completed-btn-practice,
body.quiz-page .quiz-completed-card .completed-leaderboard-link {
  background: var(--color-brand-soft-wash) !important;
  border-color: var(--color-brand-border-soft) !important;
  color: var(--color-brand-dark) !important;
}

body.quiz-page .boss-result-overlay {
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background:
    radial-gradient(circle at 20% 14%, rgba(242, 184, 75, 0.18), transparent 18rem),
    radial-gradient(circle at 82% 12%, rgba(23, 143, 134, 0.16), transparent 20rem), rgba(9, 42, 86, 0.58);
  box-sizing: border-box;
}

body.quiz-page .boss-result-card {
  isolation: isolate;
  display: grid;
  gap: clamp(0.8rem, 2vw, 1.05rem);
  width: min(560px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-width: min(560px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-height: calc(100svh - clamp(2rem, 8vw, 5rem));
  margin: auto;
  padding: clamp(1.15rem, 3.5vw, 1.75rem);
  box-sizing: border-box;
  overflow: auto;
  border: 2px solid rgba(183, 121, 31, 0.4);
  border-bottom: 5px solid rgba(183, 121, 31, 0.55);
  border-radius: 10px;
  background:
    linear-gradient(90deg, var(--color-reward-dark) 0, var(--color-brand) 52%, var(--color-jade) 100%) top / 100% 5px
      no-repeat,
    radial-gradient(circle at 18% 0%, rgba(242, 184, 75, 0.13), transparent 15rem),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.96)),
    linear-gradient(rgba(18, 63, 122, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.04) 1px, transparent 1px),
    var(--color-surface-card);
  background-size:
    100% 5px,
    auto,
    auto,
    30px 30px,
    30px 30px,
    auto;
  box-shadow: 0 24px 58px rgba(9, 42, 86, 0.28);
  text-align: left;
}

body.quiz-page .boss-result-card::before {
  content: '';
  position: absolute;
  inset: 0.7rem;
  z-index: -1;
  border: 1px dashed rgba(183, 121, 31, 0.24);
  border-radius: 7px;
  pointer-events: none;
}

body.quiz-page .boss-result-title {
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-md);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.04;
  text-transform: none;
}

body.quiz-page .boss-result-body {
  margin: 0;
  padding: 0.78rem 0.9rem;
  border: 1px solid rgba(23, 143, 134, 0.22);
  border-left: 5px solid var(--color-jade);
  border-radius: 8px;
  background: rgba(237, 249, 247, 0.72);
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-size: var(--type-body);
  font-weight: 750;
  line-height: 1.42;
}

body.quiz-page .boss-result-actions {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.15rem;
}

body.quiz-page .boss-result-card .btn-accent {
  min-height: 52px;
  padding: 0.78rem 1rem;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
}

body.quiz-page .boss-result-lore-btn {
  border-color: var(--color-brand-dark) !important;
  border-bottom: 4px solid var(--color-brand-dark-deep) !important;
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark)) !important;
  color: #fffdf8 !important;
  box-shadow: 0 14px 26px rgba(18, 63, 122, 0.22) !important;
}

body.quiz-page .boss-result-back {
  border-color: rgba(18, 63, 122, 0.18) !important;
  border-bottom: 4px solid rgba(18, 63, 122, 0.3) !important;
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.78) !important;
  color: var(--color-brand-dark) !important;
  box-shadow: 0 10px 18px rgba(18, 63, 122, 0.08) !important;
}

body.quiz-page .example-overlay {
  padding: clamp(1rem, 4vw, 2.5rem);
  background:
    radial-gradient(circle at 18% 16%, rgba(242, 184, 75, 0.18), transparent 18rem),
    radial-gradient(circle at 84% 10%, rgba(23, 143, 134, 0.16), transparent 20rem), rgba(9, 42, 86, 0.58);
  box-sizing: border-box;
}

body.quiz-page .example-overlay .overlay-card {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade) 0, var(--color-brand) 100%);
  --overlay-top-accent-height: 10px;
  position: relative;
  display: grid;
  gap: clamp(0.62rem, 1.6vw, 0.9rem);
  width: min(720px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-width: min(720px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-height: calc(100svh - clamp(2rem, 8vw, 5rem));
  margin: 0;
  padding: clamp(1rem, 2.8vw, 1.45rem);
  overflow: auto;
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-top-color: transparent;
  border-bottom: 4px solid rgba(183, 121, 31, 0.42);
  border-radius: 10px;
  background:
    linear-gradient(90deg, var(--color-jade) 0, var(--color-brand) 100%) top / 100% 10px no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.96)),
    var(--color-surface-card);
  background-size:
    100% 10px,
    auto,
    auto;
  background-origin: border-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box;
  box-shadow: 0 24px 58px rgba(9, 42, 86, 0.28);
  text-align: left;
}

body.quiz-page .example-overlay .overlay-card::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}

body.quiz-page .example-overlay .overlay-card .heading {
  justify-self: start;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-jade-dark);
  font-family: var(--font-main);
  font-size: var(--type-xs);
  font-weight: 950;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: none;
  text-transform: none;
}

body.quiz-page .example-overlay .overlay-card .text {
  margin: 0;
  color: var(--color-text-strong);
  font-family: var(--font-main);
  font-size: var(--type-title-md);
  font-weight: 900;
  line-height: 1.18;
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline {
  display: grid;
  gap: clamp(0.5rem, 1.4vw, 0.78rem);
  font-size: var(--type-body);
  font-weight: 700;
  line-height: 1.25;
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline .example-line {
  display: grid;
  gap: 0.16rem;
  padding-top: clamp(0.46rem, 1.2vw, 0.64rem);
  border-top: 0;
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline .example-line:first-child {
  padding-top: 0;
  border-top: 0;
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline .example-line-label {
  color: var(--color-brand-dark-muted);
  font-family: var(--font-main);
  font-size: var(--type-xs);
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: none;
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline .example-line-value {
  color: var(--color-text-strong);
  font-size: var(--type-title-sm);
  font-weight: 950;
  line-height: 1.16;
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline .example-line-thai .example-line-value {
  font-family: var(--font-main);
  font-size: var(--type-title-md);
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline .example-line-phonetic .example-line-value {
  color: var(--color-brand-dark);
  font-size: var(--type-title-sm);
  font-weight: 900;
}

body.quiz-page .example-overlay .overlay-card .text.is-multiline .example-line-english .example-line-value {
  font-size: var(--type-title-sm);
}

body.quiz-page .example-overlay .overlay-card .text .sel {
  padding: 0.02em 0.08em;
  border-radius: 0.18em;
  background: var(--color-reward-wash);
  color: var(--color-jade-dark);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

body.quiz-page .example-overlay > .timer {
  position: absolute;
  left: clamp(1.25rem, 7vw, 4.5rem);
  right: clamp(1.25rem, 7vw, 4.5rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 0.85rem);
  height: 3px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 253, 248, 0.38);
}

body.quiz-page .example-overlay > .timer .timer-fill {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-jade) 0%, var(--color-reward) 100%);
}

body.quiz-page .example-overlay .flags-wrap {
  display: none;
}

@media (max-width: 640px) {
  body.quiz-page {
    --quiz-shell-width: calc(100vw - 1.25rem);
    --quiz-options-width: calc(100vw - 1.25rem);
    --symbol-font-size: clamp(1.7rem, 9vw, 2.65rem);
    --page-padding: 0.75rem;
    padding-bottom: calc(var(--page-padding) + 8.75rem + env(safe-area-inset-bottom, 0px));
  }

  body.quiz-page .quiz-hero {
    padding: 0.92rem 1rem;
  }

  body.quiz-page .quiz-hero-label {
    font-size: var(--type-2xs);
    letter-spacing: 0.12em;
  }

  body.quiz-page .quiz-hero-title {
    font-size: var(--type-title-md);
  }

  body.quiz-page .prompt-card {
    padding: 0.95rem 1rem;
    gap: 0.2rem;
  }

  body.quiz-page .prompt-label {
    font-size: var(--type-xs);
    letter-spacing: 0.08em;
  }

  body.quiz-page .options {
    gap: 0.62rem;
  }

  body.quiz-page .options button,
  body.quiz-page .audio-dictation-choice {
    min-width: 0;
    width: 100%;
    min-height: 54px;
    padding: 0.74rem 0.88rem;
    font-size: var(--type-body);
  }

  body.quiz-page .stats {
    padding: 0.62rem 0.68rem 0.72rem;
  }

  body.quiz-page .stats-line {
    font-size: var(--type-caption);
  }

  body.quiz-page .footer {
    grid-auto-columns: max-content;
    justify-content: start;
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    width: fit-content;
    margin: 0.8rem auto 0;
    max-width: calc(100vw - 1rem);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body.quiz-page .footer .btn-accent,
  body.quiz-page .footer .sound-toggle,
  body.quiz-page .footer .sound-help,
  body.quiz-page .footer .quiz-preferences select,
  body.quiz-page .footer .pro-tip {
    min-height: 40px;
    font-size: var(--type-caption);
  }

  body.quiz-page .footer .pro-tip {
    display: none;
  }

  body.quiz-page.boss-mode {
    padding-bottom: calc(var(--page-padding) + 1.5rem + env(safe-area-inset-bottom, 0px));
  }

  body.quiz-page.boss-mode .boss-hero-image {
    width: min(300px, 74vw);
    max-height: 30vh;
  }

  body.quiz-page.boss-mode .boss-hero-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.18rem;
  }

  body.quiz-page.boss-mode .boss-hero-desc {
    width: 100%;
    text-align: left;
    white-space: normal;
  }

  body.quiz-page.boss-mode .boss-bar-label {
    width: 2.8rem;
    font-size: var(--type-xs);
  }
}

@media (min-width: 900px) {
  body.quiz-page .footer {
    left: auto;
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.quiz-page .quiz-progress-bar,
  body.quiz-page .boss-bar-fill,
  body.quiz-page .options button,
  body.quiz-page .word-btn,
  body.quiz-page .audio-dictation-choice,
  body.quiz-page .star-celebration-card,
  body.quiz-page .quiz-completed-card,
  body.quiz-page .boss-result-card,
  body.quiz-page .boss-lore-card-overlay,
  body.quiz-page .example-overlay .overlay-card {
    animation: none;
    transition: none;
  }
}

/* ThaiQuest 2.0 quiz direction refinement */
body.quiz-page {
  --quiz-shell-width: min(1040px, calc(100vw - clamp(1.5rem, 6vw, 4.5rem)));
  --quiz-options-width: min(900px, calc(100vw - clamp(1.5rem, 6vw, 4.5rem)));
  --options-max-width: 900px;
  --quiz-stage-shadow: 0 22px 48px rgba(9, 42, 86, 0.13);
  padding-top: calc(clamp(1rem, 2.4vw, 1.6rem) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--page-padding) + env(safe-area-inset-bottom, 0px));
}

body.quiz-page .quiz-hero,
body.quiz-page .prompt-card,
body.quiz-page .stats {
  border-radius: 10px;
}

body.quiz-page .quiz-hero {
  --quiz-hero-background: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 34%);
  align-items: stretch;
  gap: clamp(1.2rem, 3.5vw, 2.6rem);
  max-width: var(--quiz-shell-width);
  text-align: left;
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-bottom: 4px solid var(--color-reward-dark);
  background:
    linear-gradient(180deg, #fffdf8 0%, rgba(255, 253, 248, 0.98) 42%, rgba(255, 248, 237, 0.96) 100%),
    radial-gradient(circle at 80% 18%, rgba(255, 255, 255, 0.52), transparent 34%), var(--quiz-hero-background),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px), var(--color-surface-card);
  background-position: center, center, center, center, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat, repeat, no-repeat;
  background-size:
    auto,
    auto,
    cover,
    32px 32px,
    32px 32px,
    auto;
  box-shadow: var(--quiz-stage-shadow);
  overflow: visible;
}

body.quiz-page .quiz-hero-ornament {
  --quiz-hero-ornament-size: clamp(96px, 9vw, 144px);
  position: absolute;
  top: calc(var(--quiz-hero-ornament-size) * -0.14);
  z-index: 1;
  width: var(--quiz-hero-ornament-size);
  aspect-ratio: 1;
  background-image: url('/asset/ui/quiz-card-corner-ornament.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: saturate(0.94) brightness(1.03);
  opacity: 1;
  pointer-events: none;
}

body.quiz-page .quiz-hero-ornament-start {
  left: calc(var(--quiz-hero-ornament-size) * -0.1);
  transform: scaleY(-1);
}

body.quiz-page .quiz-hero-ornament-end {
  right: calc(var(--quiz-hero-ornament-size) * -0.1);
  transform: rotate(180deg);
}

body.quiz-page .quiz-hero::before {
  inset: 0 0 auto;
  width: auto;
  height: 6px;
  border-radius: 10px 10px 0 0;
}

body.quiz-page .quiz-hero::after {
  opacity: 0;
}

body.quiz-page .quiz-hero-content {
  grid-column: 1;
  align-items: flex-start;
  max-width: 42rem;
}

body.quiz-page .quiz-hero-visual {
  position: relative;
  z-index: 1;
  grid-column: 2;
  align-self: stretch;
  display: grid;
  min-height: 100%;
  place-items: center;
  overflow: hidden;
}

body.quiz-page .quiz-hero-visual-image {
  position: relative;
  z-index: 1;
  width: min(100%, 340px);
  height: 100%;
  max-height: 210px;
  object-fit: contain;
  object-position: center;
}

@media (min-width: 701px) and (min-height: 721px) {
  body.quiz-page .quiz-hero-content {
    padding-inline-start: clamp(3.25rem, 5vw, 5.5rem);
  }
}

body.quiz-page .quiz-hero-label {
  color: var(--color-jade-dark);
  font-size: var(--type-xs);
  font-weight: 900;
  letter-spacing: 0.18em;
}

body.quiz-page .quiz-hero-title {
  font-size: var(--type-title-lg);
  line-height: 1.04;
}

body.quiz-page .quiz-hero-subtitle {
  max-width: 38rem;
  font-size: var(--type-body);
  font-weight: 650;
}

body.quiz-page .prompt-card {
  isolation: isolate;
  margin-top: clamp(1rem, 2.5vw, 1.5rem);
  margin-bottom: clamp(0.9rem, 2.2vw, 1.3rem);
  padding: clamp(1.35rem, 3vw, 2.1rem);
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: none;
}

body.quiz-page .prompt-card::before {
  display: none;
}

body.quiz-page .prompt-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border: 1px dashed rgba(183, 121, 31, 0.28);
  border-radius: inherit;
  pointer-events: none;
}

body.quiz-page .prompt-label,
body.quiz-page #symbol,
body.quiz-page .boss-hud-inline {
  position: relative;
  z-index: 1;
}

body.quiz-page .quiz-hero-tip {
  display: none;
}

body.quiz-page .prompt-label {
  display: inline-flex;
  align-self: flex-start;
  margin: 0 0 0.65rem;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-xs);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

body.quiz-page #symbol {
  margin-top: 0;
  color: var(--color-text-strong);
}

body.quiz-page #symbol .color-swatch {
  display: block;
  width: clamp(4.4rem, 14vw, 6.75rem);
  aspect-ratio: 1;
  margin: 0 auto clamp(0.45rem, 1.4vw, 0.7rem);
  border: 1px dashed rgba(183, 121, 31, 0.42);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 4px rgba(255, 253, 248, 0.86),
    0 8px 18px rgba(18, 63, 122, 0.1);
}

body.quiz-page #symbol .color-swatch.color-swatch-only {
  margin-bottom: 0;
}

body.quiz-page #symbol .color-symbol-text {
  display: block;
}

body.quiz-page #symbol .emoji-line {
  display: none;
}

body.quiz-page.quiz-mode-standard .options,
body.quiz-page.quiz-mode-cloze .options,
body.quiz-page.quiz-mode-audio .options,
body.quiz-page.boss-mode .options {
  display: grid;
  grid-template-columns: 1fr;
  width: var(--quiz-options-width);
  max-width: var(--quiz-options-width);
  align-items: stretch;
}

body.quiz-page.quiz-mode-standard .options button,
body.quiz-page.quiz-mode-cloze .options button,
body.quiz-page.quiz-mode-audio .options button,
body.quiz-page.boss-mode .options button {
  width: min(100%, calc(var(--quiz-options-width) / 3));
  max-width: calc(var(--quiz-options-width) / 3);
  min-width: 0;
  justify-self: center;
}

body.quiz-page .options button,
body.quiz-page .word-btn,
body.quiz-page .audio-dictation-choice {
  border-radius: 10px;
  border-color: rgba(18, 63, 122, 0.22);
  border-bottom-color: rgba(18, 63, 122, 0.52);
  border-bottom-width: 5px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(255, 250, 241, 0.97)),
    linear-gradient(90deg, rgba(18, 63, 122, 0.035) 0, rgba(18, 63, 122, 0.035) 1px, transparent 1px);
  background-size:
    auto,
    24px 24px;
  box-shadow: 0 14px 28px rgba(9, 42, 86, 0.1);
  font-size: var(--type-body-lg);
  font-weight: 850;
}

body.quiz-page .options button:focus-visible,
body.quiz-page .word-btn:focus-visible,
body.quiz-page .audio-dictation-choice:focus-visible {
  background:
    linear-gradient(180deg, rgba(237, 249, 247, 0.98), rgba(255, 253, 248, 0.96)),
    linear-gradient(90deg, rgba(23, 143, 134, 0.05) 0, rgba(23, 143, 134, 0.05) 1px, transparent 1px);
  border-color: rgba(23, 143, 134, 0.36);
  border-bottom-color: var(--color-jade-dark);
}

@media (hover: hover) and (pointer: fine) {
  body.quiz-page .options button:hover,
  body.quiz-page .word-btn:hover,
  body.quiz-page .audio-dictation-choice:hover {
    background:
      linear-gradient(180deg, rgba(237, 249, 247, 0.98), rgba(255, 253, 248, 0.96)),
      linear-gradient(90deg, rgba(23, 143, 134, 0.05) 0, rgba(23, 143, 134, 0.05) 1px, transparent 1px);
    border-color: rgba(23, 143, 134, 0.36);
    border-bottom-color: var(--color-jade-dark);
  }
}

body.quiz-page .options button:active,
body.quiz-page .audio-dictation-choice:active {
  top: 2px;
  border-bottom-width: 3px;
}

@media (hover: hover) and (pointer: fine) {
  body.quiz-page .word-btn:active {
    top: 2px;
    border-bottom-width: 3px;
  }
}

body.quiz-page button.answer-correct,
body.quiz-page .sentence-answer-area.answer-correct {
  background:
    linear-gradient(180deg, rgba(223, 245, 233, 0.98), rgba(255, 253, 248, 0.96)), var(--color-success-fade) !important;
}

body.quiz-page button.answer-wrong,
body.quiz-page .sentence-answer-area.answer-incorrect {
  background:
    linear-gradient(180deg, rgba(255, 225, 231, 0.96), rgba(255, 253, 248, 0.95)), var(--color-error-soft) !important;
}

body.quiz-page #feedback {
  max-width: var(--quiz-options-width);
  padding: 0 0.25rem;
  font-size: var(--type-body);
  font-weight: 850;
}

body.quiz-page .stats {
  width: var(--quiz-options-width);
  max-width: var(--quiz-options-width);
  margin: 1rem auto 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.quiz-page .stats-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  font-size: var(--type-caption);
}

body.quiz-page .stats-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  min-width: 0;
}

body.quiz-page .stats-metric {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.12rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.quiz-page .stats-metric-label {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--type-micro);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

body.quiz-page .stats-metric-value {
  color: var(--color-text-strong);
  font-size: var(--type-action);
  font-weight: 950;
  white-space: nowrap;
}

body.quiz-page .stats-stars {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  line-height: 1;
  white-space: nowrap;
}

body.quiz-page .stats-stars .star {
  display: inline-block;
  width: clamp(1.25rem, 4vw, 1.75rem);
  height: clamp(1.25rem, 4vw, 1.75rem);
  background-image: url('/asset/metric-icons/star-rating.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 4px 7px rgba(183, 121, 31, 0.15));
}

body.quiz-page .stats-stars .star--accent {
  transform: translateY(-0.04rem) scale(1.06);
}

body.quiz-page .stats-stars .star[data-star-state='empty'] {
  background-image: url('/asset/metric-icons/star-rating-empty.webp');
  filter: drop-shadow(0 3px 6px rgba(18, 63, 122, 0.1));
}

body.quiz-page .footer {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  width: fit-content;
  margin: 1rem auto 0;
  padding: 0.2rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  background-color: transparent;
  background-image: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.quiz-page.quiz-mode-sentence .options {
  display: flex;
  flex-direction: column;
  width: var(--quiz-options-width);
  max-width: var(--quiz-options-width);
  gap: 0.9rem;
}

body.quiz-page .sentence-prompt {
  --sentence-prompt-min-size: 10px;
  width: 100%;
  max-width: 44rem;
  margin: 0.2rem auto 0;
  color: var(--color-brand-dark);
  font-size: var(--sentence-prompt-fit-size, var(--type-title-lg));
  font-weight: 900;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

body.quiz-page .sentence-thai-hint {
  max-width: 44rem;
  margin: 0.45rem auto 0;
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-size: var(--type-body-lg);
  font-weight: 800;
  opacity: 1;
}

body.quiz-page .sentence-answer-area {
  min-height: 92px;
  padding: 1rem;
  border: 2px dashed rgba(183, 121, 31, 0.42);
  background: linear-gradient(180deg, rgba(252, 241, 219, 0.72), rgba(255, 253, 248, 0.92)), var(--color-reward-wash);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

body.quiz-page .sentence-word-bank {
  margin-bottom: 1.4rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.quiz-page .sentence-answer-area .word-btn {
  background: var(--color-jade-wash);
  border-color: rgba(23, 143, 134, 0.28);
  border-bottom-color: var(--color-jade-dark);
}

body.quiz-page .answer-placeholder {
  color: var(--color-brand-dark-muted);
  font-size: var(--type-caption);
  letter-spacing: 0;
}

body.quiz-page .audio-dictation-symbol {
  gap: 0.85rem;
}

body.quiz-page .audio-dictation-play {
  width: 92px;
  height: 92px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0;
  line-height: 0;
  text-indent: 0;
  box-shadow: none;
  overflow: visible;
}

body.quiz-page .audio-dictation-play:hover,
body.quiz-page .audio-dictation-play:focus-visible {
  background: transparent;
  filter: drop-shadow(0 10px 18px rgba(18, 63, 122, 0.18));
}

body.quiz-page .audio-dictation-hint {
  color: var(--color-brand-dark-muted);
  font-size: var(--type-caption);
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.quiz-page .audio-dictation-toggle {
  gap: 0.16rem;
  padding: 0.22rem;
  border-color: rgba(183, 121, 31, 0.24);
  background: var(--color-reward-wash);
}

body.quiz-page .dictation-chip {
  min-height: 2rem;
  padding: 0.35rem 0.72rem;
  border-radius: var(--radius-pill);
}

body.quiz-page.quiz-mode-cloze #symbol .cloze-placeholder {
  line-height: 1;
  vertical-align: baseline;
}

body.quiz-page.boss-mode {
  --quiz-shell-width: min(1120px, calc(100vw - clamp(1.25rem, 5vw, 4rem)));
  --quiz-options-width: min(920px, calc(100vw - clamp(1.25rem, 5vw, 4rem)));
  overflow-x: clip;
}

html:has(body.quiz-page.boss-mode) {
  overflow-x: clip;
}

body.quiz-page.boss-mode .quiz-hero {
  grid-template-columns: 1fr;
  min-height: min(46vh, 460px);
  padding: clamp(1rem, 2.6vw, 1.45rem);
}

body.quiz-page.boss-mode .quiz-hero::before {
  content: none;
  display: none;
}

body.quiz-page.boss-mode .quiz-hero-content {
  max-width: none;
}

body.quiz-page.boss-mode .quiz-hero-visual {
  display: none;
}

body.quiz-page.boss-mode .boss-hero {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

body.quiz-page.boss-mode .boss-hero-image {
  width: min(370px, 34vw);
  max-height: 42vh;
}

body.quiz-page.boss-mode .quiz-hero-ornament {
  --quiz-hero-ornament-size: clamp(124px, 12vw, 188px);
  --boss-hero-ornament-edge-offset: calc(var(--quiz-hero-ornament-size) * -0.14);
  z-index: 3;
  background-image: url('/asset/ui/boss-card-corner-ornament.webp');
  filter: saturate(1.05) brightness(1.02);
}

body.quiz-page.boss-mode .quiz-hero-ornament-start {
  left: var(--boss-hero-ornament-edge-offset);
  transform: none;
}

body.quiz-page.boss-mode .quiz-hero-ornament-end {
  right: var(--boss-hero-ornament-edge-offset);
  transform: scaleX(-1);
}

body.quiz-page.boss-mode .boss-hero-panel,
body.quiz-page.boss-mode .boss-bars {
  border-radius: 10px;
  border-color: rgba(183, 121, 31, 0.34);
  border-bottom: 4px solid rgba(183, 121, 31, 0.45);
}

body.quiz-page.boss-mode .boss-hero-panel {
  padding: 1rem;
  text-align: left;
}

body.quiz-page.boss-mode .boss-hero-header {
  align-items: flex-start;
  flex-direction: column;
  gap: 0.2rem;
}

body.quiz-page.boss-mode .boss-hero-panel .boss-hero-name {
  white-space: normal;
}

body.quiz-page.boss-mode .boss-hero-desc {
  width: 100%;
  font-size: var(--type-caption);
  font-weight: 850;
  letter-spacing: 0.08em;
  overflow: visible;
  text-align: left;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: normal;
}

body.quiz-page.boss-mode .boss-bar-track {
  height: 14px;
}

@media (min-width: 860px) {
  body.quiz-page.boss-mode .boss-hero {
    display: grid;
    grid-template-columns: minmax(360px, 420px) minmax(360px, 1fr);
    align-items: center;
    gap: clamp(1.5rem, 4vw, 3rem);
  }

  body.quiz-page.boss-mode .boss-hero-image-wrap {
    justify-self: center;
  }

  body.quiz-page.boss-mode .boss-hero-panel {
    justify-self: stretch;
  }
}

@media (max-width: 700px) {
  body.quiz-page {
    --quiz-shell-width: calc(100vw - 2rem);
    --quiz-options-width: calc(100vw - 2rem);
  }

  body.quiz-page .quiz-hero,
  body.quiz-page .prompt-card {
    border-radius: 10px;
  }

  body.quiz-page .quiz-hero-content {
    max-width: none;
  }

  body.quiz-page .quiz-hero {
    grid-template-columns: 1fr;
  }

  body.quiz-page .quiz-hero-visual {
    display: none;
  }

  body.quiz-page .quiz-hero-title {
    font-size: var(--type-title-md);
  }

  body.quiz-page .prompt-card {
    padding: 1.05rem;
    border-radius: 18px;
  }

  body.quiz-page .prompt-card::after {
    inset: 0;
  }

  body.quiz-page.quiz-mode-standard .options,
  body.quiz-page.quiz-mode-cloze .options,
  body.quiz-page.quiz-mode-audio .options,
  body.quiz-page.boss-mode .options {
    grid-template-columns: 1fr;
  }

  body.quiz-page.quiz-mode-standard .options button,
  body.quiz-page.quiz-mode-cloze .options button,
  body.quiz-page.quiz-mode-audio .options button,
  body.quiz-page.boss-mode .options button {
    width: 100%;
    max-width: 100%;
    justify-self: stretch;
  }

  body.quiz-page.quiz-mode-standard .options button:last-child:nth-child(odd),
  body.quiz-page.quiz-mode-cloze .options button:last-child:nth-child(odd),
  body.quiz-page.quiz-mode-audio .options button:last-child:nth-child(odd),
  body.quiz-page.boss-mode .options button:last-child:nth-child(odd) {
    grid-column: auto;
  }

  body.quiz-page .stats-line,
  body.quiz-page .stats-line {
    grid-template-columns: 1fr;
  }

  body.quiz-page .stats-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.quiz-page .stats-metric {
    flex-direction: column;
    justify-content: center;
    gap: 0.18rem;
    padding: 0.12rem 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body.quiz-page .stats-metric-label {
    max-width: 100%;
    font-size: var(--type-micro);
    letter-spacing: 0.08em;
  }

  body.quiz-page .stats-metric-value {
    font-size: var(--type-action-sm);
  }

  body.quiz-page .stats-stars {
    width: 100%;
    box-sizing: border-box;
  }

  body.quiz-page .sentence-answer-area {
    min-height: 82px;
    padding: 0.8rem;
  }

  body.quiz-page .sentence-word-bank {
    padding: 0.75rem;
  }

  body.quiz-page .audio-dictation-play {
    width: 82px;
    height: 82px;
  }

  body.quiz-page.boss-mode .quiz-hero {
    min-height: 0;
  }

  body.quiz-page.boss-mode .boss-hero-image {
    width: min(320px, 78vw);
    max-height: 32vh;
  }

  body.quiz-page.boss-mode .quiz-hero-ornament {
    --quiz-hero-ornament-size: clamp(104px, 28vw, 124px);
    --boss-hero-ornament-edge-offset: calc(var(--quiz-hero-ornament-size) * -0.14);
  }
}

@media (orientation: landscape) and (max-height: 720px) {
  body.home.quest-mode .quest-card:not(.collapsed):not(.preview):not(.premium-locked):not(.premium-checking)::before {
    height: 100%;
    background:
      linear-gradient(90deg, rgba(255, 248, 237, 0.74), rgba(255, 248, 237, 0.48) 46%, rgba(255, 248, 237, 0.78)),
      linear-gradient(180deg, rgba(15, 76, 129, 0.08), rgba(255, 196, 77, 0.04) 100%),
      var(--quest-card-background-active);
    background-position: center center;
    background-size: cover;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 4px), transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 4px), transparent 100%);
  }

  body.quiz-page {
    --page-padding: 0.65rem;
    --quiz-shell-width: 100%;
    --quiz-options-width: min(100%, 42rem);
    --symbol-font-size: clamp(1.45rem, 6vh, 2rem);
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    padding-right: calc(0.65rem + max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)));
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(0.65rem + max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)));
    overflow-x: hidden;
  }

  body.quiz-page .quiz-hero {
    grid-template-columns: 1fr;
    align-items: center;
    gap: 0;
    min-height: clamp(6rem, 20vh, 7rem);
    padding: 0.62rem 0.85rem 0.68rem;
  }

  body.quiz-page .quiz-hero-visual {
    display: none;
  }

  body.quiz-page .quiz-hero-label,
  body.quiz-page .quiz-hero-subtitle {
    display: none;
  }

  body.quiz-page .quiz-hero-title {
    font-size: var(--type-title-sm);
    line-height: 1.08;
  }

  body.quiz-page.boss-mode {
    --quiz-shell-width: min(100%, 58rem);
    --quiz-options-width: min(100%, 44rem);
    --symbol-font-size: var(--type-title-sm);
    padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
  }

  body.quiz-page.boss-mode .quiz-hero {
    min-height: 0;
    padding: 0.34rem 0.55rem;
  }

  body.quiz-page.boss-mode .boss-hero {
    display: grid;
    grid-template-columns: minmax(4.6rem, 6.2rem) minmax(0, 1fr);
    align-items: center;
    gap: 0.58rem;
    max-width: min(100%, 58rem);
  }

  body.quiz-page.boss-mode .boss-hero-image-wrap {
    justify-self: center;
  }

  body.quiz-page.boss-mode .boss-hero-image {
    width: min(100%, 6.2rem);
    max-height: 18vh;
  }

  body.quiz-page.boss-mode .boss-hero-panel {
    width: 100%;
    padding: 0.42rem 0.58rem;
  }

  body.quiz-page.boss-mode .boss-hero-header {
    gap: 0.08rem;
  }

  body.quiz-page.boss-mode .boss-hero-name {
    font-size: var(--type-title-sm);
    line-height: 1;
  }

  body.quiz-page.boss-mode .boss-hero-desc {
    font-size: var(--type-micro);
    line-height: 1.05;
  }

  body.quiz-page.boss-mode .boss-hero-hp-row,
  body.quiz-page.boss-mode .boss-bar-row {
    gap: 0.45rem;
  }

  body.quiz-page.boss-mode .boss-bar-label {
    width: 2.45rem;
    font-size: var(--type-micro);
  }

  body.quiz-page.boss-mode .boss-bar-track,
  body.quiz-page.boss-mode .boss-hero-hp .boss-bar-track {
    height: 10px;
  }

  body.quiz-page .prompt-card {
    margin-top: 0.48rem;
    margin-bottom: 0.52rem;
    padding: 0.68rem 0.85rem;
  }

  body.quiz-page.boss-mode .prompt-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(13rem, 0.85fr);
    align-items: center;
    column-gap: 0.58rem;
    row-gap: 0.28rem;
    max-width: var(--quiz-shell-width);
    margin-top: 0.34rem;
    margin-bottom: 0.34rem;
    padding: 0.48rem 0.58rem;
  }

  body.quiz-page.boss-mode .prompt-label {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  body.quiz-page.boss-mode #symbol {
    min-height: 0;
    margin: 0;
  }

  body.quiz-page.boss-mode #symbol .cloze-hints {
    margin-top: 0.22rem;
  }

  body.quiz-page.boss-mode .boss-bars {
    margin-top: 0;
    padding: 0.42rem 0.54rem;
    gap: 0.32rem;
  }

  body.quiz-page .prompt-label {
    margin-bottom: 0.34rem;
    font-size: var(--type-micro);
    letter-spacing: 0.08em;
  }

  body.quiz-page .audio-dictation-symbol {
    gap: 0.34rem;
  }

  body.quiz-page .audio-dictation-play {
    width: 64px;
    height: 64px;
  }

  body.quiz-page .audio-dictation-hint {
    font-size: var(--type-micro);
  }

  body.quiz-page .audio-dictation-toggle {
    padding: 0.14rem;
  }

  body.quiz-page .dictation-chip {
    min-height: 1.7rem;
    padding: 0.2rem 0.58rem;
    font-size: var(--type-micro);
  }

  body.quiz-page.quiz-mode-standard .options,
  body.quiz-page.quiz-mode-cloze .options,
  body.quiz-page.quiz-mode-sentence .options,
  body.quiz-page.quiz-mode-audio .options,
  body.quiz-page.boss-mode .options {
    gap: 0.42rem;
  }

  body.quiz-page .sentence-prompt {
    margin-top: 0;
    font-size: var(--sentence-prompt-fit-size, var(--type-title-lg));
    line-height: 1.15;
  }

  body.quiz-page .sentence-thai-hint {
    margin-top: 0.22rem;
    font-size: var(--type-body);
    line-height: 1.15;
  }

  body.quiz-page .sentence-answer-area {
    min-height: 56px;
    padding: 0.55rem;
  }

  body.quiz-page .sentence-word-bank {
    margin-bottom: 0.6rem;
    padding: 0;
  }

  body.quiz-page .word-btn {
    min-height: 44px;
    padding: 0.45rem 0.65rem;
    font-size: var(--type-body-lg);
  }

  body.quiz-page.quiz-mode-standard .options button,
  body.quiz-page.quiz-mode-cloze .options button,
  body.quiz-page.quiz-mode-audio .options button,
  body.quiz-page.boss-mode .options button {
    width: min(100%, 26rem);
    max-width: min(100%, 26rem);
    min-height: 46px;
    padding: 0.5rem 0.72rem;
    font-size: var(--type-body);
    border-bottom-width: 4px;
  }

  body.quiz-page .stats {
    margin-top: 0.52rem;
  }

  body.quiz-page.boss-mode .options {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    width: var(--quiz-options-width);
    max-width: var(--quiz-options-width);
    gap: 0.3rem;
  }

  body.quiz-page.boss-mode .options button {
    width: 100%;
    max-width: 100%;
    min-height: 38px;
    padding: 0.34rem 0.5rem;
    font-size: var(--type-caption);
    line-height: 1.18;
  }

  body.quiz-page.boss-mode.quiz-mode-sentence .options {
    gap: 0.3rem;
  }

  body.quiz-page.boss-mode.quiz-mode-sentence .sentence-answer-area {
    min-height: 44px;
    padding: 0.42rem;
  }

  body.quiz-page.boss-mode.quiz-mode-sentence .sentence-word-bank {
    margin-bottom: 0;
    padding: 0;
    gap: 0.3rem;
  }

  body.quiz-page.boss-mode.quiz-mode-sentence .sentence-word-bank .word-btn {
    flex: 0 0 auto;
    width: auto;
    max-width: 100%;
    min-height: 38px;
    padding: 0.34rem 0.5rem;
    font-size: var(--type-caption);
    line-height: 1.18;
  }
}

/* ThaiQuest 2.0 stats and progress dashboard */
body.stats-page {
  --stats-panel-border: rgba(18, 63, 122, 0.14);
  --stats-panel-shadow: 0 18px 42px rgba(18, 63, 122, 0.1);
  --stats-card-shadow: 0 10px 24px rgba(28, 36, 48, 0.08);
  --stats-icon-row: 5.25rem;
  --stats-value-row: 3.45rem;
  --stats-label-row: 2.4rem;
  --stats-sublabel-row: 1.25rem;
  --stats-heat-0: #f3eadb;
  --stats-heat-1: #d8ecf5;
  --stats-heat-2: #b8e2d8;
  --stats-heat-3: #f4cf7a;
  --stats-heat-4: #123f7a;
  --maturity-known-color: var(--color-jade);
  --maturity-learning-color: var(--color-brand);
  --maturity-unseen-color: #e6dac8;
}

body.stats-page .stats-content {
  max-width: 1160px;
  padding: 0 clamp(0.9rem, 3vw, 2rem);
}

body.stats-page .stats-hero {
  max-width: none;
  margin: 1.2rem auto 2rem;
  padding: 1.35rem 1.5rem;
  text-align: left;
  border: 1px solid var(--stats-panel-border);
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 253, 248, 0.94), rgba(255, 250, 241, 0.9)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px), var(--color-surface-card);
  background-size:
    auto,
    42px 42px,
    42px 42px,
    auto;
  box-shadow: var(--stats-panel-shadow);
}

body.stats-page .stats-hero h2 {
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-lg);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.05;
  text-shadow: none;
  text-transform: none;
}

body.stats-page .stats-lead {
  max-width: 44rem;
  margin: 0.45rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--type-body);
  font-weight: 650;
  line-height: 1.45;
  opacity: 1;
}

body.stats-page .stats-section {
  margin-bottom: 2.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(18, 63, 122, 0.1);
}

body.stats-page .stats-section-title {
  margin: 0 0 0.35rem;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: none;
}

body.stats-page .stats-section-lead {
  max-width: 44rem;
  margin: 0 0 1rem;
  color: var(--color-text-muted);
  font-size: var(--type-caption);
  font-weight: 600;
  line-height: 1.45;
  opacity: 1;
}

body.stats-page [hidden] {
  display: none !important;
}

body.stats-page #review-stats-empty:not([hidden]) {
  margin-top: 1rem;
}

body.stats-page .stats-feedback {
  border: 1px solid var(--stats-panel-border);
  border-radius: 8px;
  background: var(--color-brand-soft-wash);
  color: var(--color-brand-dark);
  box-shadow: var(--stats-card-shadow);
}

body.stats-page .stats-feedback-error {
  background: var(--color-error-soft);
  color: #a51931;
}

body.stats-page .personal-bests-grid,
body.stats-page .session-stats-grid,
body.stats-page .achievements-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
}

body.stats-page .personal-best-card,
body.stats-page .session-stat-card,
body.stats-page .settings-group {
  border: 1px solid var(--stats-panel-border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.94)), var(--color-surface-card);
  box-shadow: var(--stats-card-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.stats-page .personal-best-card,
body.stats-page .session-stat-card {
  display: grid;
  grid-template-rows: var(--stats-icon-row) var(--stats-value-row) var(--stats-label-row) var(--stats-sublabel-row);
  min-height: 14.75rem;
  padding: 1.15rem 0.95rem;
  align-content: center;
  align-items: center;
  justify-items: center;
  text-align: center;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

body.stats-page .personal-best-card::before {
  height: 5px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-jade), var(--color-reward));
  opacity: 1;
}

body.stats-page .personal-best-card:hover,
body.stats-page .session-stat-card:hover,
body.stats-page .category-mastery-card:hover {
  transform: none;
  border-color: rgba(23, 143, 134, 0.34);
  box-shadow: 0 16px 34px rgba(18, 63, 122, 0.12);
}

body.stats-page .personal-best-icon,
body.stats-page .session-stat-icon {
  grid-row: 1;
  width: 4.85rem;
  height: 4.85rem;
  margin: 0;
  align-self: center;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 0;
  filter: drop-shadow(0 6px 10px rgba(18, 63, 122, 0.14));
  overflow: visible;
}

body.stats-page .personal-best-icon-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

body.stats-page .session-stat-icon::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

body.stats-page .session-stat-icon[data-stats-icon='focus']::before {
  background-image: url('/asset/metric-icons/focus.webp');
}

body.stats-page .session-stat-icon[data-stats-icon='weekly']::before {
  background-image: url('/asset/metric-icons/streak.webp');
}

body.stats-page .session-stat-icon[data-stats-icon='time']::before {
  background-image: url('/asset/metric-icons/due.webp');
}

body.stats-page .session-stat-icon[data-stats-icon='accuracy']::before {
  background-image: url('/asset/achievements/perfect-gold.webp');
}

body.stats-page .personal-best-value,
body.stats-page .session-stat-value,
body.stats-page .activity-stat-value,
body.stats-page .maturity-donut-total,
body.stats-page .maturity-legend-count {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-weight: 950;
  letter-spacing: 0;
}

body.stats-page .personal-best-value,
body.stats-page .session-stat-value {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  line-height: 0.98;
}

body.stats-page .personal-best-value {
  font-size: var(--type-stat-value);
}

body.stats-page .session-stat-value {
  font-size: var(--type-stat-value);
}

body.stats-page .personal-best-label,
body.stats-page .session-stat-label,
body.stats-page .personal-best-sublabel,
body.stats-page .activity-stat-label,
body.stats-page .maturity-donut-label,
body.stats-page .category-mastery-count {
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: none;
}

body.stats-page .personal-best-label,
body.stats-page .session-stat-label {
  grid-row: 3;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  margin-top: 0;
  font-size: var(--type-caption);
}

body.stats-page .personal-best-sublabel {
  grid-row: 4;
  align-self: start;
  margin-top: 0;
  font-size: var(--type-caption);
}

body.stats-page .activity-graph-container,
body.stats-page .analytics-maturity-card {
  border: 1px solid var(--stats-panel-border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 250, 241, 0.94)), var(--color-surface-card);
  box-shadow: var(--stats-card-shadow);
}

body.stats-page .activity-graph-container {
  padding: 1rem;
  scrollbar-color: rgba(18, 63, 122, 0.28) transparent;
}

body.stats-page .activity-graph {
  min-height: 104px;
}

body.stats-page .activity-day-label,
body.stats-page .activity-legend,
body.stats-page .activity-loading,
body.stats-page .activity-error {
  color: var(--color-text-muted);
}

body.stats-page .activity-cell,
body.stats-page .activity-legend-cell {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(18, 63, 122, 0.08);
  border-radius: 3px;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

body.stats-page .activity-cell:hover {
  transform: none;
  border-color: var(--color-brand-dark);
  box-shadow: 0 0 0 2px rgba(18, 63, 122, 0.1);
}

body.stats-page .activity-cell[data-level='0'],
body.stats-page .activity-legend-cell[data-level='0'] {
  background: var(--stats-heat-0);
}

body.stats-page .activity-cell[data-level='1'],
body.stats-page .activity-legend-cell[data-level='1'] {
  background: var(--stats-heat-1);
}

body.stats-page .activity-cell[data-level='2'],
body.stats-page .activity-legend-cell[data-level='2'] {
  background: var(--stats-heat-2);
}

body.stats-page .activity-cell[data-level='3'],
body.stats-page .activity-legend-cell[data-level='3'] {
  background: var(--stats-heat-3);
}

body.stats-page .activity-cell[data-level='4'],
body.stats-page .activity-legend-cell[data-level='4'] {
  background: var(--stats-heat-4);
  border-color: var(--color-brand-dark);
  box-shadow: inset 0 0 0 1px rgba(255, 253, 248, 0.42);
}

body.stats-page .activity-cell-today {
  box-shadow: 0 0 0 2px var(--color-reward-dark);
}

body.stats-page .activity-summary {
  justify-content: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

body.stats-page .activity-stat {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.stats-page .analytics-subtitle {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-body);
  font-weight: 850;
  letter-spacing: 0;
}

body.stats-page .analytics-maturity-card::before {
  height: 5px;
  background: linear-gradient(90deg, var(--color-jade), var(--color-brand));
  opacity: 1;
}

body.stats-page .maturity-donut {
  box-shadow:
    0 12px 24px rgba(18, 63, 122, 0.12),
    inset 0 0 0 4px rgba(255, 253, 248, 0.8);
}

body.stats-page .maturity-donut::after {
  background: var(--color-surface-card);
  box-shadow: inset 0 0 0 1px rgba(18, 63, 122, 0.1);
}

body.stats-page .maturity-legend-dot {
  border-radius: 3px;
}

body.stats-page .accuracy-trend-chart {
  height: 128px;
  padding: 0.75rem 0.45rem 0;
  border: 1px solid var(--stats-panel-border);
  border-radius: 8px;
  background: linear-gradient(rgba(18, 63, 122, 0.06) 1px, transparent 1px), var(--color-surface-card);
  background-size: 100% 25%;
}

body.stats-page .accuracy-bar {
  min-width: 5px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--color-jade), var(--color-brand));
  transition: opacity 0.12s ease;
}

body.stats-page .accuracy-bar[data-reviewed='0'] {
  background: var(--stats-heat-0);
  border: 1px solid rgba(18, 63, 122, 0.12);
}

body.stats-page .accuracy-bar-tooltip {
  background: var(--color-brand-dark);
  border-radius: 6px;
  font-family: var(--font-main);
}

body.stats-page .category-mastery-list {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
}

body.stats-page .category-loading,
body.stats-page .category-empty,
body.stats-page .category-error {
  border: 1px dashed rgba(18, 63, 122, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--color-text-muted);
}

body.stats-page .category-mastery-card {
  gap: 0.9rem;
  padding: 1rem 0.85rem;
  border: 1px solid var(--stats-panel-border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.94)), var(--color-surface-card);
  box-shadow: var(--stats-card-shadow);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

body.stats-page .category-mastery-circle {
  width: 78px;
  height: 78px;
  background: conic-gradient(var(--color-jade) 0 var(--progress), rgba(18, 63, 122, 0.12) var(--progress) 100%);
}

body.stats-page .category-mastery-circle::after {
  width: 62px;
  height: 62px;
  background: var(--color-surface-card);
}

body.stats-page .category-mastery-circle-label {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-caption);
  font-weight: 900;
}

body.stats-page .category-mastery-star-icon {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  margin-top: 0.1rem;
  background: url('/asset/metric-icons/stars.webp') center / contain no-repeat;
  opacity: 1;
  filter: drop-shadow(0 2px 4px rgba(18, 63, 122, 0.12));
}

body.stats-page .category-mastery-name {
  color: var(--color-text-strong);
  font-family: var(--font-main);
  font-size: var(--type-caption);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.25;
  text-transform: none;
}

body.stats-page .boss-lore-card {
  grid-template-columns: 104px minmax(0, 1fr);
  border: 1px solid var(--stats-panel-border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.94)), var(--color-surface-card);
  box-shadow: var(--stats-card-shadow);
}

body.stats-page .boss-lore-media {
  width: 104px;
  height: 104px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.stats-page .boss-lore-name {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-body-lg);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
}

body.stats-page .boss-lore-quest {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand-dark);
  letter-spacing: 0;
}

body.stats-page .boss-lore-text-paragraph {
  color: var(--color-text-muted);
}

body.stats-page .settings-grid {
  width: min(100%, 980px);
  gap: 0.85rem;
}

body.stats-page .settings-group,
body.stats-page .session-settings {
  padding: 1rem;
  border: 1px solid var(--stats-panel-border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.94)), var(--color-surface-card);
  box-shadow: var(--stats-card-shadow);
}

body.stats-page .settings-group-title,
body.stats-page .session-settings-title {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-body);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: none;
}

body.stats-page .settings-description,
body.stats-page .settings-helper,
body.stats-page .session-settings-label {
  color: var(--color-text-muted);
  font-family: var(--font-main);
  letter-spacing: 0;
}

body.stats-page .session-settings-row,
body.stats-page .settings-row {
  border-color: rgba(18, 63, 122, 0.09);
}

body.stats-page .settings-row.settings-row-action {
  display: flex;
  margin-top: auto;
  padding: 0.85rem 0 0;
  border-top: 1px solid rgba(18, 63, 122, 0.09);
  border-bottom: 0;
}

body.stats-page .settings-row-action .settings-action-btn,
body.stats-page .settings-row-action .settings-action-link {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1rem;
  justify-content: center;
  text-align: center;
  white-space: normal;
}

body.stats-page .learning-mode-settings-row {
  justify-content: center;
}

body.stats-page .learning-mode-settings-row .learning-mode-segment {
  width: 100%;
}

body.stats-page .learning-mode-settings-row .learning-mode-button {
  flex: 1;
}

body.stats-page .session-duration-options button,
body.stats-page .break-duration-options button,
body.stats-page .settings-action-link,
body.stats-page .settings-action-btn {
  border-radius: 999px;
  font-family: var(--font-main);
  font-weight: 800;
  letter-spacing: 0;
}

@media (max-width: 640px) {
  body.stats-page {
    --stats-icon-row: 4.7rem;
    --stats-value-row: 3rem;
    --stats-label-row: 2.35rem;
    --stats-sublabel-row: 1.2rem;
  }

  body.stats-page .stats-content {
    padding: 0 0.75rem;
  }

  body.stats-page .stats-hero {
    margin-top: 0.75rem;
    padding: 1rem;
  }

  body.stats-page .stats-hero h2 {
    font-size: var(--type-title-md);
  }

  body.stats-page .personal-bests-grid,
  body.stats-page .session-stats-grid,
  body.stats-page .achievements-summary-grid,
  body.stats-page .category-mastery-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.stats-page .personal-best-card,
  body.stats-page .session-stat-card {
    min-height: 13.7rem;
    padding: 0.85rem 0.7rem;
  }

  body.stats-page .personal-best-icon,
  body.stats-page .session-stat-icon {
    width: 4.25rem;
    height: 4.25rem;
  }

  body.stats-page .personal-best-value {
    font-size: var(--type-title-sm);
  }

  body.stats-page .session-stat-value {
    font-size: var(--type-title-sm);
  }

  body.stats-page .personal-best-label,
  body.stats-page .session-stat-label {
    font-size: var(--type-xs);
  }

  body.stats-page .activity-graph-container {
    padding: 0.8rem;
  }

  body.stats-page .activity-summary {
    gap: 0.55rem;
  }

  body.stats-page .activity-stat {
    width: 100%;
    justify-content: space-between;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  body.stats-page .maturity-legend {
    flex-direction: column;
    gap: 0.65rem;
    width: min(100%, 18rem);
  }

  body.stats-page .category-mastery-circle {
    width: 70px;
    height: 70px;
  }

  body.stats-page .category-mastery-circle::after {
    width: 56px;
    height: 56px;
  }

  body.stats-page .boss-lore-card {
    grid-template-columns: 1fr;
  }

  body.stats-page .boss-lore-media {
    width: 100%;
    height: auto;
    max-height: 260px;
    aspect-ratio: 4 / 3;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body.stats-page .boss-lore-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
  }
}

@media (max-width: 360px) {
  body.stats-page .personal-bests-grid,
  body.stats-page .session-stats-grid,
  body.stats-page .achievements-summary-grid,
  body.stats-page .category-mastery-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.stats-page .personal-best-card,
  body.stats-page .session-stat-card,
  body.stats-page .category-mastery-card,
  body.stats-page .activity-cell,
  body.stats-page .accuracy-bar {
    transition: none;
  }
}

/* ThaiQuest 2.0 achievements and medal cabinet */
body.achievements-page,
.achievements-modal,
.achievement-unlock-card {
  --achievement-bronze: #a85f2a;
  --achievement-silver: #667789;
  --achievement-gold: #b7791f;
  --achievement-gold-soft: #fff0c4;
  --achievement-locked: #d9cfbf;
  --achievement-card-shadow: 0 12px 28px rgba(28, 36, 48, 0.1);
}

body.achievements-page .achievements-content {
  max-width: 1180px;
  padding: 0 clamp(0.9rem, 3vw, 2rem);
}

body.achievements-page .achievements-hero {
  max-width: none;
  margin: 1.2rem auto 1.4rem;
  padding: 1.35rem 1.5rem;
  text-align: left;
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 253, 248, 0.96), rgba(255, 250, 241, 0.9)),
    linear-gradient(rgba(183, 121, 31, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.04) 1px, transparent 1px), var(--color-surface-card);
  background-size:
    auto,
    42px 42px,
    42px 42px,
    auto;
  box-shadow: 0 18px 42px rgba(18, 63, 122, 0.1);
}

body.achievements-page .achievements-hero h2 {
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-lg);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.05;
  text-shadow: none;
  text-transform: none;
}

body.achievements-page .achievements-lead {
  max-width: 44rem;
  margin: 0.45rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--type-body);
  font-weight: 650;
  line-height: 1.45;
  opacity: 1;
}

body.achievements-page .achievements-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 2rem;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

body.achievements-page .summary-stat {
  min-height: 104px;
  padding: 1rem 6.5rem 1rem 1rem;
  box-sizing: border-box;
  text-align: left;
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.94)), var(--color-surface-card);
  box-shadow: var(--achievement-card-shadow);
  position: relative;
  overflow: hidden;
}

body.achievements-page .summary-stat-icon {
  position: absolute;
  right: 0.35rem;
  bottom: 0.2rem;
  z-index: 0;
  width: 5.65rem;
  height: 5.65rem;
  object-fit: contain;
  opacity: 1;
  pointer-events: none;
  filter: drop-shadow(0 12px 18px rgba(18, 63, 122, 0.16));
}

body.achievements-page .summary-stat-icon-total {
  right: 0.15rem;
  bottom: -0.1rem;
  width: 6.25rem;
  height: 6.25rem;
}

body.achievements-page .summary-stat::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-jade), var(--color-reward));
}

body.achievements-page .summary-bronze::before {
  background: var(--achievement-bronze);
}

body.achievements-page .summary-silver::before {
  background: var(--achievement-silver);
}

body.achievements-page .summary-gold::before {
  background: var(--achievement-gold);
}

body.achievements-page .summary-stat-value,
body.achievements-page .summary-stat.summary-bronze .summary-stat-value,
body.achievements-page .summary-stat.summary-silver .summary-stat-value,
body.achievements-page .summary-stat.summary-gold .summary-stat-value {
  position: relative;
  z-index: 1;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-stat-value);
  font-weight: 950;
  letter-spacing: 0;
}

body.achievements-page .summary-stat-label {
  position: relative;
  z-index: 1;
  color: var(--color-text-muted);
  font-size: var(--type-caption);
  font-weight: 750;
}

body.achievements-page .achievements-section {
  padding-top: 1.25rem;
  border-top: 1px solid rgba(18, 63, 122, 0.1);
}

body.achievements-page .achievements-section-title {
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  font-weight: 900;
}

body.achievements-page .achievements-page-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.95rem;
}

body.achievements-page .achievement-page-card,
.achievements-modal .achievement-card {
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.94)), var(--color-surface-card);
  box-shadow: var(--achievement-card-shadow);
  overflow: hidden;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

body.achievements-page .achievement-page-card {
  padding: 1rem;
}

.achievements-modal .achievement-card {
  padding: 0.95rem;
}

body.achievements-page .achievement-page-card::before,
.achievements-modal .achievement-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-jade), var(--color-reward));
}

body.achievements-page .achievement-page-card:hover,
.achievements-modal .achievement-card:hover {
  transform: none;
  border-color: rgba(23, 143, 134, 0.34);
  box-shadow: 0 18px 38px rgba(18, 63, 122, 0.14);
}

body.achievements-page .achievement-page-card.locked,
.achievements-modal .achievement-card.locked {
  opacity: 1;
  filter: none;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.72), rgba(238, 228, 213, 0.68)), var(--color-surface-muted);
}

body.achievements-page .achievement-page-card.locked::before,
.achievements-modal .achievement-card.locked::before {
  background: var(--achievement-locked);
}

body.achievements-page .achievement-page-card.tier-bronze::before,
.achievements-modal .achievement-card.tier-bronze::before {
  background: var(--achievement-bronze);
}

body.achievements-page .achievement-page-card.tier-silver::before,
.achievements-modal .achievement-card.tier-silver::before {
  background: var(--achievement-silver);
}

body.achievements-page .achievement-page-card.tier-gold::before,
.achievements-modal .achievement-card.tier-gold::before {
  background: var(--achievement-gold);
}

body.achievements-page .achievement-page-card.tier-gold,
.achievements-modal .achievement-card.tier-gold {
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.98), rgba(255, 253, 248, 0.95)), var(--color-surface-card);
}

body.achievements-page .achievement-page-image-container,
.achievements-modal .achievement-image-container,
.achievement-unlock-image-container {
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.92), rgba(255, 240, 196, 0.72) 70%),
    var(--achievement-gold-soft);
  box-shadow:
    inset 0 0 0 6px rgba(255, 253, 248, 0.76),
    0 10px 20px rgba(183, 121, 31, 0.14);
}

body.achievements-page .achievement-page-image-container {
  width: 132px;
  height: 132px;
}

.achievements-modal .achievement-image-container {
  width: 76px;
  height: 76px;
}

body.achievements-page .achievement-page-image,
.achievements-modal .achievement-image,
.achievement-unlock-image {
  width: 86%;
  height: 86%;
  object-fit: contain;
}

body.achievements-page .achievement-page-card.locked .achievement-page-image,
.achievements-modal .achievement-card.locked .achievement-image {
  opacity: 0.62;
  filter: grayscale(0.35) saturate(0.75);
}

body.achievements-page .achievement-page-title,
.achievements-modal .achievement-name,
.achievement-unlock-name {
  color: var(--color-text-strong);
  font-family: var(--font-main);
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: none;
}

body.achievements-page .achievement-page-description,
.achievements-modal .achievement-description,
body.achievements-page .achievement-page-progress-text,
.achievements-modal .progress-text {
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-weight: 600;
}

body.achievements-page .achievement-page-tier-badges,
.achievements-modal .tier-badges {
  align-items: center;
  gap: 0.4rem;
}

body.achievements-page .achievement-page-tier-badge,
.achievements-modal .tier-badge,
.achievement-unlock-tier {
  border: 1px solid rgba(18, 63, 122, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  color: var(--color-brand-dark);
}

body.achievements-page .achievement-page-tier-badge.bronze,
.achievements-modal .tier-badge.bronze,
.achievement-unlock-tier.bronze {
  background: linear-gradient(135deg, #8c4b22, var(--achievement-bronze));
  color: #fffdf8;
}

body.achievements-page .achievement-page-tier-badge.silver,
.achievements-modal .tier-badge.silver,
.achievement-unlock-tier.silver {
  background: linear-gradient(135deg, #526274, var(--achievement-silver));
  color: #fffdf8;
}

body.achievements-page .achievement-page-tier-badge.gold,
.achievements-modal .tier-badge.gold,
.achievement-unlock-tier.gold {
  background: linear-gradient(135deg, #fff6d7, var(--achievement-gold));
  color: var(--color-text-strong);
}

body.achievements-page .achievement-page-tier-badge.locked,
.achievements-modal .tier-badge.locked {
  background: #ece3d5;
  color: #7a705f;
  opacity: 1;
}

body.achievements-page .achievement-page-tier-badge.unlocked {
  width: clamp(34px, 3vw, 42px);
  height: clamp(34px, 3vw, 42px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: transparent;
  flex: 0 0 auto;
  font-size: 0;
}

body.achievements-page .achievement-page-tier-badge.bronze.unlocked {
  background: url('/asset/achievements/achievement-check-bronze.webp') center / contain no-repeat;
}

body.achievements-page .achievement-page-tier-badge.silver.unlocked {
  background: url('/asset/achievements/achievement-check-silver.webp') center / contain no-repeat;
}

body.achievements-page .achievement-page-tier-badge.gold.unlocked {
  background: url('/asset/achievements/achievement-check-gold.webp') center / contain no-repeat;
}

body.achievements-page .achievement-page-progress-bar,
.achievements-modal .progress-bar {
  height: 8px;
  border: 1px solid rgba(18, 63, 122, 0.1);
  border-radius: 999px;
  background: #efe4d3;
}

body.achievements-page .achievement-page-progress-fill,
.achievements-modal .progress-fill {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-jade), var(--color-reward));
}

.achievements-modal-overlay {
  background: rgba(9, 42, 86, 0.42);
}

.achievements-modal {
  max-width: min(760px, 94vw);
  border: 1px solid rgba(18, 63, 122, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.96)), var(--color-surface-card);
  box-shadow: 0 28px 60px rgba(9, 42, 86, 0.24);
}

.achievements-modal .achievements-header {
  border-bottom: 1px solid rgba(18, 63, 122, 0.12);
  background:
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px), rgba(255, 250, 241, 0.92);
  background-size:
    36px 36px,
    36px 36px,
    auto;
}

.achievements-modal .achievements-title {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-weight: 950;
  letter-spacing: 0;
}

.achievements-modal .achievements-close-btn {
  border: 1px solid var(--color-brand-border-soft);
  background: var(--color-brand-soft-wash);
  color: var(--color-brand-dark);
}

.achievements-modal .achievements-content {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 1rem;
  overflow-y: auto;
}

.achievements-modal .achievements-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.achievement-unlock-overlay {
  background: rgba(9, 42, 86, 0.48);
}

.achievement-unlock-card {
  display: grid;
  justify-items: center;
  align-items: center;
  max-width: min(390px, 92vw);
  padding: 1.4rem 1.4rem 1.65rem;
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.96)), var(--color-surface-card);
  box-shadow: 0 26px 58px rgba(9, 42, 86, 0.28);
}

.achievement-unlock-heading,
.achievement-unlock-name,
.achievement-unlock-tier {
  text-align: center;
}

.achievement-unlock-heading {
  margin-bottom: 0.85rem;
  color: var(--color-reward-deep);
  font-family: var(--font-main);
  font-size: var(--type-caption);
  font-weight: 950;
  letter-spacing: 0.08em;
  text-shadow: none;
}

.achievement-unlock-image-container {
  width: 210px;
  height: 210px;
  margin: 0 auto 0.9rem;
  display: grid;
  place-items: center;
}

.achievement-unlock-name,
.achievement-unlock-name.tier-bronze,
.achievement-unlock-name.tier-silver,
.achievement-unlock-name.tier-gold {
  margin-bottom: 0.7rem;
  color: var(--color-brand-dark);
  font-size: var(--type-body-lg);
  text-shadow: none;
}

.achievement-unlock-tier {
  display: block;
  width: clamp(8.5rem, 36vw, 10.75rem);
  aspect-ratio: 3 / 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: none;
  color: transparent;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
}

.achievement-unlock-tier.bronze {
  background: url('/asset/achievements/tier-pill-bronze.png') center / contain no-repeat;
}

.achievement-unlock-tier.silver {
  background: url('/asset/achievements/tier-pill-silver.png') center / contain no-repeat;
}

.achievement-unlock-tier.gold {
  background: url('/asset/achievements/tier-pill-gold.png') center / contain no-repeat;
}

.achievement-unlock-overlay .timer {
  height: 5px;
  border-top: 0;
  background: rgba(18, 63, 122, 0.12);
}

.achievement-unlock-overlay .timer-fill {
  background: linear-gradient(90deg, var(--color-jade), var(--color-reward));
}

@media (max-width: 640px) {
  body.achievements-page .achievements-content {
    padding: 0 0.75rem;
  }

  body.achievements-page .achievements-hero {
    margin-top: 0.75rem;
    padding: 1rem;
  }

  body.achievements-page .achievements-hero h2 {
    font-size: var(--type-title-md);
  }

  body.achievements-page .achievements-summary,
  body.achievements-page .achievements-page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.achievements-page .summary-stat {
    min-height: 96px;
    padding: 0.85rem 4.65rem 0.85rem 0.7rem;
  }

  body.achievements-page .summary-stat-icon {
    right: 0.25rem;
    width: 4rem;
    height: 4rem;
  }

  body.achievements-page .summary-stat-icon-total {
    width: 4.65rem;
    height: 4.65rem;
  }

  body.achievements-page .summary-stat-value {
    font-size: var(--type-title-sm);
  }

  body.achievements-page .achievement-page-card {
    padding: 0.78rem;
  }

  body.achievements-page .achievement-page-image-container {
    width: 104px;
    height: 104px;
  }

  body.achievements-page .achievement-page-title {
    font-size: var(--type-caption);
  }

  body.achievements-page .achievement-page-description {
    font-size: var(--type-xs);
  }

  .achievements-modal {
    max-height: 88vh;
  }

  .achievements-modal .achievements-content {
    padding: 0.75rem;
  }

  .achievements-modal .achievements-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .achievements-modal .achievement-card {
    padding: 0.75rem;
  }

  .achievement-unlock-image-container {
    width: 190px;
    height: 190px;
  }
}

@media (max-width: 360px) {
  body.achievements-page .achievements-summary,
  body.achievements-page .achievements-page-grid,
  .achievements-modal .achievements-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.achievements-page .achievement-page-card,
  body.achievements-page .achievement-page-tier-badge,
  body.achievements-page .achievement-page-progress-fill,
  .achievements-modal-overlay,
  .achievements-modal-overlay--closing,
  .achievements-modal,
  .achievements-modal-overlay--closing .achievements-modal,
  .achievements-modal .achievement-card,
  .achievements-modal .tier-badge,
  .achievements-modal .progress-fill,
  .achievement-unlock-overlay,
  .achievement-unlock-card,
  .achievement-unlock-image-container,
  .achievement-unlock-overlay .timer-fill {
    animation: none;
    transition: none;
  }
}

/* ThaiQuest 2.0 secondary screens and support flows */
body.pricing-page,
body.highscores-page,
body.legal {
  background:
    radial-gradient(circle at 14% 10%, rgba(242, 184, 75, 0.16), transparent 24rem),
    radial-gradient(circle at 88% 18%, rgba(23, 143, 134, 0.13), transparent 22rem),
    linear-gradient(rgba(18, 63, 122, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.032) 1px, transparent 1px),
    linear-gradient(180deg, var(--color-bg) 0%, var(--color-surface) 62%, #f6ead6 100%);
  background-size:
    auto,
    auto,
    44px 44px,
    44px 44px,
    auto;
}

body,
body.pricing-page,
body.stats-page,
body.highscores-page,
body.achievements-page,
body.legal,
body.quiz-page {
  background:
    radial-gradient(circle at 14% 10%, rgba(242, 184, 75, 0.13), transparent 24rem),
    radial-gradient(circle at 88% 18%, rgba(23, 143, 134, 0.1), transparent 22rem),
    url('/asset/site-backgrounds/thaiquest-site-background.webp'),
    linear-gradient(180deg, var(--color-bg) 0%, var(--color-surface) 62%, #f6ead6 100%);
  background-position:
    14% 10%,
    88% 18%,
    center top,
    center;
  background-repeat: no-repeat, no-repeat, repeat, no-repeat;
  background-size:
    auto,
    auto,
    clamp(560px, 54vw, 980px) auto,
    auto;
}

body.pricing-page::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(135deg, rgba(18, 63, 122, 0.05) 0 1px, transparent 1px 52px),
    radial-gradient(circle at 50% 0%, rgba(255, 253, 248, 0.8), transparent 32rem);
  opacity: 0.7;
  transform: none;
  width: auto;
  height: auto;
  border-radius: 0;
  filter: none;
}

body.pricing-page .pricing-content,
body.highscores-page .highscores-content {
  max-width: 1040px;
  padding-inline: clamp(1rem, 4vw, 1.6rem);
}

body.pricing-page .pricing-hero,
body.highscores-page .highscores-hero {
  max-width: none;
  margin: 1.2rem auto 2rem;
  padding: 1.35rem 1.5rem;
  text-align: left;
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 253, 248, 0.94), rgba(255, 250, 241, 0.9)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px), var(--color-surface-card);
  background-size:
    auto,
    42px 42px,
    42px 42px,
    auto;
  box-shadow: 0 18px 42px rgba(18, 63, 122, 0.1);
}

body.pricing-page .pricing-hero h2,
body.highscores-page .highscores-hero h2 {
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-lg);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.05;
  text-transform: none;
  text-shadow: none;
}

body.pricing-page .pricing-lead,
body.highscores-page .highscores-lead {
  max-width: 620px;
  margin: 0.45rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--type-body);
  font-weight: 650;
  line-height: 1.45;
  opacity: 1;
}

body.pricing-page .pricing-feedback,
body.highscores-page .leaderboard-loading,
body.highscores-page .leaderboard-empty {
  border: 1px solid rgba(18, 63, 122, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--color-text-muted);
}

body.pricing-page .pricing-plans {
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

body.pricing-page .pricing-card {
  gap: 1rem;
  padding: 1.35rem;
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-bottom: 4px solid rgba(18, 63, 122, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.94)), var(--color-surface-card);
  box-shadow: 0 16px 34px rgba(18, 63, 122, 0.11);
  overflow: hidden;
}

body.pricing-page .pricing-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--color-brand), var(--color-jade), var(--color-reward));
}

body.pricing-page .pricing-card[data-plan='yearly'] {
  border-color: rgba(183, 121, 31, 0.38);
  border-bottom-color: var(--color-reward-dark);
  box-shadow: 0 18px 36px rgba(183, 121, 31, 0.16);
}

body.pricing-page .pricing-card[data-plan='yearly']::after {
  content: 'Best value';
  position: absolute;
  top: 0.85rem;
  right: 0.9rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-radius: var(--radius-pill);
  background: var(--color-reward-wash);
  color: var(--color-reward-deep);
  font-size: var(--type-xs);
  font-weight: 900;
}

body.pricing-page .pricing-card h3,
body.pricing-page .pricing-feature-card h3,
body.pricing-page .pricing-restore h3,
body.pricing-page .pricing-manage h3 {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-weight: 900;
  letter-spacing: 0;
}

body.pricing-page .pricing-card h3 {
  padding-right: 0;
}

body.pricing-page .pricing-card[data-plan='yearly'] h3 {
  padding-right: 5.5rem;
}

body.pricing-page .pricing-amount {
  color: var(--color-text-strong);
  font-size: var(--type-title-md);
  font-weight: 950;
  letter-spacing: 0;
}

body.pricing-page .pricing-frequency,
body.pricing-page .pricing-plan-disclosure,
body.pricing-page .pricing-feature-card p,
body.pricing-page .pricing-restore p,
body.pricing-page .pricing-manage p {
  color: var(--color-text-muted);
  opacity: 1;
}

body.pricing-page .pricing-save {
  color: var(--color-reward-deep);
}

body.pricing-page .pricing-current {
  border: 1px solid rgba(183, 121, 31, 0.28);
  background: var(--color-reward-wash);
  color: var(--color-reward-deep);
}

body.pricing-page .pricing-benefits {
  color: var(--color-text);
  font-weight: 620;
}

body.pricing-page .pricing-benefits li::before {
  color: var(--color-jade-dark);
}

body.pricing-page .pricing-card .btn-accent,
body.pricing-page .pricing-restore .btn-accent,
body.pricing-page .pricing-manage .btn-accent {
  width: 100%;
  min-height: 46px;
  font-size: var(--type-action);
  font-weight: 900;
  line-height: 1;
}

body.pricing-page .pricing-feature-card,
body.pricing-page .pricing-restore,
body.pricing-page .pricing-manage {
  border: 1px solid rgba(18, 63, 122, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
  box-shadow: none;
}

body.pricing-page .pricing-features {
  gap: 0.85rem;
  margin-bottom: 1rem;
}

body.highscores-page .highscores-content {
  max-width: 960px;
}

body.highscores-page .user-rank-section:empty,
body.highscores-page .leaderboard-meta-container:empty {
  display: none;
}

body.highscores-page .user-rank-card {
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 246, 216, 0.92), rgba(255, 253, 248, 0.9) 62%), var(--color-reward-wash);
  box-shadow: 0 18px 38px rgba(183, 121, 31, 0.13);
}

body.highscores-page .user-rank-header,
body.highscores-page .leaderboard-header {
  color: var(--color-brand-muted);
  font-family: var(--font-main);
  font-weight: 850;
  letter-spacing: 0.08em;
}

body.highscores-page .user-rank-position {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-display);
  font-weight: 950;
  letter-spacing: 0;
}

body.highscores-page .user-rank-stats,
body.highscores-page .nearby-row {
  color: var(--color-text-muted);
}

body.highscores-page .nearby-row.is-you {
  background: rgba(23, 143, 134, 0.1);
  color: var(--color-jade-dark);
}

body.highscores-page .leaderboard-tabs-row {
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

body.highscores-page .leaderboard-tabs-container {
  flex: 0 1 auto;
  min-width: 0;
}

body.highscores-page .leaderboard-tabs {
  justify-content: flex-start;
  gap: 0.45rem;
}

body.highscores-page .leaderboard-tab {
  border: 1px solid rgba(18, 63, 122, 0.16);
  border-bottom-width: 3px;
  border-radius: var(--radius-pill);
  background: rgba(255, 253, 248, 0.78);
  color: var(--color-brand-dark);
  font-size: var(--type-action-sm);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
}

body.highscores-page .leaderboard-tab:hover,
body.highscores-page .leaderboard-tab:focus-visible {
  border-color: rgba(23, 143, 134, 0.35);
  color: var(--color-jade-dark);
}

body.highscores-page .leaderboard-tab.active {
  border-color: var(--color-brand-dark);
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark));
  color: #fffdf8;
}

body.highscores-page .leaderboard-card {
  border: 1px solid rgba(18, 63, 122, 0.15);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.95)), var(--color-surface-card);
  box-shadow: 0 18px 38px rgba(18, 63, 122, 0.12);
}

body.highscores-page .leaderboard-row {
  border-bottom-color: rgba(18, 63, 122, 0.09);
}

body.highscores-page .leaderboard-header {
  background: rgba(18, 63, 122, 0.06);
}

body.highscores-page .leaderboard-row.rank-gold {
  background: linear-gradient(90deg, rgba(242, 184, 75, 0.2), rgba(255, 253, 248, 0));
}

body.highscores-page .leaderboard-row.rank-gold .lb-rank {
  color: var(--color-reward-deep);
}

body.highscores-page .leaderboard-row.rank-silver {
  background: linear-gradient(90deg, rgba(82, 98, 116, 0.12), rgba(255, 253, 248, 0));
}

body.highscores-page .leaderboard-row.rank-bronze {
  background: linear-gradient(90deg, rgba(191, 116, 55, 0.14), rgba(255, 253, 248, 0));
}

body.highscores-page .leaderboard-row.current-user {
  border-left: 4px solid var(--color-jade);
  background: rgba(23, 143, 134, 0.1);
}

body.highscores-page .lb-level,
body.highscores-page .lb-quests {
  color: var(--color-jade-dark);
}

body.highscores-page .leaderboard-meta-container {
  border-top-color: rgba(18, 63, 122, 0.1);
  background: rgba(255, 248, 237, 0.64);
}

body.highscores-page .leaderboard-meta {
  color: var(--color-text-muted);
  font-weight: 650;
}

body.legal main {
  max-width: 860px;
  margin: clamp(1.2rem, 2vw, 1.75rem) auto 2rem;
  padding: 1.4rem 1.6rem 1.8rem;
  border-top: 5px solid var(--color-jade);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  box-shadow: 0 18px 42px rgba(18, 63, 122, 0.1);
}

body.legal h1 {
  margin: 0 0 0.45rem;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-md);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.15;
}

body.legal h2 {
  margin: 1.55rem 0 0.45rem;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  font-weight: 900;
}

body.legal h3 {
  color: var(--color-jade-dark);
  font-size: var(--type-body);
  font-weight: 850;
}

body.legal p,
body.legal li {
  color: var(--color-text);
  font-size: var(--type-body);
  line-height: 1.65;
}

body.legal main > p:first-of-type {
  color: var(--color-text-muted);
  font-weight: 750;
}

body.legal a {
  color: var(--color-brand-dark);
  font-weight: 750;
  text-decoration-color: rgba(18, 63, 122, 0.28);
  text-underline-offset: 0.18em;
}

body.legal ul {
  padding-left: 1.15rem;
}

.review-mode-container {
  max-width: 680px;
}

.review-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(23, 143, 134, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(241, 251, 249, 0.96), rgba(255, 253, 248, 0.95)), var(--color-jade-wash-soft);
  box-shadow: 0 10px 22px rgba(14, 98, 92, 0.1);
}

.review-title {
  color: var(--color-brand-dark);
  font-weight: 950;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--type-body-lg);
  line-height: 1.1;
}

.review-back-btn,
.review-shuffle-btn.active {
  border-color: var(--color-brand-dark);
  border-bottom: 3px solid var(--color-brand-dark-deep);
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark));
  color: #fffdf8;
  box-shadow: 0 10px 20px rgba(18, 63, 122, 0.2);
}

.review-settings-btn,
.review-filter-chip,
.review-shuffle-btn,
.review-settings-stepper-btn,
.review-settings-select {
  border-color: rgba(23, 143, 134, 0.24);
  background: rgba(255, 253, 248, 0.82);
  color: var(--color-jade-dark);
}

.review-filter-chip.active {
  border-color: var(--color-jade-dark);
  background: linear-gradient(180deg, var(--color-jade), var(--color-jade-dark));
  box-shadow: 0 10px 20px rgba(14, 98, 92, 0.16);
}

.review-settings-panel {
  border-color: rgba(23, 143, 134, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
}

.review-progress::after {
  background: linear-gradient(90deg, var(--color-jade), var(--color-reward));
}

.review-card-face {
  border: 1px solid rgba(23, 143, 134, 0.18);
  border-radius: 8px;
  box-shadow: 0 18px 38px rgba(14, 98, 92, 0.12);
}

.review-card-front,
.review-card-back {
  background: var(--study-card-background), var(--color-surface-card);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-origin: border-box;
  background-clip: border-box;
}

.review-card-sheen {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 8px;
  pointer-events: none;
  opacity: var(--study-sheen-opacity);
  background:
    radial-gradient(
      circle at var(--study-pointer-x) var(--study-pointer-y),
      rgba(255, 255, 255, 0.62) 0%,
      rgba(255, 247, 185, 0.22) 18%,
      rgba(118, 216, 224, 0.14) 33%,
      transparent 58%
    ),
    linear-gradient(
      115deg,
      transparent 16%,
      rgba(255, 255, 255, 0.2) 32%,
      rgba(255, 230, 118, 0.24) 42%,
      rgba(88, 205, 192, 0.18) 52%,
      transparent 70%
    );
  mix-blend-mode: screen;
  filter: saturate(1.15);
  transition: opacity 180ms ease-out;
}

.review-card-thai,
.review-card-translation,
.review-card-meaning,
.review-card-phonetic,
.review-card-meaning-ref,
.review-card-thai-ref {
  color: var(--color-brand-dark);
}

.review-card-phonetic-hint {
  color: var(--color-text-muted);
}

.review-buttons {
  padding-inline: 0;
}

.review-btn {
  min-height: 56px;
  flex-direction: row;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border-width: 1px;
  border-bottom-width: 3px;
  background: rgba(255, 253, 248, 0.9);
  color: var(--color-brand-dark);
  box-shadow: 0 10px 20px rgba(14, 98, 92, 0.08);
}

.review-btn-again {
  border-color: rgba(201, 47, 69, 0.24);
  border-bottom-color: rgba(201, 47, 69, 0.58);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.92));
  color: #8b1f2c;
}

.review-btn-good {
  border-color: var(--color-jade-dark);
  border-bottom-color: var(--color-jade-dark);
  background: linear-gradient(180deg, var(--color-jade), var(--color-jade-dark));
  color: #fffdf8;
  box-shadow: 0 12px 24px rgba(14, 98, 92, 0.16);
}

.review-btn-key {
  min-width: 1.7em;
  padding: 0.18em 0.45em;
  border-radius: 6px;
  background: rgba(18, 63, 122, 0.08);
  color: currentColor;
}

.review-btn-good .review-btn-key {
  background: rgba(255, 253, 248, 0.18);
}

.review-btn-again .review-btn-key {
  background: rgba(201, 47, 69, 0.08);
}

.review-summary {
  border: 1px solid rgba(23, 143, 134, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: 0 18px 38px rgba(14, 98, 92, 0.12);
}

.review-summary-heading {
  color: var(--color-brand-dark);
  font-size: var(--type-title-md);
}

.review-stat-item,
.review-srs-summary,
.review-srs-stat {
  border: 1px solid rgba(23, 143, 134, 0.14);
  border-radius: 8px;
  background: rgba(237, 249, 247, 0.72);
}

.review-action-exit {
  border-color: rgba(18, 63, 122, 0.2);
  background: rgba(255, 253, 248, 0.86);
  color: var(--color-brand-dark);
}

.auth-scrim,
.onboarding-overlay,
.session-complete-overlay,
.break-reminder-overlay,
.achievement-unlock-overlay,
.achievements-modal-overlay {
  background: rgba(9, 42, 86, 0.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.auth-scrim {
  background:
    radial-gradient(circle at 18% 16%, rgba(242, 184, 75, 0.18), transparent 18rem),
    radial-gradient(circle at 84% 10%, rgba(23, 143, 134, 0.16), transparent 20rem), rgba(9, 42, 86, 0.58);
}

.auth-dialog,
.auth-box,
.onboarding-content,
.session-complete-card,
.break-reminder-card,
.settings-group,
.session-settings,
.star-celebration-card,
.flashcard-lock-overlay,
.achievements-modal,
.achievement-unlock-card {
  border: 1px solid rgba(18, 63, 122, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.95)), var(--color-surface-card);
  box-shadow: 0 24px 54px rgba(9, 42, 86, 0.22);
}

.auth-dialog {
  isolation: isolate;
  --overlay-top-accent: linear-gradient(
    90deg,
    var(--color-reward-dark) 0,
    var(--color-brand) 52%,
    var(--color-jade) 100%
  );
  --overlay-top-accent-height: 5px;
  overflow: auto;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-top-color: transparent;
  border-bottom: 4px solid rgba(183, 121, 31, 0.48);
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height) no-repeat,
    radial-gradient(circle at 18% 0%, rgba(242, 184, 75, 0.13), transparent 15rem),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.96)),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height),
    auto,
    auto,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box;
  box-shadow: 0 28px 62px rgba(9, 42, 86, 0.3);
}

.auth-dialog::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 5px) + 1px);
  border-radius: inherit;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  background: var(--overlay-top-accent);
  pointer-events: none;
  z-index: 0;
}

.auth-dialog > :not(.auth-close) {
  position: relative;
  z-index: 1;
}

.auth-close {
  position: absolute;
  z-index: 2;
}

.auth-box {
  max-width: none;
  margin: 1.15rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.level-up-overlay,
.streak-milestone-overlay,
.daily-goal-overlay,
.star-celebration-overlay,
.quiz-completed-overlay,
.boss-result-overlay {
  padding: clamp(1rem, 4vw, 2.5rem);
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 18% 16%, rgba(242, 184, 75, 0.18), transparent 18rem),
    radial-gradient(circle at 84% 10%, rgba(23, 143, 134, 0.16), transparent 20rem), rgba(9, 42, 86, 0.58);
  box-sizing: border-box;
}

.level-up-card,
.streak-milestone-card,
.daily-goal-card,
.star-celebration-card,
.quiz-completed-card,
.boss-result-card {
  isolation: isolate;
  --overlay-top-accent: linear-gradient(
    90deg,
    var(--color-reward-dark) 0,
    var(--color-brand) 52%,
    var(--color-jade) 100%
  );
  --overlay-top-accent-height: 5px;
  --overlay-visual-size: clamp(5.8rem, 22vw, 8.8rem);
  --overlay-visual-opacity: 0.1;
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(0.45rem, 1.4vw, 0.72rem);
  width: min(420px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-width: min(420px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-height: calc(100svh - clamp(2rem, 8vw, 5rem));
  margin: auto;
  padding: clamp(1rem, 3vw, 1.35rem);
  box-sizing: border-box;
  overflow: auto;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-top-color: transparent;
  border-bottom: 4px solid rgba(183, 121, 31, 0.48);
  border-radius: 10px;
  background:
    linear-gradient(90deg, var(--color-reward-dark) 0, var(--color-brand) 52%, var(--color-jade) 100%) top / 100% 5px
      no-repeat,
    radial-gradient(circle at 18% 0%, rgba(242, 184, 75, 0.13), transparent 15rem),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.96)),
    var(--color-surface-card);
  background-size:
    100% 5px,
    auto,
    auto,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box;
  box-shadow: 0 24px 58px rgba(9, 42, 86, 0.28);
  color: var(--color-text);
  text-align: center;
  transform: none;
  animation: none;
}

.level-up-card {
  --overlay-visual: url('/asset/metric-icons/xp.webp');
}

.level-up-overlay {
  --overlay-particle-visual: url('/asset/metric-icons/xp.webp');
}

.streak-milestone-card {
  --overlay-visual: url('/asset/metric-icons/streak.webp');
}

.streak-milestone-overlay {
  --overlay-particle-visual: url('/asset/metric-icons/streak.webp');
}

.daily-goal-card {
  --overlay-visual: url('/asset/metric-icons/goal-celebration.webp');
}

.daily-goal-overlay {
  --overlay-particle-visual: url('/asset/metric-icons/goal-celebration.webp');
}

.star-celebration-card {
  --overlay-visual: url('/asset/metric-icons/star-rating.webp');
}

.star-celebration-overlay {
  --overlay-particle-visual: url('/asset/metric-icons/star-rating.webp');
}

.onboarding-activation-recap-overlay {
  --overlay-particle-visual: url('/asset/achievements/first-steps-gold.webp');
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 18% 16%, rgba(242, 184, 75, 0.18), transparent 18rem),
    radial-gradient(circle at 84% 10%, rgba(23, 143, 134, 0.16), transparent 20rem), rgba(9, 42, 86, 0.58);
  box-sizing: border-box;
}

.onboarding-activation-recap-card {
  isolation: isolate;
  --overlay-top-accent: linear-gradient(
    90deg,
    var(--color-reward-dark) 0,
    var(--color-brand) 52%,
    var(--color-jade) 100%
  );
  --overlay-top-accent-height: 5px;
  --overlay-visual: url('/asset/achievements/first-steps-gold.webp');
  --overlay-visual-size: clamp(5.8rem, 22vw, 8.8rem);
  --overlay-visual-opacity: 0.08;
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(0.55rem, 1.6vw, 0.8rem);
  width: min(420px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-width: min(420px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-height: calc(100svh - clamp(2rem, 8vw, 5rem));
  margin: auto;
  padding: clamp(1rem, 3vw, 1.35rem);
  box-sizing: border-box;
  overflow: auto;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-top-color: transparent;
  border-bottom: 4px solid rgba(183, 121, 31, 0.48);
  border-radius: 10px;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height) no-repeat,
    radial-gradient(circle at 18% 0%, rgba(242, 184, 75, 0.13), transparent 15rem),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.96)),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height),
    auto,
    auto,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box;
  box-shadow: 0 24px 58px rgba(9, 42, 86, 0.28);
  color: var(--color-text);
  text-align: center;
}

.onboarding-activation-recap-card::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  pointer-events: none;
  z-index: 2;
}

.onboarding-activation-recap-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--overlay-visual);
  background-repeat: no-repeat;
  background-position: center;
  background-size: var(--overlay-visual-size);
  filter: saturate(0.92) contrast(0.96);
  opacity: var(--overlay-visual-opacity);
  pointer-events: none;
  z-index: 0;
}

.onboarding-activation-recap-card > * {
  position: relative;
  z-index: 1;
}

.onboarding-activation-recap-art {
  width: clamp(4.5rem, 16vw, 5.8rem);
  height: clamp(4.5rem, 16vw, 5.8rem);
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(9, 42, 86, 0.16));
}

.onboarding-activation-recap-title {
  justify-self: center;
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.2;
  text-shadow: none;
  text-transform: none;
}

.onboarding-activation-recap-progress {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 26rem);
  min-height: 2.7rem;
  padding: 0.55rem 0.72rem;
  border: 1px solid rgba(183, 121, 31, 0.24);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-body);
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  line-height: 1.2;
}

.onboarding-activation-recap-copy {
  max-width: 26rem;
  margin: 0;
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-size: var(--type-sm);
  font-weight: 700;
  line-height: 1.38;
}

.onboarding-activation-recap-actions {
  display: grid;
  gap: 0.65rem;
  width: 100%;
  margin-top: 0.15rem;
}

.onboarding-activation-next-step,
.onboarding-activation-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 0.78rem 1rem;
  box-sizing: border-box;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
}

.onboarding-activation-next-step {
  border-color: var(--color-brand-dark) !important;
  border-bottom: 4px solid var(--color-brand-dark-deep) !important;
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark)) !important;
  color: #fffdf8 !important;
  box-shadow: 0 14px 26px rgba(18, 63, 122, 0.22) !important;
}

.onboarding-activation-retry {
  border-color: rgba(18, 63, 122, 0.18) !important;
  border-bottom: 4px solid rgba(18, 63, 122, 0.3) !important;
  background: rgba(255, 253, 248, 0.78) !important;
  color: var(--color-brand-dark) !important;
  box-shadow: 0 10px 18px rgba(18, 63, 122, 0.08) !important;
}

.onboarding-activation-next-step:hover,
.onboarding-activation-next-step:focus-visible,
.onboarding-activation-retry:hover,
.onboarding-activation-retry:focus-visible {
  transform: none;
}

.quiz-completed-card {
  --overlay-visual: url('/asset/achievements/quest-master-gold.webp');
}

.quiz-completed-overlay {
  --overlay-particle-visual: url('/asset/achievements/quest-master-gold.webp');
}

.boss-result-card {
  --overlay-visual: url('/asset/bosses/boss-placeholder.webp');
  --overlay-visual-opacity: 0.08;
}

.boss-result-overlay {
  --overlay-particle-visual: url('/asset/bosses/boss-placeholder.webp');
}

body.quiz-page .level-up-overlay,
body.quiz-page .streak-milestone-overlay,
body.quiz-page .daily-goal-overlay,
body.quiz-page .star-celebration-overlay,
body.quiz-page .quiz-completed-overlay,
body.quiz-page .boss-result-overlay {
  padding: clamp(1rem, 4vw, 2.5rem);
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 18% 16%, rgba(242, 184, 75, 0.18), transparent 18rem),
    radial-gradient(circle at 84% 10%, rgba(23, 143, 134, 0.16), transparent 20rem), rgba(9, 42, 86, 0.58);
  box-sizing: border-box;
}

body.quiz-page .level-up-card,
body.quiz-page .streak-milestone-card,
body.quiz-page .daily-goal-card,
body.quiz-page .star-celebration-card,
body.quiz-page .quiz-completed-card,
body.quiz-page .boss-result-card {
  isolation: isolate;
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(0.45rem, 1.4vw, 0.72rem);
  width: min(420px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-width: min(420px, calc(100vw - clamp(1.5rem, 6vw, 4rem)));
  max-height: calc(100svh - clamp(2rem, 8vw, 5rem));
  margin: auto;
  padding: clamp(1rem, 3vw, 1.35rem);
  box-sizing: border-box;
  overflow: auto;
  border: 1px solid rgba(183, 121, 31, 0.3);
  border-top-color: transparent;
  border-bottom: 4px solid rgba(183, 121, 31, 0.48);
  border-radius: 10px;
  background:
    linear-gradient(90deg, var(--color-reward-dark) 0, var(--color-brand) 52%, var(--color-jade) 100%) top / 100% 5px
      no-repeat,
    radial-gradient(circle at 18% 0%, rgba(242, 184, 75, 0.13), transparent 15rem),
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(252, 241, 219, 0.96)),
    var(--color-surface-card);
  background-size:
    100% 5px,
    auto,
    auto,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box;
  box-shadow: 0 24px 58px rgba(9, 42, 86, 0.28);
  color: var(--color-text);
  text-align: center;
  transform: none;
  animation: none;
}

.level-up-card::before,
.streak-milestone-card::before,
.daily-goal-card::before,
.star-celebration-card::before,
.quiz-completed-card::before,
.boss-result-card::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}

body.quiz-page .level-up-card::before,
body.quiz-page .streak-milestone-card::before,
body.quiz-page .daily-goal-card::before,
body.quiz-page .star-celebration-card::before,
body.quiz-page .quiz-completed-card::before,
body.quiz-page .boss-result-card::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}

.level-up-card::after,
.streak-milestone-card::after,
.daily-goal-card::after,
.star-celebration-card::after,
.quiz-completed-card::after,
.boss-result-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--overlay-visual);
  background-repeat: no-repeat;
  background-position: center;
  background-size: var(--overlay-visual-size);
  filter: saturate(0.92) contrast(0.96);
  opacity: var(--overlay-visual-opacity);
  pointer-events: none;
  z-index: 0;
}

.level-up-card > *,
.streak-milestone-card > *,
.daily-goal-card > *,
.star-celebration-card > *,
.quiz-completed-card > *,
.boss-result-card > * {
  position: relative;
  z-index: 1;
}

.level-up-heading,
.streak-milestone-heading,
.daily-goal-heading,
.star-celebration-card .celebrate-heading,
.quiz-completed-card .completed-heading {
  justify-self: center;
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-body);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.2;
  text-shadow: none;
  text-transform: none;
}

body.quiz-page .level-up-heading,
body.quiz-page .streak-milestone-heading,
body.quiz-page .daily-goal-heading,
body.quiz-page .star-celebration-card .celebrate-heading,
body.quiz-page .quiz-completed-card .completed-heading {
  letter-spacing: 0;
  text-transform: none;
}

.level-up-number,
.streak-milestone-days,
.daily-goal-number {
  margin: -0.1rem 0 0;
  background: none;
  color: var(--color-text-strong);
  font-family: var(--font-main);
  font-size: var(--type-overlay-result);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.95;
  text-shadow: none;
  -webkit-text-fill-color: currentColor;
}

.streak-milestone-card,
.daily-goal-card {
  grid-template-columns: 1fr;
  grid-template-areas: none;
}

.streak-milestone-heading,
.daily-goal-heading {
  grid-area: auto;
}

.streak-milestone-icon,
.daily-goal-icon {
  display: none;
}

.streak-milestone-days,
.daily-goal-number {
  grid-area: auto;
}

.streak-milestone-label,
.daily-goal-label {
  grid-area: auto;
  margin: -0.2rem 0 0;
  color: var(--color-brand-dark-muted);
  font-family: var(--font-main);
  font-size: var(--type-sm);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
}

.streak-milestone-message,
.daily-goal-message {
  display: none;
}

.star-celebration-card .celebrate-stars,
.quiz-completed-card .completed-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  margin: 0;
  color: var(--color-reward-deep);
  text-shadow: none;
}

body.quiz-page .star-celebration-card .celebrate-stars,
body.quiz-page .quiz-completed-card .completed-stars {
  gap: 0.32rem;
  margin: 0;
}

.star-celebration-card .celebrate-star-icon,
.quiz-completed-card .completed-star-icon {
  display: inline-block;
  width: clamp(2.15rem, 7vw, 2.8rem);
  height: clamp(2.15rem, 7vw, 2.8rem);
  background-image: url('/asset/metric-icons/star-rating.webp');
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 7px 12px rgba(183, 121, 31, 0.16));
}

body.quiz-page .star-celebration-card .celebrate-star-icon,
body.quiz-page .quiz-completed-card .completed-star-icon {
  width: clamp(2.15rem, 7vw, 2.8rem);
  height: clamp(2.15rem, 7vw, 2.8rem);
}

.star-celebration-card .celebrate-star-icon[data-star-state='empty'],
.quiz-completed-card .completed-star-icon[data-star-state='empty'] {
  background-image: url('/asset/metric-icons/star-rating-empty.webp');
  filter: drop-shadow(0 5px 9px rgba(18, 63, 122, 0.12));
}

.star-celebration-card .celebrate-message,
.star-celebration-card .celebrate-retry,
.star-celebration-card .celebrate-meta,
.quiz-completed-card .completed-stats {
  max-width: 26rem;
  margin: 0;
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-size: var(--type-sm);
  font-weight: 700;
  line-height: 1.38;
  opacity: 1;
}

body.quiz-page .star-celebration-card .celebrate-message,
body.quiz-page .star-celebration-card .celebrate-retry,
body.quiz-page .star-celebration-card .celebrate-meta,
body.quiz-page .quiz-completed-card .completed-stats {
  margin: 0;
  font-size: var(--type-sm);
  font-weight: 700;
}

.star-celebration-card .celebrate-message--no-stars {
  color: var(--color-text-muted);
}

.star-celebration-card .celebrate-meta {
  font-size: var(--type-xs);
  font-weight: 750;
}

.star-celebration-card .celebrate-close,
.star-celebration-card .celebrate-review-mistakes,
.quiz-completed-card .completed-btn,
.quiz-completed-card .completed-leaderboard-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 0.78rem 1rem;
  box-sizing: border-box;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
}

body.quiz-page .star-celebration-card .celebrate-close,
body.quiz-page .star-celebration-card .celebrate-review-mistakes,
body.quiz-page .quiz-completed-card .completed-btn,
body.quiz-page .quiz-completed-card .completed-leaderboard-link {
  min-height: 52px;
  height: auto;
  border-radius: 10px;
  padding: 0.78rem 1rem;
  font-family: var(--font-main);
  font-size: var(--type-action);
  letter-spacing: 0;
  text-transform: none;
}

.star-celebration-card .celebrate-close,
.quiz-completed-card .completed-btn-restart {
  border-color: var(--color-brand-dark) !important;
  border-bottom: 4px solid var(--color-brand-dark-deep) !important;
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark)) !important;
  color: #fffdf8 !important;
  box-shadow: 0 14px 26px rgba(18, 63, 122, 0.22) !important;
}

body.quiz-page .star-celebration-card .celebrate-close,
body.quiz-page .quiz-completed-card .completed-btn-restart {
  border-color: var(--color-brand-dark) !important;
  border-bottom: 4px solid var(--color-brand-dark-deep) !important;
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark)) !important;
  color: #fffdf8 !important;
  box-shadow: 0 14px 26px rgba(18, 63, 122, 0.22) !important;
}

.star-celebration-card .celebrate-review-mistakes,
.quiz-completed-card .completed-btn-practice,
.quiz-completed-card .completed-leaderboard-link {
  border-color: rgba(18, 63, 122, 0.18) !important;
  border-bottom: 4px solid rgba(18, 63, 122, 0.3) !important;
  background: rgba(255, 253, 248, 0.78) !important;
  color: var(--color-brand-dark) !important;
  box-shadow: 0 10px 18px rgba(18, 63, 122, 0.08) !important;
}

body.quiz-page .star-celebration-card .celebrate-review-mistakes,
body.quiz-page .quiz-completed-card .completed-btn-practice,
body.quiz-page .quiz-completed-card .completed-leaderboard-link {
  border-color: rgba(18, 63, 122, 0.18) !important;
  border-bottom: 4px solid rgba(18, 63, 122, 0.3) !important;
  background: rgba(255, 253, 248, 0.78) !important;
  color: var(--color-brand-dark) !important;
  box-shadow: 0 10px 18px rgba(18, 63, 122, 0.08) !important;
}

.star-celebration-card .celebrate-review-mistakes:hover,
.star-celebration-card .celebrate-close:hover,
.quiz-completed-card .completed-btn:hover,
.quiz-completed-card .completed-leaderboard-link:hover {
  transform: none;
}

.quiz-completed-card .completed-buttons {
  display: grid;
  gap: 0.65rem;
  width: 100%;
  margin-top: 0.25rem;
}

body.quiz-page .quiz-completed-card .completed-buttons {
  gap: 0.65rem;
  margin-top: 0.25rem;
}

.quiz-completed-card .completed-leaderboard-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 1.25rem;
}

.star-celebration-overlay ~ .star-streak-wrap {
  display: none;
}

.boss-result-body {
  max-width: 26rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-main);
  font-size: var(--type-body);
  font-weight: 700;
  line-height: 1.42;
  opacity: 1;
}

.boss-rush-countdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 26rem);
  margin: -0.1rem 0 0;
  padding: 0.55rem 0.72rem;
  border: 1px solid rgba(183, 121, 31, 0.24);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-sm);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1.2;
}

.level-up-overlay > .timer,
.streak-milestone-overlay > .timer,
.daily-goal-overlay > .timer {
  position: absolute;
  left: clamp(1.25rem, 7vw, 4.5rem);
  right: clamp(1.25rem, 7vw, 4.5rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 0.85rem);
  height: 3px;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 253, 248, 0.38);
  pointer-events: none;
  z-index: 1;
}

.level-up-overlay > .timer .timer-fill,
.streak-milestone-overlay > .timer .timer-fill,
.daily-goal-overlay > .timer .timer-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-jade), var(--color-reward));
  transform: translateX(0%);
  animation: timerDrain var(--overlay-duration, 5000ms) linear forwards;
}

.level-up-overlay .confetti-wrap,
.streak-milestone-overlay .confetti-wrap,
.daily-goal-overlay .confetti-wrap,
.star-celebration-overlay .confetti-wrap,
.quiz-completed-overlay .confetti-wrap,
.boss-result-overlay .confetti-wrap {
  display: none;
}

.onboarding-activation-recap-overlay .confetti-wrap {
  display: none;
}

.boss-result-card {
  gap: clamp(0.7rem, 1.8vw, 0.95rem);
}

.boss-result-title {
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.12;
  text-shadow: none;
  text-transform: none;
}

body.quiz-page .boss-result-title {
  font-size: var(--type-title-sm);
  letter-spacing: 0;
  line-height: 1.12;
}

.boss-result-actions {
  display: grid;
  gap: 0.65rem;
  width: 100%;
  margin-top: 0.25rem;
}

body.quiz-page .boss-result-body {
  max-width: 26rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 700;
}

body.quiz-page .boss-result-actions {
  display: grid;
  gap: 0.65rem;
  width: 100%;
  margin-top: 0.25rem;
}

.boss-result-card .btn-accent {
  min-height: 52px;
  padding: 0.78rem 1rem;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
}

.boss-result-card .btn-accent:not(.boss-result-back) {
  border-color: var(--color-brand-dark) !important;
  border-bottom: 4px solid var(--color-brand-dark-deep) !important;
  background: linear-gradient(180deg, var(--color-brand), var(--color-brand-dark)) !important;
  color: #fffdf8 !important;
  box-shadow: 0 14px 26px rgba(18, 63, 122, 0.22) !important;
}

.boss-result-back {
  border-color: rgba(18, 63, 122, 0.18) !important;
  border-bottom: 4px solid rgba(18, 63, 122, 0.3) !important;
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.78) !important;
  color: var(--color-brand-dark) !important;
  box-shadow: 0 10px 18px rgba(18, 63, 122, 0.08) !important;
}

.onboarding-button,
.auth-actions .chip,
.session-complete-actions button,
.break-reminder-actions button,
.boss-lore-card-overlay .btn-accent,
.star-celebration-card .celebrate-close,
.star-celebration-card .celebrate-review-mistakes,
.quiz-completed-card .completed-btn,
.quiz-completed-card .completed-leaderboard-link,
.boss-result-card .btn-accent,
.boss-result-back {
  border-radius: 10px;
}

body.quiz-page .boss-lore-card-overlay .btn-accent,
body.quiz-page .star-celebration-card .celebrate-close,
body.quiz-page .star-celebration-card .celebrate-review-mistakes,
body.quiz-page .quiz-completed-card .completed-btn,
body.quiz-page .quiz-completed-card .completed-leaderboard-link,
body.quiz-page .boss-result-card .btn-accent,
body.quiz-page .boss-result-back {
  border-radius: 10px;
}

@media (max-width: 520px) {
  .level-up-overlay,
  .streak-milestone-overlay,
  .daily-goal-overlay,
  .star-celebration-overlay,
  .quiz-completed-overlay,
  .boss-result-overlay,
  .example-overlay {
    right: auto !important;
    left: 0 !important;
    width: 100vw;
    width: 100dvw;
    max-width: 100dvw;
  }
  .level-up-overlay > .timer,
  .streak-milestone-overlay > .timer,
  .daily-goal-overlay > .timer {
    left: clamp(1rem, 6vw, 1.5rem);
    right: clamp(1rem, 6vw, 1.5rem);
  }
  body.quiz-page .example-overlay .overlay-card {
    width: 100%;
    max-width: 100%;
  }
  .onboarding-activation-recap-overlay {
    right: auto !important;
    left: 0 !important;
    width: 100vw;
    width: 100dvw;
    max-width: 100dvw;
  }
}

.auth-box {
  max-width: 360px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.onboarding-content {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade), var(--color-brand), var(--color-reward-dark));
  --overlay-top-accent-height: 6px;
  width: min(680px, calc(100vw - 2rem));
  max-height: min(720px, calc(100vh - 2rem));
  position: relative;
  display: grid;
  gap: 1.15rem;
  padding: 1.45rem;
  border: 1px solid rgba(18, 63, 122, 0.16);
  border-top-color: transparent;
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: var(--radius-card);
  overflow: auto;
  text-align: left;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height, 6px) no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 248, 237, 0.96)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height, 6px),
    auto,
    36px 36px,
    36px 36px,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box, padding-box;
  overflow-x: hidden;
}

.onboarding-content::before {
  content: '';
  position: absolute;
  inset: -1px -1px auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}

.onboarding-header {
  display: grid;
  grid-template-columns: minmax(150px, 0.52fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(1rem, 3vw, 1.4rem);
}

.onboarding-art-stack {
  position: relative;
  min-height: clamp(132px, 24vw, 176px);
  overflow: hidden;
  border: 1px solid rgba(23, 143, 134, 0.2);
  border-bottom: 4px solid rgba(183, 121, 31, 0.38);
  border-radius: 14px;
  background:
    radial-gradient(circle at 76% 20%, rgba(242, 184, 75, 0.3), transparent 4.8rem),
    radial-gradient(circle at 18% 82%, rgba(23, 143, 134, 0.22), transparent 5.5rem),
    linear-gradient(145deg, rgba(237, 249, 247, 0.96), rgba(255, 248, 237, 0.96));
}

.onboarding-art-stack::before {
  content: '';
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1.35rem;
  height: 2px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, rgba(23, 143, 134, 0), rgba(23, 143, 134, 0.44), rgba(183, 121, 31, 0));
}

.onboarding-art,
.onboarding-boss-art,
.onboarding-lantern-art {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
}

.onboarding-art {
  left: clamp(0.7rem, 3vw, 1.05rem);
  bottom: clamp(0.8rem, 3vw, 1.1rem);
  width: clamp(78px, 14vw, 108px);
  height: clamp(78px, 14vw, 108px);
  filter: drop-shadow(0 8px 12px rgba(18, 63, 122, 0.16));
}

.onboarding-boss-art {
  right: clamp(0.25rem, 2vw, 0.7rem);
  bottom: clamp(0.1rem, 1vw, 0.35rem);
  width: clamp(112px, 20vw, 152px);
  height: clamp(112px, 20vw, 152px);
  filter: drop-shadow(0 12px 18px rgba(9, 42, 86, 0.18));
}

.onboarding-lantern-art {
  top: 0.55rem;
  right: clamp(0.7rem, 3vw, 1.15rem);
  width: clamp(38px, 8vw, 58px);
  height: clamp(38px, 8vw, 58px);
  opacity: 0.9;
  filter: drop-shadow(0 8px 10px rgba(183, 121, 31, 0.18));
}

.onboarding-title {
  width: 100%;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.2;
  text-align: left;
  text-transform: none;
  text-shadow: none;
}

.onboarding-steps {
  display: grid;
  gap: 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.onboarding-step {
  display: grid;
  grid-template-columns: 2.5rem 2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-height: 3.4rem;
  padding: 0.62rem 0;
  border-top: 1px solid rgba(18, 63, 122, 0.08);
  color: var(--color-text);
  font-family: var(--font-main);
  font-size: var(--type-body);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: none;
  text-shadow: none;
}

.onboarding-step:first-child {
  border-top: 0;
}

.onboarding-step-icon {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  filter: drop-shadow(0 6px 9px rgba(18, 63, 122, 0.12));
}

.onboarding-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(183, 121, 31, 0.34);
  border-bottom: 3px solid rgba(183, 121, 31, 0.45);
  border-radius: 8px;
  background: var(--color-reward-wash);
  color: var(--color-reward-deep);
  font-size: var(--type-caption);
  font-weight: 950;
  line-height: 1;
}

.onboarding-step-text {
  min-width: 0;
}

.onboarding-button {
  align-self: stretch;
  min-height: 54px;
  margin-top: 0.25rem;
  padding: 0.8rem 1rem;
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
  text-shadow: none;
  animation: none;
}

.onboarding-button:hover,
.onboarding-button:focus-visible {
  transform: translateY(-1px);
  text-shadow: none;
}

.home-onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: radial-gradient(circle at 50% 0%, rgba(255, 196, 77, 0.18), transparent 32rem), rgba(9, 42, 86, 0.74);
  backdrop-filter: blur(12px);
}

.home-onboarding-panel {
  --overlay-top-accent: linear-gradient(90deg, var(--color-jade), var(--color-brand), var(--color-reward-dark));
  --overlay-top-accent-height: 6px;
  position: relative;
  box-sizing: border-box;
  width: min(880px, calc(100vw - 2rem));
  max-height: min(820px, calc(100vh - 2rem));
  display: grid;
  gap: clamp(1rem, 2.4vw, 1.35rem);
  padding: clamp(1.05rem, 3vw, 1.45rem);
  overflow: auto;
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-top-color: transparent;
  border-bottom: 4px solid var(--color-reward-dark);
  border-radius: 16px;
  background:
    var(--overlay-top-accent) top / 100% var(--overlay-top-accent-height, 6px) no-repeat,
    linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(255, 248, 237, 0.97)),
    linear-gradient(rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 63, 122, 0.045) 1px, transparent 1px),
    var(--color-surface-card);
  background-size:
    100% var(--overlay-top-accent-height, 6px),
    auto,
    36px 36px,
    36px 36px,
    auto;
  background-origin: border-box, padding-box, padding-box, padding-box, padding-box;
  background-clip: border-box, padding-box, padding-box, padding-box, padding-box;
  box-shadow: 0 24px 68px rgba(4, 21, 48, 0.32);
}

.home-onboarding-panel::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: calc(var(--overlay-top-accent-height, 6px) + 1px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--overlay-top-accent);
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}

.home-onboarding-scroll-shield {
  display: none;
}

.home-onboarding-header {
  display: grid;
  grid-template-columns: minmax(240px, 0.86fr) minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(1rem, 3vw, 1.45rem);
}

.home-onboarding-visual {
  position: relative;
  min-height: clamp(190px, 29vw, 270px);
  overflow: hidden;
  border: 1px solid rgba(23, 143, 134, 0.2);
  border-bottom: 4px solid rgba(183, 121, 31, 0.4);
  border-radius: 14px;
  background:
    radial-gradient(circle at 74% 16%, rgba(242, 184, 75, 0.3), transparent 5.8rem),
    radial-gradient(circle at 12% 82%, rgba(23, 143, 134, 0.22), transparent 7rem),
    linear-gradient(145deg, rgba(237, 249, 247, 0.98), rgba(255, 248, 237, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 253, 248, 0.72);
}

.home-onboarding-visual::before {
  content: '';
  position: absolute;
  left: clamp(1rem, 4vw, 1.5rem);
  right: clamp(1rem, 4vw, 1.5rem);
  bottom: clamp(1.4rem, 4vw, 2rem);
  height: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, rgba(23, 143, 134, 0), rgba(23, 143, 134, 0.5), rgba(183, 121, 31, 0));
}

.home-onboarding-art {
  width: 112px;
  height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(18, 63, 122, 0.18));
}

.home-onboarding-boss,
.home-onboarding-guide,
.home-onboarding-lantern,
.home-onboarding-quest-mark {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
}

.home-onboarding-boss {
  right: clamp(0.25rem, 2vw, 0.75rem);
  bottom: clamp(0.05rem, 1vw, 0.3rem);
  width: clamp(160px, 25vw, 240px);
  height: clamp(160px, 25vw, 240px);
  filter: drop-shadow(0 16px 22px rgba(9, 42, 86, 0.22));
}

.home-onboarding-guide {
  left: clamp(0.75rem, 3vw, 1.2rem);
  bottom: clamp(0.7rem, 2vw, 1rem);
  width: clamp(78px, 12vw, 116px);
  height: clamp(78px, 12vw, 116px);
  filter: drop-shadow(0 12px 16px rgba(18, 63, 122, 0.18));
}

.home-onboarding-lantern {
  top: clamp(0.65rem, 2vw, 1rem);
  right: clamp(1rem, 4vw, 1.5rem);
  width: clamp(42px, 7vw, 66px);
  height: clamp(42px, 7vw, 66px);
  opacity: 0.92;
  filter: drop-shadow(0 10px 12px rgba(183, 121, 31, 0.18));
}

.home-onboarding-quest-mark {
  top: clamp(0.75rem, 3vw, 1.25rem);
  left: clamp(0.85rem, 3vw, 1.25rem);
  width: clamp(58px, 9vw, 82px);
  height: clamp(58px, 9vw, 82px);
  filter: drop-shadow(0 9px 12px rgba(18, 63, 122, 0.15));
}

.home-onboarding-title-group {
  min-width: 0;
  align-self: center;
}

.home-onboarding-title {
  margin: 0;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-title-sm);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.12;
}

.home-onboarding-summary {
  margin: 0.45rem 0 0;
  color: var(--color-text);
  font-size: var(--type-body);
  font-weight: 650;
  line-height: 1.45;
}

.home-onboarding-route {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.home-onboarding-route-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: center;
  gap: 0.24rem;
  padding: 0.55rem 0;
  border-top: 1px solid rgba(18, 63, 122, 0.1);
  text-align: center;
}

.home-onboarding-route-icon {
  width: clamp(3.8rem, 8vw, 5.15rem);
  height: clamp(3.8rem, 8vw, 5.15rem);
  object-fit: contain;
  filter: drop-shadow(0 10px 13px rgba(18, 63, 122, 0.16));
}

.home-onboarding-route-label {
  min-width: 0;
  overflow: visible;
  color: var(--color-brand-dark);
  font-size: var(--type-xs);
  font-weight: 900;
  line-height: 1.12;
  text-overflow: clip;
  white-space: normal;
}

.home-onboarding-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-onboarding-step {
  display: grid;
  grid-template-columns: clamp(6.35rem, 10vw, 7.6rem) minmax(0, 1fr);
  gap: clamp(0.8rem, 2vw, 1.1rem);
  align-items: center;
  min-height: 7.25rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid rgba(18, 63, 122, 0.1);
  border-bottom: 3px solid rgba(183, 121, 31, 0.2);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.62);
}

.home-onboarding-step:first-child {
  border-top: 1px solid rgba(18, 63, 122, 0.1);
}

.home-onboarding-step-media {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: clamp(6.35rem, 10vw, 7.6rem);
  height: clamp(6.35rem, 10vw, 7.6rem);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.home-onboarding-step-icon {
  width: clamp(5.25rem, 8.6vw, 6.55rem);
  height: clamp(5.25rem, 8.6vw, 6.55rem);
  object-fit: contain;
  filter: drop-shadow(0 12px 16px rgba(18, 63, 122, 0.17));
}

.home-onboarding-step-index {
  position: absolute;
  right: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid rgba(183, 121, 31, 0.34);
  border-bottom: 2px solid rgba(183, 121, 31, 0.45);
  border-radius: 999px;
  background: var(--color-reward-wash);
  color: var(--color-reward-deep);
  font-size: var(--type-2xs);
  font-weight: 950;
  line-height: 1;
}

.home-onboarding-step-copy {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.home-onboarding-step-title {
  color: var(--color-brand-dark);
  font-size: var(--type-body);
  font-weight: 900;
  line-height: 1.25;
}

.home-onboarding-step-body {
  color: var(--color-text-muted);
  font-size: var(--type-small);
  font-weight: 650;
  line-height: 1.4;
}

.home-onboarding-goal-panel {
  display: grid;
  gap: 0.55rem;
  text-align: center;
}

.home-onboarding-goal-title {
  margin: 0;
  color: var(--color-brand-dark);
  font-size: var(--type-body);
  font-weight: 950;
  line-height: 1.2;
}

.home-onboarding-goal-copy {
  margin: 0;
  color: var(--color-text);
  font-size: var(--type-small);
  font-weight: 650;
  line-height: 1.35;
}

.home-onboarding-goal-options {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-self: center;
  gap: 0.35rem;
  padding: 0.28rem;
  border: 1px solid rgba(18, 63, 122, 0.14);
  border-bottom: 3px solid rgba(183, 121, 31, 0.2);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.84);
}

.home-onboarding-goal-option {
  min-width: 7.25rem;
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease,
    transform 0.12s ease;
}

.home-onboarding-goal-option:hover,
.home-onboarding-goal-option:focus-visible {
  background: var(--color-jade-wash);
  border-color: rgba(23, 143, 134, 0.26);
  box-shadow: 0 8px 18px rgba(18, 63, 122, 0.1);
  transform: translateY(-1px);
}

.home-onboarding-goal-option:active {
  transform: translateY(1px) scale(0.98);
}

.home-onboarding-goal-option.is-selected {
  background: linear-gradient(135deg, var(--color-brand), var(--color-jade-dark));
  border-color: rgba(9, 42, 86, 0.18);
  box-shadow:
    0 10px 22px rgba(9, 42, 86, 0.2),
    inset 0 1px 0 rgba(255, 253, 248, 0.3);
  color: #fffdf8;
}

.home-onboarding-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.home-onboarding-start,
.home-onboarding-dismiss {
  min-height: 52px;
  padding: 0.78rem 1rem;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: var(--type-action);
  font-weight: 900;
  letter-spacing: 0;
}

.home-onboarding-dismiss {
  border: 1px solid rgba(18, 63, 122, 0.18);
  background: rgba(255, 253, 248, 0.88);
  color: var(--color-brand-dark);
}

.home-onboarding-dismiss:hover,
.home-onboarding-dismiss:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(18, 63, 122, 0.32);
  background: var(--color-jade-wash);
}

.session-complete-icon {
  border: 1px solid rgba(23, 143, 134, 0.2);
  background: var(--color-jade-wash);
  color: var(--color-jade-dark);
}

.break-reminder-icon {
  display: block;
  width: clamp(4.2rem, 17vw, 5rem);
  height: clamp(4.2rem, 17vw, 5rem);
  margin: -0.25rem auto 0.4rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(9, 42, 86, 0.16));
}

.session-complete-title,
.break-reminder-title,
.session-settings-title,
.settings-group-title {
  color: var(--color-brand-dark);
  font-family: var(--font-main);
  font-weight: 900;
  letter-spacing: 0;
}

.break-reminder-timer,
.session-stat-value {
  color: var(--color-brand-dark);
}

.session-duration-options button,
.break-duration-options button,
.settings-action-btn,
.settings-action-link {
  border-color: rgba(18, 63, 122, 0.18);
  background: rgba(255, 253, 248, 0.9);
  color: var(--color-brand-dark);
}

.session-duration-options button.active,
.break-duration-options button.active,
.settings-action-btn:hover,
.settings-action-link:hover {
  background: var(--color-brand);
  color: #fffdf8;
}

.settings-time-input,
.auth-field {
  border-color: rgba(18, 63, 122, 0.16);
  background: rgba(255, 253, 248, 0.9);
}

@media (max-width: 700px) {
  body.pricing-page .pricing-content,
  body.highscores-page .highscores-content {
    padding-inline: 0.9rem;
  }

  body.pricing-page .pricing-hero h2,
  body.highscores-page .highscores-hero h2,
  body.legal h1 {
    font-size: var(--type-title-md);
  }

  body.pricing-page .pricing-card[data-plan='yearly']::after {
    position: static;
    align-self: flex-start;
    order: -1;
  }

  body.pricing-page .pricing-card h3 {
    padding-right: 0;
  }

  body.highscores-page .leaderboard-tabs-row {
    align-items: stretch;
    flex-direction: column;
  }

  body.highscores-page .leaderboard-tabs,
  body.highscores-page .leaderboard-tab {
    width: 100%;
  }

  body.highscores-page .leaderboard-tab {
    flex: 1 1 0;
    padding-inline: 0.7rem;
  }

  body.highscores-page .leaderboard-row {
    grid-template-columns: 44px minmax(0, 1fr) 40px 62px;
    padding-inline: 0.75rem;
  }

  body.legal {
    padding-inline: 0.85rem;
  }

  body.legal main {
    margin-top: 0;
    padding: 1rem;
  }

  .review-title-row {
    grid-template-columns: minmax(4.25rem, 1fr) minmax(0, 1fr) minmax(4.25rem, 1fr);
    grid-template-areas: 'back title actions';
    align-items: center;
    justify-items: stretch;
    gap: 0.55rem;
  }

  .review-back-btn {
    grid-area: back;
    width: auto;
    max-width: max-content;
    align-self: center;
    justify-self: start;
  }

  .review-title {
    grid-area: title;
    min-width: 0;
    justify-self: center;
    text-align: center;
  }

  .review-header-actions {
    grid-area: actions;
    justify-self: end;
    justify-content: flex-end;
  }

  .review-buttons {
    padding-inline: 0;
  }

  .review-btn-key {
    display: none;
  }

  .onboarding-content {
    width: min(94vw, 620px);
    padding: 1rem;
  }

  .onboarding-header {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .onboarding-art-stack {
    min-height: 132px;
  }

  .onboarding-title {
    text-align: left;
  }

  .onboarding-step {
    grid-template-columns: 2.35rem 1.85rem minmax(0, 1fr);
    min-height: 3.1rem;
    gap: 0.55rem;
    padding: 0.62rem 0;
  }

  .onboarding-step-icon {
    width: 2.3rem;
    height: 2.3rem;
  }

  .home-onboarding-panel {
    width: min(94vw, 680px);
    padding: 1rem;
    border-radius: 14px;
  }

  .home-onboarding-scroll-shield {
    position: sticky;
    top: -1rem;
    z-index: 5;
    display: block;
    height: 2.7rem;
    margin: -1rem -1rem -2.7rem;
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
    background: linear-gradient(
      180deg,
      rgba(255, 253, 248, 0.99) 0%,
      rgba(255, 253, 248, 0.92) 46%,
      rgba(255, 253, 248, 0) 100%
    );
    pointer-events: none;
  }

  .home-onboarding-header {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .home-onboarding-visual {
    min-height: 168px;
  }

  .home-onboarding-boss {
    width: clamp(138px, 43vw, 184px);
    height: clamp(138px, 43vw, 184px);
  }

  .home-onboarding-guide {
    width: clamp(66px, 20vw, 92px);
    height: clamp(66px, 20vw, 92px);
  }

  .home-onboarding-route {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .home-onboarding-route-item {
    grid-template-columns: 3.5rem minmax(0, 1fr);
    gap: 0.55rem;
    padding: 0.4rem 0;
  }

  .home-onboarding-route-icon {
    width: 3.5rem;
    height: 3.5rem;
  }

  .home-onboarding-steps {
    grid-template-columns: 1fr;
  }

  .home-onboarding-step {
    grid-template-columns: 5.25rem minmax(0, 1fr);
    gap: 0.65rem;
    padding: 0.65rem 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    background: transparent;
  }

  .home-onboarding-step-media {
    width: 5.25rem;
    height: 5.25rem;
  }

  .home-onboarding-step-icon {
    width: 4.6rem;
    height: 4.6rem;
  }

  .home-onboarding-step-index {
    width: 1.3rem;
    height: 1.3rem;
  }

  .home-onboarding-actions {
    grid-template-columns: 1fr;
    position: sticky;
    bottom: -1rem;
    z-index: 3;
    margin-inline: -1rem;
    margin-bottom: -1rem;
    padding: 2rem 1rem 1rem;
    border-top: 1px solid rgba(18, 63, 122, 0.08);
    background: #fffdf8;
    box-shadow: 0 -12px 22px rgba(255, 253, 248, 0.9);
  }

  .home-onboarding-actions::before {
    content: '';
    position: absolute;
    top: 0.42rem;
    left: 50%;
    width: 1.05rem;
    height: 1.05rem;
    border-right: 4px solid rgba(9, 42, 86, 0.86);
    border-bottom: 4px solid rgba(9, 42, 86, 0.86);
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(255, 253, 248, 0.95)) drop-shadow(0 8px 10px rgba(9, 42, 86, 0.2));
    transform: translateX(-50%) rotate(45deg);
    animation: home-onboarding-scroll-cue 1.25s ease-in-out infinite;
  }
}

@keyframes home-onboarding-scroll-cue {
  0%,
  100% {
    opacity: 0.58;
    translate: 0 -2px;
  }

  50% {
    opacity: 1;
    translate: 0 5px;
  }
}

/* Hide the top accent only when a container is backed by artwork. */
body.home .player-card[data-avatar-background='true']::after {
  display: none;
}

body.home .quest-card[data-quest-background]::after,
body.home .quiz-card[data-quiz-background]::after,
body.home .flashcard-section[data-study-background]::after {
  display: none;
}

body.quiz-page .quiz-hero[data-quiz-background]::before {
  display: none;
}
