/* ==========================================================================
   Istoria României — "Liquid Glass" design system
   ========================================================================== */

:root {
  /* Ink */
  --ink: #2a241d;
  --ink-2: #554b40;
  --ink-3: #8a7e6f;
  --ink-4: #b3a796;

  /* Warm golds */
  --gold-50: #fff8e6;
  --gold-100: #fcebc3;
  --gold-200: #f7d68a;
  --gold-300: #eebd57;
  --gold-400: #d99f3a;
  --gold-500: #be8028;
  --gold-600: #95601a;

  /* Romanian tricolor */
  --ro-blue: #1f4fbf;
  --ro-yellow: #fcd116;
  --ro-red: #ce1126;

  /* Glass material */
  --glass-tint-top: rgba(255, 255, 255, 0.66);
  --glass-tint-bottom: rgba(255, 252, 245, 0.36);
  --glass-edge: rgba(255, 255, 255, 0.82);
  --glass-blur: 22px;
  --glass-saturate: 170%;

  /* Depth: several soft, warm-tinted layers rather than one hard shadow */
  --shadow-float:
    0 1px 1px rgba(110, 72, 18, 0.03),
    0 6px 16px -4px rgba(110, 72, 18, 0.07),
    0 18px 48px -12px rgba(110, 72, 18, 0.12),
    0 40px 90px -30px rgba(110, 72, 18, 0.14);
  --shadow-card:
    0 1px 2px rgba(110, 72, 18, 0.05),
    0 10px 28px -12px rgba(110, 72, 18, 0.22);
  --inner-light:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(255, 255, 255, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  --glow-gold:
    0 0 0 1.5px rgba(246, 196, 92, 0.85),
    0 0 18px 2px rgba(250, 190, 80, 0.5),
    0 0 56px 8px rgba(255, 200, 100, 0.32),
    0 22px 44px -18px rgba(170, 110, 20, 0.5);

  --r-xl: 32px;
  --r-lg: 26px;
  --r-md: 20px;
  --r-sm: 14px;

  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-script: "Great Vibes", "Snell Roundhand", cursive;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.5, 1);

  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: #fbf2e3;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
h1, h2, h3, p, figure, blockquote, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 3px; border-radius: 12px; }

.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 16px; height: 16px; stroke-width: 2; }
.icon--xs { width: 13px; height: 13px; stroke-width: 2; }

/* ---------- Ambient background ----------
   Glass needs something to refract: a heavily blurred copy of the hero
   landscape, washed with cream, plus slow-drifting golden light orbs. */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ambient__image {
  position: absolute; inset: -10%;
  background: url("../img/ambient.webp") 60% 40% / cover no-repeat;
  filter: blur(44px) saturate(1.25);
  opacity: 0.6;
}
.ambient::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(55% 45% at 12% 18%, rgba(255, 251, 242, 0.95), transparent 70%),
    radial-gradient(50% 50% at 50% 100%, rgba(255, 248, 235, 0.85), transparent 70%),
    linear-gradient(180deg, rgba(255, 249, 238, 0.35), rgba(255, 246, 230, 0.65));
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(30px); opacity: 0.55;
  background: radial-gradient(circle at 35% 35%, #fff6d8, #f6cd78 45%, rgba(246, 205, 120, 0) 70%);
  animation: drift 26s ease-in-out infinite alternate;
}
.orb--1 { width: 420px; height: 420px; top: -120px; right: 8%; }
.orb--2 { width: 300px; height: 300px; bottom: 6%; left: -80px; animation-duration: 32s; }
.orb--3 { width: 220px; height: 220px; top: 45%; left: 38%; opacity: 0.35; animation-duration: 22s; }
.orb--4 { width: 160px; height: 160px; top: 18%; left: 24%; opacity: 0.4; filter: blur(18px); animation-duration: 30s; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(40px, -30px, 0) scale(1.08); }
  100% { transform: translate3d(-30px, 25px, 0) scale(0.96); }
}

/* ==========================================================================
   The glass material
   ========================================================================== */
.glass {
  position: relative;
  isolation: isolate;
  background: linear-gradient(150deg, var(--glass-tint-top), var(--glass-tint-bottom));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-edge);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-float), var(--inner-light);
}
/* Specular rim: light catches the top-left and bottom-right edges */
.glass::before {
  content: ""; position: absolute; inset: -1px; z-index: 2; pointer-events: none;
  border-radius: inherit; padding: 1.4px;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.25) 28%, rgba(255, 255, 255, 0) 50%,
    rgba(255, 255, 255, 0.2) 72%, rgba(255, 255, 255, 0.85) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
/* Surface sheen: a soft bloom of light across the top of the pane */
.glass::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(120% 80% at 8% -20%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 38%);
}
.glass--pill { border-radius: 999px; }

/* Inner glass (cards inside panels): brighter, thinner, its own sheen */
.chapter-card, .game-card, .badge, .quiz__option, .stat, .settings li {
  position: relative;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.4));
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card), inset 0 1px 0 #fff, inset 0 -8px 20px -14px rgba(196, 150, 80, 0.25);
}

/* Cursor-following specular highlight (JS sets --mx / --my) */
.chapter-card::after, .game-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 3;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, -40%), rgba(255, 255, 255, 0.55), transparent 60%);
  opacity: 0; transition: opacity 0.35s var(--ease);
  mix-blend-mode: soft-light;
}
.chapter-card:hover::after, .game-card:hover::after { opacity: 1; }

/* ==========================================================================
   Layout
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-areas: "side main" "foot foot";
  column-gap: 34px;
  row-gap: 26px;
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px 28px 28px;
}
.sidebar { grid-area: side; }
.main { grid-area: main; min-width: 0; }
.banner { grid-area: foot; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 24px; align-self: start;
  display: flex; flex-direction: column; gap: 26px;
  padding: 30px 14px 16px;
  border-radius: 36px;
}
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 0 6px; }
.brand__logo { width: 88px; height: 88px; margin-bottom: 2px; animation: flutter 6s ease-in-out infinite; transform-origin: 30% 80%; }
@keyframes flutter { 50% { transform: rotate(2deg) translateY(-2px) scale(1.02); } }
.brand__name { font-size: 1.62rem; line-height: 1.05; font-weight: 700; letter-spacing: -0.025em; }
.brand__tagline { font-size: 0.7rem; color: var(--ink-3); letter-spacing: 0.01em; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  padding: 13px 16px; border-radius: 22px;
  color: var(--ink-2); font-weight: 500; font-size: 0.95rem;
  transition: background 0.3s var(--ease), color 0.3s, transform 0.3s var(--spring), box-shadow 0.3s;
}
.nav__item .icon { color: var(--ink-3); transition: color 0.3s, transform 0.4s var(--spring); }
.nav__item:hover { background: rgba(255, 255, 255, 0.45); color: var(--ink); }
.nav__item:hover .icon { transform: scale(1.1) rotate(-4deg); }
.nav__item.is-active {
  color: var(--ink); font-weight: 600;
  background: linear-gradient(100deg, rgba(247, 224, 178, 0.95), rgba(255, 244, 222, 0.75) 60%, rgba(255, 255, 255, 0.5));
  box-shadow: 0 6px 18px -8px rgba(190, 128, 40, 0.45), inset 0 1px 0 #fff, inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}
.nav__item.is-active .icon { color: var(--gold-600); fill: rgba(217, 159, 58, 0.25); }

.sidebar__quote {
  margin-top: 18px;
  padding: 20px 18px 18px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.25));
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 1px 0 #fff, 0 8px 20px -12px rgba(110, 72, 18, 0.2);
}
.sidebar__quote blockquote { font-style: italic; font-size: 0.88rem; line-height: 1.6; color: var(--ink-2); }
.tricolor { display: inline-flex; margin-top: 14px; border-radius: 99px; overflow: hidden; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.tricolor i { width: 12px; height: 6px; }
.tricolor i:nth-child(1) { background: var(--ro-blue); }
.tricolor i:nth-child(2) { background: var(--ro-yellow); }
.tricolor i:nth-child(3) { background: var(--ro-red); }

/* ---------- Top bar ---------- */
.topbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  margin-bottom: 8px;
}
.topbar__brand { display: none; align-items: center; gap: 8px; margin-right: auto; font-weight: 700; letter-spacing: -0.02em; }
.topbar__brand img { width: 40px; height: 40px; }

.search {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: min(340px, 100%); height: 48px; padding: 0 18px 0 14px;
  transition: width 0.45s var(--ease), box-shadow 0.3s;
}
.search:focus-within { width: min(420px, 100%); box-shadow: var(--shadow-float), var(--inner-light), 0 0 0 4px rgba(238, 189, 87, 0.22); }
.search__toggle { display: grid; place-items: center; color: var(--ink-2); }
.search__input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 0.9rem; }
.search__input::placeholder { color: var(--ink-3); }
.search__input::-webkit-search-cancel-button { display: none; }

.icon-btn {
  position: relative; display: grid; place-items: center;
  width: 48px; height: 48px; color: var(--ink-2);
  transition: transform 0.35s var(--spring), color 0.2s;
}
.icon-btn:hover { transform: translateY(-2px) scale(1.04); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn__dot {
  position: absolute; top: 7px; right: 7px; z-index: 3;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
  display: grid; place-items: center;
  font-size: 0.62rem; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, #f2b24a, #cf7f1f);
  box-shadow: 0 2px 6px rgba(207, 127, 31, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.profile-chip {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 6px 18px 6px 7px;
  transition: transform 0.35s var(--spring);
}
.profile-chip:hover { transform: translateY(-2px); }
.profile-chip img { width: 42px; height: 42px; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 4px 12px rgba(110, 72, 18, 0.25); }
.profile-chip__text { display: flex; flex-direction: column; line-height: 1.2; }
.profile-chip__text strong { font-size: 0.86rem; font-weight: 600; }
.profile-chip__text small { font-size: 0.72rem; color: var(--ink-3); }

/* Popovers (search results, notifications) */
.popover {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
  width: 340px; max-width: calc(100vw - 32px);
  padding: 10px; border-radius: 24px;
  --glass-tint-top: rgba(255, 255, 255, 0.86);
  --glass-tint-bottom: rgba(255, 251, 243, 0.72);
  animation: pop 0.35s var(--spring);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(0.97); } }
.popover__title { padding: 6px 10px 8px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.search__results { left: 0; right: auto; width: 100%; min-width: 280px; }
.search__results button, .notif__panel li {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px; border-radius: 16px; text-align: left;
  transition: background 0.2s;
}
.search__results button:hover, .search__results button.is-focus { background: rgba(247, 224, 178, 0.55); }
.res-icon, .notif__icon {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 12px;
  color: var(--gold-600);
  background: linear-gradient(160deg, #fff, var(--gold-100));
  box-shadow: inset 0 1px 0 #fff, 0 3px 8px -2px rgba(190, 128, 40, 0.35);
}
.search__results strong, .notif__panel strong { display: block; font-size: 0.86rem; font-weight: 600; }
.search__results small, .notif__panel small { font-size: 0.74rem; color: var(--ink-3); }
.search__empty { padding: 12px; font-size: 0.85rem; color: var(--ink-3); }
.notif { position: relative; }
.notif__panel li { align-items: flex-start; }
.notif__panel p { font-size: 0.8rem; color: var(--ink-2); }

/* ==========================================================================
   Home — hero
   ========================================================================== */
.view.is-active { animation: viewIn 0.6s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 8px;
  align-items: center;
  margin-bottom: 26px;
}
.hero__copy { position: relative; z-index: 2; padding-top: 4px; }
.hero h1 {
  font-size: clamp(2.1rem, 3.3vw, 3rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.035em;
  max-width: 12em;
  text-wrap: balance;
}
.hero__lead { margin-top: 18px; max-width: 32em; font-size: 1.04rem; line-height: 1.6; color: var(--ink-2); }

.progress-card {
  display: flex; align-items: center; gap: 18px;
  width: min(560px, 100%);
  margin-top: 30px; padding: 22px 26px 24px 20px;
  border-radius: var(--r-lg); text-align: left;
  transition: transform 0.45s var(--spring), box-shadow 0.45s var(--ease);
}
.progress-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-float), var(--inner-light), 0 0 40px -8px rgba(240, 180, 60, 0.45); }
.progress-card__icon {
  display: grid; place-items: center; flex: none;
  width: 50px; height: 50px; border-radius: 50%;
  color: var(--ink-2);
  background: linear-gradient(160deg, #fff, rgba(255, 255, 255, 0.5));
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 16px -6px rgba(110, 72, 18, 0.3), inset 0 -2px 6px rgba(196, 150, 80, 0.15);
}
.progress-card__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.progress-card__row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.progress-card__label { font-size: 0.92rem; color: var(--ink-2); }
.progress-card__meta { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-2); white-space: nowrap; }
.progress-card__meta .icon { transition: transform 0.35s var(--spring); }
.progress-card:hover .progress-card__meta .icon { transform: translateX(3px); }
.progress-card__value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }

/* Golden progress bar */
.progress {
  position: relative; display: block;
  height: 14px; border-radius: 99px;
  background: linear-gradient(180deg, rgba(235, 222, 200, 0.55), rgba(255, 255, 255, 0.75));
  box-shadow: inset 0 1px 3px rgba(110, 72, 18, 0.18), 0 1px 0 rgba(255, 255, 255, 0.9);
}
.progress__fill {
  position: absolute; inset: 0 auto 0 0;
  width: var(--value, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #f3cf7a 0%, #ecb648 45%, #f6c35a 75%, #ffe7a6 100%);
  box-shadow:
    0 0 14px rgba(240, 180, 60, 0.7),
    0 0 4px rgba(214, 150, 40, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -2px 3px rgba(170, 110, 20, 0.25);
  overflow: hidden;
  transition: width 1.4s var(--ease);
}
.progress__fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.75) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: shimmer 3.2s ease-in-out infinite 1s;
}
@keyframes shimmer { 60%, 100% { transform: translateX(100%); } }

/* Hero art: an organic glass "lens" holding the castle */
.hero__art { position: relative; margin: -86px -8px 0 0; aspect-ratio: 9 / 7.6; }
.hero__frame {
  position: absolute; inset: 0;
  border-radius: 46% 20% 42% 50% / 30% 24% 56% 62%;
  overflow: hidden;
  /* fade the left and bottom edges so the scene dissolves into the page */
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 26%), linear-gradient(0deg, transparent 0%, #000 22%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent 0%, #000 26%), linear-gradient(0deg, transparent 0%, #000 22%);
  mask-composite: intersect;
  animation: float 9s ease-in-out infinite;
}
.hero__frame img { width: 100%; height: 100%; object-fit: cover; object-position: 56% 48%; transform: scale(1.04); transition: transform 1.2s var(--ease); }
.hero__art:hover .hero__frame img { transform: scale(1.1); }
/* glass rim on top of the image */
.hero__frame::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.75), inset 0 0 40px rgba(255, 245, 220, 0.6);
  background:
    radial-gradient(70% 40% at 30% 0%, rgba(255, 255, 255, 0.45), transparent 70%),
    linear-gradient(200deg, rgba(255, 236, 200, 0.18), transparent 45%);
}
@keyframes float { 50% { transform: translateY(-8px); } }

.hero__badge {
  position: absolute; top: 18%; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px 10px 10px;
  animation: float 7s ease-in-out infinite reverse;
}
.hero__badge strong { display: block; font-size: 0.9rem; font-weight: 600; }
.hero__badge small { display: block; font-size: 0.74rem; color: var(--ink-3); }
.flag-dot {
  display: inline-block; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(90deg, var(--ro-blue) 0 33.3%, var(--ro-yellow) 33.3% 66.6%, var(--ro-red) 66.6%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.6), inset 0 -3px 6px rgba(0, 0, 0, 0.18), 0 4px 10px -2px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Panels
   ========================================================================== */
.panel { padding: 24px 26px 26px; margin-bottom: 26px; }
.panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.panel h2 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.panel__head p { margin-top: 3px; font-size: 0.9rem; color: var(--ink-2); }

/* Segmented filter with a sliding liquid indicator */
.pills {
  position: relative; display: flex; gap: 2px;
  padding: 4px; border-radius: 99px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.3));
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 2px rgba(110, 72, 18, 0.08), 0 4px 14px -8px rgba(110, 72, 18, 0.2);
  overflow-x: auto; scrollbar-width: none;
}
.pills::-webkit-scrollbar { display: none; }
.pills__indicator {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0;
  border-radius: 99px;
  background: linear-gradient(180deg, #fbe8bf, #f1d091);
  box-shadow: 0 4px 12px -4px rgba(190, 128, 40, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 2px rgba(190, 128, 40, 0.25);
  transition: transform 0.55s var(--spring), width 0.55s var(--spring);
}
.pill {
  position: relative; z-index: 1;
  padding: 8px 16px; border-radius: 99px;
  font-size: 0.82rem; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  transition: color 0.25s;
}
.pill:hover { color: var(--ink); }
.pill.is-active { color: var(--ink); font-weight: 600; }

/* ---------- Chapter cards ---------- */
.chapter-track {
  position: relative;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px;
}
/* faint timeline thread behind the cards */
.chapter-track::before {
  content: ""; position: absolute; left: 4%; right: 4%; top: 42%; height: 2px; z-index: -1;
  background: linear-gradient(90deg, transparent, rgba(232, 190, 110, 0.7) 15%, rgba(232, 190, 110, 0.7) 85%, transparent);
}

.chapter-card {
  display: flex; flex-direction: column;
  padding: 7px 7px 14px;
  cursor: pointer;
  transition: transform 0.5s var(--spring), box-shadow 0.4s var(--ease), border-color 0.3s;
  animation: rise 0.7s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.97); } }
.chapter-card:hover { transform: translateY(-6px); box-shadow: 0 0 0 1px rgba(246, 205, 120, 0.6), 0 0 28px -4px rgba(250, 190, 80, 0.45), 0 24px 40px -18px rgba(150, 95, 20, 0.45), inset 0 1px 0 #fff; }
.chapter-card:active { transform: translateY(-2px) scale(0.98); }

.chapter-card__media { position: relative; border-radius: 15px; aspect-ratio: 1 / 0.92; }
.chapter-card__media img {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; border-radius: inherit;
  -webkit-mask-image: linear-gradient(180deg, #000 55%, rgba(0, 0, 0, 0.6) 80%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 55%, rgba(0, 0, 0, 0.6) 80%, transparent 100%);
  transition: transform 0.8s var(--ease), filter 0.5s;
}
.chapter-card:hover .chapter-card__media img { transform: scale(1.035); filter: saturate(1.12) brightness(1.03); }
.chapter-card__num {
  position: absolute; left: 8px; bottom: -12px; z-index: 2;
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 0.85rem; font-weight: 700; color: var(--ink);
  background: linear-gradient(160deg, #fff, rgba(255, 249, 235, 0.85));
  border: 1px solid #fff;
  box-shadow: 0 4px 12px -2px rgba(110, 72, 18, 0.35), inset 0 -2px 4px rgba(196, 150, 80, 0.2);
}
.chapter-card__body { padding: 20px 6px 0; }
.chapter-card h3 { font-size: 0.9rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.chapter-card__dates { margin-top: 3px; font-size: 0.74rem; color: var(--ink-3); }
.chapter-card__summary { margin-top: 10px; font-size: 0.84rem; line-height: 1.55; color: var(--ink-2); }

.chapter-card__status {
  margin-top: auto; padding: 14px 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--ink-2);
}
.status-check {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, #eebd57 55%, #c98a2b);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 4px 12px -2px rgba(201, 138, 43, 0.6);
}
.status-ring {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid rgba(138, 126, 111, 0.45);
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 1px 2px rgba(110, 72, 18, 0.1);
}
.status-bar { width: 100%; height: 8px; margin: 9px 0 4px; }
.status-label { font-weight: 500; }
.chapter-card[data-status-kind="in-progress"] .status-label { font-weight: 600; color: var(--ink); }
.chapter-card[data-status-kind="not-started"] .status-label { color: var(--ink-3); }

/* The chapter in progress: warm, glowing, slightly lifted */
.chapter-card.is-active {
  background: linear-gradient(170deg, rgba(255, 252, 243, 0.97), rgba(255, 241, 210, 0.75));
  border-color: rgba(255, 230, 170, 1);
  box-shadow: var(--glow-gold), inset 0 0 24px rgba(255, 214, 140, 0.45), inset 0 1px 0 #fff;
  transform: translateY(-4px);
}
.chapter-card.is-active::before {
  content: ""; position: absolute; inset: -3px; border-radius: 23px; z-index: -1; pointer-events: none;
  background: conic-gradient(from var(--angle, 0deg), rgba(255, 214, 120, 0.9), rgba(255, 245, 210, 0.2), rgba(240, 170, 60, 0.9), rgba(255, 245, 210, 0.2), rgba(255, 214, 120, 0.9));
  filter: blur(8px);
  animation: halo 6s linear infinite;
}
@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes halo { to { --angle: 360deg; } }
.chapter-card.is-active:hover { transform: translateY(-8px); }
.chapter-card.is-hidden { display: none; }

.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.chapter-card--large { padding: 9px 9px 18px; }
.chapter-card--large .chapter-card__media { aspect-ratio: 4 / 3; }
.chapter-card--large h3 { font-size: 1.05rem; }

/* ---------- Game cards ---------- */
.game-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.game-card {
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 24px;
  transition: transform 0.5s var(--spring), box-shadow 0.4s var(--ease);
  animation: rise 0.7s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 80ms + 250ms);
}
.game-card:hover { transform: translateY(-6px); box-shadow: 0 0 0 1px rgba(246, 205, 120, 0.55), 0 0 30px -6px rgba(250, 190, 80, 0.45), 0 26px 44px -20px rgba(150, 95, 20, 0.5), inset 0 1px 0 #fff; }
.game-card__media { position: relative; height: 150px; }
.game-card__media img {
  width: 100%; height: 100%; object-fit: cover;
  -webkit-mask-image: linear-gradient(180deg, #000 42%, rgba(0, 0, 0, 0.55) 72%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 42%, rgba(0, 0, 0, 0.55) 72%, transparent 100%);
  transition: transform 0.9s var(--ease);
}
.game-card:hover .game-card__media img { transform: scale(1.06); }
.chip {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 8px; border-radius: 99px;
  font-size: 0.68rem; font-weight: 600; color: var(--ink-2);
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 10px -4px rgba(110, 72, 18, 0.3);
}
.game-card__body { display: flex; flex-direction: column; flex: 1; padding: 0 18px 18px; margin-top: -26px; position: relative; }
.game-card h3 { font-size: 1.04rem; font-weight: 700; letter-spacing: -0.015em; }
.game-card p { margin-top: 6px; font-size: 0.8rem; line-height: 1.5; color: var(--ink-2); }
.game-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 16px; }
.game-card__players { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--ink-3); }

/* ---------- Buttons ---------- */
.btn-gold {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px 0 20px; border-radius: 99px;
  font-size: 0.84rem; font-weight: 600; color: #fff; white-space: nowrap;
  text-shadow: 0 1px 1px rgba(110, 60, 5, 0.35);
  background: linear-gradient(180deg, #e3b25c 0%, #cc903a 52%, #b67a25 100%);
  border: 1px solid rgba(255, 228, 170, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 6px rgba(120, 70, 10, 0.25),
    0 8px 18px -6px rgba(182, 122, 37, 0.65),
    0 2px 4px rgba(182, 122, 37, 0.25);
  transition: transform 0.35s var(--spring), box-shadow 0.3s, filter 0.3s;
}
/* glossy upper lens */
.btn-gold::before {
  content: ""; position: absolute; left: 6%; right: 6%; top: 1px; height: 52%; border-radius: 99px 99px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.05));
  pointer-events: none;
}
.btn-gold .icon { transition: transform 0.35s var(--spring); }
.btn-gold:hover { transform: translateY(-2px); filter: brightness(1.06) saturate(1.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 6px rgba(120, 70, 10, 0.25), 0 12px 26px -8px rgba(182, 122, 37, 0.8), 0 0 22px -4px rgba(255, 200, 100, 0.7); }
.btn-gold:hover .icon { transform: translateX(3px); }
.btn-gold:active { transform: translateY(0) scale(0.96); }
.btn-gold:disabled { filter: grayscale(0.4) brightness(1.05); cursor: default; opacity: 0.7; transform: none; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px 0 18px;
  font-size: 0.82rem; font-weight: 600; color: var(--ink);
  --glass-blur: 12px;
  transition: transform 0.35s var(--spring);
}
.ghost-btn:hover { transform: translateY(-2px); }
.ghost-btn .icon { transition: transform 0.35s var(--spring); }
.ghost-btn:hover .icon { transform: translateX(3px); }

/* ==========================================================================
   Footer banner
   ========================================================================== */
.banner {
  display: grid; grid-template-columns: minmax(200px, 340px) 1fr minmax(220px, 440px); align-items: center; gap: 12px;
  min-height: 140px; padding: 0; overflow: hidden;
  border-radius: 40px;
}
.banner__art { align-self: stretch; position: relative; }
.banner__art img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 42% 62%;
  filter: sepia(0.12) saturate(0.95) brightness(1.04);
  -webkit-mask-image: linear-gradient(90deg, #000 40%, rgba(0, 0, 0, 0.5) 72%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 40%, rgba(0, 0, 0, 0.5) 72%, transparent 100%);
}
.banner__art--end img {
  object-position: 100% 50%; filter: none;
  -webkit-mask-image: linear-gradient(270deg, #000 74%, transparent 100%);
  mask-image: linear-gradient(270deg, #000 74%, transparent 100%);
}
.banner__quote { text-align: center; font-size: 1.04rem; line-height: 1.6; color: var(--ink-2); }

/* ==========================================================================
   Secondary views
   ========================================================================== */
.view-head { display: flex; align-items: center; gap: 18px; margin: 6px 0 26px; }
.view-head__icon {
  display: grid; place-items: center; flex: none;
  width: 60px; height: 60px; border-radius: 20px; color: var(--gold-600);
  background: linear-gradient(160deg, #fff, var(--gold-100));
  border: 1px solid #fff;
  box-shadow: var(--glow-gold);
}
.view-head__icon .icon { width: 28px; height: 28px; }
.view-head h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; }
.view-head p { margin-top: 4px; color: var(--ink-2); }

/* Stats + badges */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 20px 22px; border-radius: var(--r-lg); }
.stat__icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 10px; border-radius: 14px; color: var(--gold-600); background: linear-gradient(160deg, #fff, var(--gold-100)); box-shadow: inset 0 1px 0 #fff, 0 4px 10px -4px rgba(190, 128, 40, 0.45); }
.stat strong { font-size: 1.35rem; letter-spacing: -0.02em; }
.stat small { color: var(--ink-3); font-size: 0.8rem; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 24px 16px 20px; animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--i) * 60ms); transition: transform 0.4s var(--spring); }
.badge:hover { transform: translateY(-4px); }
.badge__medal {
  position: relative; display: grid; place-items: center;
  width: 74px; height: 74px; margin-bottom: 8px; border-radius: 50%; color: #fff;
  background: radial-gradient(circle at 35% 28%, #fff1c2, #f0c260 45%, #c98a2b 80%, #9c6418);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.8), 0 0 0 6px rgba(232, 190, 110, 0.6), 0 12px 24px -8px rgba(160, 100, 20, 0.6), 0 0 30px -6px rgba(255, 200, 100, 0.8);
}
.badge__medal .icon { width: 32px; height: 32px; stroke-width: 1.8; filter: drop-shadow(0 1px 1px rgba(120, 70, 10, 0.4)); }
.badge strong { font-size: 0.92rem; }
.badge small { font-size: 0.78rem; color: var(--ink-3); line-height: 1.45; }
.badge.is-locked .badge__medal { background: radial-gradient(circle at 35% 28%, #fff, #e7e1d7 55%, #bfb5a6); box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.7), 0 10px 20px -10px rgba(80, 60, 30, 0.4); color: #9a8f80; }
.badge.is-locked strong { color: var(--ink-3); }
.badge__lock { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: var(--ink-3); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); }

/* Profile */
.profile-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.profile-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 34px; }
.profile-card__avatar { width: 112px; height: 112px; border-radius: 50%; box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.9), var(--glow-gold); margin-bottom: 18px; }
.profile-card__bio { display: inline-flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--ink-2); }
.profile-card__bio .flag-dot { width: 22px; height: 22px; }
.profile-card__level { display: flex; justify-content: space-between; width: 100%; margin: 26px 0 10px; font-size: 0.82rem; color: var(--ink-2); }
.profile-card .progress { width: 100%; }
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-radius: var(--r-md); }
.settings strong { display: block; font-size: 0.92rem; font-weight: 600; }
.settings small { font-size: 0.8rem; color: var(--ink-3); }

/* iOS-style glass switch */
.switch { position: relative; flex: none; width: 52px; height: 30px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 99px;
  background: rgba(200, 188, 170, 0.45);
  box-shadow: inset 0 1px 3px rgba(110, 72, 18, 0.2);
  transition: background 0.3s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(180deg, #fff, #f6f0e6);
  box-shadow: 0 3px 8px rgba(80, 50, 10, 0.3), inset 0 -1px 2px rgba(0, 0, 0, 0.06);
  transition: transform 0.45s var(--spring), width 0.25s;
}
.switch input:checked + span { background: linear-gradient(180deg, #f0c260, #d99f3a); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:active + span::after { width: 30px; }
.switch input:checked:active + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold-400); outline-offset: 3px; }

/* Quiz */
.quiz { padding: 30px; }
.quiz__loading { color: var(--ink-3); }
.quiz__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.quiz__count { font-size: 0.82rem; font-weight: 600; color: var(--ink-3); letter-spacing: 0.04em; text-transform: uppercase; }
.quiz__dots { display: flex; gap: 6px; }
.quiz__dots i { width: 26px; height: 6px; border-radius: 99px; background: rgba(200, 188, 170, 0.45); transition: background 0.4s, box-shadow 0.4s; }
.quiz__dots i.is-done { background: var(--gold-300); box-shadow: 0 0 8px rgba(240, 180, 60, 0.6); }
.quiz__dots i.is-now { background: linear-gradient(90deg, var(--gold-300), var(--gold-100)); }
.quiz__question { font-size: clamp(1.25rem, 2.2vw, 1.6rem); line-height: 1.3; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 22px; max-width: 30em; }
.quiz__options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quiz__option {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-align: left; font-weight: 500;
  transition: transform 0.35s var(--spring), box-shadow 0.3s, background 0.3s;
}
.quiz__option:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 0 0 1px rgba(246, 205, 120, 0.6), 0 0 22px -6px rgba(250, 190, 80, 0.5), var(--shadow-card); }
.quiz__option:disabled { cursor: default; }
.quiz__letter { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 11px; font-size: 0.8rem; font-weight: 700; color: var(--gold-600); background: linear-gradient(160deg, #fff, var(--gold-100)); box-shadow: inset 0 1px 0 #fff, 0 3px 8px -3px rgba(190, 128, 40, 0.4); }
.quiz__option.is-correct { background: linear-gradient(165deg, rgba(240, 252, 232, 0.95), rgba(214, 240, 196, 0.7)); box-shadow: 0 0 0 1.5px rgba(120, 180, 90, 0.7), 0 0 24px -6px rgba(120, 190, 90, 0.6); }
.quiz__option.is-correct .quiz__letter { color: #fff; background: linear-gradient(160deg, #9ad27a, #5c9e3f); }
.quiz__option.is-wrong { background: linear-gradient(165deg, rgba(255, 238, 236, 0.95), rgba(250, 210, 205, 0.7)); box-shadow: 0 0 0 1.5px rgba(206, 80, 70, 0.55); animation: shake 0.4s; }
.quiz__option.is-wrong .quiz__letter { color: #fff; background: linear-gradient(160deg, #f08a7e, #c9493c); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.quiz__foot { display: flex; justify-content: flex-end; margin-top: 22px; min-height: 40px; }
.quiz__result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 10px 0; }
.quiz__score {
  display: grid; place-items: center; width: 140px; height: 140px; border-radius: 50%; margin-bottom: 8px;
  background: conic-gradient(var(--gold-300) calc(var(--pct) * 1%), rgba(200, 188, 170, 0.3) 0);
  box-shadow: var(--glow-gold);
}
.quiz__score span { display: grid; place-items: center; width: 112px; height: 112px; border-radius: 50%; font-size: 2rem; font-weight: 800; background: linear-gradient(160deg, #fff, var(--gold-50)); box-shadow: inset 0 2px 6px rgba(110, 72, 18, 0.12); }
.quiz__result p { color: var(--ink-2); max-width: 26em; }
.quiz__result .btn-gold { margin-top: 10px; }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal__scrim {
  position: absolute; inset: 0;
  background: rgba(250, 236, 210, 0.35);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  backdrop-filter: blur(12px) saturate(130%);
  animation: fade 0.35s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal__dialog {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  width: min(860px, 100%); max-height: calc(100vh - 48px); overflow: hidden;
  border-radius: 36px; padding: 14px;
  --glass-tint-top: rgba(255, 255, 255, 0.82);
  --glass-tint-bottom: rgba(255, 249, 238, 0.66);
  animation: modalIn 0.55s var(--spring);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.94); } }
.modal.is-closing .modal__dialog { animation: modalOut 0.25s var(--ease) forwards; }
.modal.is-closing .modal__scrim { animation: fadeOut 0.25s var(--ease) forwards; }
@keyframes modalOut { to { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes fadeOut { to { opacity: 0; } }
.modal__close { position: absolute; top: 18px; right: 18px; z-index: 5; width: 42px; height: 42px; }
.modal__media { position: relative; }
.modal__media img {
  width: 100%; height: 100%; min-height: 320px; object-fit: cover; object-position: 50% 40%; border-radius: 26px;
  -webkit-mask-image: linear-gradient(90deg, #000 62%, transparent 100%), linear-gradient(180deg, #000 70%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, #000 62%, transparent 100%), linear-gradient(180deg, #000 70%, transparent 100%);
  mask-composite: intersect;
}
.modal__media .chapter-card__num { width: 42px; height: 42px; left: 16px; bottom: 16px; font-size: 1.05rem; }
.modal__content { padding: 22px 26px 18px 30px; overflow-y: auto; }
.modal__eyebrow { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-500); }
.modal h2 { margin-top: 6px; padding-right: 40px; font-size: 1.9rem; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; }
.modal__dates { margin-top: 4px; color: var(--ink-3); }
.modal__progress { display: flex; align-items: center; gap: 12px; margin: 18px 0 20px; }
.modal__progress .progress { flex: 1; height: 10px; }
.modal__progress small { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.modal__body p { color: var(--ink-2); line-height: 1.65; margin-bottom: 12px; }
.modal__facts { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 22px; }
.modal__facts li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; border-radius: 14px; font-size: 0.86rem;
  background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.9);
}
.modal__facts li::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--gold-300); box-shadow: 0 0 8px rgba(240, 180, 60, 0.8); }
.modal__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 120;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 22px; font-size: 0.88rem; font-weight: 500;
  --glass-tint-top: rgba(255, 255, 255, 0.85);
  transform: translateX(-50%);
  animation: toastIn 0.5s var(--spring);
}
.toast .icon { color: var(--gold-500); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px) scale(0.95); } }

/* ==========================================================================
   Bottom navigation (mobile)
   ========================================================================== */
.bottom-nav { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1280px) {
  .chapter-track {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 168px;
    overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 12px;
    margin: -16px -14px -12px; padding: 16px 14px 14px;
    scrollbar-width: none;
  }
  .chapter-track::-webkit-scrollbar { display: none; }
  .chapter-card { scroll-snap-align: start; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "main" "foot"; padding: 16px 20px 110px; }
  .sidebar { display: none; }
  .topbar__brand { display: inline-flex; }
  .profile-chip__text { display: none; }
  .profile-chip { padding: 6px; height: 54px; }
  .hero__art { margin-top: -40px; }

  .bottom-nav {
    position: fixed; z-index: 50;
    left: 50%; bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex; gap: 2px;
    width: min(560px, calc(100% - 24px)); padding: 6px;
    border-radius: 30px;
    --glass-tint-top: rgba(255, 255, 255, 0.72);
    --glass-tint-bottom: rgba(255, 250, 240, 0.55);
  }
  .bottom-nav__indicator {
    position: absolute; top: 6px; bottom: 6px; left: 0; width: 0; border-radius: 24px;
    background: linear-gradient(180deg, rgba(251, 232, 191, 0.95), rgba(241, 208, 145, 0.85));
    box-shadow: 0 6px 14px -6px rgba(190, 128, 40, 0.6), inset 0 1px 0 #fff;
    transition: transform 0.55s var(--spring), width 0.55s var(--spring);
  }
  .bottom-nav__item {
    position: relative; z-index: 1; flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 2px 6px; border-radius: 24px;
    font-size: 0.64rem; font-weight: 500; color: var(--ink-3);
    transition: color 0.25s;
  }
  .bottom-nav__item .icon { width: 22px; height: 22px; transition: transform 0.4s var(--spring); }
  .bottom-nav__item.is-active { color: var(--ink); font-weight: 600; }
  .bottom-nav__item.is-active .icon { color: var(--gold-600); transform: translateY(-1px) scale(1.08); }

  .toast { bottom: 104px; }
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 0; }
  .hero__art { order: -1; margin: 0 -8px 8px; aspect-ratio: 16 / 10; }
  .hero__frame { border-radius: 38% 62% 44% 56% / 50% 40% 60% 50%; }
  .hero__badge { top: auto; bottom: 8%; right: 4%; }
  .progress-card { width: 100%; }
  .quiz__options { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .banner { grid-template-columns: 1fr; padding: 0; text-align: center; gap: 4px; }
  .banner__art { height: 140px; }
  .banner__art img { -webkit-mask-image: linear-gradient(180deg, #000 45%, transparent); mask-image: linear-gradient(180deg, #000 45%, transparent); }
  .banner__art--end { height: 120px; }
  .banner__art--end img { object-position: 30% 50%; -webkit-mask-image: linear-gradient(0deg, #000 45%, transparent); mask-image: linear-gradient(0deg, #000 45%, transparent); }
  .banner__quote { padding: 0 20px; }

  .modal { padding: 0; align-items: end; }
  .modal__dialog { grid-template-columns: 1fr; border-radius: 32px 32px 0 0; max-height: 92vh; overflow-y: auto; padding: 10px; animation: sheetIn 0.55s var(--spring); }
  .modal.is-closing .modal__dialog { animation: sheetOut 0.25s var(--ease) forwards; }
  .modal__media img { min-height: 0; height: 230px; -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent 100%); mask-image: linear-gradient(180deg, #000 60%, transparent 100%); }
  .modal__content { padding: 18px 12px 12px; overflow: visible; }
  .modal h2 { font-size: 1.6rem; }
}
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .app { padding: 12px 16px 104px; row-gap: 18px; }
  .topbar { gap: 8px; }
  .topbar__brand span { display: none; }
  /* search collapses to an icon and expands over the top bar */
  .search { width: 46px; padding: 0; justify-content: center; }
  .search .search__input { display: none; }
  .search.is-open { position: absolute; left: 0; right: 0; width: auto; padding: 0 16px 0 14px; justify-content: flex-start; z-index: 40; }
  .search.is-open .search__input { display: block; }
  .search:focus-within { width: auto; }
  .icon-btn, .search { height: 46px; }
  .icon-btn { width: 46px; }
  .profile-chip { height: 50px; }
  .profile-chip img { width: 38px; height: 38px; }
  .hero h1 { font-size: 1.95rem; }
  .hero__lead { font-size: 0.96rem; }
  .progress-card { padding: 16px 16px 18px 14px; gap: 12px; }
  .progress-card__icon { width: 42px; height: 42px; }
  .progress-card__label { font-size: 0.82rem; }
  .panel { padding: 18px 16px 20px; border-radius: 28px; }
  .panel__head { flex-direction: column; }
  .pills { max-width: 100%; }
  .chapter-track { grid-auto-columns: 152px; margin: -16px -16px -12px; padding: 16px 16px 14px; }
  .game-grid { grid-template-columns: 1fr; }
  .game-card__media { height: 170px; }
  .chapter-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .chapter-card--large .chapter-card__summary { display: none; }
  .bottom-nav__item span { font-size: 0.6rem; }
  .quiz { padding: 20px 16px; }
  .view-head__icon { width: 50px; height: 50px; border-radius: 16px; }
}

@media (max-width: 380px) {
  .chapter-grid { grid-template-columns: 1fr; }
  .bottom-nav__item span { display: none; }
  .bottom-nav__item { padding: 12px 2px; }
}

/* Browsers without backdrop-filter: fall back to more opaque surfaces */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { --glass-tint-top: rgba(255, 253, 248, 0.94); --glass-tint-bottom: rgba(255, 249, 238, 0.9); }
}

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