/* ═══════════════════════════════════════════════════════════════════
   Pan Sowa v2 – Mobile-first stylesheet
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Colors */
  --bg: #fdfcf8;
  --ink: #2d3e33;
  --muted: #7a8c82;
  --panel: #ffffff;
  --line: #e2e8e4;
  --blue: #5ba2ff;
  --green: #48d48a;
  --red: #ff7081;
  --yellow: #ffd05b;
  --purple: #a78bfa;
  --orange: #ff9f5b;

  /* Typography */
  --font-body: 'Quicksand', sans-serif;
  --font-dyslexic: 'Lexend', sans-serif;
  --font-base: 1rem;
  --font-scale: 1;
  --letter-spacing: 0;
  --word-spacing: 0;
  --line-height: 1.6;

  /* Spacing & sizing */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --tap-target: 44px;
  --gap: 16px;
  --gap-lg: 24px;
  --panel-border: 2px solid var(--line);
  --panel-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);

  /* Layers */
  --z-under: -1;
  --z-base: 0;
  --z-elevated: 1;
  --z-sticky: 10;
  --z-overlay: 50;
  --z-modal: 100;
}

/* ═══ Reset ═══ */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; -webkit-tap-highlight-color: transparent; }
[x-cloak] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* ═══ Body ═══ */

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  background: #fdfcf8 url("/background.jpg") center top / cover fixed no-repeat;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(var(--font-base) * var(--font-scale));
  letter-spacing: var(--letter-spacing);
  word-spacing: var(--word-spacing);
  line-height: var(--line-height);
  overflow-x: hidden;
}

/* body::before overlay removed - was causing visibility issues */

body.dark {
  --bg: #0f172a; --ink: #f1f5f9; --muted: #94a3b8;
  --panel: #1e293b; --line: #334155;
  background:
    radial-gradient(circle at 50% 8%, rgba(75, 111, 255, 0.22), transparent 34%),
    linear-gradient(180deg, rgba(3, 7, 18, 0.12), rgba(3, 7, 18, 0.82)),
    #050916 url("/background_dark.png") center top / cover fixed no-repeat;
}
/* dark body::before removed */

/* Dark mode overrides for elements with hardcoded light backgrounds */
body.dark .hero { background: linear-gradient(135deg, #1e293b, #1a2d3d, #0f2f4a); }
body.dark .hero-art {
  border-color: rgba(148, 180, 255, 0.38);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
body.dark .question-box { background: linear-gradient(135deg, #1e293b, #1a2d3d); border-color: #3b5998; }
body.dark .login-inputs { background: #1e293b; }
body.dark .start-box { background: linear-gradient(135deg, #1e293b, #0f2f4a); border-color: #3b5998; box-shadow: none; }
body.dark .mission-art-placeholder { background: #334155; }
body.dark .streak-card { background: linear-gradient(135deg, #1e293b, #0f2f4a); border-color: #3b5998; box-shadow: none; }
body.dark .feedback-card.correct { background: #0a2e1a; border-color: #2d8a4e; }
body.dark .feedback-card.wrong { background: #2e0a0a; border-color: #8a2d2d; }
body.dark .feedback-card.pending { background: #0f2f4a; border-color: #3b5998; }
body.dark .ai-box { background: #1e293b; border-color: #3b5998; }
body.dark .ai-box [style*="background:#f8faff"] { background: #0f172a !important; }
body.dark .badge-card.earned { background: #0f2f4a; border-color: #3b5998; }
body.dark .progress-bar { background: #334155; }
body.dark .speak-btn { background: #1e293b; }

body.dyslexic {
  --font-body: var(--font-dyslexic);
  --letter-spacing: 0.04em;
  --word-spacing: 0.12em;
  --line-height: 1.8;
}

/* ═══ Typography ═══ */

h1 { font-size: clamp(2em, 6vw, 3.8em); line-height: 1; letter-spacing: 0; }
h2 { font-size: clamp(1.4em, 4vw, 2.2em); }
h3 { font-size: 1.15em; }
p, li, td, th, span, a, button, input, select, textarea, label, blockquote { font-size: inherit; }
.eyebrow { font-size: 0.8em; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }

/* ═══ Buttons ═══ */

button {
  cursor: pointer; border: none; background: none;
  min-height: var(--tap-target); min-width: var(--tap-target);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; border-radius: var(--radius-sm);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--blue); color: #fff;
  padding: 0 24px; border-radius: 999px;
  white-space: nowrap;
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  border: 2px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 0 20px; border-radius: 999px;
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }

.btn-action {
  background: var(--orange); color: #fff;
  padding: 0 18px; border-radius: 999px; font-size: 0.9rem;
}

.btn-icon {
  width: var(--tap-target); height: var(--tap-target);
  border: var(--panel-border); border-radius: var(--radius-sm);
  font-size: 1.3rem; background: #fff;
}
.btn-icon:hover { border-color: var(--red); color: var(--red); }

.btn-a11y {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1); color: #fff;
  font-size: 0.8rem; font-weight: 800;
}
.btn-a11y:hover { background: rgba(255,255,255,0.25); }
.btn-a11y.active { background: var(--blue); border-color: var(--blue); }

/* ═══ Forms ═══ */

input, select, textarea {
  width: 100%; min-height: 40px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 8px 12px;
  font-weight: 600;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }

.field { display: grid; gap: 4px; align-content: start; }
.field span { font-weight: 800; color: var(--muted); font-size: 0.85rem; }
form.card { display: grid; gap: 12px; align-content: start; }

/* ═══ Cards ═══ */

.card {
  background: var(--panel); border: var(--panel-border); border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 24px; position: relative;
}
.card-sm { padding: 16px; border-radius: var(--radius-sm); }
.card > h3:first-child:not(:last-child) { margin-bottom: 12px; }
.card > p + a,
.card > p + button { margin-top: 12px; }

/* ═══ Layout ═══ */

.topbar {
  max-width: 1480px; margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center; gap: 16px; position: relative;
  z-index: 20;
}
.topbar::before {
  content: ""; position: absolute;
  top: -40px; left: 50%; width: 100vw; height: calc(100% + 40px);
  transform: translateX(-50%);
  background: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.1) 70%, transparent 100%);
  z-index: var(--z-under); pointer-events: none;
}

/* Topbar centered nav */
.topbar-nav {
  display: flex; gap: 4px; justify-content: center; align-items: center;
  padding: 5px;
  border: 1px solid rgba(150,190,255,0.24);
  border-radius: 28px;
  background: rgba(8,18,44,0.58);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  position: relative;
}
.topbar-tab {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; border-radius: 20px;
  background: transparent;
  padding: 9px 16px;
  font-weight: 800; color: rgba(255,255,255,0.85);
  white-space: nowrap; min-height: 42px; font-size: 0.9rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.topbar-tab .tab-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 7px;
  color: #c9d7ff; background: rgba(255,255,255,0.08);
  font-size: 0.85rem; line-height: 1; flex-shrink: 0;
}
.topbar-tab:hover { background: rgba(255,255,255,0.08); }
.topbar-tab.active {
  background: linear-gradient(135deg, #5ba2ff, #6d5dfc);
  border-color: rgba(255,255,255,0.2); color: #fff;
  box-shadow: 0 0 24px rgba(91,162,255,0.34);
}
.topbar-tab.active .tab-icon { color: #fff; background: rgba(255,255,255,0.18); }

.topbar-more { position: relative; }
.more-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 190px;
  background: rgba(8,18,44,0.97);
  border: 1px solid rgba(150,190,255,0.24);
  border-radius: 14px; padding: 6px;
  z-index: 200;
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 56px rgba(0,0,0,0.5);
}
.more-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 14px;
  border: none; border-radius: 10px;
  background: transparent; color: rgba(255,255,255,0.85);
  font-weight: 700; text-align: left; cursor: pointer;
  transition: background 0.12s;
}
.more-item:hover, .more-item.active { background: rgba(91,162,255,0.2); color: #fff; }

/* Topbar right HUD */
.topbar-hud {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  border: 1px solid rgba(150,190,255,0.28);
  border-radius: 22px;
  background: rgba(8,18,44,0.62);
  padding: 4px 8px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.26), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* Global app shell */
.app-shell {
  display: grid;
  grid-template-columns: 256px 1fr 272px;
  grid-template-rows: auto;
  gap: 16px;
  max-width: 1480px; margin: 0 auto;
  padding: 8px 16px 40px;
  align-items: start;
}
.app-sidebar-left {
  grid-column: 1;
  position: sticky; top: 8px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 80px);
  overflow-y: auto; scrollbar-width: none;
}
.app-sidebar-left::-webkit-scrollbar { display: none; }
.app-main {
  grid-column: 2;
  min-width: 0;
}
.app-content-section { display: block; }
.app-sidebar-right {
  grid-column: 3;
  position: sticky; top: 8px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  padding-bottom: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 190, 255, 0.38) rgba(8, 18, 44, 0.38);
}
.app-sidebar-right::-webkit-scrollbar { width: 6px; }
.app-sidebar-right::-webkit-scrollbar-track { background: rgba(8, 18, 44, 0.38); border-radius: 999px; }
.app-sidebar-right::-webkit-scrollbar-thumb { background: rgba(150, 190, 255, 0.38); border-radius: 999px; }

/* Change password page (no shell) */
.change-password-wrap {
  max-width: 480px; margin: 40px auto; padding: 0 16px;
}

/* ═══ LEFT SIDEBAR — nowa karta gracza ═══ */
.sidebar-player-card {
  color: #f8fbff;
  border: 1px solid rgba(150,190,255,0.22);
  border-radius: 22px;
  background: rgba(8,18,44,0.72);
  box-shadow: 0 18px 44px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
  padding: 18px 16px 16px;
  display: grid;
  gap: 6px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 88px; height: 88px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #5ba2ff, #8b5cf6);
  box-shadow: 0 0 32px rgba(91,162,255,0.38), 0 0 0 3px rgba(91,162,255,0.18);
  margin: 0 auto 4px;
  font-size: 2.4rem; font-weight: 900; overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-player-card > strong { color: #fff; font-size: 1.25rem; line-height: 1.1; }
.sidebar-grade { color: #a5c4ff; font-size: 0.85rem; font-weight: 800; }
.sidebar-label { color: #6b87b8; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; }
.sidebar-level-big {
  display: inline-block;
  margin: 4px auto 0;
  padding: 4px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,208,91,0.18), rgba(255,159,91,0.12));
  border: 1px solid rgba(255,208,91,0.28);
}
.sidebar-level-big span { color: #ffd05b; font-size: 1.05rem; font-weight: 900; }
.sidebar-xp-row { display: grid; gap: 4px; margin-top: 4px; }
.sidebar-xp { height: 8px; border-radius: 999px; }
.sidebar-xp-row small { color: #7a9acd; font-size: 0.76rem; font-weight: 800; text-align: right; }

.sidebar-wallet {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(150,190,255,0.22);
  border-radius: 18px;
  background: rgba(8,18,44,0.72);
  box-shadow: 0 8px 24px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-wallet-cell {
  padding: 14px 10px;
  text-align: center;
  display: grid; gap: 3px;
}
.sidebar-wallet-cell + .sidebar-wallet-cell { border-left: 1px solid rgba(255,255,255,0.1); }
.sidebar-coin-icon { color: #ffd05b; font-size: 1.3rem; filter: drop-shadow(0 0 8px rgba(255,208,91,0.5)); }
.sidebar-crystal-icon { color: #a78bfa; font-size: 1.3rem; filter: drop-shadow(0 0 8px rgba(139,92,246,0.5)); }
.sidebar-wallet-cell strong { color: #fff; font-size: 1.3rem; font-weight: 900; line-height: 1; }
.sidebar-wallet-cell small { color: #7a9acd; font-size: 0.74rem; font-weight: 800; }

/* ═══ RIGHT SIDEBAR — karty ═══ */
.side-progress-body {
  display: grid; gap: 12px; justify-items: center;
}
.progress-ring-lg {
  width: 152px; height: 152px;
}
.progress-ring-lg::after { inset: 16px; }
.progress-ring-lg span { font-size: 1.9rem; }
.progress-owl-bubble {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
}
.progress-owl-img {
  width: 64px; height: 64px; flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #f8eed8, #d9c8a8);
  border: 2px solid rgba(255,208,91,0.45);
  box-shadow: 0 4px 14px rgba(0,0,0,0.32), 0 0 18px rgba(255,208,91,0.22);
  display: grid; place-items: center;
}
.progress-owl-img img {
  width: 110%; height: 110%;
  object-fit: cover;
  object-position: 50% 30%;
}
.progress-bubble {
  flex: 1;
  background: #fff;
  border-radius: 14px 14px 14px 4px;
  padding: 10px 12px;
  display: grid; gap: 3px;
  position: relative;
  box-shadow: 0 4px 18px rgba(0,0,0,0.22);
}
.progress-bubble strong { color: #1a2744; font-size: 0.97rem; font-weight: 900; }
.side-progress-card .progress-bubble strong { font-size: 0.97rem; }
.progress-bubble span { color: #4a5e84; font-size: 0.78rem; font-weight: 700; }

.side-challenge-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.reward-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255,208,91,0.12);
  border: 1px solid rgba(255,208,91,0.28);
  color: #ffd05b; font-size: 0.85rem; font-weight: 900;
}
.reward-chip span { font-size: 0.7rem; }
.reward-claim-btn {
  cursor: pointer;
  background: linear-gradient(135deg, #ffd05b, #f59e0b);
  color: #3b2500;
  box-shadow: 0 0 18px rgba(255,208,91,0.22);
}
.reward-claim-btn:hover { transform: translateY(-1px); }
.challenge-feedback {
  color: #ffd05b;
  font-weight: 900;
  min-height: 1.2em;
}

.achievement-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.85rem;
}
.achievement-item:last-child { border-bottom: none; }
.achievement-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: rgba(150,190,255,0.4);
}
.achievement-dot.dot-good { background: linear-gradient(135deg, #48d48a, #5ba2ff); }
.achievement-item span { flex: 1; color: #d8e4ff; font-weight: 700; }
.achievement-item small { color: #48d48a; font-weight: 900; font-size: 0.78rem; white-space: nowrap; }

.map-treasure-card.chest-ready { border-color: rgba(255,208,91,0.6); cursor: pointer; }
.map-treasure-card.chest-ready:hover { background: rgba(255,208,91,0.12); }

/* Adventures subject block */
/* ═══ PRZYGODY SECTION — realm carousel ═══ */
.adventures-section { padding-top: 0; }
.adventures-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 14px;
  gap: 16px;
}
.adventures-header h2 { font-size: 1.7rem; color: #fff; margin-bottom: 4px; }

.carousel-nav { display: flex; gap: 8px; flex-shrink: 0; }
.carousel-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(150,190,255,0.3);
  background: rgba(255,255,255,0.07);
  color: #fff;
  font-size: 1.3rem;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.carousel-btn:hover { background: rgba(91,162,255,0.2); border-color: rgba(91,162,255,0.55); }

.realm-carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-bottom: 20px;
}
.realm-carousel::-webkit-scrollbar { display: none; }

.realm-carousel-card {
  flex: 0 0 calc(25% - 12px);
  min-width: 200px;
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  height: 268px;
  border: 1px solid rgba(150,190,255,0.2);
  box-shadow: 0 10px 34px rgba(0,0,0,0.38);
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.realm-carousel-card:first-child {
  flex: 0 0 calc(29% - 12px);
  height: 290px;
  border-color: color-mix(in srgb, var(--realm-accent) 60%, rgba(255,255,255,0.2));
  box-shadow: 0 14px 48px rgba(0,0,0,0.5), 0 0 32px color-mix(in srgb, var(--realm-accent) 30%, transparent);
}
.realm-carousel-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 54px rgba(0,0,0,0.52), 0 0 0 2px var(--realm-accent, #5ba2ff);
}

.rcc-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.62;
  transition: opacity 0.2s;
}
.realm-carousel-card:hover .rcc-bg { opacity: 0.78; }
.rcc-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(4,8,28,0.94) 0%, rgba(4,8,28,0.46) 50%, rgba(4,8,28,0.04) 100%);
}
.rcc-body {
  position: relative; z-index: 1;
  height: 100%;
  padding: 16px;
  display: flex; flex-direction: column; justify-content: flex-end;
  gap: 5px;
}
.rcc-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.rcc-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--realm-accent, #5ba2ff);
  display: grid; place-items: center;
  font-size: 0.95rem; font-weight: 900;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.rcc-level {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem; font-weight: 800; color: #d8eaff;
}
.rcc-title { color: #fff; font-size: 1.15rem; font-weight: 900; line-height: 1.15; }
.rcc-desc { color: rgba(200,220,255,0.68); font-size: 0.75rem; font-weight: 700; }
.rcc-progress {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
}
.rcc-bar {
  flex: 1; height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.15); overflow: hidden;
}
.rcc-bar i {
  display: block; height: 100%; border-radius: 999px;
  background: var(--realm-accent, #5ba2ff);
  box-shadow: 0 0 8px var(--realm-accent, #5ba2ff);
}
.rcc-pct { color: #fff; font-size: 0.78rem; font-weight: 900; min-width: 28px; text-align: right; }
.rcc-footer {
  display: flex; align-items: center; justify-content: space-between;
  color: rgba(180,210,255,0.6); font-size: 0.73rem; font-weight: 700;
}
.rcc-cta { color: var(--realm-accent, #5ba2ff); font-weight: 900; }

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  min-height: 56px;
  padding: 6px 10px 6px 6px;
  border: 1px solid rgba(150, 190, 255, 0.18);
  border-radius: 20px;
  background: rgba(8, 18, 44, 0.34);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 10px 28px rgba(0,0,0,0.18);
  backdrop-filter: blur(12px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 2;
}

.logo-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background:
    radial-gradient(circle at 48% 30%, rgba(255,244,206,0.96), rgba(245,184,89,0.66) 54%, rgba(91,162,255,0.42)),
    linear-gradient(135deg, rgba(91,162,255,0.5), rgba(109,93,252,0.62));
  border: 2px solid rgba(255,208,91,0.52);
  box-shadow: 0 0 22px rgba(255,208,91,0.18), 0 8px 18px rgba(0,0,0,0.28);
}
.logo-mark img {
  width: 118%;
  height: 118%;
  object-fit: cover;
  object-position: 50% 28%;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-text h1 {
  margin: 0;
  font-size: 1.55rem;
  color: #fff;
  text-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 20px rgba(91,162,255,0.18);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.logo-text .eyebrow {
  color: #a5f3fc;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  margin-bottom: 2px;
}
.topbar .logo-text .eyebrow { display: none; }
.topbar-a11y {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(150, 190, 255, 0.2);
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
}
.topbar-a11y .btn-a11y {
  min-width: 34px;
  min-height: 34px;
  border-radius: 12px;
  color: #dbe8ff;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.82rem;
  font-weight: 900;
}
.topbar-a11y .btn-a11y:hover,
.topbar-a11y .btn-a11y.active {
  color: #fff;
  border-color: rgba(255,208,91,0.48);
  background: linear-gradient(135deg, rgba(91,162,255,0.42), rgba(109,93,252,0.38));
  box-shadow: 0 0 18px rgba(91,162,255,0.2);
}

.user-pill {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid rgba(150, 190, 255, 0.28);
  border-radius: 22px;
  background: rgba(8, 18, 44, 0.62);
  padding: 6px 10px;
  backdrop-filter: blur(12px); flex-wrap: nowrap; justify-content: flex-end; min-width: 0;
  box-shadow: 0 16px 42px rgba(0,0,0,0.26), inset 0 1px 0 rgba(255,255,255,0.08);
  position: relative;
  z-index: 2;
}
.user-pill > span { color: #fff; font-weight: 800; font-size: 0.95rem; }
.hud-stat {
  min-height: 42px;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: #f8fbff;
  border-right: 1px solid rgba(255,255,255,0.12);
  white-space: nowrap;
}
.hud-stat span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3b2500;
  background: linear-gradient(135deg, #ffd05b, #ff9f5b);
  box-shadow: 0 0 16px rgba(255, 208, 91, 0.32);
  font-size: 0.82rem;
  line-height: 1;
}
.hud-stat:not(.coin-stat) span { color: #fff; background: linear-gradient(135deg, #8b5cf6, #5ba2ff); }
.hud-stat strong { font-size: 0.96rem; }
.hud-stat small { color: #b8c8e8; font-size: 0.76rem; font-weight: 900; margin-left: -4px; }
/* When the HUD icon is the AI-PNG (assets/ui/icon-*.png) — fills the same 24px chip */
.hud-stat .hud-icon { overflow: hidden; padding: 0; }
.hud-stat .hud-icon img { width: 100%; height: 100%; object-fit: cover; }
.hud-stat .hud-icon .missing-asset { background: transparent; border: 0; padding: 0; font-size: 0.42rem; min-width: 0; color: #3b2500; }
.hud-stat:not(.coin-stat) .hud-icon .missing-asset { color: #fff; }
.mode-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(255,255,255,0.36);
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
}
.mode-chip.exam {
  background: rgba(255, 208, 91, 0.24);
  border-color: rgba(255, 208, 91, 0.64);
  color: #fff8dc;
}

.a11y-row { display: flex; gap: 3px; border-right: 1px solid rgba(255,255,255,0.3); padding-right: 8px; }

.tabs {
  width: max-content;
  max-width: min(560px, calc(100vw - 32px)); margin: 0 auto;
  padding: 6px;
  display: flex; gap: 6px; overflow-x: auto;
  position: relative; z-index: 20; scrollbar-width: none;
  border: 1px solid rgba(150, 190, 255, 0.24);
  border-radius: 24px;
  background: rgba(8, 18, 44, 0.58);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 42px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.08);
}
.tabs::-webkit-scrollbar { display: none; }

.tab-chip {
  gap: 9px;
  border: 1px solid transparent; border-radius: 18px;
  background: transparent; padding: 10px 14px;
  font-weight: 800; color: rgba(255,255,255,0.9);
  white-space: nowrap; backdrop-filter: blur(8px);
  min-height: 44px; font-size: 0.92rem;
}
.tab-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #c9d7ff;
  background: rgba(255,255,255,0.08);
  font-size: 0.9rem;
  line-height: 1;
}
.tab-chip:hover { background: rgba(255,255,255,0.08); }
.tab-chip.active {
  background: linear-gradient(135deg, #5ba2ff, #6d5dfc);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
  box-shadow: 0 0 28px rgba(91, 162, 255, 0.34);
}
.tab-chip.active .tab-icon { color: #fff; background: rgba(255,255,255,0.18); }

body.dark .tab-chip {
  border-color: transparent;
  background: transparent;
  color: rgba(255,255,255,0.9);
}
body.dark .tab-chip:hover { background: rgba(255,255,255,0.08); }
body.dark .tab-chip.active { background: linear-gradient(135deg, #5ba2ff, #6d5dfc); border-color: rgba(255,255,255,0.2); color: #fff; }

.shell { max-width: 1480px; margin: 0 auto; padding: 0 16px 40px; position: relative; }

@media (min-width: 821px) {
  .tabs {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
  }
  .user-pill .mode-chip,
  .user-pill .a11y-row,
  .user-pill .btn-ghost {
    display: none;
  }
}

/* ═══ Adventures Restructure ═══ */

.subjects-stack {
  display: grid;
  gap: 40px;
  margin-top: 12px;
}

.subject-section {
  display: grid;
  gap: 20px;
}

.subject-head {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 12px;
}

.subject-visual-mini {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.subject-visual-mini img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  padding: 8px;
  border: var(--panel-border);
}

.subject-icon-mini {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  background: var(--subj-color);
  color: #fff;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.8rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.missions-grid {
  display: grid;
  gap: 20px;
}

.mission-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s;
}
.mission-card:hover { transform: translateY(-4px); }

.mission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

/* ═══ Grids ═══ */

.grid-2 { display: grid; gap: var(--gap-lg); grid-template-columns: 1fr 1fr; }

.mission-section-stack { display: grid; gap: var(--gap-lg); margin-top: 16px; }
.mission-section-group { display: grid; gap: var(--gap-md); }
.empty-panel { margin-top: 12px; padding: 14px 16px; border: var(--panel-border); border-left: 5px solid var(--subj-color, var(--blue)); border-radius: var(--radius); background: linear-gradient(90deg, color-mix(in srgb, var(--subj-color, var(--blue)) 10%, var(--panel)), var(--panel)); box-shadow: var(--panel-shadow); color: var(--muted); font-weight: 800; }
body.dark .empty-panel { background: linear-gradient(90deg, #0f2f4a, #1e293b); border-color: #3b5998; border-left-color: #7dd3fc; box-shadow: none; color: var(--ink); }
.table-section-label { color: var(--muted); font-size: 0.78rem; font-weight: 900; margin-bottom: 4px; }
.compact-grid { gap: var(--gap-sm); }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); padding: 10px 0; }
.check-row input { width: 18px; height: 18px; accent-color: var(--blue); }
.grid-3 { display: grid; gap: var(--gap-lg); grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { display: grid; gap: var(--gap-lg); grid-template-columns: 1fr 1fr 1fr 1fr; }
.wide { grid-column: 1 / -1; }
.stack { display: grid; gap: var(--gap); }

/* ═══ Subject cards ═══ */

.subject-card { padding: 20px; display: grid; gap: 12px; }
.subject-visual { aspect-ratio: 16/10; border-radius: var(--radius); overflow: hidden; background: #f8faff; border: var(--panel-border); position: relative; }
.subject-visual img { width: 100%; height: 100%; object-fit: cover; }
.subject-icon {
  position: absolute; left: 10px; bottom: 10px;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--subj-color, var(--blue));
  color: #fff; font-weight: 800; font-size: 1.2rem; z-index: var(--z-elevated);
}

.mission-card {
  border: var(--panel-border); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 10px; background: var(--panel);
}
.mission-card:hover { border-color: var(--subj-color, var(--blue)); }
.mission-title { display: block; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--subj-color) 34%, var(--line)); border-left: 4px solid var(--subj-color); border-radius: var(--radius-sm); background: linear-gradient(90deg, color-mix(in srgb, var(--subj-color) 15%, var(--panel)), color-mix(in srgb, var(--subj-color) 5%, var(--panel))); color: var(--ink); font-size: 1rem; font-weight: 900; line-height: 1.25; overflow-wrap: anywhere; }
.mission-meta { color: var(--muted); font-size: 0.85rem; font-weight: 700; line-height: 1.35; }
.mission-mastery { margin-top: 4px; }
.mission-mastery .mastery-row { display: grid; gap: 6px; }
.mission-mastery .mastery-bar { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 20%, transparent); overflow: hidden; }
.mission-mastery .mastery-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--green, #2e9d68)); transition: width 0.3s ease; }
.mission-mastery .mastery-label { color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.mission-mastery .mastery-label.muted { font-style: italic; opacity: 0.75; }
body.dark .mission-mastery .mastery-bar { background: color-mix(in srgb, var(--ink) 18%, transparent); }

.mastery-summary { display: grid; gap: 6px; }
.mastery-question-row { display: grid; grid-template-columns: 18px 1fr 80px auto; gap: 8px; align-items: center; font-size: 0.85rem; }
.mastery-icon { font-weight: 900; font-size: 1.1rem; text-align: center; }
.mastery-question-text { color: var(--ink); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.mastery-summary .mastery-bar { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 20%, transparent); overflow: hidden; }
.mastery-summary .mastery-fill { height: 100%; transition: width 0.3s ease; }
.mastery-pct { font-size: 0.85rem; white-space: nowrap; }
.mastery-pct small { opacity: 0.7; font-weight: 600; }
.mission-art { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius-sm); border: var(--panel-border); }
.mission-art-placeholder { aspect-ratio: 16/9; border-radius: var(--radius-sm); display: grid; place-items: center; background: #f0f7ff; font-size: 1.8rem; color: var(--subj-color, var(--blue)); font-weight: 800; }
body.dark .mission-title { background: linear-gradient(90deg, #0f2f4a, #1e293b); border-color: #3b5998; border-left-color: #7dd3fc; color: var(--ink); }

/* ═══ Hero ═══ */

.hero {
  display: grid; grid-template-columns: 1fr 220px; align-items: center; gap: 24px;
  padding: 24px 32px; background: linear-gradient(135deg, #fff, #f0f9ff, #fff5f9);
  border: var(--panel-border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--panel-shadow);
}
.hero-art { aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: var(--panel-border); }
.hero-content { display: grid; gap: 10px; }
.hero-content h2 { color: var(--blue); }

.student-stats-screen {
  display: grid;
  gap: 20px;
  min-width: 0;
  max-width: 100%;
}
.stats-hero {
  position: relative;
  grid-template-columns: minmax(0, 1fr) 240px;
  padding: 30px 34px;
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(105deg, rgba(8,18,42,0.92), rgba(12,31,64,0.78)),
    url("/assets/ui/adventure-map-bg.png") center / cover;
  border: 1px solid rgba(150,190,255,0.24);
  box-shadow: 0 24px 70px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.08);
  min-width: 0;
}
.stats-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 24%, rgba(255,208,91,0.16), transparent 18%),
    radial-gradient(circle at 72% 36%, rgba(124,108,255,0.14), transparent 20%);
}
.stats-hero > * {
  position: relative;
  z-index: 1;
}
.stats-hero .hero-content h2 {
  color: #fff;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
}
.stats-hero-lead {
  max-width: 620px;
  color: #cfe0ff;
  font-weight: 800;
}
.stats-hero .hero-art {
  width: 220px;
  height: 220px;
  justify-self: end;
  border-radius: 32px;
  border-color: rgba(255,208,91,0.36);
  box-shadow: 0 0 42px rgba(255,208,91,0.18);
}
.stats-level-track {
  display: grid;
  gap: 6px;
  max-width: 420px;
}
.stats-level-track small {
  color: #aebfe4;
  font-weight: 800;
}
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.stats-orb-card {
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 18px;
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(circle at 18% 18%, rgba(255,208,91,0.16), transparent 32%),
    linear-gradient(145deg, rgba(16,32,68,0.88), rgba(8,18,42,0.82));
  border: 1px solid rgba(150,190,255,0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 18px 40px rgba(0,0,0,0.22);
}
.stats-orb-card span {
  color: #aebfe4;
  font-weight: 900;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stats-orb-card strong {
  font-size: 2rem;
  line-height: 1;
}
.stats-card-grid {
  margin-top: 0 !important;
  min-width: 0;
}

.stat-row { display: flex; flex-wrap: wrap; gap: 8px; font-weight: 800; font-size: 0.9rem; }
.stat-chip { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.6); padding: 2px 8px; border: var(--panel-border); border-radius: var(--radius-sm); }
.stat-chip.highlight { background: rgba(239,68,68,0.15); border-color: var(--red); color: var(--red); font-weight: 800; }

.start-box { background: transparent; border: 0; border-radius: 0; padding: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; box-shadow: none; }

/* ═══ Student metric panels ═══ */

.student-metric-panel {
  overflow: hidden;
  border-width: 2px;
}
.student-metric-panel h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.student-metric-panel h3::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--metric-color, var(--blue));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--metric-color, var(--blue)) 18%, transparent);
}
.badges-panel {
  --metric-color: var(--yellow);
  border-color: color-mix(in srgb, var(--yellow) 70%, var(--line));
  background: linear-gradient(135deg, var(--panel), #fffdf5);
}
.progress-panel {
  --metric-color: var(--green);
  border-color: color-mix(in srgb, var(--green) 65%, var(--line));
  background: linear-gradient(135deg, var(--panel), #f3fff8);
}
body.dark .badges-panel,
body.dark .progress-panel {
  --metric-color: #7dd3fc;
  background: linear-gradient(135deg, var(--panel), #0f2f4a);
  border-color: #3b5998;
}

/* ═══ Badges ═══ */

.badge-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.badge-card {
  border: 2px solid color-mix(in srgb, var(--yellow) 58%, var(--line));
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  background: linear-gradient(135deg, #fff, #fffaf0);
  box-shadow: 0 6px 16px rgba(180, 138, 61, 0.12);
}
.badge-card img {
  width: 70px;
  height: 70px;
  object-fit: contain;
  filter: grayscale(1) opacity(0.36);
  background: #fffdf5;
  border: 2px solid color-mix(in srgb, var(--yellow) 45%, var(--line));
  border-radius: var(--radius-sm);
  padding: 6px;
}
.badge-card.earned {
  border-color: var(--yellow);
  background: linear-gradient(135deg, #fff, #fff4cc);
  box-shadow: 0 8px 20px rgba(255, 207, 91, 0.22);
}
.badge-card.earned img { filter: none; opacity: 1; border-color: var(--yellow); }
body.dark .badge-card {
  background: linear-gradient(135deg, #1e293b, #0f2f4a);
  border-color: #3b5998;
  box-shadow: none;
}
body.dark .badge-card.earned { border-color: #7dd3fc; background: linear-gradient(135deg, #1e293b, #0c4a6e); }
body.dark .badge-card img { background: #0f2f4a; border-color: #3b5998; }
body.dark .badge-card.earned img { border-color: #7dd3fc; }

/* ═══ Progress ═══ */

.progress-bar { height: 12px; border-radius: 999px; background: #f0f4f8; border: var(--panel-border); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--green); border-radius: inherit; }

/* ═══ Streak ═══ */

.streak-card { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, #fff, #f3fff8); border: 2px solid color-mix(in srgb, var(--green) 58%, var(--line)); border-radius: var(--radius); padding: 14px; position: relative; overflow: hidden; box-shadow: 0 6px 16px rgba(46, 204, 113, 0.12); }
.streak-card::after { content: "🔥"; position: absolute; right: -8px; bottom: -8px; font-size: 3rem; opacity: 0.1; }
.streak-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); background: var(--yellow); display: grid; place-items: center; font-size: 1.5rem; flex-shrink: 0; }
.streak-value { display: inline-block; font-size: 1.4rem; color: #9b6717; }
.streak-label { color: #b48a3d; font-weight: 700; }
body.dark .streak-icon { background: #0c4a6e; }
body.dark .streak-value { color: #7dd3fc; }
body.dark .streak-label { color: #bae6fd; }

/* ═══ Suggestion cards ═══ */

.suggested-tests-panel {
  display: grid;
  gap: 12px;
  background:
    radial-gradient(circle at 12% 0%, rgba(91,162,255,0.18), transparent 32%),
    linear-gradient(145deg, rgba(11,24,58,0.92), rgba(7,15,38,0.9));
  border: 1px solid rgba(150,190,255,0.24);
  box-shadow: 0 18px 42px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
}
.suggested-tests-panel h3 { color: #fff; margin-bottom: 2px; }
.suggest-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(150,190,255,0.24);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035)),
    rgba(8,18,44,0.66);
  padding: 12px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.suggest-card:hover {
  border-color: rgba(139,92,246,0.72);
  box-shadow: 0 0 24px rgba(139,92,246,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.suggest-card.priority:hover { border-color: rgba(255,208,91,0.78); }
.suggest-icon {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}
.suggest-icon img { width: 40px; height: 40px; object-fit: contain; }
.suggest-info { display: grid; gap: 2px; }
.suggest-info strong { color: #fff; font-size: 0.98rem; line-height: 1.22; }
.suggest-info span { color: #b8c8e8; font-weight: 800; font-size: 0.82rem; }
.suggest-card .btn-primary { min-width: 90px; min-height: 42px; border-radius: 16px; }

/* ═══ Filters ═══ */

.filter-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.filter-row::-webkit-scrollbar { display: none; }
.chip { border: 2px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 0.85rem; white-space: nowrap; min-height: 38px; background: var(--panel); color: var(--muted); }
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ═══ Modals ═══ */

.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: 16px;
  background: rgba(15,23,42,0.8); backdrop-filter: blur(8px);
}
.modal-panel {
  width: min(800px, 100%); max-height: min(94vh, 900px);
  background: var(--panel); border-radius: var(--radius-lg);
  padding: 28px; display: grid; grid-template-rows: auto 1fr auto;
  gap: 20px; box-shadow: 0 40px 100px rgba(0,0,0,0.3);
  border: var(--panel-border);
}
.modal-head { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 16px; border-bottom: 2px solid var(--line); padding-bottom: 16px; }
.modal-scroll { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 8px; overscroll-behavior: contain; }
.modal-foot { border-top: 2px solid var(--line); padding-top: 16px; }

/* ═══ Quiz ═══ */

.quiz-count { font-weight: 800; color: var(--blue); font-size: 0.9rem; white-space: nowrap; }
.question-box { background: linear-gradient(135deg, #fff, #f0f9ff); border: 2px solid #bcd4fb; border-radius: var(--radius); padding: 20px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.question-box h3 { font-size: clamp(1.15rem, 2.5vw, 1.6rem); }

.speak-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); border: var(--panel-border); background: #fff; font-size: 1.2rem; }
.speak-btn:hover { background: var(--blue); border-color: var(--blue); color: #fff; }
.speak-btn.speaking { background: var(--blue); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(91,162,255,0.4); } 50% { box-shadow: 0 0 0 12px rgba(91,162,255,0); } }

.answer-list { display: grid; gap: 10px; }

.answer-btn {
  display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 12px;
  border: var(--panel-border); border-radius: var(--radius); background: var(--panel);
  padding: 10px 16px; text-align: left; min-height: 56px; font-size: 1rem; font-weight: 700;
}
.answer-btn:hover:not(:disabled):not(.correct):not(.wrong) { border-color: var(--blue); background: #f0f7ff; }
.answer-btn .mark { width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; background: #f1f5f9; color: var(--blue); font-weight: 800; font-size: 1.1rem; }
.answer-btn.selected { border-color: var(--blue); background: #f0f7ff; }
.answer-btn.selected .mark { background: var(--blue); color: #fff; }
.answer-btn.correct { border-color: var(--green); background: #f0fdf4; color: var(--green); }
.answer-btn.correct .mark { background: var(--green); color: #fff; }
.answer-btn.wrong { border-color: var(--red); background: #fef2f2; color: var(--red); }
.answer-btn.wrong .mark { background: var(--red); color: #fff; }

body.dark .answer-btn { background: #1e293b; border-color: #334155; color: var(--ink); }
body.dark .answer-btn .mark { background: #0f2f4a; color: #93c5fd; }
body.dark .answer-btn:hover:not(:disabled):not(.correct):not(.wrong) { background: #1a3a5c; border-color: var(--blue); }
body.dark .answer-btn.selected { background: #1a3a5c; border-color: var(--blue); color: var(--ink); }
body.dark .answer-btn.selected .mark { background: var(--blue); color: #fff; }
body.dark .answer-btn.correct { background: #0a2d1a; border-color: #22c55e; color: #4ade80; }
body.dark .answer-btn.correct .mark { background: #22c55e; color: #0a2d1a; }
body.dark .answer-btn.wrong { background: #2d0a0a; border-color: #ef4444; color: #f87171; }
body.dark .answer-btn.wrong .mark { background: #ef4444; color: #fff; }

.quiz-source-badge { display: inline-block; margin-top: 6px; font-size: 0.78rem; font-weight: 700; color: var(--muted); background: var(--bg); border: var(--panel-border); border-radius: var(--radius-sm); padding: 2px 8px; }

.feedback-box { display: grid; gap: 12px; }
.feedback-card { border: var(--panel-border); border-radius: var(--radius); padding: 20px; font-weight: 700; display: grid; gap: 12px; }
.feedback-card.correct { border-color: var(--green); background: #f0fdf4; }
.feedback-card.wrong { border-color: var(--red); background: #fef2f2; }
.feedback-card.pending { border-color: var(--yellow); background: #fffdf5; }

.ai-box { border: 2px solid #bcd4fb; border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }

/* ═══ Practice ═══ */

.flashcard { min-height: 260px; border: var(--panel-border); border-radius: var(--radius); padding: 28px; display: grid; place-items: center; }
.flashcard.flipped { border-color: var(--green); background: #f0fdf4; }
.flashcard h3 { font-size: clamp(1.4rem, 3vw, 2.2rem); text-align: center; }

.pair-board { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pair-item { border: var(--panel-border); border-radius: var(--radius); padding: 12px; font-weight: 700; font-size: 0.9rem; min-height: 52px; text-align: left; }
.pair-item.selected { border-color: var(--blue); background: #f0f7ff; }
.pair-item.matched { border-color: var(--green); background: #f0fdf4; opacity: 0.7; }

/* Adventure practice modes: Flashcards + Pairs */
.practice-panel {
  position: relative;
  width: min(1040px, 100%);
  min-height: min(760px, calc(100dvh - 36px));
  color: #f8fbff;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(139,92,246,0.36);
  background:
    linear-gradient(180deg, rgba(5, 9, 27, 0.34), rgba(5, 9, 27, 0.95)),
    radial-gradient(circle at 18% 18%, color-mix(in srgb, var(--realm-color, #8b5cf6) 34%, transparent), transparent 28%),
    var(--realm-image, url("/assets/realms/math-realm.png")) center / cover no-repeat,
    #08142d;
  box-shadow: 0 36px 110px rgba(0,0,0,0.58), inset 0 1px 0 rgba(255,255,255,0.1);
}
.practice-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4,8,23,0.86), rgba(4,8,23,0.56) 52%, rgba(4,8,23,0.9)),
    radial-gradient(circle at 80% 20%, rgba(255,208,91,0.14), transparent 22%);
}
.practice-panel > * { position: relative; z-index: 1; }
.practice-head {
  border-color: rgba(255,255,255,0.14);
}
.practice-head h2,
.practice-head .eyebrow {
  color: #fff;
  text-shadow: 0 2px 14px rgba(0,0,0,0.5);
}
.practice-head h2 {
  font-size: clamp(1.15rem, 2vw, 1.55rem);
}
.practice-panel .btn-icon {
  color: #edf4ff;
  background: rgba(8, 18, 44, 0.72);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 18px rgba(91,162,255,0.14);
}
.practice-panel .btn-icon:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--realm-color, #8b5cf6), #6d5dfc);
  border-color: rgba(255,255,255,0.28);
}
.practice-scroll {
  display: grid;
  align-content: start;
  gap: 18px;
  padding-right: 4px;
}
.practice-intro {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 6% 50%, color-mix(in srgb, var(--realm-color, #8b5cf6) 20%, transparent), transparent 24%),
    rgba(8,18,44,0.72);
  border: 1px solid rgba(255,255,255,0.16);
  color: #eaf2ff;
  font-weight: 850;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.practice-mode-badge {
  display: inline-grid;
  place-items: center;
  min-height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--realm-color, #8b5cf6), #6d5dfc);
  box-shadow: 0 0 18px color-mix(in srgb, var(--realm-color, #8b5cf6) 38%, transparent);
  font-weight: 900;
}
.practice-intro strong {
  color: #ffd07a;
  font-size: 1.05rem;
  font-weight: 900;
}
.practice-intro span:last-child {
  color: #eaf2ff;
  line-height: 1.35;
}
.adventure-flashcard {
  position: relative;
  min-height: 360px;
  padding: clamp(24px, 4vw, 46px);
  border-radius: 26px;
  color: #2c1d12;
  border: 1px solid rgba(92, 54, 24, 0.45);
  background:
    radial-gradient(circle at 20% 12%, rgba(255,255,255,0.38), transparent 24%),
    linear-gradient(135deg, #f6ddb0, #e2bd7f);
  box-shadow: 0 18px 38px rgba(0,0,0,0.34), inset 0 0 0 2px rgba(255,255,255,0.18);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.adventure-flashcard::after {
  content: "Kliknij, aby odwrócić";
  position: absolute;
  right: 22px;
  bottom: 18px;
  padding: 6px 10px;
  border-radius: 999px;
  color: rgba(64, 39, 18, 0.76);
  background: rgba(255,255,255,0.26);
  border: 1px solid rgba(92,54,24,0.16);
  font-size: 0.78rem;
  font-weight: 900;
}
.adventure-flashcard:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 48px rgba(0,0,0,0.4), 0 0 26px rgba(255,208,91,0.18), inset 0 0 0 2px rgba(255,255,255,0.24);
}
.adventure-flashcard.flipped {
  color: #063820;
  border-color: rgba(72,212,138,0.72);
  background: linear-gradient(135deg, #d9ffe9, #9af0bf);
  box-shadow: 0 18px 38px rgba(0,0,0,0.34), 0 0 32px rgba(72,212,138,0.28);
}
.adventure-flashcard.flipped::after {
  content: "Kliknij, aby wrócić";
  color: rgba(6,56,32,0.76);
  border-color: rgba(6,56,32,0.16);
}
.adventure-flashcard .eyebrow {
  color: #6b4520;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}
.adventure-flashcard.flipped .eyebrow {
  color: #0f5d39;
}
.adventure-flashcard h3 {
  max-width: 860px;
  color: inherit;
  font-size: clamp(1.45rem, 2.4vw, 2.25rem);
  line-height: 1.28;
}
.adventure-flashcard small {
  display: block;
  max-width: 760px;
  margin-top: 18px;
  color: rgba(64,39,18,0.68);
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
}
.adventure-flashcard.flipped small { color: rgba(6,56,32,0.72); }
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 2px;
}
.practice-actions .btn-ghost,
.practice-actions .btn-primary {
  min-height: 48px;
  border-radius: 16px;
  font-weight: 900;
}
.practice-panel .pair-board {
  gap: 20px;
  align-items: start;
}
.practice-panel .pair-board .stack {
  display: grid;
  gap: 12px;
  align-content: start;
}
.practice-panel .pair-stack {
  padding: 14px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.025)),
    rgba(7, 16, 38, 0.64);
  border: 1px solid rgba(255,255,255,0.13);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.practice-panel .pair-stack h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  color: #f8fbff;
  font-size: 0.95rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.practice-panel .pair-stack h3::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--realm-color, #8b5cf6);
  box-shadow: 0 0 14px color-mix(in srgb, var(--realm-color, #8b5cf6) 50%, transparent);
}
.practice-panel .pair-item {
  min-height: 74px;
  padding: 15px 17px;
  border-radius: 18px;
  color: #241509;
  background: linear-gradient(135deg, #f7e1b6, #e8ca8e);
  border: 1px solid rgba(92, 54, 24, 0.42);
  box-shadow: 0 12px 26px rgba(0,0,0,0.24), inset 0 0 0 2px rgba(255,255,255,0.14);
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.42;
  opacity: 1;
  text-align: left;
  overflow-wrap: anywhere;
  transition: transform 0.16s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.practice-panel .pair-item:disabled:not(.matched) {
  opacity: 1;
}
.practice-panel .pair-item:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #ffd07a;
  box-shadow: 0 16px 30px rgba(0,0,0,0.3), 0 0 20px rgba(255,208,91,0.18);
}
.practice-panel .pair-item.selected {
  border-color: #48d48a;
  background: linear-gradient(135deg, #f8e2b8, #e6c785);
  box-shadow: 0 0 0 3px rgba(72,212,138,0.24), 0 0 26px rgba(72,212,138,0.28);
}
.practice-panel .pair-item.matched {
  color: #064e3b;
  border-color: #48d48a;
  background: linear-gradient(135deg, #d9ffe9, #9af0bf);
  opacity: 0.9;
}

/* ═══ Match & Order ═══ */

.match-board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-item { border: var(--panel-border); border-radius: var(--radius); padding: 10px 14px; font-weight: 700; text-align: left; min-height: 48px; }
.match-item.selected { border-color: var(--blue); background: #f0f7ff; }
.match-item.matched { border-color: var(--green); }
.match-item.correct { border-color: var(--green); background: #f0fdf4; }
.match-item.wrong { border-color: var(--red); background: #fef2f2; }

.order-board { display: grid; gap: 8px; }
.order-chip { border: var(--panel-border); border-radius: var(--radius-sm); padding: 8px 14px; font-weight: 700; }
.order-row { display: flex; align-items: center; gap: 8px; }
.order-row.correct { border-color: var(--green); }
.order-row.wrong { border-color: var(--red); }

/* ═══ Tables ═══ */

table { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; font-weight: 800; letter-spacing: 0.04em; padding: 8px 10px; }
td { background: var(--panel); padding: 12px 10px; }
td:first-child { border-radius: var(--radius) 0 0 var(--radius); border-left: 2px solid var(--line); }
td:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-right: 2px solid var(--line); }
td { border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); }

.status-badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 8px; font-weight: 800; font-size: 0.8rem; }
.status-done { background: #e6f9f0; color: var(--green); }
.status-pending { background: #fff8e6; color: #d97706; }

/* ═══ Rewards ═══ */

.reward-screen {
  color: #f8fbff;
  position: relative;
  isolation: isolate;
}
.reward-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 76% 24%, rgba(255,208,91,0.14), transparent 16%),
    radial-gradient(circle at 18% 72%, rgba(72,212,138,0.12), transparent 22%),
    linear-gradient(180deg, rgba(3,7,22,0.16), rgba(3,7,22,0.52));
}

.reward-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.reward-player-panel {
  display: grid;
  gap: 14px;
}
.reward-side-nav {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 24px;
  background: rgba(8, 18, 44, 0.66);
  border: 1px solid rgba(150,190,255,0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.reward-side-nav button {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: 14px;
  color: #d8e4ff;
  background: transparent;
  font-weight: 900;
  text-align: left;
}
.reward-side-nav button span {
  width: 22px;
  display: inline-grid;
  place-items: center;
  color: #aebfe4;
}
.reward-side-nav button:hover,
.reward-side-nav button.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(91,162,255,0.82), rgba(109,93,252,0.76));
  box-shadow: 0 0 22px rgba(91,162,255,0.22);
}
.reward-side-nav button:hover span,
.reward-side-nav button.active span {
  color: #fff;
}

.student-room-card {
  min-height: 124px;
  display: grid;
  align-content: end;
  gap: 4px;
  padding: 16px;
  border-radius: 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background:
    radial-gradient(ellipse at 75% 30%, rgba(255,180,90,0.28) 0%, transparent 55%),
    radial-gradient(ellipse at 25% 85%, rgba(255,120,60,0.18) 0%, transparent 50%),
    linear-gradient(135deg, #3a2855 0%, #2a1d3f 60%, #1d1430 100%);
  border: 1px solid rgba(255,180,90,0.28);
  box-shadow: 0 18px 44px rgba(0,0,0,0.32), inset 0 1px 0 rgba(255,220,180,0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.student-room-card::before {
  content: "";
  position: absolute;
  top: 14px; right: 16px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255,210,140,0.85) 0%, rgba(255,170,90,0.4) 40%, transparent 70%);
  filter: blur(1px);
}
.student-room-card::after {
  content: "🏠";
  position: absolute;
  top: 12px; left: 14px;
  font-size: 1.1rem;
  opacity: 0.62;
}
.student-room-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 52px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,220,180,0.18);
}
.student-room-card strong { font-size: 0.95rem; }
.student-room-card span { color: #f5e3c8; font-weight: 700; font-size: 0.78rem; }

.sidebar-role-card { gap: 8px; }
.sidebar-role-card .sidebar-avatar.role-teacher { background: linear-gradient(135deg, #ff9f5b, #f472b6); }
.sidebar-role-card .sidebar-avatar.role-parent  { background: linear-gradient(135deg, #48d48a, #5ba2ff); }
.sidebar-role-card .sidebar-avatar.role-admin   { background: linear-gradient(135deg, #f43f5e, #8b5cf6); }

.sidebar-context-chip {
  background: rgba(91,162,255,0.1);
  border: 1px solid rgba(91,162,255,0.22);
  border-radius: 14px;
  padding: 10px 12px;
  display: grid; gap: 2px;
  text-align: left;
  margin-top: 2px;
}
.sidebar-context-chip strong { color: #fff; font-size: 1rem; font-weight: 900; }
.sidebar-context-chip .sidebar-grade { font-size: 0.78rem; }

.sidebar-teacher-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(150,190,255,0.18);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 2px;
}

.sidebar-controls {
  display: grid; gap: 8px;
}
.sidebar-controls .a11y-row {
  display: flex; gap: 6px;
}
.sidebar-logout {
  width: 100%; font-size: 0.82rem; padding: 8px 16px;
  border: 1px solid rgba(150,190,255,0.2);
  border-radius: 12px; color: rgba(180,200,255,0.7);
}
.sidebar-logout:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* Logo as a home button */
.logo-wrap:hover { opacity: 0.88; transform: translateY(-1px); }

/* "Skarbiec / Nagrody" entry in the left hub (replaces the removed top tab) */
.sidebar-treasure-btn {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 76px;
  padding: 12px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 208, 120, 0.48);
  background:
    radial-gradient(circle at 82% 25%, rgba(255,208,91,0.32), transparent 28%),
    linear-gradient(135deg, rgba(139, 92, 246, 0.38), rgba(255, 180, 90, 0.24)),
    rgba(10, 22, 54, 0.72);
  color: #fff;
  font-weight: 900;
  font-size: 0.98rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0,0,0,0.32), 0 0 26px rgba(255,208,91,0.12), inset 0 1px 0 rgba(255,255,255,0.14);
  transition: transform 0.15s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.sidebar-treasure-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0,0,0,0.36), inset 0 1px 0 rgba(255,255,255,0.2); }
.sidebar-treasure-btn.active {
  border-color: rgba(255, 208, 120, 0.85);
  box-shadow: 0 0 0 2px rgba(255, 208, 120, 0.4), 0 10px 24px rgba(0,0,0,0.34);
}
.sidebar-treasure-btn .treasure-btn-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  display: grid; place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background: radial-gradient(circle at 35% 30%, #ffe0a0, #f0a040);
  box-shadow: 0 2px 12px rgba(0,0,0,0.34), 0 0 20px rgba(255,208,91,0.22);
}
.treasure-btn-icon img,
.treasure-btn-coin img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.treasure-btn-text {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: left;
}
.treasure-btn-text strong {
  color: #fff;
  font-size: 1.06rem;
  line-height: 1.1;
}
.treasure-btn-text small {
  color: #ffe7a8;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.15;
}
.treasure-btn-coin {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  filter: drop-shadow(0 0 14px rgba(255,208,91,0.32));
}

/* "Back to map" button on the rewards screen (student) */
.reward-back-btn {
  justify-self: start;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #dbe8ff;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s ease;
}
.reward-back-btn:hover { background: rgba(255,255,255,0.16); }

.reward-main {
  display: grid;
  gap: 16px;
}

.reward-hero,
.reward-card,
.reward-collection-panel,
.reward-league-card,
.reward-shop-panel,
.recent-unlocks-panel {
  border: 1px solid rgba(150, 190, 255, 0.2);
  background: rgba(8, 18, 44, 0.72);
  box-shadow: 0 20px 54px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
}
.reward-hero {
  position: relative;
  display: grid;
  grid-template-columns: 180px minmax(330px, 1fr) minmax(220px, 290px);
  gap: 24px;
  align-items: center;
  min-height: 220px;
  padding: 26px 30px;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 72%, rgba(255,208,91,0.28), transparent 18%),
    radial-gradient(circle at 18% 20%, rgba(139,92,246,0.22), transparent 28%),
    linear-gradient(90deg, rgba(5,10,27,0.84), rgba(5,10,27,0.34) 48%, rgba(5,10,27,0.86)),
    url("/assets/ui/adventure-map-bg.png") center / cover no-repeat,
    linear-gradient(135deg, rgba(8,18,44,0.86), rgba(5,11,28,0.94));
}
.reward-hero h2 {
  color: #fff;
  max-width: 520px;
  font-size: clamp(2.15rem, 3.4vw, 3rem);
  line-height: 1.08;
  text-shadow: 0 0 28px rgba(255,208,91,0.2);
}
.reward-hero p:not(.eyebrow) { color: #cbd9ff; font-weight: 800; max-width: 560px; }
.reward-owl-scene {
  position: relative;
  min-height: 170px;
  display: grid;
  place-items: center;
}
.reward-owl {
  width: 158px;
  height: 158px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #f8eed8, #d9c8a8);
  border: 3px solid rgba(255,208,91,0.5);
  box-shadow: 0 22px 28px rgba(0,0,0,0.42), 0 0 36px rgba(255,208,91,0.32);
  animation: owlFloat 4s ease-in-out infinite;
}
.reward-owl img {
  width: 110%;
  height: 110%;
  object-fit: cover;
  object-position: 50% 32%;
}
.reward-chest {
  position: absolute;
  right: 22px;
  bottom: 10px;
  color: #ffd05b;
  font-size: 3.8rem;
  filter: drop-shadow(0 0 18px rgba(255,208,91,0.42));
}
.reward-owl-scene::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 8px;
  bottom: 6px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,208,91,0.38), transparent 68%);
  filter: blur(4px);
}
.reward-wallet {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.13);
}
.reward-wallet span,
.reward-wallet small { color: #d8e4ff; font-weight: 900; }
.reward-wallet strong { display: flex; gap: 8px; align-items: center; color: #fff; font-size: 1.35rem; }
.reward-wallet .crystal-line { color: #d8b4fe; font-size: 1rem; }

.reward-content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
/* Top row: badges + league side by side */
.reward-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.reward-shop-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 26px;
}
.reward-section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-top: 8px;
  min-width: 0;
}
.reward-section-head h3 { color: #fff; font-size: 1.35rem; }
.reward-section-head > div {
  min-width: 0;
}
.reward-section-head span {
  color: #cbd9ff;
  font-weight: 900;
  flex: 0 0 auto;
}

.reward-filter-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.reward-filter-row::-webkit-scrollbar { display: none; }
.reward-filter-row button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  color: #dfeaff;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  white-space: nowrap;
  font-weight: 900;
}
.reward-filter-row button.active {
  color: #fff;
  background: linear-gradient(135deg, #6d5dfc, #3b82f6);
  box-shadow: 0 0 20px rgba(91,162,255,0.3);
}

.reward-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.reward-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: 14px 12px;
  border-radius: 18px;
  overflow: hidden;
  min-height: 284px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.reward-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 34%, rgba(255,255,255,0.12), transparent 28%),
    radial-gradient(circle at 50% 32%, rgba(255,208,91,0.18), transparent 36%);
}
.reward-card > * { position: relative; z-index: 1; }
.reward-card.rarity-card-rare { border-color: rgba(72,212,138,0.42); }
.reward-card.rarity-card-epic { border-color: rgba(181,108,255,0.7); box-shadow: 0 20px 54px rgba(0,0,0,0.28), 0 0 30px rgba(181,108,255,0.26), inset 0 1px 0 rgba(255,255,255,0.08); }
.reward-card.rarity-card-common { border-color: rgba(56,189,248,0.46); }
.reward-card.rarity-card-legendary { border-color: rgba(245,158,11,0.68); box-shadow: 0 20px 54px rgba(0,0,0,0.28), 0 0 28px rgba(245,158,11,0.18), inset 0 1px 0 rgba(255,255,255,0.08); }
.reward-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255,208,91,0.58);
  box-shadow: 0 24px 64px rgba(0,0,0,0.34), 0 0 24px rgba(255,208,91,0.18);
}
.reward-state {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #5ba2ff);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}
.reward-state.rarity-rare { background: linear-gradient(135deg, #22c55e, #178f53); }
.reward-state.rarity-epic { background: linear-gradient(135deg, #8b5cf6, #b56cff); }
.reward-state.rarity-common { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.reward-state.rarity-legendary { background: linear-gradient(135deg, #f59e0b, #b45309); }
.reward-art {
  width: min(122px, 100%);
  height: 122px;
  display: grid;
  place-items: center;
  margin-top: 22px;
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,0.18), transparent 28%),
    radial-gradient(circle, rgba(255,208,91,0.2), rgba(139,92,246,0.12) 62%, rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 0 34px rgba(255,208,91,0.18), inset 0 1px 0 rgba(255,255,255,0.1);
}
.reward-art img { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 14px 20px rgba(0,0,0,0.34)); }
.reward-copy { display: grid; gap: 5px; align-self: end; }
.reward-copy h3 {
  min-height: 2.3em;
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reward-cost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #ffd05b; font-weight: 900; }
.reward-card .btn-action {
  width: min(118px, 100%);
  min-height: 38px;
  color: #fff;
  background: linear-gradient(135deg, #5ba2ff, #6d5dfc);
}
.reward-card.owned { border-color: rgba(72,212,138,0.55); }
.reward-card.owned .reward-state { background: linear-gradient(135deg, #48d48a, #2ca96d); }
.reward-card.locked { opacity: 0.72; filter: saturate(0.7); }
.reward-card.locked .reward-state { background: rgba(148,163,184,0.36); }
.reward-card.locked .btn-action {
  background: linear-gradient(135deg, rgba(100,116,139,0.78), rgba(88,80,170,0.72));
}
.reward-empty-state {
  grid-column: 1 / -1;
  min-height: 180px;
}
.reward-collection-panel,
.reward-league-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 26px;
}
.reward-badge-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.reward-badge-strip img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  justify-self: center;
  padding: 7px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,208,91,0.18), transparent 44%),
    rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  opacity: 0.45;
  filter: grayscale(0.7);
}
.reward-badge-strip img.earned {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 20px rgba(255,208,91,0.24);
}
.reward-wide-btn {
  min-height: 42px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #6d5dfc);
  font-weight: 900;
}
.reward-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-items: end;
}
.reward-podium div {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04)),
    radial-gradient(circle at 50% 0%, rgba(255,208,91,0.16), transparent 48%);
  border: 1px solid rgba(255,255,255,0.1);
}
.reward-podium div::before {
  content: "2";
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #94a3b8, #64748b);
  font-weight: 900;
  box-shadow: 0 0 16px rgba(255,255,255,0.18);
}
.reward-podium div:first-child::before { content: "1"; background: linear-gradient(135deg, #ffd05b, #f59e0b); }
.reward-podium div:nth-child(3)::before { content: "3"; background: linear-gradient(135deg, #f59e0b, #92400e); }
.reward-podium div.first {
  background: linear-gradient(180deg, rgba(255,208,91,0.22), rgba(255,255,255,0.06));
  transform: translateY(-8px);
  order: 2;
  box-shadow: 0 0 26px rgba(255,208,91,0.18);
}
.reward-podium div:nth-child(2) { order: 1; }
.reward-podium div:nth-child(3) { order: 3; }
.podium-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(91,162,255,0.16);
  font-size: 2rem;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.18);
}
.podium-avatar img,
.podium-avatar > span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
.podium-avatar img { object-fit: cover; }
.reward-podium strong { color: #fff; }
.reward-podium small { display: flex; gap: 4px; align-items: center; color: #ffd05b; font-weight: 900; }
.reward-rank-list { display: grid; gap: 6px; }
.reward-rank-list div {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.reward-rank-list span { color: #aebfe4; font-weight: 900; }
.reward-rank-list strong { color: #fff; }
.reward-rank-list small { color: #cbd9ff; font-weight: 800; }
.reward-league-card table { color: #f8fbff; }
.reward-league-card th { color: #aebfe4; }
.recent-unlocks-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 26px;
}
.recent-unlocks-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.recent-unlocks-grid div {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
}
.recent-unlocks-grid img { width: 70px; height: 70px; object-fit: contain; }
.recent-unlocks-grid strong { color: #fff; text-align: center; }
.recent-unlocks-grid span { color: #ffd05b; font-weight: 900; }
.recent-unlocks-grid strong,
.recent-unlocks-grid span {
  overflow-wrap: anywhere;
}
.reward-scroll-note {
  padding: 12px 20px;
  border-radius: 16px;
  color: #4a2d0b;
  text-align: center;
  font-weight: 900;
  background: linear-gradient(135deg, #e8c68a, #f5deb1);
  border: 1px solid rgba(92,54,24,0.28);
}

@media (max-width: 820px) {
  .reward-layout {
    grid-template-columns: 1fr;
  }
  .reward-player-panel {
    display: none;
  }
  .reward-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 22px;
    border-radius: 24px;
  }
  .reward-wallet {
    width: 100%;
  }
  .reward-owl-scene {
    display: none;
  }
  .reward-content-grid {
    grid-template-columns: 1fr;
  }
  .reward-top-row {
    grid-template-columns: 1fr;
  }
  .reward-section-head {
    align-items: start;
    flex-direction: column;
    gap: 6px;
  }
  .reward-section-head span {
    max-width: 100%;
    white-space: normal;
  }
  .reward-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  .reward-collection-panel,
  .reward-league-card {
    padding: 16px;
    border-radius: 22px;
  }
  .reward-badge-strip {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
  }
  .reward-badge-strip img {
    width: 48px;
    height: 48px;
  }
  .recent-unlocks-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ═══ Misc ═══ */

.version-badge { position: fixed; bottom: 12px; right: 12px; color: var(--muted); font-size: 0.75rem; font-weight: 700; opacity: 0.6; z-index: var(--z-base); }

/* ═══ Theory / Learn view ═══ */
.theory-section {
  background: linear-gradient(135deg, #fff, #fef9f0);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 16px;
}
body.dark .theory-section { background: linear-gradient(135deg, #1e293b, #0f2f4a); border-color: #3b5998; }
.theory-section h3 { color: var(--orange); font-size: 1.3em; }
body.dark .theory-section h3 { color: #7dd3fc; }
.theory-section p { line-height: 1.7; font-weight: 600; }
.theory-section .example {
  background: var(--panel);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: 800;
}
body.dark .theory-section .example { background: #0f2f4a; border-color: #3b5998; }

.theory-hero-art {
  width: min(100%, 360px);
  aspect-ratio: 2 / 1;
  object-fit: contain;
  justify-self: center;
  background: var(--panel);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 10px;
}
body.dark .theory-hero-art { background: #0f2f4a; border-color: #3b5998; }
.theory-section ol,
.theory-section ul {
  display: grid;
  gap: 10px;
  padding-left: 22px;
  line-height: 1.65;
  font-weight: 650;
}
.learning-explain-list {
  list-style: none;
  padding-left: 0;
}
.learning-explain-list li {
  background: var(--panel);
  border: var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
body.dark .learning-explain-list li { background: #0f2f4a; border-color: #3b5998; }
.learning-explain-list strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}
body.dark .learning-explain-list strong { color: #e0f2fe; }

.theory-lead {
  display: block;
  background: linear-gradient(135deg, #eefbf3, #eaf3ff);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  line-height: 1.75;
  font-weight: 750;
}
.theory-lead:has(.theory-hero-art) {
  display: grid;
  grid-template-columns: minmax(180px, 320px) 1fr;
  gap: 18px;
  align-items: center;
}
.theory-lead > div { min-width: 0; }
body.dark .theory-lead {
  background: linear-gradient(135deg, #0f2f4a, #102a43);
  border-color: #3b5998;
}
.theory-term-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.theory-term-cloud span {
  background: #eef6ff;
  border: 1px solid rgba(35, 104, 209, 0.22);
  color: #1e3a8a;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.9rem;
  font-weight: 800;
}
body.dark .theory-term-cloud span {
  background: #123554;
  border-color: #3b5998;
  color: #dbeafe;
}
.theory-story {
  background: linear-gradient(135deg, #eefbf3, #eaf3ff);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
body.dark .theory-story {
  background: linear-gradient(135deg, #0f2f4a, #102a43);
  border-color: #3b5998;
}

.theory-summary-grid {
  display: grid;
  gap: 14px;
  margin-top: 10px;
}
.theory-summary-block {
  background: var(--panel);
  border: var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  padding: 16px 18px;
}
.theory-summary-block h4 {
  color: var(--blue);
  font-size: 1rem;
  font-weight: 900;
  margin-bottom: 10px;
}
.theory-summary-block ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding-left: 0;
  list-style: none;
}
.theory-summary-block li {
  border: 1px solid rgba(35, 104, 209, 0.18);
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 5%, var(--panel));
  color: var(--ink);
  padding: 7px 11px;
  font-weight: 900;
  line-height: 1.2;
}
body.dark .theory-summary-block {
  background: #102a43;
  border-color: #3b5998;
}
body.dark .theory-summary-block h4 { color: #7dd3fc; }
body.dark .theory-summary-block li {
  background: #0f2f4a;
  border-color: #3b5998;
}

.theory-summary-editor h3 { margin-bottom: 14px; }
.theory-summary-panels {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  gap: 14px;
  align-items: start;
}
.theory-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.theory-summary-head h4 { margin: 0; }
.theory-summary-head span { color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.summary-term-list { display: grid; gap: 8px; }
.summary-term-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(35, 104, 209, 0.18);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--blue) 4%, var(--panel));
  padding: 6px;
}
.summary-term-row.selected {
  border-color: rgba(35, 104, 209, 0.58);
  background: color-mix(in srgb, var(--blue) 12%, var(--panel));
  box-shadow: 0 0 0 2px rgba(35, 104, 209, 0.10);
}
.summary-term-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 900;
  line-height: 1.25;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
}
.summary-term-btn:hover { background: rgba(35, 104, 209, 0.08); }
.summary-term-row.selected .summary-term-btn {
  color: var(--blue);
  font-weight: 1000;
}
.summary-term-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn-mini.danger { color: var(--red); border-color: rgba(220, 38, 38, 0.28); }
.summary-term-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}
.summary-term-form input { min-height: 42px; }
.term-explanation-panel { min-height: 220px; }
.term-explanation-text {
  line-height: 1.7;
  font-weight: 700;
  font-size: 1rem;
}
.term-explanation-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.term-explanation-meta span {
  border: 1px solid rgba(35, 104, 209, 0.18);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  padding: 5px 9px;
}
.term-explanation-edit {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.term-explanation-edit textarea {
  min-height: 120px;
  resize: vertical;
}
body.dark .summary-term-row {
  background: #0f2f4a;
  border-color: #3b5998;
}
body.dark .summary-term-row.selected {
  background: #123554;
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.14);
}
body.dark .summary-term-btn { color: #e5eefb; }
body.dark .summary-term-btn:hover { background: rgba(125, 211, 252, 0.08); }
body.dark .summary-term-row.selected .summary-term-btn { color: #7dd3fc; }
@media (max-width: 760px) {
  .theory-summary-panels { grid-template-columns: 1fr; }
  .summary-term-row { grid-template-columns: 1fr; }
  .summary-term-actions { justify-content: flex-start; }
  .summary-term-form { grid-template-columns: 1fr; }
}
.learning-explain-list li {
  position: relative;
  overflow: hidden;
}
.learning-explain-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #1f73e8, #1ca66a);
}
.theory-tip {
  background: #fff8e6;
  border: var(--panel-border);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-weight: 700;
}
body.dark .theory-tip { background: #0f2f4a; border-color: #3b5998; }

/* Mathematical fraction notation
   .frac wraps a numerator (.fnum) and denominator (.fden).
   vertical-align: middle puts the fraction bar at the surrounding
   text's x-height midline, so adjacent text (e.g. the whole-number
   part of a mixed number "2 1/3") appears at the fraction-bar level
   and stays in its normal font size. */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  vertical-align: middle;
  font-size: 0.78em;
  line-height: 1.05;
  margin: 0 0.18em;
  position: relative;
  top: -0.05em;
}
.fnum {
  border-bottom: 1.6px solid currentColor;
  padding: 0 0.35em 0.06em;
  text-align: center;
  min-width: 1ch;
}
.fden {
  padding: 0.06em 0.35em 0;
  text-align: center;
  min-width: 1ch;
}
/* Mixed numbers: a whole-number part followed by a fraction should
   keep the whole part at normal size and slightly tighten the space. */
.mixnum {
  display: inline-block;
  vertical-align: middle;
}
.mixnum .frac {
  margin-left: 0.1em;
}
.theory-diagram {
  max-width: 100%;
  border-radius: var(--radius);
  border: var(--panel-border);
  background: #fff;
  padding: 12px;
  display: grid;
  place-items: center;
  gap: 8px;
  font-weight: 800;
}

.motto { font-size: 0.85rem; color: var(--muted); font-style: italic; }

.chart-row { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 10px; font-weight: 700; font-size: 0.9rem; }

/* ═══ Responsive: tablet & phone ═══ */

@media (max-width: 1100px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .hero { grid-template-columns: 1fr; padding: 20px 24px; }
  .hero-art { display: none; }
  .topbar { gap: 12px; }
  .logo-svg { width: 56px; height: 56px; }
  .logo-text h1 { font-size: 1.9rem; }
  .user-pill { padding: 5px 9px; gap: 6px; }
  .user-pill > span { font-size: 0.86rem; }
  .hud-stat { padding: 0 10px; }
  .mode-chip { font-size: 0.72rem; padding: 3px 8px; }
  .stat-row { flex-wrap: wrap; }
}

@media (max-width: 820px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 16px 12px 6px; flex-direction: column; align-items: stretch; }
  .logo-wrap { justify-content: center; }
  .user-pill {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    border-radius: 20px;
  }
  .hud-stat { min-height: 36px; border-right: 0; padding: 0 8px; }
  .hud-stat span { width: 22px; height: 22px; }
  .a11y-row,
  .user-pill .mode-chip,
  .user-pill .btn-ghost,
  .user-pill .user-avatar-circle { display: none; }
  .tabs {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: var(--z-sticky);
    width: auto;
    max-width: none;
    justify-content: space-around;
    padding: 6px;
    gap: 4px;
    border-radius: 22px;
  }
  .shell { padding: 0 12px 92px; }
  .modal-panel { padding: 20px; }
  .tab-chip { flex: 1 1 0; padding: 8px 10px; font-size: 0.78rem; gap: 6px; }
  .tab-icon { width: 22px; height: 22px; }
  .badge-grid { grid-template-columns: 1fr 1fr; }
  table { font-size: 0.8rem; }
  .student-report-card .grid-2 { grid-template-columns: 1fr; }
  .theory-lead { grid-template-columns: 1fr; }
  .theory-hero-art { width: min(100%, 300px); }
}

@media (max-width: 600px) {
  .badge-grid { grid-template-columns: 1fr 1fr; }
  .theory-summary-panels { grid-template-columns: 1fr; }
  .theory-lead:has(.theory-hero-art) { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .profile-grid, .badge-grid { grid-template-columns: 1fr; }
  /* Keep both pair columns side by side (matching needs prompt + answer in
     view at once); just make the cards compact enough to fit a phone. */
  .pair-board { grid-template-columns: 1fr 1fr; gap: 8px; }
  .practice-panel .pair-board { gap: 10px; }
  .practice-panel .pair-stack { padding: 8px; border-radius: 16px; }
  .practice-panel .pair-stack h3 { font-size: 0.74rem; gap: 6px; }
  .practice-panel .pair-item {
    min-height: 52px;
    padding: 9px 10px;
    font-size: 0.8rem;
    line-height: 1.3;
    border-radius: 13px;
  }
  .logo-svg { width: 48px; height: 48px; }
  .logo-text h1 { font-size: 1.6rem; }
  .logo-text .eyebrow { font-size: 0.66rem; }
  .hud-stat strong { font-size: 0.82rem; }
  .hud-stat small { display: none; }
  .tab-chip { min-height: 48px; flex-direction: column; padding: 6px 5px; font-size: 0.68rem; line-height: 1.1; }
}

/* Landscape phone / tablet – limit modal height and padding */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-overlay { padding: 6px; }
  .modal-panel { padding: 12px; gap: 10px; border-radius: var(--radius); max-height: 98vh; }
  .modal-head { padding-bottom: 10px; }
  .modal-foot { padding-top: 10px; }
  .modal-head h2 { font-size: 1.1rem; }
}

/* ═══ Visibility Fixes ═══ */
.logo-text h1 { text-shadow: 0 4px 15px rgba(0,0,0,0.7), 0 0 20px rgba(0,0,0,0.4) !important; }
.logo-text .eyebrow { color: #fff !important; text-shadow: 0 2px 5px rgba(0,0,0,0.6) !important; font-weight: 800 !important; }
.user-pill > span { text-shadow: 0 2px 4px rgba(0,0,0,0.5) !important; }
.stat-chip { background: #fff !important; color: #2d3e33 !important; font-weight: 800 !important; box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important; opacity: 1 !important; }
body.dark .stat-chip { background: #1e293b !important; color: #f1f5f9 !important; }
.view-header .eyebrow { color: var(--muted) !important; font-weight: 800 !important; }
.hero .eyebrow { background: var(--blue); color: #fff !important; padding: 2px 8px; border-radius: var(--radius-sm); display: inline-block; margin-bottom: 8px; }

/* ═══ Organized Views Fixes ═══ */
.skill-tag { background: #f0f4f8; border-radius: var(--radius-sm); padding: 6px 10px; font-weight: 700; font-size: 0.8rem; color: var(--ink); border: 1px solid var(--line); }
body.dark .skill-tag { background: #0f2f4a; color: #bae6fd; border-color: #3b5998; }

.pct-badge { background: #e0f2fe; color: #0369a1; padding: 4px 8px; border-radius: var(--radius-sm); font-weight: 800; font-size: 0.85rem; }
body.dark .pct-badge { background: #0c4a6e; color: #7dd3fc; }

.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table-card { padding-bottom: 8px !important; }

tr.highlight td { background: #f0f9ff !important; border-top-color: #bae6fd !important; border-bottom-color: #bae6fd !important; }
body.dark tr.highlight td { background: #075985 !important; border-top-color: #0369a1 !important; border-bottom-color: #0369a1 !important; }

.material-card, .skill-card { transition: transform 0.2s; }
.material-card:hover, .skill-card:hover { transform: translateY(-4px); }

/* Ensure strong contrast for table text in dark mode */
body.dark td { color: #f1f5f9; }
body.dark th { color: #94a3b8; }

/* ═══ Charts & Reports ═══ */
.student-report-card { padding: 24px; }
.report-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: var(--panel-border);
}
.chart-stack { display: grid; gap: 12px; }
.chart-row { display: grid; gap: 6px; }
.report-chart-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; }
.report-chart-row .chart-bar-bg { grid-column: 1 / -1; }
.chart-label { min-width: 0; font-weight: 800; font-size: 0.85rem; line-height: 1.25; }
.chart-label span { display: block; overflow-wrap: anywhere; }
.chart-value { color: var(--muted); font-weight: 800; white-space: nowrap; }
.chart-bar-bg { background: var(--line); height: 10px; border-radius: 999px; border: var(--panel-border); overflow: hidden; }
.chart-bar { height: 100%; border-radius: 5px; transition: width 1s ease-out; }

.student-report-card .grid-2 { align-items: start; }
.report-summary { display: grid; gap: 12px; min-width: 0; }
.report-summary h4 { margin-bottom: 0 !important; }
.wisdom-box { min-width: 0; background: #fdfcf8; border: var(--panel-border); padding: 16px; border-radius: var(--radius); height: auto; overflow-wrap: anywhere; }
body.dark .wisdom-box { background: #0f2f4a; border-color: #3b5998; }
.wisdom-box p { font-weight: 700; font-size: 0.95rem; }
.wisdom-box strong { overflow-wrap: anywhere; }

.suggest-icon img { width: 40px; height: 40px; object-fit: contain; }

/* ═══ Login ═══ */

.login-wrap {
  min-height: 100dvh;
  max-width: none;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at 72% 20%, rgba(255,208,91,0.16), transparent 18%),
    radial-gradient(circle at 18% 78%, rgba(72,212,138,0.12), transparent 22%),
    linear-gradient(180deg, rgba(3,7,22,0.1), rgba(3,7,22,0.72)),
    url("/background_dark.png") center / cover fixed;
}
.login-wrap .login-card {
  display: grid;
  gap: 18px;
  width: min(980px, 100%);
  padding: 20px;
  border-radius: 30px;
  border: 1px solid rgba(150,190,255,0.28);
  background:
    linear-gradient(145deg, rgba(13, 27, 58, 0.9), rgba(8, 17, 39, 0.84)),
    rgba(9, 18, 42, 0.88);
  box-shadow: 0 30px 90px rgba(0,0,0,0.48), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
}
.login-hero-panel {
  min-height: 240px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  gap: 20px;
  padding: 26px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(90deg, rgba(9, 18, 42, 0.36), rgba(9, 18, 42, 0.78)),
    url("/assets/ui/adventure-map-bg.png") center / cover;
  border: 1px solid rgba(255,255,255,0.14);
}
.login-hero-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 32% 24%, rgba(255,208,91,0.18), transparent 20%);
}
.login-hero-copy,
.login-owl-portrait {
  position: relative;
  z-index: 1;
}
.login-hero-copy {
  display: grid;
  gap: 8px;
}
.login-brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.login-brand-mark {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,244,206,0.98), rgba(245,184,89,0.72) 58%, rgba(91,162,255,0.44)),
    linear-gradient(135deg, rgba(91,162,255,0.5), rgba(109,93,252,0.62));
  border: 3px solid rgba(255,208,91,0.62);
  box-shadow: 0 0 34px rgba(255,208,91,0.24), 0 14px 28px rgba(0,0,0,0.32);
}
.login-brand-mark img {
  width: 120%;
  height: 120%;
  object-fit: cover;
  object-position: 50% 28%;
}
.login-hero-copy h1 {
  color: #fff;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 30px rgba(91,162,255,0.22);
}
.login-hero-copy p:not(.eyebrow) {
  max-width: 430px;
  color: #d8e6ff;
  font-weight: 800;
  font-size: 1.05rem;
}
.login-owl-portrait {
  width: 188px;
  height: 188px;
  justify-self: center;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,244,206,0.96), rgba(245,184,89,0.7) 54%, rgba(109,93,252,0.5));
  border: 4px solid rgba(255,208,91,0.66);
  box-shadow: 0 0 46px rgba(255,208,91,0.34), 0 20px 44px rgba(0,0,0,0.34);
  overflow: hidden;
}
.login-owl-portrait img {
  width: 122%;
  height: 122%;
  object-fit: cover;
  object-position: 50% 28%;
}
.login-message {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  color: #dbe8ff;
  text-align: center;
  font-weight: 900;
}
.login-message .btn-primary {
  margin-top: 6px;
}
.login-error p {
  color: #fecaca;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.profile-btn {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 3px 12px;
  align-items: center;
  min-height: 82px;
  padding: 12px;
  text-align: left;
  border: 1px solid rgba(150,190,255,0.22);
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 12%, rgba(91,162,255,0.18), transparent 34%),
    rgba(14, 28, 60, 0.76);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.profile-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(91,162,255,0.72);
  box-shadow: 0 12px 30px rgba(0,0,0,0.26), 0 0 22px rgba(91,162,255,0.16);
}
.profile-btn.selected {
  border-color: rgba(255,208,91,0.82);
  background:
    radial-gradient(circle at 18% 12%, rgba(255,208,91,0.2), transparent 34%),
    linear-gradient(135deg, rgba(91,162,255,0.46), rgba(109,93,252,0.34));
  box-shadow: 0 0 0 2px rgba(255,208,91,0.14), 0 18px 34px rgba(0,0,0,0.28), 0 0 28px rgba(255,208,91,0.16);
}
.profile-avatar {
  width: 54px; height: 54px; border-radius: 16px;
  display: grid; place-items: center; background: var(--blue);
  color: #fff; font-size: 1.5rem; grid-row: span 2;
  overflow: hidden;
}
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-name {
  min-width: 0;
  color: #fff;
  font-weight: 900;
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.profile-role {
  color: #aebfe4;
  font-weight: 800;
  font-size: 0.8rem;
}

.login-inputs {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(150,190,255,0.22);
  background: rgba(7, 16, 38, 0.72);
}
.login-inputs .field span {
  color: #c9d8f6;
}
.login-inputs input {
  min-height: 48px;
  color: #fff;
  background: rgba(6, 14, 34, 0.86);
  border-color: rgba(150,190,255,0.28);
}
.login-submit {
  width: 100%;
  height: 52px;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(135deg, #5ba2ff, #7c5cff);
  box-shadow: 0 12px 28px rgba(91, 162, 255, 0.28), 0 0 24px rgba(124, 92, 255, 0.18);
}
.login-submit:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(91, 162, 255, 0.34), 0 0 30px rgba(124, 92, 255, 0.24);
}
.login-submit:disabled {
  color: rgba(216, 228, 255, 0.48);
  background: rgba(91, 122, 176, 0.42);
  box-shadow: none;
  cursor: not-allowed;
}
body.dark .login-inputs { background: rgba(7, 16, 38, 0.72); border-color: rgba(150,190,255,0.22); }
body.dark .profile-btn { border-color: rgba(150,190,255,0.22); }
body.dark .profile-btn:hover { border-color: rgba(91,162,255,0.72); }
body.dark .profile-btn.selected { border-color: rgba(255,208,91,0.82); }

@media (max-width: 720px) {
  .stats-hero {
    grid-template-columns: 1fr;
    padding: 22px;
    border-radius: 24px;
    max-width: 100%;
    overflow: hidden;
  }
  .stats-hero .hero-art {
    display: none;
  }
  .stats-hero .hero-content,
  .stats-hero .start-box,
  .stats-level-track,
  .stats-level-track .progress-bar {
    min-width: 0;
    max-width: 100%;
  }
  .stats-hero .hero-content h2 {
    overflow-wrap: anywhere;
  }
  .stats-hero .start-box .btn-primary {
    max-width: 100%;
    min-height: 46px;
    height: auto;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }
  .stats-overview-grid {
    grid-template-columns: 1fr;
  }
  .stats-orb-card {
    min-height: 86px;
  }
  .login-wrap {
    align-items: start;
    padding: 14px;
  }
  .login-wrap .login-card {
    padding: 14px;
    border-radius: 24px;
  }
  .login-hero-panel {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 22px;
  }
  .login-owl-portrait {
    width: 116px;
    height: 116px;
    justify-self: start;
  }
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══ Network View Styles ═══ */
.steps-list { display: grid; gap: 20px; }
.step-item { display: flex; gap: 16px; align-items: flex-start; }
.step-num { 
  width: 32px; height: 32px; border-radius: 50%; 
  background: var(--blue); color: #fff; 
  display: grid; place-items: center; 
  font-weight: 800; flex-shrink: 0; 
}
.ip-chip { 
  background: #f8fafc; border: var(--panel-border); 
  padding: 12px 20px; border-radius: var(--radius); 
  font-size: 1.1rem; color: var(--blue);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
body.dark .ip-chip { background: #1e293b; border-color: #334155; }

/* ═══ UI Polish & Visibility ═══ */
.logo-owl-body { fill: #c89b5c; }
body.dark .logo-owl-body { fill: var(--blue); }

.user-avatar-circle {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: grid; place-items: center;
  font-size: 1.2rem; flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(91,162,255,0.5), 0 4px 12px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.user-avatar-circle:hover { box-shadow: 0 0 0 3px rgba(91,162,255,0.8), 0 4px 16px rgba(0,0,0,0.4); }
.user-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Visibility fixes for Topbar in Light Mode */
.logo-text h1 { color: #fff !important; text-shadow: 0 4px 15px rgba(0,0,0,0.8), 0 0 25px rgba(0,0,0,0.5) !important; }
.logo-text .eyebrow { color: #fff !important; text-shadow: 0 2px 8px rgba(0,0,0,0.7) !important; font-weight: 800 !important; opacity: 1 !important; }
.user-pill > span { color: #fff !important; text-shadow: 0 2px 6px rgba(0,0,0,0.6) !important; }

/* Visibility for Section Headers */
.view-header {
  background: var(--panel);
  padding: 16px 20px;
  border-radius: var(--radius);
  border: var(--panel-border);
  backdrop-filter: blur(4px);
  margin-bottom: 24px;
  box-shadow: var(--panel-shadow);
}
body.dark .view-header {
  background: var(--panel);
  border-color: var(--line);
}
.view-header h2 { text-shadow: none !important; color: var(--ink) !important; }
.view-header .eyebrow { color: var(--blue) !important; font-weight: 800 !important; }

/* Shared shell for teacher/admin utility screens. These views keep the
   existing workflows, but visually sit in the same adventure UI as the map. */
.tool-screen {
  --tool-accent: #7c6cff;
  --tool-accent-2: #38bdf8;
  min-width: 0;
  max-width: 100%;
}
.tool-screen > .view-header {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  display: grid;
  align-content: center;
  padding: 22px 28px 22px 104px;
  border: 1px solid rgba(125, 181, 255, 0.28);
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 208, 91, 0.18), transparent 28%),
    linear-gradient(135deg, rgba(37, 99, 235, 0.22), rgba(124, 58, 237, 0.14) 42%, rgba(8, 18, 42, 0.84)),
    rgba(12, 24, 52, 0.72);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}
.tool-screen > .view-header::before {
  content: "";
  position: absolute;
  left: 28px;
  top: 50%;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  transform: translateY(-50%);
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.9), transparent 12%),
    linear-gradient(135deg, var(--tool-accent-2), var(--tool-accent));
  box-shadow: 0 0 28px rgba(96, 165, 250, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}
.tool-screen > .view-header::after {
  content: "";
  position: absolute;
  inset: auto 24px 18px auto;
  width: 170px;
  height: 86px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.18), transparent 68%);
  pointer-events: none;
}
.tool-screen > .view-header .eyebrow {
  color: #8fc8ff !important;
  letter-spacing: 0.11em;
}
.tool-screen > .view-header h2 {
  color: #f8fbff !important;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.05;
  max-width: 760px;
}
.tool-screen > .card,
.tool-screen form.card,
.tool-screen .grid-2 > .card,
.tool-screen .grid-2 > form.card,
.tool-screen .subjects-stack > .card {
  border-color: rgba(148, 180, 255, 0.34);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(10, 23, 52, 0.82)),
    var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.tool-screen .card > h3:first-child,
.tool-screen form.card > h3:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f8fbff;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.tool-screen .card > h3:first-child::before,
.tool-screen form.card > h3:first-child::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.58);
}
.tool-screen input,
.tool-screen select,
.tool-screen textarea,
.tool-screen .users-search {
  border-color: rgba(148, 180, 255, 0.32);
  background: rgba(8, 18, 42, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tool-screen input,
.tool-screen select,
.tool-screen textarea {
  min-height: 44px;
}
.tool-screen textarea {
  line-height: 1.5;
}
.tool-screen input::placeholder,
.tool-screen textarea::placeholder {
  color: rgba(203, 213, 225, 0.48);
}
.tool-screen input:focus,
.tool-screen select:focus,
.tool-screen textarea:focus {
  border-color: rgba(96, 165, 250, 0.8);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.tool-screen .field span {
  color: #9fb2d8;
  letter-spacing: 0.01em;
}
.tool-screen p,
.tool-screen li,
.tool-screen td,
.tool-screen blockquote {
  color: #dbe7ff;
}
.tool-screen small,
.tool-screen .suggest-info span,
.tool-screen .review-answer,
.tool-screen [style*="color:var(--muted)"],
.tool-screen [style*="color: var(--muted)"] {
  color: #9fb2d8 !important;
}
.tool-screen strong {
  color: #f8fbff;
}
.tool-screen .card-sm,
.tool-screen .suggest-card,
.tool-screen .review-answer,
.tool-screen .ai-explanation,
.tool-screen .preview-question-card {
  border-color: rgba(148, 180, 255, 0.24);
  background:
    linear-gradient(145deg, rgba(20, 34, 68, 0.82), rgba(9, 18, 42, 0.7)),
    rgba(12, 24, 52, 0.72);
}
.tool-screen .card-sm {
  display: grid;
  gap: 10px;
}
.tool-screen .table-wrap {
  border-radius: 18px;
}
.tool-screen table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}
.tool-screen th,
.tool-screen td {
  text-align: left;
  vertical-align: middle;
}
.tool-screen td {
  background: rgba(15, 27, 58, 0.72);
  border-top: 1px solid rgba(148, 180, 255, 0.18);
  border-bottom: 1px solid rgba(148, 180, 255, 0.18);
  line-height: 1.35;
  overflow-wrap: break-word;
}
.tool-screen td:first-child {
  border-left: 1px solid rgba(148, 180, 255, 0.18);
  border-radius: 16px 0 0 16px;
}
.tool-screen td:last-child {
  border-right: 1px solid rgba(148, 180, 255, 0.18);
  border-radius: 0 16px 16px 0;
}
.tool-screen th {
  color: #9fb2d8;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  text-transform: uppercase;
}
.tool-screen .btn-primary {
  background: linear-gradient(135deg, #60a5fa, #6d5dfc);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.24);
}
.tool-screen .btn-ghost {
  border-color: rgba(148, 180, 255, 0.34);
  background: rgba(12, 24, 52, 0.62);
  color: #eaf2ff;
}
.tool-screen .btn-ghost:hover {
  border-color: rgba(96, 165, 250, 0.72);
  background: rgba(37, 99, 235, 0.18);
}
.tool-screen .stat-chip {
  min-height: 30px;
  align-items: center;
}
.tool-screen .check-card {
  border-color: rgba(96, 165, 250, 0.34);
  background: rgba(10, 36, 68, 0.72);
}
.tool-screen .check-card strong {
  color: #f8fbff;
}
.tool-screen .check-card small {
  color: #9fb2d8;
}
.tool-screen .table-section-label {
  margin-bottom: 4px;
  color: #8fc8ff;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
@media (max-width: 820px) {
  .tool-screen {
    overflow-x: hidden;
    padding-bottom: 84px;
  }
  .tool-screen,
  .tool-screen .grid-2,
  .tool-screen .subjects-stack,
  .tool-screen .card,
  .tool-screen form.card,
  .tool-screen .student-report-card,
  .tool-screen .report-summary,
  .tool-screen .wisdom-box,
  .tool-screen .chart-stack,
  .tool-screen .chart-row {
    min-width: 0;
    max-width: 100%;
  }
  .tool-screen > .view-header {
    min-height: 96px;
    padding: 20px 18px 20px 82px;
    border-radius: 20px;
  }
  .tool-screen > .view-header::before {
    left: 18px;
    width: 46px;
    height: 46px;
  }
  .tool-screen .table-wrap {
    max-width: 100%;
    margin-inline: 0;
    padding-inline: 0;
    overflow-x: auto;
  }
  .tool-screen table {
    min-width: 520px;
  }
  .tool-screen .report-chart-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

/* Stat chips visibility */
.stat-chip { background: #fff !important; color: #2d3e33 !important; border: 2px solid var(--blue) !important; }
body.dark .stat-chip { background: #1e293b !important; color: #f1f5f9 !important; border-color: var(--line) !important; }

.notice {
  padding: 16px;
  border-radius: var(--radius);
  border: var(--panel-border);
  font-weight: 800;
}
.notice-success { background: #f0fdf4; border-color: var(--green); color: var(--green); }
.notice-error { background: #fef2f2; border-color: var(--red); color: var(--red); }
body.dark .notice-success { background: #0a2e1a; color: #7ee2a8; }
body.dark .notice-error { background: #2e0a0a; color: #ff9aa7; }

.goal-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}


.report-stat-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.coin-value,
.coin-inline,
.reward-cost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
  vertical-align: middle;
}
.coin-icon {
  width: 1.05em;
  height: 1.05em;
  min-width: 1.05em;
  display: inline-block;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff7b0 0 18%, #facc15 19% 52%, #d97706 53% 100%);
  border: 1px solid rgba(146, 64, 14, 0.55);
  box-shadow: inset -2px -2px 0 rgba(146, 64, 14, 0.18), inset 2px 2px 0 rgba(255, 255, 255, 0.35);
  position: relative;
  vertical-align: -0.12em;
}
.coin-icon::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  border: 1px solid rgba(146, 64, 14, 0.35);
}
body.dark .coin-icon {
  background: radial-gradient(circle at 34% 30%, #fef3c7 0 18%, #fbbf24 19% 52%, #b45309 53% 100%);
  border-color: rgba(251, 191, 36, 0.52);
}
.rewards-badges-panel .badge-grid { margin-top: 12px; }
.check-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 12px;
  border: var(--panel-border);
  border-radius: var(--radius);
  background: #f8fbff;
  font-weight: 800;
}
.check-card input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-top: 2px;
  accent-color: var(--blue);
}
.check-card span { display: grid; gap: 2px; }
.check-card small { color: var(--muted); font-size: 0.8rem; font-weight: 700; line-height: 1.35; }
body.dark .check-card { background: #0f2f4a; border-color: #3b5998; }

.info-panel {
  margin-top: 24px;
  padding: 16px;
  background: #f0f7ff;
  border-radius: var(--radius);
  border: var(--panel-border);
}
body.dark .info-panel { background: #0f2f4a; border-color: #3b5998; }
.info-panel p {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--blue);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.ai-status-card { display: grid; gap: 14px; }
.ai-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.metric-panel {
  min-width: 0;
  padding: 14px;
  border: var(--panel-border);
  border-radius: var(--radius);
  background: #f8fbff;
}
body.dark .metric-panel { background: #0f2f4a; border-color: #3b5998; }
.metric-panel span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}
.metric-panel strong {
  display: block;
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.ai-status-note {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
}


.ai-wait-panel {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
}
.ai-wait {
  position: relative;
  color: var(--blue);
  font-weight: 800;
}
.ai-wait::after {
  content: "...";
  display: inline-block;
  width: 1.35em;
  text-align: left;
  animation: aiPulse 1.1s ease-in-out infinite;
}
.ai-wait span { display: none; }
@keyframes aiPulse {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1px); }
}
body.dark .ai-wait { color: #7dd3fc; }

.ai-explanation {
  background: #f8faff;
  padding: 12px;
  border-radius: var(--radius);
  border: var(--panel-border);
}
body.dark .ai-explanation { background: #0f2f4a; border-color: #3b5998; }

.review-answer {
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: var(--panel-border);
  margin: 8px 0;
}
body.dark .review-answer { background: #0f2f4a; border-color: #3b5998; }

.users-search {
  max-width: 200px;
  padding: 8px;
  border-radius: var(--radius);
  border: var(--panel-border);
}
.users-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.users-admin-grid {
  grid-template-columns: minmax(300px, 0.82fr) minmax(540px, 1.18fr);
  align-items: start;
}
.users-table-wrap {
  overflow-x: auto;
}
.users-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.users-table .user-id-cell {
  font-size: 0.75rem;
  color: var(--muted);
}
.users-table .user-actions-cell {
  width: 144px;
  white-space: normal;
}
.users-table .user-actions-cell .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 2px;
  min-width: 96px;
  min-height: 32px;
  padding: 0 8px;
  font-size: 0.8rem;
  line-height: 1;
}
.users-table .danger-action {
  color: var(--red);
}
.users-table .success-action {
  color: var(--green, #2e9d68);
}
.users-table .strong-action {
  font-weight: 800;
}
@media (min-width: 821px) {
  .users-table th:nth-child(1),
  .users-table td:nth-child(1) { width: 25%; }
  .users-table th:nth-child(2),
  .users-table td:nth-child(2) { width: 18%; }
  .users-table th:nth-child(3),
  .users-table td:nth-child(3) { width: 17%; }
  .users-table th:nth-child(5),
  .users-table td:nth-child(5) { width: 16%; }
  .users-table th:nth-child(7),
  .users-table td:nth-child(7) { width: 24%; }
  .users-table th:nth-child(4),
  .users-table td:nth-child(4),
  .users-table th:nth-child(6),
  .users-table .user-id-cell {
    display: none;
  }
}

/* Phone: stop the admin user manager from overflowing sideways. The form and
   the accounts panel stack, and the 7-column table becomes labelled cards
   (using each cell's data-label) instead of a horizontally scrolling table. */
@media (max-width: 768px) {
  .users-admin-grid { grid-template-columns: 1fr; }
  .users-table-wrap { overflow-x: visible; }
  .users-table { table-layout: auto; }
  .users-table thead { display: none; }
  .users-table tr {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
  }
  .users-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    width: auto !important;
    padding: 4px 0;
    border: 0;
    text-align: right;
  }
  .users-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--muted);
    font-weight: 800;
    text-align: left;
  }
  .users-table .user-actions-cell {
    width: auto;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .users-table .user-actions-cell .btn-ghost {
    width: 100%;
    margin: 2px 0 0;
  }
}

.quiz-progress-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 8px 14px;
}

.quiz-media {
  max-width: 100%;
  border-radius: var(--radius);
  border: var(--panel-border);
}
.question-box .quiz-media {
  margin-bottom: 8px;
  display: block;
}

/* Responsive hardening for compact screens */
.ip-chip, .ip-chip strong, .suggest-info, .report-card-head > div { min-width: 0; }
.ip-chip strong { display: block; overflow-wrap: anywhere; }
.section-title-row { flex-wrap: wrap; }
.order-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 820px) {
  .suggest-card { grid-template-columns: 40px minmax(0, 1fr); }
  .suggest-card .btn-action,
  .suggest-card .btn-primary { grid-column: 1 / -1; width: 100%; text-align: center; }
  .report-card-head { flex-direction: column; align-items: flex-start; }
  .report-card-head > div:last-child { text-align: left !important; }
  .question-box { grid-template-columns: 1fr; }
  .speak-btn { justify-self: start; }
  .match-board, .order-options-grid { grid-template-columns: 1fr; }
  .ai-box > div, .modal-foot { flex-wrap: wrap; }
  .ai-box button, .modal-foot button { flex: 1 1 160px; }
  .users-panel-head {
    align-items: stretch;
  }
  .users-panel-head h3 {
    width: 100%;
  }
  .users-search {
    width: 100%;
    max-width: none;
    min-height: 46px;
  }
  .users-table-wrap {
    overflow: visible;
  }
  .tool-screen .users-table {
    display: block;
    min-width: 0;
    border-spacing: 0;
  }
  .users-table thead {
    display: none;
  }
  .users-table tbody,
  .users-table tr,
  .users-table td {
    display: block;
    width: 100%;
  }
  .tool-screen .users-table tr {
    position: relative;
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid rgba(148, 180, 255, 0.24);
    border-radius: 18px;
    background:
      radial-gradient(circle at 94% 14%, rgba(96, 165, 250, 0.13), transparent 30%),
      rgba(11, 25, 55, 0.78);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
  .tool-screen .users-table td,
  .tool-screen .users-table td:first-child,
  .tool-screen .users-table td:last-child {
    min-height: 0;
    padding: 8px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .tool-screen .users-table td:not(.user-actions-cell) {
    display: grid;
    grid-template-columns: minmax(86px, 34%) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    color: #eaf2ff;
    overflow-wrap: anywhere;
  }
  .users-table td::before {
    content: attr(data-label);
    color: #91a7d0;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .users-table .user-id-cell {
    font-size: 0.72rem;
  }
  .tool-screen .users-table .user-actions-cell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 180, 255, 0.16);
  }
  .users-table .user-actions-cell::before {
    margin-bottom: -2px;
  }
  .users-table .user-actions-cell .btn-ghost {
    width: 100%;
    min-height: 42px;
    justify-content: center;
    font-size: 0.88rem;
  }
}


.subject-subtitle { color: var(--muted); font-size: 0.9rem; font-weight: 700; line-height: 1.35; }
.curriculum-stack { display: grid; gap: 24px; margin-top: 16px; }
.curriculum-section { display: grid; gap: 14px; }
.curriculum-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--subj-color) 42%, var(--line)); border-left: 5px solid var(--subj-color); border-radius: var(--radius-sm); background: linear-gradient(90deg, color-mix(in srgb, var(--subj-color) 16%, var(--panel)), color-mix(in srgb, var(--subj-color) 5%, var(--panel))); box-shadow: var(--panel-shadow); font-weight: 900; color: var(--ink); text-align: left; }
.curriculum-section-title span { line-height: 1.25; min-width: 0; }
.curriculum-section-toggle { display: flex; align-items: center; justify-content: flex-start; gap: 10px; min-width: 0; flex: 1; border: 0; background: transparent; color: inherit; padding: 0; text-align: left; font: inherit; cursor: pointer; }
.section-chevron { order: 2; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: 0 0 24px; border: 1px solid color-mix(in srgb, var(--subj-color) 32%, var(--line)); border-radius: 999px; background: var(--panel); color: color-mix(in srgb, var(--subj-color) 68%, var(--ink)); font-weight: 900; line-height: 1; }
.section-title-text { order: 1; flex: 0 1 auto; overflow-wrap: anywhere; text-align: left; }
.curriculum-title-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.curriculum-section-title small { color: color-mix(in srgb, var(--subj-color) 62%, var(--ink)); font-size: 0.78rem; font-weight: 900; white-space: nowrap; border: 1px solid color-mix(in srgb, var(--subj-color) 34%, var(--line)); border-radius: 999px; padding: 4px 8px; background: var(--panel); }
.curriculum-topic-list { display: grid; gap: 18px; padding-top: 6px; }
.curriculum-topic-card { display: grid; gap: 16px; border: var(--panel-border); border-radius: var(--radius); background: var(--panel); box-shadow: var(--panel-shadow); padding: 18px; min-width: 0; }
.curriculum-topic-head { display: flex; justify-content: space-between; gap: 12px; min-width: 0; }
.curriculum-topic-title { display: grid; gap: 10px; min-width: 0; }
.curriculum-topic-title h3 { font-size: 1.08rem; color: var(--ink); line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.curriculum-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.curriculum-title-row > :first-child { min-width: 0; }
.curriculum-meta-row { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-chip { display: inline-flex; align-items: center; min-height: 28px; border: 1px solid color-mix(in srgb, var(--subj-color) 26%, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--subj-color) 7%, var(--panel)); color: var(--muted); padding: 3px 8px; font-size: 0.78rem; font-weight: 900; line-height: 1.2; }
.curriculum-issues { display: grid; gap: 10px; border: 1px solid color-mix(in srgb, var(--subj-color) 22%, var(--line)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--subj-color) 6%, var(--panel)); padding: 12px; }
.curriculum-issues h4 { color: color-mix(in srgb, var(--subj-color) 58%, var(--ink)); font-size: 0.82rem; font-weight: 900; line-height: 1.2; }
.curriculum-issues p { white-space: pre-line; color: var(--ink); font-size: 0.86rem; line-height: 1.45; font-weight: 650; overflow-wrap: anywhere; }
.curriculum-requirement-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.requirement-column { display: grid; align-content: start; gap: 10px; border: 1px solid color-mix(in srgb, var(--subj-color) 20%, var(--line)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--subj-color) 5%, var(--panel)); padding: 12px; min-width: 0; }
.requirement-column h4 { color: color-mix(in srgb, var(--subj-color) 58%, var(--ink)); font-size: 0.8rem; font-weight: 900; line-height: 1.2; }
.requirement-column p { white-space: pre-line; color: var(--ink); font-size: 0.82rem; line-height: 1.45; font-weight: 650; overflow-wrap: anywhere; }
.requirement-content { color: var(--ink); font-size: 0.84rem; line-height: 1.5; font-weight: 650; overflow-wrap: anywhere; }
.requirement-content p { margin: 0; }
.requirement-content ul { display: grid; gap: 6px; margin: 0; padding-left: 18px; }
.requirement-content li { padding-left: 2px; }
.curriculum-issues .requirement-content { font-size: 0.88rem; }
.requirement-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.btn-mini { min-height: 28px; min-width: auto; padding: 3px 8px; border: 1px solid color-mix(in srgb, var(--subj-color) 25%, var(--line)); border-radius: 999px; background: var(--panel); color: var(--muted); font-size: 0.75rem; font-weight: 900; }
.btn-mini:hover { border-color: var(--subj-color); color: var(--ink); }
.requirement-column.missing { background: #fff0f6; border-color: #f9a8d4; }
.requirement-column.missing h4 { color: #be185d; }
.requirement-column.missing p { color: #9d174d; font-style: italic; }
.requirement-column.editing { grid-column: span 2; }
.requirement-edit-box { display: grid; gap: 8px; }
.curriculum-inline-edit { padding: 10px; border: 1px solid color-mix(in srgb, var(--subj-color) 20%, var(--line)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--subj-color) 4%, var(--panel)); }
.requirement-edit-box textarea { min-height: 150px; resize: vertical; border-width: 1px; border-radius: var(--radius-sm); font-size: 0.86rem; line-height: 1.45; }
.requirement-edit-box.curriculum-inline-edit textarea { min-height: 70px; }
.requirement-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-error { color: var(--red); font-size: 0.82rem; font-weight: 800; }
body.dark .subject-head, body.dark .curriculum-topic-card { background: var(--panel); border-color: #3b5998; box-shadow: none; }
body.dark .subject-visual-mini img { background: #0f2f4a; border-color: #3b5998; }
body.dark .curriculum-section-title { background: linear-gradient(90deg, #0f2f4a, #1e293b); border-color: #3b5998; border-left-color: #7dd3fc; box-shadow: none; color: var(--ink); }
body.dark .curriculum-section-title small, body.dark .meta-chip, body.dark .section-chevron { background: #0f2f4a; border-color: #3b5998; color: #cbd5e1; }
body.dark .requirement-column, body.dark .curriculum-issues, body.dark .curriculum-inline-edit { background: #0f2f4a; border-color: #3b5998; }
body.dark .requirement-column.missing { background: #3b1230; border-color: #be185d; }
body.dark .requirement-column.missing h4, body.dark .requirement-column.missing p { color: #f9a8d4; }
body.dark .btn-mini { background: #0f2f4a; border-color: #3b5998; color: #cbd5e1; }
body.dark .requirement-column h4, body.dark .curriculum-issues h4 { color: #7dd3fc; }
@media (max-width: 1100px) { .curriculum-requirement-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) { .curriculum-section-title { align-items: flex-start; flex-direction: column; } .curriculum-title-actions, .curriculum-title-row { width: 100%; } .curriculum-topic-card { padding: 14px; } .curriculum-requirement-grid { grid-template-columns: 1fr; } .requirement-column.editing { grid-column: span 1; } }

.section-prep-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.prep-exam-btn {
  border-color: rgba(31, 115, 232, 0.28);
  background: #eef6ff;
  color: #1e3a8a;
  font-weight: 900;
}
body.dark .prep-exam-btn {
  background: #123554;
  border-color: #3b5998;
  color: #dbeafe;
}
@media (max-width: 720px) {
  .section-prep-actions { justify-content: flex-start; width: 100%; }
}

/* ── Question preview modal ── */
.preview-question-card {
  background: var(--bg);
  border: var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.preview-q-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.preview-q-num {
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  font-size: 0.8rem;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.preview-q-type, .preview-q-level {
  font-size: 0.75rem;
  background: var(--panel);
  border: var(--panel-border);
  border-radius: 20px;
  padding: 2px 8px;
  color: var(--muted);
  font-weight: 700;
}
.preview-q-text {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 10px;
  line-height: 1.4;
}
.preview-answers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.preview-answers li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--panel);
  border: var(--panel-border);
  font-size: 0.92rem;
}
.preview-answers li.preview-correct {
  border-color: var(--green);
  background: #f0fdf4;
  font-weight: 700;
}
body.dark .preview-answers li.preview-correct {
  background: #0a2e1a;
}
.preview-ans-letter {
  font-weight: 900;
  color: var(--muted);
  font-size: 0.8rem;
  min-width: 16px;
  flex-shrink: 0;
}
.preview-answers li.preview-correct .preview-ans-letter {
  color: var(--green);
}
.preview-check {
  margin-left: auto;
  color: var(--green);
  font-weight: 900;
}
.preview-open-answer {
  font-size: 0.9rem;
  color: var(--muted);
  background: #f0fdf4;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 6px;
}
body.dark .preview-open-answer {
  background: #0a2e1a;
}
.preview-explanation {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: var(--panel-border);
  font-style: italic;
}

/* ═══ Pan Sowa 2.0 adventure map ═══ */
.adventure-screen {
  --adventure-bg: rgba(5, 12, 31, 0.78);
  --adventure-line: rgba(150, 190, 255, 0.22);
  --adventure-text: #f8fbff;
  --adventure-muted: #b8c8e8;
  color: var(--adventure-text);
  isolation: isolate;
  position: relative;   /* contain the ambient ::before to this column */
}

.adventure-screen::before {
  content: "";
  position: absolute;   /* was fixed → it bled the dark tint over the side panels */
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(circle at 20% 14%, rgba(91, 162, 255, 0.2), transparent 28%),
    radial-gradient(circle at 78% 18%, rgba(139, 92, 246, 0.2), transparent 30%),
    linear-gradient(180deg, rgba(2, 6, 18, 0.6), rgba(2, 6, 18, 0.9));
}

.adventure-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--adventure-line);
  border-radius: 28px;
  padding: 24px;
  background:
    radial-gradient(circle at 22% 18%, rgba(91, 162, 255, 0.25), transparent 28%),
    radial-gradient(circle at 76% 20%, rgba(139, 92, 246, 0.22), transparent 30%),
    linear-gradient(145deg, rgba(8, 18, 44, 0.94), rgba(5, 12, 31, 0.9));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.1);
}
/* Map view: no outer card — the map IS the stage */
.map-shell .adventure-stage {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
  overflow: visible;
}
.map-shell .adventure-stage::before { display: none; }

.adventure-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 72%, rgba(72, 212, 138, 0.13), transparent 23%),
    radial-gradient(circle at 90% 82%, rgba(255, 208, 91, 0.14), transparent 18%);
}

.adventure-stage > * { position: relative; z-index: 1; }

.adventure-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.adventure-stage-head h2,
.realm-hero-copy h2 {
  color: #fff;
  text-shadow: 0 0 28px rgba(91, 162, 255, 0.38), 0 4px 20px rgba(0,0,0,0.55);
}

.adventure-lead {
  color: var(--adventure-muted);
  margin-top: 4px;
  font-weight: 700;
}

.adventure-filter {
  justify-content: center;
  margin-bottom: 18px;
}

.adventure-filter .chip,
.realm-back,
.realm-tabs span {
  color: #dfeaff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.adventure-filter .chip {
  flex: 0 0 auto;
  min-width: max-content;
  padding-inline: 16px;
}

.adventure-filter .chip.active,
.realm-tabs span.active {
  color: #fff;
  border-color: rgba(139, 92, 246, 0.85);
  background: linear-gradient(135deg, #6d5dfc, #3b82f6);
  box-shadow: 0 0 24px rgba(91, 162, 255, 0.34);
}

.realm-back {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  white-space: nowrap;
}
.realm-back:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.35); }
.realm-back.compact { justify-self: start; margin-bottom: 14px; }

.realm-map {
  position: relative;
  min-height: clamp(600px, calc(100vh - 120px), 860px);
  overflow: hidden;
  padding: 0;
  margin: 0;
  border-radius: 30px;
  border: 1px solid rgba(150, 190, 255, 0.22);
  background:
    radial-gradient(circle at 74% 14%, rgba(185,211,255,0.22), transparent 7%),
    radial-gradient(circle at 26% 36%, rgba(255,208,91,0.14), transparent 12%),
    radial-gradient(circle at 68% 56%, rgba(91,162,255,0.14), transparent 18%),
    linear-gradient(180deg, rgba(4,9,24,0.08), rgba(4,9,24,0.32)),
    url("/assets/ui/adventure-map-bg.png") center / cover no-repeat,
    linear-gradient(145deg, #07142f, #050916);
  box-shadow: inset 0 0 70px rgba(0,0,0,0.34), 0 22px 66px rgba(0,0,0,0.28);
}

.realm-map::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 80%, rgba(72,212,138,0.14), transparent 18%),
    radial-gradient(circle at 55% 46%, rgba(139,92,246,0.12), transparent 16%),
    linear-gradient(90deg, rgba(2,6,18,0.18), transparent 22%, transparent 72%, rgba(2,6,18,0.18));
}

/* Title overlay at the top of the map */
.map-title-overlay {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 4;
  pointer-events: none;
  white-space: nowrap;
}
.map-title-overlay h2 {
  color: #fff;
  font-size: clamp(1.6rem, 2.2vw, 2.1rem);
  font-weight: 900;
  text-shadow: 0 0 32px rgba(91,162,255,0.5), 0 4px 20px rgba(0,0,0,0.7);
  margin: 0;
  letter-spacing: 0.01em;
}

/* Grade filter — hidden on map, kept in DOM for functionality */
.map-grade-filter { display: none; }

/* Quick nav inside map — bottom, absolute */
.realm-map .map-quick-nav {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
}

.map-moon {
  position: absolute;
  top: 9%;
  right: 23%;
  width: 58px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #dbeafe, #8fb8ff 64%, rgba(141,183,255,0.2));
  box-shadow: 0 0 36px rgba(141,183,255,0.48);
  opacity: 0.86;
}
.map-waterfall {
  position: absolute;
  left: 47%;
  top: 30%;
  width: 16%;
  height: 36%;
  border-radius: 999px;
  transform: rotate(24deg);
  background: linear-gradient(180deg, rgba(160,220,255,0.12), rgba(91,162,255,0.42), rgba(72,212,138,0.08));
  filter: blur(7px);
  opacity: 0.72;
}
.map-treasure-card {
  position: absolute;
  left: 3.5%;
  bottom: 5.5%;
  width: 210px;
  min-height: 108px;
  display: grid;
  grid-template-columns: 72px 1fr;
  align-content: center;
  gap: 4px 14px;
  padding: 14px 16px;
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(255,180,90,0.32) 0%, transparent 60%),
    linear-gradient(135deg, #5a3a1a 0%, #3a2510 60%, #2a1810 100%);
  border: 2px solid rgba(255,180,90,0.55);
  box-shadow: 0 14px 40px rgba(0,0,0,0.5), 0 0 28px rgba(255,180,90,0.32), inset 0 1px 0 rgba(255,220,160,0.18);
  z-index: 5;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.map-treasure-card:hover { transform: translateY(-3px); box-shadow: 0 18px 48px rgba(0,0,0,0.55), 0 0 36px rgba(255,180,90,0.45), inset 0 1px 0 rgba(255,220,160,0.22); }
.map-treasure-card .chest-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  filter: drop-shadow(0 0 18px rgba(255,208,91,0.55)) drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.map-treasure-card strong { align-self: end; font-size: 1rem; line-height: 1.12; color: #ffe6b8; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.map-treasure-card small { color: #f0d4a0; font-weight: 800; font-size: 0.78rem; }

/* Realm card positions on the adventure map */
.realm-map .realm-card:nth-of-type(1) { left: 18%; top: 17%; }                          /* featured — upper left-center */
.realm-map .realm-card:nth-of-type(2) { right: 12%; top: 26%; --pin-scale: 0.96; }      /* upper right */
.realm-map .realm-card:nth-of-type(3) { right: 3%;  top: 10%; --pin-scale: 0.93; }      /* far top-right */
.realm-map .realm-card:nth-of-type(4) { left: 4%;   top: 52%; --pin-scale: 0.95; }      /* mid-left */
.realm-map .realm-card:nth-of-type(5) { right: 6%;  top: 52%; --pin-scale: 0.95; }      /* mid-right */
.realm-map .realm-card:nth-of-type(6) { left: 28%;  bottom: 12%; --pin-scale: 0.94; }   /* lower-center */
.realm-map .realm-card:nth-of-type(7) { right: 6%;  bottom: 8%; --pin-scale: 0.93; }

.realm-map .realm-card:nth-of-type(1)::before {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -22px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,208,91,0.28), transparent 70%);
  filter: blur(2px);
}

.realm-map .realm-card:nth-of-type(1)::after,
.realm-map .realm-card:nth-of-type(2)::after,
.realm-map .realm-card:nth-of-type(3)::after,
.realm-map .realm-card:nth-of-type(4)::after,
.realm-map .realm-card:nth-of-type(5)::after,
.realm-map .realm-card:nth-of-type(6)::after,
.realm-map .realm-card:nth-of-type(7)::after {
  opacity: 0.45;
}

.realm-card {
  position: absolute;
  width: clamp(195px, 16vw, 240px);
  min-height: 88px;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px;
  overflow: hidden;
  text-align: left;
  border-radius: 22px;
  border: 1px solid color-mix(in srgb, var(--realm-color) 55%, rgba(255,255,255,0.2));
  background:
    linear-gradient(90deg, rgba(4, 9, 24, 0.78), rgba(3, 8, 24, 0.58)),
    radial-gradient(circle at 50% 22%, color-mix(in srgb, var(--realm-color) 22%, transparent), transparent 44%),
    var(--realm-image) center / cover no-repeat,
    rgba(11, 22, 52, 0.82);
  box-shadow:
    0 18px 48px rgba(0,0,0,0.38),
    0 0 20px color-mix(in srgb, var(--realm-color) 22%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  transform: scale(var(--pin-scale, 1));
  z-index: 3;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.realm-card.featured {
  width: clamp(240px, 20vw, 296px);
  min-height: 100px;
  grid-template-columns: 68px minmax(0, 1fr);
  padding: 15px;
  border-width: 2px;
  border-color: color-mix(in srgb, var(--realm-color) 80%, #fff);
  box-shadow:
    0 28px 80px rgba(0,0,0,0.52),
    0 0 48px color-mix(in srgb, var(--realm-color) 50%, transparent),
    0 0 80px color-mix(in srgb, var(--realm-color) 22%, transparent),
    inset 0 1px 0 rgba(255,255,255,0.18);
  z-index: 4;
}

.realm-card.featured::before {
  content: "";
  position: absolute;
  inset: -50% -25% auto;
  height: 72%;
  pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--realm-color) 38%, transparent), transparent 64%);
  opacity: 0.9;
}

.realm-card.locked {
  opacity: 0.82;
}

.realm-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--realm-color) 18%, transparent), transparent 42%),
    radial-gradient(circle at 18% 18%, rgba(255,255,255,0.15), transparent 18%);
  opacity: 0.9;
}

.realm-card:hover {
  transform: translateY(-7px) scale(var(--pin-scale, 1));
  border-color: var(--realm-color);
  box-shadow: 0 24px 60px rgba(0,0,0,0.42), 0 0 28px color-mix(in srgb, var(--realm-color) 38%, transparent);
}

.realm-card > * { position: relative; z-index: 1; }
.realm-card::after { mix-blend-mode: screen; }
.realm-status {
  position: absolute;
  top: -13px;
  left: 16px;
  padding: 5px 12px;
  border-radius: 999px;
  color: #fff;
  background: color-mix(in srgb, var(--realm-color) 74%, #111827);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.realm-art {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: color-mix(in srgb, var(--realm-color) 30%, rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 0 30px color-mix(in srgb, var(--realm-color) 34%, transparent);
}
.realm-art img { width: 40px; height: 40px; object-fit: contain; }
.realm-art span { color: #fff; font-size: 1.15rem; font-weight: 900; }

.realm-copy,
.realm-progress { display: grid; gap: 8px; }
.realm-copy strong { color: #fff; font-size: 1.02rem; line-height: 1.15; }
.realm-card.featured .realm-copy strong { font-size: 1.08rem; }
.realm-copy small,
.realm-progress small,
.realm-count { color: var(--adventure-muted); font-weight: 700; }
.realm-copy small { display: none; }
.realm-progress {
  grid-column: 2;
  gap: 5px;
}
.realm-progress > span:first-child { display: flex; justify-content: space-between; align-items: center; }
.realm-progress b { color: #fff; }

.adventure-progress {
  display: block;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.24);
}
.adventure-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--realm-color, #8b5cf6), #48d48a);
  box-shadow: 0 0 18px color-mix(in srgb, var(--realm-color, #8b5cf6) 60%, transparent);
  transition: width 0.45s ease;
}

.map-daily-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1.2fr) minmax(160px, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: 22px;
  color: #f8fbff;
  background:
    linear-gradient(135deg, rgba(14, 24, 58, 0.84), rgba(8, 18, 44, 0.64)),
    radial-gradient(circle at 8% 50%, rgba(139,92,246,0.22), transparent 28%);
  border: 1px solid rgba(150, 190, 255, 0.2);
  box-shadow: 0 18px 48px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
}
.map-daily-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #6d5dfc, #8b5cf6);
  box-shadow: 0 0 28px rgba(139,92,246,0.34);
  font-size: 1.35rem;
  font-weight: 900;
}
.map-daily-card span { color: #cbd9ff; font-weight: 900; }
.map-daily-card strong { color: #fff; }
.map-daily-progress { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.map-daily-progress small { color: #d8e4ff; font-weight: 900; white-space: nowrap; }
.map-daily-reward {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.13);
  white-space: nowrap;
}
.map-daily-reward span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3b2500;
  background: linear-gradient(135deg, #ffd05b, #ff9f5b);
}

.map-quick-nav {
  width: min(540px, 82%);
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px auto 0;
  padding: 10px;
  border-radius: 24px;
  background: rgba(8, 18, 44, 0.74);
  border: 1px solid rgba(150, 190, 255, 0.24);
  box-shadow: 0 18px 50px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
}
.map-quick-nav button {
  position: relative;
  min-height: 78px;
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 8px 6px;
  border-radius: 16px;
  color: #f8fbff;
  background: transparent;
  font-weight: 900;
}
.map-quick-nav button + button { border-left: 1px solid rgba(255,255,255,0.1); }
.map-quick-nav button:hover {
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.map-quick-nav button span {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.2rem;
  background: linear-gradient(135deg, #5ba2ff, #6d5dfc);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 18px rgba(91,162,255,0.3);
  color: #fff;
}
.map-quick-nav .qn-events span { background: linear-gradient(135deg, #8b5cf6, #b56cff); box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 18px rgba(139,92,246,0.35); }
.map-quick-nav .qn-friends span { background: linear-gradient(135deg, #3b82f6, #5ba2ff); box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 18px rgba(91,162,255,0.35); }
.map-quick-nav .qn-rank span { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 18px rgba(251,191,36,0.45); }
.map-quick-nav .qn-settings span { background: linear-gradient(135deg, #ef4444, #f97316); box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 18px rgba(249,115,22,0.35); }
.map-quick-nav button strong {
  font-size: 0.82rem;
  line-height: 1.12;
}
.map-quick-nav button i {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #f97316);
  font-size: 0.75rem;
  font-style: normal;
  box-shadow: 0 0 16px rgba(249,115,22,0.4);
}

.map-scroll-note {
  width: min(760px, 92%);
  justify-self: center;
  margin: 10px auto 0;
  padding: 12px 22px;
  border-radius: 15px;
  color: #5b3511;
  text-align: center;
  font-weight: 900;
  background:
    linear-gradient(90deg, rgba(112,65,24,0.12), transparent 14%, transparent 86%, rgba(112,65,24,0.12)),
    linear-gradient(135deg, #e6bd78, #f6deb0);
  border: 1px solid rgba(92,54,24,0.34);
  box-shadow: 0 12px 34px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.32);
}

.realm-detail {
  display: grid;
  gap: 18px;
  color: #f8fbff;
}
.realm-hero {
  position: relative;
  min-height: 330px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: center;
  gap: 20px;
  overflow: hidden;
  border-radius: 28px;
  padding: 34px 30px;
  border: 1px solid color-mix(in srgb, var(--realm-color) 45%, rgba(255,255,255,0.18));
  background:
    linear-gradient(90deg, rgba(5, 9, 27, 0.96), rgba(5, 9, 27, 0.32) 56%, rgba(5, 9, 27, 0.82)),
    radial-gradient(circle at 59% 54%, color-mix(in srgb, var(--realm-color) 28%, transparent), transparent 30%),
    var(--realm-image) center / cover no-repeat,
    linear-gradient(135deg, rgba(14, 22, 55, 0.92), rgba(5, 11, 28, 0.78));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 24px 58px rgba(0,0,0,0.34);
}

.realm-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 63% 42%, color-mix(in srgb, var(--realm-color) 34%, transparent), transparent 18%),
    radial-gradient(circle at 72% 70%, rgba(255,208,91,0.16), transparent 15%),
    linear-gradient(180deg, rgba(5,10,27,0.08), rgba(5,10,27,0.56));
  mix-blend-mode: screen;
}

.realm-hero > * { position: relative; z-index: 1; }

.realm-hero-copy {
  display: grid;
  gap: 12px;
  align-self: center;
}
.realm-hero-copy .eyebrow {
  color: color-mix(in srgb, var(--realm-color) 66%, #fff);
  text-shadow: 0 0 18px color-mix(in srgb, var(--realm-color) 42%, transparent);
}
.realm-hero-copy h2 {
  font-size: clamp(2rem, 3.4vw, 3.25rem);
  line-height: 1;
}
.realm-hero-copy p:not(.eyebrow) {
  color: #d8e4ff;
  max-width: 560px;
  font-size: 1.02rem;
  font-weight: 800;
}
.realm-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.realm-tabs span { padding: 8px 16px; border-radius: 999px; font-weight: 900; }

.realm-hero-guide {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: end;
  min-height: 210px;
  width: min(100%, 280px);
  display: grid;
  place-items: end center;
  margin-top: 96px;
}
.realm-guide-owl {
  position: relative;
  z-index: 2;
  width: 154px;
  height: 154px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #f8eed8, #d9c8a8);
  border: 3px solid rgba(255,208,91,0.5);
  box-shadow: 0 14px 30px rgba(0,0,0,0.42), 0 0 36px color-mix(in srgb, var(--realm-color, #ffd07a) 40%, transparent);
  animation: owlFloat 4.4s ease-in-out infinite;
}
.realm-guide-owl img {
  width: 110%;
  height: 110%;
  object-fit: cover;
  object-position: 50% 32%;
}
.realm-hero-guide::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 4px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--realm-color) 40%, rgba(255,255,255,0.1)), transparent 70%);
  filter: blur(4px);
}
.realm-crystal {
  position: absolute;
  width: 26px;
  height: 46px;
  clip-path: polygon(50% 0, 100% 28%, 78% 100%, 22% 100%, 0 28%);
  background: linear-gradient(160deg, #d8b4fe, var(--realm-color));
  box-shadow: 0 0 24px color-mix(in srgb, var(--realm-color) 60%, transparent);
  opacity: 0.9;
}
.realm-crystal.crystal-a { left: 12%; bottom: 34px; transform: rotate(-12deg); }
.realm-crystal.crystal-b { right: 11%; bottom: 74px; width: 20px; height: 36px; transform: rotate(16deg); }
.realm-magic-symbols {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  color: color-mix(in srgb, var(--realm-color) 62%, #fff);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-shadow: 0 0 18px color-mix(in srgb, var(--realm-color) 50%, transparent);
}

.realm-level-card {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  justify-self: end;
  width: min(100%, 320px);
  z-index: 3;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: 22px;
  color: #fff;
  background: rgba(8, 18, 44, 0.72);
  border: 1px solid rgba(255,255,255,0.16);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 44px rgba(0,0,0,0.28), 0 0 28px color-mix(in srgb, var(--realm-color) 22%, transparent);
}
.realm-tabs { display: none; }
.treasure-glow {
  position: absolute;
  right: 14px;
  top: -24px;
  color: #ffd05b;
  opacity: 0.72;
  font-size: 2.8rem;
  filter: drop-shadow(0 0 18px rgba(255,208,91,0.34));
}
.level-orb {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--realm-color), #6d5dfc);
  box-shadow: 0 0 28px color-mix(in srgb, var(--realm-color) 50%, transparent);
  font-size: 1.4rem;
  font-weight: 900;
}

.level-board {
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(8,18,44,0.78), rgba(6,14,35,0.66)),
    radial-gradient(circle at 18% 0%, color-mix(in srgb, var(--realm-color) 18%, transparent), transparent 34%);
  border: 1px solid rgba(150,190,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 18px 54px rgba(0,0,0,0.24);
}
.level-board-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.level-board-head h3 { color: #fff; font-size: 1.35rem; }
.level-board-head p { color: var(--adventure-muted); font-weight: 800; margin-top: 2px; }
.level-board-head > span {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.13);
  font-weight: 900;
  white-space: nowrap;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 18px;
}
.level-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.13);
  background:
    linear-gradient(180deg, rgba(14,25,60,0.82), rgba(8,16,41,0.92)),
    radial-gradient(circle at 50% 18%, color-mix(in srgb, var(--realm-color) 14%, transparent), transparent 48%);
  box-shadow: 0 16px 34px rgba(0,0,0,0.24);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.level-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 84% 14%, color-mix(in srgb, var(--realm-color) 36%, transparent), transparent 26%),
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 42%);
  opacity: 0.66;
}
.level-card > * { position: relative; z-index: 1; }
.level-card:hover { transform: translateY(-4px); }
.level-card.open {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  overflow: visible;
}
.level-card.open,
.level-card.active { border-color: color-mix(in srgb, var(--realm-color) 78%, #fff); box-shadow: 0 0 28px color-mix(in srgb, var(--realm-color) 30%, transparent); }
.level-card.completed {
  border-color: rgba(72, 212, 138, 0.76);
  box-shadow: 0 0 28px rgba(72, 212, 138, 0.22);
}
.level-card.locked {
  filter: saturate(0.62);
  opacity: 0.72;
}
.level-card.locked .level-art img { filter: grayscale(0.35) brightness(0.74); }
.level-card.completed::after {
  content: "✓";
  position: absolute;
  top: 10px;
  left: 10px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #48d48a, #2ca96d);
  font-weight: 900;
  box-shadow: 0 0 18px rgba(72,212,138,0.38);
  z-index: 2;
}
.level-card-main {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  text-align: left;
  border-radius: 0;
}
.level-card.open .level-card-main {
  align-self: start;
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) auto;
  align-items: center;
  /* Flat bottom so the header reads as the "chapter" cap directly above its
     adventures, which carry on in the panel below. */
  border-radius: 20px 20px 0 0;
  border-bottom: 2px solid color-mix(in srgb, var(--realm-color) 60%, rgba(255,255,255,0.16));
  background:
    linear-gradient(180deg, rgba(14,25,60,0.84), rgba(8,16,41,0.94)),
    radial-gradient(circle at 50% 18%, color-mix(in srgb, var(--realm-color) 18%, transparent), transparent 48%);
}
.level-card-main:hover { background: rgba(255,255,255,0.04); }
.level-art {
  position: relative;
  width: 100%;
  height: 140px;
  overflow: hidden;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--realm-color) 28%, transparent), transparent 50%),
    rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.level-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: calc(50% + var(--level-shift, 0%)) center;
  filter: saturate(1.12) contrast(0.94) brightness(0.78);
  transform: scale(1.03);
}
.level-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 34%, rgba(4,9,26,0.74)),
    radial-gradient(circle at 78% 18%, color-mix(in srgb, var(--realm-color) 42%, transparent), transparent 26%);
}
.level-art-glow {
  position: absolute;
  right: 12px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--realm-color);
  filter: blur(16px);
  opacity: 0.62;
}
.level-card.active .level-art img,
.level-card.open .level-art img {
  filter: saturate(1.18) contrast(1) brightness(0.92);
}
.level-content { display: grid; align-content: center; gap: 7px; min-width: 0; }
.level-content strong {
  min-height: 2.36em;
  color: #fff;
  font-size: 1.02rem;
  line-height: 1.2;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.level-content small,
.level-state { color: var(--adventure-muted); font-weight: 700; }
.level-content > small {
  min-height: 2.4em;
  overflow: hidden;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.level-state { color: #9be7ff; font-size: 0.72rem; text-transform: uppercase; }
.level-card.completed .level-state { color: #91f7bd; }
.level-card.locked .level-state { color: #aab5ce; }
.level-stars { color: #ffd05b; letter-spacing: 0.05em; }
.level-progress-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: #fff;
}
.level-progress-line b { color: #fff; font-weight: 900; }
.level-progress-line small { color: var(--adventure-muted); font-size: 0.78rem; }
.level-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.level-mode-row i {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #dfeaff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
}
.level-card.active .level-mode-row i:nth-child(2),
.level-card.open .level-mode-row i:nth-child(2) {
  color: #fff;
  background: linear-gradient(135deg, var(--realm-color), #6d5dfc);
  border-color: rgba(255,255,255,0.18);
}
.level-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--realm-color), #6d5dfc);
  color: #fff;
  font-weight: 900;
  font-size: 0.95rem;
  box-shadow: 0 0 18px color-mix(in srgb, var(--realm-color) 42%, transparent);
}
.level-missions {
  position: relative;
  min-width: 0;
  /* Extra left inset makes the adventures clearly hang off the wyprawa spine. */
  padding: 18px 16px 18px 34px;
  display: grid;
  gap: 14px;
  /* Flat top joins seamlessly to the header above (one continuous chapter). */
  border-radius: 0 0 20px 20px;
  background:
    linear-gradient(135deg, rgba(8,18,44,0.68), rgba(6,14,35,0.52)),
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--realm-color) 18%, transparent), transparent 34%);
}
/* The "spine" of the wyprawa: a glowing rail that runs from the header down
   through every adventure, so the adventures visibly belong to this wyprawa. */
.level-missions::before {
  content: "";
  position: absolute;
  left: 15px;
  top: -2px;
  bottom: 22px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--realm-color) 92%, #fff), rgba(91,162,255,0.22));
  box-shadow: 0 0 18px color-mix(in srgb, var(--realm-color) 60%, transparent);
}
.adventure-prep {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--realm-color) 24%, rgba(255,255,255,0.07)), rgba(255,255,255,0.06)),
    rgba(7, 16, 38, 0.56);
  border: 1px solid color-mix(in srgb, var(--realm-color) 42%, rgba(255,255,255,0.14));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 24px color-mix(in srgb, var(--realm-color) 14%, transparent);
}
/* Glowing node where the wyprawa header meets its spine. */
.adventure-prep::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 50%;
  width: 13px;
  height: 13px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff, var(--realm-color) 64%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--realm-color) 24%, transparent), 0 0 14px color-mix(in srgb, var(--realm-color) 72%, transparent);
}
.adventure-prep-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.adventure-prep-copy span {
  color: #9be7ff;
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}
.adventure-prep-copy strong {
  color: #fff;
  font-size: 1.03rem;
  line-height: 1.16;
}
.adventure-prep-copy small {
  color: #d8e4ff;
  font-weight: 850;
}
.adventure-mission-list {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}
.level-card.open .adventure-mission-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.adventure-mission-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  grid-template-areas:
    "art title"
    "art meta"
    "art mastery"
    "art actions";
  align-items: start;
  gap: 8px 12px;
  color: #f8fbff;
  border-radius: 14px 18px 18px 14px;
  border-color: rgba(150,190,255,0.18);
  /* Realm-tinted left edge ties each adventure to its wyprawa spine. */
  border-left: 3px solid color-mix(in srgb, var(--realm-color) 58%, rgba(150,190,255,0.2));
  background:
    linear-gradient(180deg, rgba(11,24,58,0.9), rgba(7,15,38,0.86)),
    radial-gradient(circle at 14% 12%, color-mix(in srgb, var(--realm-color) 18%, transparent), transparent 34%);
  box-shadow: 0 14px 30px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.08);
}
.level-card.open .adventure-mission-card {
  grid-template-columns: 1fr;
  grid-template-areas:
    "art"
    "title"
    "meta"
    "mastery"
    "actions";
  align-items: start;
  gap: 8px;
  padding: 14px;
}
.level-card.open .adventure-mission-card .mission-art,
.level-card.open .adventure-mission-card .mission-art-placeholder,
.level-card.open .adventure-mission-card .scene-art {
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 16 / 9;
  align-self: start;
}
.adventure-mission-card .mission-art,
.adventure-mission-card .mission-art-placeholder {
  grid-area: art;
  width: 118px;
  height: 86px;
  aspect-ratio: auto;
  align-self: start;
  border-radius: 14px;
  border-color: rgba(255,255,255,0.14);
}
.adventure-mission-card .scene-art {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: start;
  gap: 2px;
  overflow: hidden;
  padding: 10px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(7,13,32,0.08), rgba(5,12,28,0.78)),
    var(--scene-image) center / cover;
  background-position: calc(50% + var(--scene-offset, 0%)) center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 0 22px color-mix(in srgb, var(--realm-color) 18%, transparent);
}
.level-card.open .adventure-mission-card .scene-art {
  width: 100%;
  height: auto;
}
.scene-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 78% 18%, color-mix(in srgb, var(--realm-color) 46%, transparent), transparent 30%),
    linear-gradient(135deg, color-mix(in srgb, var(--realm-color) 18%, transparent), transparent 54%);
  mix-blend-mode: screen;
  opacity: 0.86;
}
.scene-art-glow {
  position: absolute;
  inset: auto 10px 10px auto;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--realm-color);
  filter: blur(16px);
  opacity: 0.72;
}
.scene-art b,
.scene-art small {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 12px rgba(0,0,0,0.55);
}
.scene-art b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--realm-color) 76%, #fff 10%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--realm-color) 42%, transparent);
}
.scene-art small {
  max-width: 100%;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0;
  color: rgba(255,255,255,0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.adventure-mission-card .mission-title {
  grid-area: title;
  min-width: 0;
  padding: 8px 10px;
  color: #fff;
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
  border-left-color: var(--realm-color);
}
.level-card.open .adventure-mission-card .mission-title {
  align-self: end;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 1.03rem;
  line-height: 1.18;
}
.adventure-mission-card .mission-meta { grid-area: meta; }
.adventure-mission-card .mission-mastery { grid-area: mastery; }
.adventure-mission-card .mission-meta,
.adventure-mission-card .mastery-label {
  color: #b8c8e8;
}
.adventure-mission-card .mission-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 2px;
  padding-top: 0;
}
.level-card.open .adventure-mission-card .mission-actions {
  align-self: center;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.adventure-mission-card .btn-action {
  min-height: 38px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
}
.adventure-mission-card .btn-action { background: linear-gradient(135deg, #3b82f6, #6d5dfc); color: #fff; }
.adventure-mission-card .btn-action:first-child { background: linear-gradient(135deg, #8b5cf6, #b56cff); }
.realm-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.1);
}
.realm-summary-top {
  margin-top: -4px;
}
.realm-summary div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 18px;
  background: rgba(8,18,44,0.66);
}
.realm-summary div + div { border-left: 1px solid rgba(255,255,255,0.1); }
.realm-summary i {
  grid-row: span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #3b2500;
  background: linear-gradient(135deg, #ffd05b, #ff9f5b);
  font-style: normal;
  box-shadow: 0 0 20px rgba(255,208,91,0.22);
}
.realm-summary span { color: var(--adventure-muted); font-weight: 800; }
.realm-summary strong { color: #fff; font-size: 1.35rem; }

@media (min-width: 1200px) {
  .realm-shell .level-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 1500px) {
  .realm-shell .level-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level-card.open .level-card-main {
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  }
  .realm-hero {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  }
  .realm-hero-guide {
    display: none;
  }
}

@media (max-width: 820px) {
  .adventure-player-panel {
    display: none;
  }
  .adventure-stage { padding: 16px; border-radius: 22px; }
  .adventure-stage-head { display: grid; }
  .realm-map {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: 0;
    overflow: visible;
    padding: 14px;
    margin-inline: 0;
    background:
      linear-gradient(180deg, rgba(4,9,24,0.24), rgba(4,9,24,0.68)),
      url("/assets/ui/adventure-map-bg.png") center / cover no-repeat,
      #07142f;
  }
  .realm-map::before,
  .realm-map::after,
  .map-moon,
  .map-waterfall,
  .map-treasure-card { display: none; }
  .realm-card,
  .realm-card.featured {
    position: relative;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: auto;
    min-height: 112px;
    grid-template-columns: 58px minmax(0, 1fr);
    transform: none;
  }
  .realm-card:hover { transform: translateY(-4px); }
  .realm-copy small { display: block; }
  .map-daily-card {
    grid-template-columns: auto 1fr;
  }
  .map-daily-progress,
  .map-daily-reward {
    grid-column: 1 / -1;
  }
  .map-quick-nav {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-radius: 20px;
  }
  .map-quick-nav button { min-height: 66px; }
  .map-quick-nav button span { font-size: 1.35rem; }
  .map-quick-nav button strong { font-size: 0.7rem; }
  .map-scroll-note { width: 100%; font-size: 0.88rem; }
  .level-grid, .adventure-mission-list, .realm-summary { grid-template-columns: 1fr; }
  .level-card.open {
    grid-column: auto;
    grid-template-columns: 1fr;
  }
  .level-card.open .level-card-main {
    grid-template-columns: 1fr;
    border-radius: 20px;
  }
  .level-missions {
    border-left: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    /* Tighter spine inset so the narrow screen keeps usable card width. */
    padding-left: 24px;
  }
  .level-missions::before { left: 11px; }
  .adventure-prep::before { left: -17px; }
  .adventure-mission-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }
  .level-card.open .adventure-mission-card {
    grid-template-columns: 84px minmax(0, 1fr);
    grid-template-areas:
      "art title"
      "art meta"
      "art mastery"
      "actions actions";
    align-items: start;
  }
  .adventure-mission-card .mission-art,
  .adventure-mission-card .mission-art-placeholder {
    width: 84px;
    height: 72px;
  }
  .level-card.open .adventure-mission-card .scene-art {
    width: 84px;
    height: 72px;
  }
  .adventure-mission-card .mission-actions {
    grid-column: 1 / -1;
  }
  .level-card.open .adventure-mission-card .mission-actions {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }
  .level-card.open .adventure-mission-card .mission-actions .btn-action:last-child:nth-child(odd) {
    grid-column: auto;
    justify-self: stretch;
    min-width: 0;
  }
  .realm-hero { grid-template-columns: 1fr; min-height: 0; padding: 20px; }
  .level-card-main { padding: 12px; }
  .level-art { height: 124px; }
}

@media (max-width: 520px) {
  .realm-tabs span { flex: 1 1 auto; text-align: center; justify-content: center; }
  .level-card.open .adventure-mission-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "art"
      "title"
      "meta"
      "mastery"
      "actions";
  }
  .level-card.open .adventure-mission-card .scene-art {
    width: 100%;
    min-height: 118px;
  }
  .level-card.open .adventure-mission-card .mission-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .adventure-prep {
    grid-template-columns: 1fr;
  }
}

/* ═══ Pan Sowa 2.0 challenge modal ═══ */
.challenge-panel {
  position: relative;
  width: min(1240px, 100%);
  min-height: min(860px, calc(100dvh - 28px));
  color: #f8fbff;
  overflow: hidden;
  border: 1px solid rgba(139, 92, 246, 0.38);
  border-radius: 30px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(5, 9, 27, 0.28), rgba(5, 9, 27, 0.94)),
    radial-gradient(circle at 16% 18%, color-mix(in srgb, var(--realm-color, #8b5cf6) 34%, transparent), transparent 28%),
    radial-gradient(circle at 84% 28%, rgba(91,162,255,0.22), transparent 24%),
    var(--realm-image, url("/assets/realms/math-realm.png")) center / cover no-repeat,
    linear-gradient(145deg, rgba(9, 15, 39, 0.98), rgba(5, 10, 27, 0.96));
  box-shadow: 0 36px 110px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.1);
}
.challenge-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 76% 58%, rgba(255,208,91,0.12), transparent 18%),
    radial-gradient(circle at 50% 32%, color-mix(in srgb, var(--realm-color, #8b5cf6) 26%, transparent), transparent 26%),
    linear-gradient(90deg, rgba(4, 8, 23, 0.88), rgba(4, 8, 23, 0.3) 54%, rgba(4, 8, 23, 0.9));
}
.challenge-panel > * { position: relative; z-index: 1; }
.challenge-panel .modal-head,
.challenge-panel .modal-foot {
  border-color: rgba(255,255,255,0.12);
}
.challenge-panel .modal-foot {
  display: flex;
  justify-content: center;
}
.challenge-panel .modal-head h2,
.challenge-panel .modal-head .eyebrow { color: #fff; }
.challenge-panel .modal-scroll { gap: 18px; padding-right: 4px; }
.challenge-panel .modal-foot .quiz-action-btn {
  width: min(420px, 100%) !important;
  min-height: 68px;
  margin-inline: auto;
  border-radius: 20px;
  color: #f6fff9;
  background: linear-gradient(135deg, #50d996, #2ca96d);
  box-shadow: 0 0 42px rgba(72, 212, 138, 0.38), inset 0 1px 0 rgba(255,255,255,0.24);
  font-size: 1.18rem;
  text-shadow: 0 1px 8px rgba(0,0,0,0.28);
  transition: transform 0.16s ease, box-shadow 0.18s ease, filter 0.18s ease, background 0.18s ease;
}
.challenge-panel .modal-foot .quiz-action-btn.ready {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #5ee8a6, #27b574);
  box-shadow: 0 0 48px rgba(72, 212, 138, 0.48), 0 14px 30px rgba(44, 169, 109, 0.24), inset 0 1px 0 rgba(255,255,255,0.3);
}
.challenge-panel .modal-foot .quiz-action-btn.ready:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 56px rgba(72, 212, 138, 0.58), 0 18px 36px rgba(44, 169, 109, 0.3), inset 0 1px 0 rgba(255,255,255,0.34);
}
.challenge-panel .modal-foot .quiz-action-btn.checked {
  background: linear-gradient(135deg, #5ba2ff, #7c5cff);
  box-shadow: 0 0 42px rgba(91, 162, 255, 0.38), inset 0 1px 0 rgba(255,255,255,0.24);
}
.challenge-panel .modal-foot .quiz-action-btn:disabled {
  color: rgba(235, 244, 255, 0.62);
  background: linear-gradient(135deg, rgba(71, 85, 105, 0.72), rgba(51, 65, 85, 0.78));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
  text-shadow: none;
  cursor: not-allowed;
  filter: saturate(0.72);
}

.challenge-head {
  grid-template-columns: minmax(140px, auto) 1fr auto minmax(110px, auto);
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
}
.quiz-font-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-self: end;
  padding: 4px;
  border-radius: 999px;
  background: rgba(8, 18, 44, 0.7);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.quiz-font-control button {
  min-width: 38px; height: 38px;
  border-radius: 999px;
  border: 0;
  background: rgba(255,255,255,0.08);
  color: #edf4ff;
  font-weight: 900;
  font-size: 0.95rem;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.15s ease;
}
.quiz-font-control button:hover:not(:disabled) { background: rgba(255,255,255,0.18); }
.quiz-font-control button:disabled { opacity: 0.4; cursor: default; }
.challenge-title { text-align: center; min-width: 0; }
.challenge-title h2 {
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  line-height: 1.2;
}
.challenge-exit,
.challenge-score {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  color: #edf4ff;
  background: rgba(8, 18, 44, 0.7);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  font-weight: 900;
}
.challenge-exit { gap: 8px; justify-self: start; }
.challenge-score { display: inline-flex; align-items: center; gap: 8px; justify-self: end; }
.challenge-score span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3b2500;
  background: linear-gradient(135deg, #ffd05b, #ff9f5b);
}

.knowledge-energy {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(8, 18, 44, 0.58);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(12px);
}
.energy-label,
.knowledge-energy .quiz-count { color: #d9e6ff; font-weight: 900; white-space: nowrap; }
.knowledge-energy .progress-bar {
  position: relative;
  height: 13px;
  background: rgba(255,255,255,0.14);
  border: 0;
}
.knowledge-energy .progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 13%, rgba(5,10,27,0.9) 13% 14%);
  opacity: 0.72;
}
.knowledge-energy .progress-bar span {
  background: linear-gradient(90deg, var(--realm-color, #8b5cf6), #5ba2ff, #48d48a);
  box-shadow: 0 0 18px color-mix(in srgb, var(--realm-color, #8b5cf6) 55%, transparent);
}
.combo-chip { color: #ffd05b; font-weight: 900; white-space: nowrap; }
.timed-challenge-chip {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px 8px 9px;
  border-radius: 999px;
  color: #ffe7a8;
  background:
    radial-gradient(circle at 18% 22%, rgba(255,208,91,0.24), transparent 34%),
    rgba(8,18,44,0.74);
  border: 1px solid rgba(255,208,91,0.34);
  box-shadow: 0 0 22px rgba(255,159,91,0.16), inset 0 1px 0 rgba(255,255,255,0.08);
  font-weight: 950;
}
.timed-challenge-chip .timer-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,208,91,0.18);
  animation: timer-swing 2.4s ease-in-out infinite;
}
.timed-challenge-chip .timer-label {
  font-size: 0.64rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffd07a;
  opacity: 0.92;
}
.timed-challenge-chip .timer-count {
  color: #fff4d4;
  font-size: 1.12rem;
  line-height: 1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
/* Urgency: the last 15 seconds turn the chip red and pulse it. */
.timed-challenge-chip.urgent {
  color: #ffd7d2;
  border-color: rgba(229,95,79,0.72);
  background:
    radial-gradient(circle at 18% 22%, rgba(229,95,79,0.32), transparent 36%),
    rgba(42,10,12,0.82);
  box-shadow: 0 0 26px rgba(229,95,79,0.42), inset 0 1px 0 rgba(255,255,255,0.08);
  animation: timer-urgent 0.9s ease-in-out infinite;
}
.timed-challenge-chip.urgent .timer-icon { background: rgba(229,95,79,0.3); animation-duration: 0.9s; }
.timed-challenge-chip.urgent .timer-label { color: #ffb3ab; }
.timed-challenge-chip.urgent .timer-count { color: #fff; }
@keyframes timer-swing {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-12deg); }
  60% { transform: rotate(12deg); }
}
@keyframes timer-urgent {
  0%, 100% { transform: scale(1); box-shadow: 0 0 26px rgba(229,95,79,0.42), inset 0 1px 0 rgba(255,255,255,0.08); }
  50% { transform: scale(1.05); box-shadow: 0 0 36px rgba(229,95,79,0.66), inset 0 1px 0 rgba(255,255,255,0.08); }
}
@media (prefers-reduced-motion: reduce) {
  .timed-challenge-chip .timer-icon,
  .timed-challenge-chip.urgent { animation: none; }
}

.challenge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 24px;
  align-items: stretch;
}
.challenge-main { display: grid; gap: 16px; }

.parchment-question {
  position: relative;
  color: #2c1d12;
  border: 1px solid rgba(92, 54, 24, 0.45);
  border-radius: 24px;
  padding: 24px 78px 24px 28px;
  background:
    radial-gradient(circle at 20% 12%, rgba(255,255,255,0.38), transparent 24%),
    linear-gradient(135deg, #f6ddb0, #e2bd7f);
  box-shadow: 0 14px 32px rgba(0,0,0,0.28), inset 0 0 0 2px rgba(255,255,255,0.18);
}
body.dark .challenge-panel .parchment-question {
  color: #2c1d12;
  border-color: rgba(92, 54, 24, 0.45);
  background:
    radial-gradient(circle at 20% 12%, rgba(255,255,255,0.38), transparent 24%),
    linear-gradient(135deg, #f6ddb0, #e2bd7f);
}
.parchment-question h3 {
  color: #2c1d12;
  text-align: center;
  font-size: calc(clamp(1.35rem, 2.6vw, 2rem) * var(--quiz-font-scale, 1));
  line-height: 1.35;
}
.challenge-panel .speak-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  color: #fff;
  border-color: rgba(255,255,255,0.28);
  background: linear-gradient(135deg, var(--realm-color, #4f46e5), #6d5dfc);
}

.challenge-panel .answer-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.challenge-panel .answer-list.answer-list-long {
  grid-template-columns: 1fr;
  gap: 12px;
}
.challenge-panel .answer-btn,
.challenge-panel .match-item,
.challenge-panel .order-chip,
.challenge-panel .order-row,
.challenge-panel .field input,
.challenge-panel textarea {
  border: 1px solid rgba(92, 54, 24, 0.38);
  border-radius: 18px;
  color: #2c1d12;
  background: linear-gradient(135deg, #f1d39d, #ddba7b);
  box-shadow: 0 12px 26px rgba(0,0,0,0.22), inset 0 0 0 2px rgba(255,255,255,0.14);
  /* text answers were inheriting the small base font; size them up to
     match the quiz and respond to the in-quiz font scaler */
  font-size: calc(1.3rem * var(--quiz-font-scale, 1));
  font-weight: 800;
  padding: 16px 18px;
  line-height: 1.4;
}
.challenge-panel textarea::placeholder,
.challenge-panel .field input::placeholder { color: rgba(92, 54, 24, 0.55); font-weight: 700; }
body.dark .challenge-panel .answer-btn,
body.dark .challenge-panel .match-item,
body.dark .challenge-panel .order-chip,
body.dark .challenge-panel .order-row,
body.dark .challenge-panel .field input,
body.dark .challenge-panel textarea {
  color: #2c1d12;
  border-color: rgba(92, 54, 24, 0.38);
  background: linear-gradient(135deg, #f1d39d, #ddba7b);
}
.challenge-panel .answer-btn {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 132px;
  padding: 24px 28px;
  font-size: 1.18rem;
  text-align: center;
  line-height: 1.25;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.challenge-panel .answer-list-long .answer-btn {
  min-height: 82px;
  padding: 18px 22px 18px 76px;
  place-items: center start;
  text-align: left;
}
.challenge-panel .answer-btn:hover:not(:disabled):not(.correct):not(.wrong) {
  transform: translateY(-4px);
  border-color: #48d48a;
  background: linear-gradient(135deg, #f8e2b8, #e6c785);
  box-shadow: 0 18px 36px rgba(0,0,0,0.28), 0 0 24px rgba(72,212,138,0.32);
}
body.dark .challenge-panel .answer-btn:hover:not(:disabled):not(.correct):not(.wrong) {
  color: #2c1d12;
  border-color: #48d48a;
  background: linear-gradient(135deg, #f8e2b8, #e6c785);
}
.challenge-panel .answer-btn .mark {
  position: absolute;
  top: 22px;
  left: 22px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--realm-color, #4f46e5), #6d5dfc);
  flex: 0 0 auto;
  box-shadow: 0 0 18px color-mix(in srgb, var(--realm-color, #4f46e5) 36%, transparent);
}
.challenge-panel .answer-btn > span:not(.mark):not(.answer-check) {
  display: block;
  max-width: 92%;
  color: inherit;
  font-size: calc(clamp(1.2rem, 2.2vw, 1.75rem) * var(--quiz-font-scale, 1));
  font-weight: 900;
}
.challenge-panel .answer-list-long .answer-btn > span:not(.mark):not(.answer-check) {
  max-width: 100%;
  font-size: calc(1.08rem * var(--quiz-font-scale, 1));
  line-height: 1.32;
}

/* ── Multiple-choice checkboxes ──────────────────────────────────────────
   Visually distinguishes multi-select questions from single-choice. */
.multi-hint {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: #ffd9a0;
  letter-spacing: 0.01em;
}
.challenge-panel .answer-btn-multi .answer-check {
  position: absolute;
  top: 18px; left: 18px;
  width: 34px; height: 34px;
  border-radius: 9px;                 /* square = checkbox (vs round .mark) */
  background: rgba(255,255,255,0.55);
  border: 2px solid rgba(92, 54, 24, 0.5);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
  display: grid; place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.challenge-panel .answer-btn-multi .answer-check::after {
  content: "";
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
}
/* Selected (before checking): purple tick */
.challenge-panel .answer-btn-multi.selected .answer-check {
  background: linear-gradient(135deg, var(--realm-color, #6d5dfc), #6d5dfc);
  border-color: transparent;
  box-shadow: 0 0 14px color-mix(in srgb, var(--realm-color, #6d5dfc) 40%, transparent);
}
.challenge-panel .answer-btn-multi.selected .answer-check::after { content: "✓"; color: #fff; }
/* After checking: correct option ticked green, wrongly-picked marked red */
.challenge-panel .answer-btn-multi.correct .answer-check {
  background: linear-gradient(135deg, #48d48a, #2da06a);
  border-color: transparent;
}
.challenge-panel .answer-btn-multi.correct .answer-check::after { content: "✓"; color: #fff; }
.challenge-panel .answer-btn-multi.wrong .answer-check {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: transparent;
}
.challenge-panel .answer-btn-multi.wrong .answer-check::after { content: "✕"; color: #fff; }
.challenge-panel .answer-btn.selected {
  transform: translateY(-3px);
  border-color: #48d48a;
  color: #2c1d12;
  background: linear-gradient(135deg, #f8e2b8, #e6c785);
  box-shadow: 0 0 0 3px rgba(72,212,138,0.24), 0 0 36px rgba(72,212,138,0.42), inset 0 0 0 2px rgba(255,255,255,0.24);
}
body.dark .challenge-panel .answer-btn.selected {
  color: #2c1d12;
  border-color: #48d48a;
  background: linear-gradient(135deg, #f8e2b8, #e6c785);
}
.challenge-panel .answer-btn.correct {
  color: #064e3b;
  border-color: #48d48a;
  background: linear-gradient(135deg, #d9ffe9, #9af0bf);
}
body.dark .challenge-panel .answer-btn.correct {
  color: #064e3b;
  border-color: #48d48a;
  background: linear-gradient(135deg, #d9ffe9, #9af0bf);
}
.challenge-panel .answer-btn.wrong {
  color: #7f1d1d;
  border-color: #ff7081;
  background: linear-gradient(135deg, #ffe0e4, #f9a5ae);
}
body.dark .challenge-panel .answer-btn.wrong {
  color: #7f1d1d;
  border-color: #ff7081;
  background: linear-gradient(135deg, #ffe0e4, #f9a5ae);
}

.owl-guide-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  align-self: stretch;
  align-content: end;
  min-height: 420px;
  padding: 18px;
}
.owl-guide-bubble {
  position: relative;
  z-index: 2;
  max-width: 190px;
  padding: 12px 16px;
  border-radius: 20px 20px 20px 6px;
  color: #1b2540;
  background: #fff8ed;
  box-shadow: 0 12px 24px rgba(0,0,0,0.22);
  font-weight: 900;
  text-align: center;
}
.owl-guide-owl {
  position: relative;
  z-index: 2;
  width: 210px;
  height: 210px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #f8eed8, #d9c8a8);
  border: 3px solid rgba(255,208,91,0.5);
  box-shadow: 0 18px 26px rgba(0,0,0,0.45), 0 0 40px rgba(255,208,91,0.32);
  animation: owlFloat 4.2s ease-in-out infinite;
}
.owl-guide-owl img {
  width: 110%;
  height: 110%;
  object-fit: cover;
  object-position: 50% 32%;
}
.owl-guide-glow {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 24px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,208,91,0.24), rgba(139,92,246,0.16) 45%, transparent 72%);
  filter: blur(8px);
}

/* ── Answer feedback reactions ──────────────────────────────────────────
   The owl + bubble react when the player checks an answer. */
.owl-guide-card.celebrate .owl-guide-owl {
  animation: owlCheer 0.7s ease;
  border-color: rgba(72, 212, 138, 0.85);
  box-shadow: 0 18px 26px rgba(0,0,0,0.45), 0 0 48px rgba(72, 212, 138, 0.6);
}
.owl-guide-card.celebrate .owl-guide-bubble {
  animation: bubblePop 0.4s ease;
  background: #eafff2;
  box-shadow: 0 12px 24px rgba(72,212,138,0.35);
}
.owl-guide-card.gentle .owl-guide-owl {
  animation: owlShake 0.5s ease;
  border-color: rgba(91, 162, 255, 0.6);
}

/* Sparkle burst — only visible while celebrating. */
.owl-sparkles { position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: 0; }
.owl-guide-card.celebrate .owl-sparkles { opacity: 1; }
.owl-sparkles span {
  position: absolute;
  font-size: 1.4rem;
  color: #ffd05b;
  opacity: 0;
  text-shadow: 0 0 8px rgba(255,208,91,0.8);
}
.owl-guide-card.celebrate .owl-sparkles span { animation: sparkleBurst 0.9s ease forwards; }
.owl-sparkles span:nth-child(1) { left: 18%; top: 30%; animation-delay: 0s; }
.owl-sparkles span:nth-child(2) { left: 78%; top: 26%; animation-delay: 0.08s; color: #b48cff; }
.owl-sparkles span:nth-child(3) { left: 30%; top: 60%; animation-delay: 0.15s; }
.owl-sparkles span:nth-child(4) { left: 70%; top: 58%; animation-delay: 0.05s; color: #5ba2ff; }
.owl-sparkles span:nth-child(5) { left: 50%; top: 18%; animation-delay: 0.2s; }
.owl-sparkles span:nth-child(6) { left: 86%; top: 46%; animation-delay: 0.12s; color: #48d48a; }

@keyframes owlCheer {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-16px) scale(1.06) rotate(-4deg); }
  55% { transform: translateY(0) scale(1.02) rotate(3deg); }
  75% { transform: translateY(-7px) scale(1.03) rotate(-2deg); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes owlShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-2deg); }
  75% { transform: translateX(6px) rotate(2deg); }
}
@keyframes bubblePop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes sparkleBurst {
  0% { opacity: 0; transform: scale(0.2) translateY(8px); }
  40% { opacity: 1; transform: scale(1.2) translateY(-4px); }
  100% { opacity: 0; transform: scale(0.9) translateY(-18px); }
}
@media (prefers-reduced-motion: reduce) {
  .owl-guide-card.celebrate .owl-guide-owl,
  .owl-guide-card.celebrate .owl-guide-bubble,
  .owl-guide-card.gentle .owl-guide-owl,
  .owl-guide-card.celebrate .owl-sparkles span { animation: none; }
}
.challenge-panel .feedback-card,
.challenge-panel .ai-box {
  color: #f8fbff;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
}
.challenge-panel .feedback-card {
  gap: 14px;
  padding: 18px 20px;
}
.challenge-panel .feedback-card > strong {
  color: #fff;
  font-size: calc(1.25rem * var(--quiz-font-scale, 1));
  line-height: 1.2;
}
.challenge-panel .quiz-feedback-message {
  margin: 0;
  color: #eef6ff;
  font-size: calc(1.2rem * var(--quiz-font-scale, 1));
  font-weight: 850;
  line-height: 1.45;
}
.challenge-panel .quiz-correct-answer {
  margin: 0;
  color: #93f2b6;
  font-size: calc(1.22rem * var(--quiz-font-scale, 1));
  font-weight: 900;
  line-height: 1.42;
}
.challenge-panel .quiz-correct-answer strong {
  color: #c9ffda;
  font-weight: 950;
}
.challenge-panel .quiz-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.challenge-panel .quiz-ai-head span {
  color: #eaf2ff;
  font-size: calc(1.15rem * var(--quiz-font-scale, 1));
  font-weight: 900;
  line-height: 1.35;
}
.challenge-panel .quiz-ai-head .btn-primary {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 16px;
  font-size: calc(1.06rem * var(--quiz-font-scale, 1));
  font-weight: 950;
  white-space: nowrap;
}
.challenge-panel .ai-explanation {
  margin: 0;
  padding: 14px 16px;
  color: #f8fbff;
  background: rgba(8,18,44,0.58);
  border: 1px solid rgba(150,190,255,0.18);
  border-left: 4px solid #7dd3fc;
  border-radius: 16px;
  font-size: calc(1.16rem * var(--quiz-font-scale, 1));
  font-weight: 800;
  line-height: 1.55;
}

@media (max-width: 820px) {
  .challenge-panel { min-height: 100dvh; max-height: 100dvh; border-radius: 0; padding: 14px; }
  .challenge-panel .modal-scroll { gap: 12px; }
  .challenge-panel .modal-foot .btn-primary {
    min-height: 58px;
    border-radius: 18px;
    font-size: 1rem;
  }
  .challenge-head {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
  }
  .challenge-exit { grid-column: 1; grid-row: 1; }
  .quiz-font-control { grid-column: 2; grid-row: 1; justify-self: center; }
  .challenge-score { grid-column: 3; grid-row: 1; }
  .challenge-title {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: left;
  }
  .challenge-exit span { display: none; }
  .quiz-font-control button { min-width: 34px; height: 34px; font-size: 0.85rem; }
  .challenge-layout { grid-template-columns: 1fr; }
  .owl-guide-card { display: none; }
  .challenge-panel .answer-list { grid-template-columns: 1fr; gap: 10px; }
  .challenge-panel .answer-btn { min-height: 72px; padding: 14px 18px 14px 62px; font-size: 1rem; text-align: left; place-items: center start; }
  .challenge-panel .answer-btn .mark { top: 50%; left: 16px; width: 34px; height: 34px; transform: translateY(-50%); }
  .challenge-panel .answer-btn > span:not(.mark) { max-width: 100%; font-size: 1.05rem; text-align: left; }
  .knowledge-energy { grid-template-columns: 1fr auto auto; gap: 8px; padding: 10px 12px; }
  .knowledge-energy .energy-label { display: none; }
  .parchment-question { padding: 18px 64px 18px 16px; }
  .parchment-question h3 { font-size: 1.25rem; }
  .challenge-panel .speak-btn { top: 16px; right: 16px; }
}

/* ═══ Pan Sowa 2.0 adventure HUD frame ═══ */
.adventure-hud-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}

.adventure-player-panel,
.adventure-side-panel {
  display: grid;
  gap: 14px;
}

.player-card,
.side-stat-card,
.side-wallet,
.owl-companion-card,
.side-progress-card,
.daily-challenge-card,
.side-badges-card,
.achievement-card {
  color: #f8fbff;
  border: 1px solid rgba(150, 190, 255, 0.22);
  border-radius: 22px;
  background: rgba(8, 18, 44, 0.72);
  box-shadow: 0 18px 44px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
}

.player-card {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
}
.player-avatar-large {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(135deg, #5ba2ff, #8b5cf6);
  box-shadow: 0 0 28px rgba(91,162,255,0.36);
  font-size: 2.15rem;
  font-weight: 900;
  overflow: hidden;
}
.player-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.player-avatar-large span {
  display: grid;
  place-items: center;
}
.player-card strong { display: block; color: #fff; font-size: 1.35rem; }
.player-card span { color: #b8c8e8; font-weight: 800; }
.player-level-line { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; margin-top: 8px; }
.level-shield {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3b2500 !important;
  background: linear-gradient(135deg, #ffd05b, #ff9f5b);
  font-weight: 900;
}

.side-stat-card,
.owl-companion-card,
.side-progress-card,
.daily-challenge-card,
.side-badges-card,
.achievement-card { padding: 16px; }
.side-stat-card { display: grid; gap: 8px; }
.side-stat-card span,
.owl-companion-card p,
.daily-challenge-card span,
.side-badges-card span,
.achievement-card span,
.side-progress-card span { color: #d8e4ff; font-weight: 900; }
.side-stat-card strong { color: #fff; font-size: 1.45rem; }
.side-stat-card small,
.daily-challenge-card small,
.achievement-card small { color: #b8c8e8; font-weight: 800; }

.side-wallet {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}
.side-wallet div { padding: 14px; display: grid; gap: 4px; }
.side-wallet div + div { border-left: 1px solid rgba(255,255,255,0.12); }
.side-wallet span { color: #b8c8e8; font-size: 0.86rem; font-weight: 800; }
.side-wallet strong { color: #fff; font-size: 1.2rem; }

.owl-companion-card { text-align: center; display: grid; gap: 8px; }
.owl-companion {
  width: 124px;
  height: 124px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #f8eed8, #d9c8a8);
  border: 3px solid rgba(255,208,91,0.5);
  box-shadow: 0 8px 22px rgba(0,0,0,0.4), 0 0 28px rgba(255,208,91,0.28);
}
.owl-companion img {
  width: 110%;
  height: 110%;
  object-fit: cover;
  object-position: 50% 35%;
}
.owl-companion-card > span { color: #d8e4ff; font-weight: 900; }

.side-progress-card { display: grid; gap: 14px; }
.side-progress-card > div:first-child { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.side-progress-card strong { color: #fff; font-size: 1.55rem; }
.side-progress-card .side-card-head span {
  color: #f6fbff;
  text-shadow: 0 0 14px rgba(91,162,255,0.3);
}
.side-progress-body {
  display: grid;
  gap: 14px;
}
.progress-ring {
  --pct: 0;
  width: 128px;
  height: 128px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#48d48a calc(var(--pct) * 1%), rgba(126,150,196,0.28) 0);
  box-shadow: 0 0 34px rgba(72,212,138,0.24);
  position: relative;
}
.progress-ring::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: #0b1734;
}
.progress-ring span { position: relative; z-index: 1; color: #fff; font-size: 1.55rem; font-weight: 900; }
.progress-owl-bubble {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(150,190,255,0.16);
}
.progress-owl-img {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #fff4ce, #d8b36c);
  border: 2px solid rgba(255,208,91,0.44);
}
.progress-owl-img img {
  width: 118%;
  height: 118%;
  object-fit: cover;
  object-position: 50% 30%;
}
.progress-bubble {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 12% 12%, rgba(255,208,91,0.18), transparent 38%),
    rgba(12, 30, 68, 0.88);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.progress-bubble strong {
  color: #fff;
  font-size: 1rem;
  line-height: 1.15;
}
.progress-bubble span {
  color: #e7f0ff;
  font-size: 0.86rem;
  line-height: 1.25;
  font-weight: 900;
}
.stats-quest-btn {
  width: 100%;
  min-height: 48px;
  display: inline-grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  justify-items: center;
  padding: 0 16px;
  border-radius: 18px;
  color: #fff;
  background:
    radial-gradient(circle at 18% 24%, rgba(255,208,91,0.24), transparent 30%),
    linear-gradient(135deg, #5ba2ff, #6d5dfc 68%, #8b5cf6);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 14px 30px rgba(91,162,255,0.24), 0 0 24px rgba(139,92,246,0.18);
  font-weight: 900;
}
.stats-quest-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(91,162,255,0.3), 0 0 30px rgba(255,208,91,0.14);
}
.stats-quest-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3b2500 !important;
  background: radial-gradient(circle at 34% 30%, #fff6b7, #ffd05b 58%, #ff9f5b);
  box-shadow: 0 0 18px rgba(255,208,91,0.36);
}

.daily-challenge-card { display: grid; gap: 10px; }
.daily-challenge-card strong { color: #fff; }
.side-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.side-card-head button {
  min-height: 32px;
  min-width: 0;
  padding: 0 10px;
  border-radius: 999px;
  color: #dbe8ff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 0.82rem;
}
.side-badge-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.side-badge-row img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  opacity: 0.46;
  filter: grayscale(0.65);
}
.side-badge-row img.earned { opacity: 1; filter: none; box-shadow: 0 0 18px rgba(255,208,91,0.28); }

.achievement-card { display: grid; gap: 10px; }
.achievement-card div {
  display: grid;
  gap: 2px;
  padding: 10px 0 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.achievement-card strong { color: #fff; }

.side-teacher-panel { display: grid; gap: 12px; }
.student-side-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.student-side-stack .achievement-card {
  min-height: 0;
}
.student-side-stack .achievement-item span {
  min-width: 0;
  line-height: 1.28;
  overflow-wrap: anywhere;
}
.side-class-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.side-stat-cell { text-align: center; padding: 10px 4px; background: rgba(255,255,255,0.06); border-radius: 14px; }
.side-stat-cell strong { display: block; font-size: 1.35rem; font-weight: 900; color: #fff; }
.side-stat-cell small { color: #9ab0d8; font-size: 0.72rem; font-weight: 700; }
.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: #e05050; color: #fff; font-size: 0.7rem; font-weight: 900;
  min-width: 18px; height: 18px; border-radius: 999px; padding: 0 4px;
  margin-right: 4px;
}

.adventure-room-card {
  min-height: 112px;
  display: grid;
  align-items: end;
  padding: 16px;
  border-radius: 22px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(8,18,44,0.88), rgba(8,18,44,0.3)),
    url("/assets/ui/adventure-map-bg.png") 20% 82% / 360px auto no-repeat,
    rgba(8,18,44,0.72);
  border: 1px solid rgba(150,190,255,0.22);
  box-shadow: 0 18px 44px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  overflow: hidden;
}
.adventure-room-card small {
  display: block;
  max-width: 150px;
  color: #d8e4ff;
  font-weight: 800;
  line-height: 1.22;
}

.adventure-screen.map-shell {
  padding: 0;
}

.map-shell .adventure-stage {
  position: relative;
  min-height: clamp(820px, calc(100vh - 130px), 1000px);
  padding: 0;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(2,6,18,0.68), transparent 18%, transparent 80%, rgba(2,6,18,0.74)),
    linear-gradient(180deg, rgba(2,6,18,0.04), rgba(2,6,18,0.15) 54%, rgba(2,6,18,0.7)),
    url("/assets/ui/adventure-map-bg.png") 78% 40% / cover no-repeat,
    #07142f;
}

/* Kept for legacy, now unused */
.map-shell .adventure-hud-layout {
  display: contents;
}

.map-shell .adventure-hud-layout::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 80%, rgba(72,212,138,0.18), transparent 18%),
    radial-gradient(circle at 60% 35%, rgba(139,92,246,0.16), transparent 22%),
    radial-gradient(circle at 83% 18%, rgba(91,162,255,0.18), transparent 18%);
}

.map-shell .adventure-player-panel,
.map-shell .adventure-side-panel {
  align-content: start;
  position: relative;
  z-index: 5;
}

.map-shell .adventure-stage::before {
  display: none;
}

.map-shell .adventure-stage-head {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 6;
  width: min(680px, 96%);
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 0;
  text-align: center;
  pointer-events: none;
}

.map-shell .adventure-stage-head .eyebrow {
  display: none;
}

.map-shell .adventure-stage-head h2 {
  font-size: clamp(1.6rem, 2.35vw, 2.15rem);
  line-height: 1.05;
  text-shadow: 0 3px 14px rgba(0,0,0,0.85), 0 0 24px rgba(255,208,91,0.3);
}

.map-shell .adventure-lead {
  color: #eef5ff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.75);
  font-size: 0.98rem;
}

.map-shell .adventure-filter {
  display: none;
}

.map-shell .realm-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  min-height: 100%;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.map-shell .realm-map::before,
.map-shell .map-moon,
.map-shell .map-waterfall {
  display: none;
}

/* In map-shell mode the new map-bg.png already shows a painted treasure
   chest in the bottom-left, so the floating chest card is hidden to avoid
   visual duplication. It remains a clickable invisible hotspot. */
.map-shell .map-treasure-card {
  left: 1%;
  bottom: 4%;
  width: 132px;
  height: 104px;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  z-index: 5;
}
.map-shell .map-treasure-card .chest-icon,
.map-shell .map-treasure-card strong { display: none; }
.map-shell .map-treasure-card small {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(8,18,44,0.78);
  border: 1px solid rgba(255,180,90,0.35);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: #ffd07a;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.map-shell .map-treasure-card:hover { transform: scale(1.03); }
.map-shell .map-treasure-card.chest-ready { animation: chestPulse 1.4s ease-in-out infinite; }
@keyframes chestPulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(255,208,91,0)); }
  50% { filter: drop-shadow(0 0 20px rgba(255,208,91,0.6)); }
}

.map-shell .realm-card {
  width: clamp(150px, 11vw, 178px);
  /* Fixed, uniform pin height — prevents any card (e.g. locked realms or
     a slow-loading icon) from ballooning and colliding with the bottom
     UI strip. Flex column keeps the art/title/count centred. */
  height: 132px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px 12px;
  text-align: center;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--realm-color) 30%, transparent), transparent 48%),
    linear-gradient(180deg, rgba(8,18,44,0.86), rgba(5,11,30,0.92));
  border-color: color-mix(in srgb, var(--realm-color) 50%, rgba(255,255,255,0.22));
  box-shadow: 0 14px 38px rgba(0,0,0,0.5), 0 0 24px color-mix(in srgb, var(--realm-color) 28%, transparent), inset 0 1px 0 rgba(255,255,255,0.12);
}

.map-shell .realm-art {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--realm-color) 78%, #fff 10%), color-mix(in srgb, var(--realm-color) 42%, #07142f)),
    radial-gradient(circle at 35% 22%, rgba(255,255,255,0.32), transparent 42%);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 22px color-mix(in srgb, var(--realm-color) 38%, transparent), inset 0 1px 0 rgba(255,255,255,0.22);
  margin-bottom: 2px;
}

.map-shell .realm-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
/* Emoji fallback span — visible only when the icon PNG failed to load
   (onerror handler adds .asset-missing to the .realm-art container). */
.map-shell .realm-art span.realm-art-fallback { display: none; }
.map-shell .realm-art.asset-missing img { display: none; }
.map-shell .realm-art.asset-missing span.realm-art-fallback {
  display: grid;
  place-items: center;
  width: 100%; height: 100%;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 1000;
  text-shadow: 0 2px 10px rgba(0,0,0,0.42);
}

.map-shell .realm-card.featured {
  width: clamp(168px, 12.4vw, 196px);
  height: 146px;
  border-color: color-mix(in srgb, var(--realm-color) 75%, #fff);
  box-shadow: 0 16px 46px rgba(0,0,0,0.55), 0 0 32px color-mix(in srgb, var(--realm-color) 40%, transparent), inset 0 1px 0 rgba(255,255,255,0.18);
}
.map-shell .realm-card.featured .realm-art { width: 64px; height: 64px; }
.map-shell .realm-card.featured .realm-art span { font-size: 1.7rem; }

.map-shell .realm-card.locked {
  opacity: 0.92;
  filter: saturate(0.72);
  border-color: rgba(150,190,255,0.18);
}

.map-shell .realm-card.locked .realm-art {
  background:
    linear-gradient(135deg, rgba(74,85,112,0.9), rgba(31,42,68,0.86)),
    radial-gradient(circle at 35% 20%, rgba(255,255,255,0.18), transparent 42%);
  box-shadow: none;
}

.map-shell .realm-card.locked .realm-art::after {
  content: "🔒";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.map-shell .realm-card.locked .realm-art span {
  opacity: 0;
}

.map-shell .realm-card .realm-status,
.map-shell .realm-copy small,
.map-shell .realm-progress > span:first-child {
  display: none;
}

.map-shell .realm-progress {
  grid-column: 1;
  display: grid;
  gap: 2px;
  justify-items: center;
}
.map-shell .realm-copy {
  text-align: center;
}
.map-shell .realm-copy strong {
  font-size: 0.86rem;
  line-height: 1.18;
  display: block;
}
.map-shell .realm-card .adventure-progress { display: none; }

.map-shell .realm-count {
  color: #ffd05b;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.map-shell .realm-card.locked .realm-count {
  color: #cbd5e1;
  font-size: 0.78rem;
  line-height: 1.2;
  font-weight: 800;
}

/* Pin positions tuned to landmarks of the new adventure-map-bg.png
   subject order: polish, math, science, history, english, it */
.map-shell .realm-map .realm-card:nth-of-type(1) { left: auto; right: 4%;  top: 26%; --pin-scale: 0.92; }  /* Polish — wizard tower (right-top) */
.map-shell .realm-map .realm-card:nth-of-type(2) { left: 4%;   right: auto; top: 16%; --pin-scale: 1; }    /* Math — tree-house cottage (left-top, featured) */
.map-shell .realm-map .realm-card:nth-of-type(3) { left: 16%;  top: 54%; --pin-scale: 0.9; }               /* Science — turquoise river (left-mid) */
.map-shell .realm-map .realm-card:nth-of-type(4) { left: 30%;  right: auto; top: 14%; --pin-scale: 0.94; } /* History — crystal cave portal (top-center) */
.map-shell .realm-map .realm-card:nth-of-type(5) { left: auto; right: 5%;  top: 55%; --pin-scale: 0.88; } /* English — book (right, raised above the bottom UI strip) */
.map-shell .realm-map .realm-card:nth-of-type(6) { left: 43%;  right: auto; top: 40%; --pin-scale: 0.9; } /* IT — camp (centre-mid, clear of the quick-nav strip) */
.map-shell .realm-map .realm-card:nth-of-type(7) { left: 60%;  top: 46%; --pin-scale: 0.86; }              /* fallback if extra realm */

.map-shell .map-daily-card {
  display: none !important;
}

.map-shell .map-quick-nav {
  position: absolute;
  left: 50%;
  bottom: 76px;
  z-index: 6;
  width: min(470px, 54%);
  transform: translateX(-50%);
  margin: 0;
  white-space: nowrap;
}

.map-shell .map-scroll-note {
  position: absolute;
  left: 50%;
  bottom: 8px;
  z-index: 6;
  width: min(540px, 60%);
  transform: translateX(-50%);
  margin: 0;
}

.map-shell .daily-challenge-card {
  min-height: 154px;
  grid-template-columns: 76px 1fr;
  align-items: center;
}

.map-shell .daily-challenge-card::before {
  content: "";
  grid-row: span 4;
  width: 64px;
  height: 76px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.72), rgba(245,215,159,0.88)),
    linear-gradient(135deg, #eab308, #f97316);
  box-shadow: 0 14px 24px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.4);
}

.map-shell .daily-challenge-card .adventure-progress,
.map-shell .daily-challenge-card small {
  grid-column: 2;
}

.map-shell .side-progress-card {
  min-height: 246px;
  grid-template-columns: 1fr 150px;
  align-items: center;
  overflow: hidden;
}

.map-shell .side-progress-card::after {
  content: "";
  grid-row: 1 / span 3;
  grid-column: 2;
  align-self: end;
  width: 160px;
  height: 170px;
  margin: -10px -18px -20px 0;
  background: url("/assets/characters/owl-guide.png") center / contain no-repeat;
  filter: drop-shadow(0 18px 22px rgba(0,0,0,0.34));
}

.map-shell .side-progress-card .progress-ring {
  grid-column: 1;
  margin: 0;
  width: 132px;
  height: 132px;
}

.map-shell .side-progress-card .btn-primary {
  grid-column: 1 / -1;
}

.adventure-screen.realm-shell .adventure-hud-layout {
  grid-template-columns: minmax(0, 1180px);
  justify-content: center;
}

.realm-shell .adventure-player-panel,
.realm-shell .adventure-side-panel {
  display: none;
}

.realm-shell .adventure-stage {
  width: 100%;
}
.realm-shell .adventure-stage-head {
  display: none;
}

@media (max-width: 1280px) {
  .adventure-hud-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .adventure-side-panel { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .progress-ring { width: 104px; height: 104px; }
}

@media (max-width: 980px) {
  .adventure-hud-layout { grid-template-columns: 1fr; }
  .adventure-player-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-card { grid-column: 1 / -1; }
  .adventure-side-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .adventure-screen.map-shell {
    width: auto;
    max-width: 100%;
    margin-inline: 0;
    margin-top: 0;
    padding: 0;
  }
  .map-shell .adventure-hud-layout {
    min-height: 0;
    grid-template-columns: 1fr;
    padding: 12px;
    overflow: visible;
    border-radius: 22px;
  }
  .map-shell .adventure-stage {
    min-height: 0;
    padding: 16px;
    overflow: hidden;
    border: 1px solid rgba(150,190,255,0.22);
    border-radius: 22px;
    background:
      radial-gradient(circle at 22% 18%, rgba(91,162,255,0.18), transparent 28%),
      linear-gradient(145deg, rgba(8,18,44,0.9), rgba(5,12,31,0.84));
    box-shadow: 0 18px 48px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  }
  .map-shell .adventure-stage-head {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    transform: none;
    margin-bottom: 16px;
    pointer-events: auto;
  }
  .map-shell .realm-map {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: 0;
    padding: 0;
    overflow: visible;
  }
  .map-shell .map-quick-nav,
  .map-shell .map-scroll-note {
    position: relative;
    left: auto;
    bottom: auto;
    width: 100%;
    transform: none;
    margin-top: 14px;
  }
  .map-shell .adventure-side-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .adventure-player-panel,
  .adventure-side-panel { grid-template-columns: 1fr; }
  .player-card { grid-template-columns: 68px 1fr; }
  .player-avatar-large { width: 68px; height: 68px; font-size: 1.8rem; border-radius: 18px; }
}

@media (max-width: 820px) {
  .adventure-player-panel {
    display: none !important;
  }
  .adventure-filter {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
  }
  .adventure-filter::-webkit-scrollbar {
    display: none;
  }
}

/* ═══ MOBILE BOTTOM NAV ═══ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--panel);
  border-top: 1px solid var(--panel-border-color, rgba(255,255,255,0.08));
  /* Below modals (--z-modal: 100) so open dialogs cover the nav instead of the
     nav overlapping their content/buttons; still above normal page chrome. */
  z-index: var(--z-overlay);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}
.bottom-nav-btn.active { color: var(--blue); }
.bottom-nav-icon { font-size: 1.25rem; line-height: 1; }

/* ═══ MOBILE SIDEBAR BACKDROP ═══ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 198;
  backdrop-filter: blur(2px);
}

/* ═══ SIDEBAR CLOSE BUTTON ═══ */
.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 10px; right: 10px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
}

/* ═══ MOBILE LAYOUT — single block, no conflicts ═══ */
@media (max-width: 768px) {
  .sidebar-backdrop { display: block; left: 272px; }
  .bottom-nav { display: flex; }
  .sidebar-close-btn { display: flex; align-items: center; justify-content: center; }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 8px 12px 72px;
  }
  /* sidebar-left: out of flow, fixed drawer */
  .app-sidebar-left {
    grid-column: auto;
    position: fixed;
    top: 0; left: -290px;
    width: 272px;
    height: 100dvh;
    z-index: 199;
    overflow-y: auto;
    transition: left 0.25s ease;
    padding: 14px 12px 24px;
    /* opaque drawer background so the page behind never shows through */
    background:
      radial-gradient(circle at 30% 8%, rgba(91,162,255,0.12), transparent 40%),
      linear-gradient(180deg, #0c1736 0%, #0a1228 60%, #070d1e 100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .app-sidebar-left.is-open { left: 0; }
  /* main: takes the only grid column */
  .app-main {
    grid-column: 1;
    padding-bottom: 0;
  }
  .app-sidebar-right { display: none; }

  /* Topbar */
  .topbar-nav { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .logo-text { display: none; }
  .topbar-hud .hud-stat:not(.coin-stat) { display: none; }

  /* Drawer navigation — the only way to reach secondary tabs on phones.
     Higher-specificity selector so it beats the base display:none rule
     regardless of source order. */
  .app-sidebar-left .sidebar-mobile-nav { display: grid; gap: 6px; margin: 4px 0 14px; }
}

/* Hidden on desktop (top nav handles navigation there). */
.sidebar-mobile-nav { display: none; }
.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: #dbe8ff;
  font-weight: 800;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.sidebar-nav-btn:hover { background: rgba(255,255,255,0.1); }
.sidebar-nav-btn.active {
  background: linear-gradient(135deg, rgba(139,92,246,0.4), rgba(91,162,255,0.28));
  border-color: rgba(139,92,246,0.6);
  color: #fff;
}
.sidebar-nav-icon {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  font-size: 0.95rem;
  flex-shrink: 0;
}
.sidebar-nav-btn.active .sidebar-nav-icon { background: rgba(255,255,255,0.18); }

/* ═══════════════════════════════════════════════════════════════════════
   NAUKA — Theory book modal
   3-column layout: ścieżka nauki | pergamin (środek) | sowa radzi + ciekawostka
   ═══════════════════════════════════════════════════════════════════════ */

.theory-book-overlay {
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 220, 120, 0.4) 0%, transparent 0.4%),
    radial-gradient(circle at 88% 22%, rgba(255, 230, 160, 0.45) 0%, transparent 0.3%),
    radial-gradient(circle at 6% 70%, rgba(170, 200, 255, 0.35) 0%, transparent 0.4%),
    radial-gradient(circle at 92% 78%, rgba(255, 200, 100, 0.4) 0%, transparent 0.35%),
    radial-gradient(circle at 22% 8%, rgba(255, 255, 255, 0.4) 0%, transparent 0.25%),
    radial-gradient(circle at 78% 4%, rgba(255, 255, 255, 0.35) 0%, transparent 0.25%),
    radial-gradient(circle at 4% 42%, rgba(255, 235, 180, 0.5) 0%, transparent 0.3%),
    radial-gradient(circle at 96% 50%, rgba(180, 220, 255, 0.4) 0%, transparent 0.3%),
    radial-gradient(circle at 16% 92%, rgba(255, 220, 150, 0.4) 0%, transparent 0.3%),
    radial-gradient(circle at 84% 95%, rgba(255, 240, 200, 0.35) 0%, transparent 0.3%),
    rgba(2, 6, 18, 0.85);
  backdrop-filter: blur(8px);
}

.theory-book-modal {
  position: relative;
  width: min(1280px, 96vw);
  max-height: 92vh;
  border-radius: 28px;
  padding: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 24%, rgba(91,162,255,0.18), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(139,92,246,0.16), transparent 30%),
    linear-gradient(160deg, #0e1d4a 0%, #0a1532 55%, #050a1c 100%);
  border: 1px solid rgba(150, 190, 255, 0.22);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #f8fbff;
}

/* ── Missing-asset placeholder ── used wherever the AI-generated image
   has not yet been uploaded — shows a labelled dashed box so the user
   can see exactly which file is missing and ask for it. */
.missing-asset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 10px;
  background: repeating-linear-gradient(45deg, rgba(255,208,91,0.18) 0 8px, rgba(255,208,91,0.08) 8px 16px);
  border: 2px dashed rgba(255,208,91,0.7);
  border-radius: 10px;
  color: #ffd07a;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: lowercase;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
  min-width: 100px;
}
.missing-asset-mini {
  padding: 3px 6px;
  font-size: 0.62rem;
  min-width: 60px;
  border-radius: 6px;
}

/* ── Top bar ── */
.theory-book-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(150, 190, 255, 0.16);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent);
}
.theory-book-title { display: flex; align-items: center; gap: 14px; }
.theory-book-icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #8b5cf6, #5fa3ff);
  font-size: 1.2rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 18px rgba(139,92,246,0.4);
  overflow: hidden;
}
.theory-book-icon img { width: 100%; height: 100%; object-fit: cover; }
.theory-book-icon .missing-asset { background: transparent; border: 0; color: #fff; font-size: 0.55rem; padding: 0; }
.theory-book-title h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.01em;
}
.theory-book-close {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: #d8e4ff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.18s ease;
}
.theory-book-close:hover { background: rgba(255,255,255,0.14); }

/* ── Loading / error ── */
.theory-book-loading { padding: 60px 32px; text-align: center; }

/* ── Main 3-column body ── */
.theory-book-body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 240px;
  gap: 18px;
  padding: 14px 18px;
  overflow: hidden;
  min-height: 0;
}

/* ── LEFT: Ścieżka nauki ── */
.theory-book-path {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(8,18,44,0.7), rgba(5,11,30,0.78));
  border: 1px solid rgba(150,190,255,0.14);
  overflow-y: auto;
  max-height: 100%;
  scrollbar-width: thin;
  scrollbar-color: rgba(150,190,255,0.32) transparent;
}
.theory-book-path h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #ffd07a;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.theory-path-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.theory-path-step {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.15s ease, border-color 0.18s ease;
  user-select: none;
}
.theory-path-step:hover { background: rgba(255,255,255,0.09); transform: translateX(2px); }
.theory-path-step .path-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.1);
  color: #c8d6f0;
  font-weight: 900;
  font-size: 0.85rem;
  border: 1px solid rgba(255,255,255,0.15);
}
.theory-path-step .path-label {
  font-size: 0.85rem;
  color: #e0e8f7;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.theory-path-step .path-status { font-size: 0.95rem; opacity: 0.85; }
.theory-path-step.done {
  background: rgba(72, 212, 138, 0.08);
  border-color: rgba(72,212,138,0.35);
}
.theory-path-step.done .path-num {
  background: linear-gradient(135deg, #48d48a, #2da06a);
  color: transparent;          /* hide the number — show ✓ instead */
  border-color: transparent;
  position: relative;
  box-shadow: 0 4px 12px rgba(72, 212, 138, 0.45), inset 0 1px 0 rgba(255,255,255,0.32);
}
.theory-path-step.done .path-num::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
}
.theory-path-step.done .path-status { display: none; }   /* visual cue moved into the badge */
.theory-path-step.active {
  background: linear-gradient(135deg, rgba(139,92,246,0.32), rgba(91,162,255,0.22));
  border-color: rgba(139,92,246,0.55);
  box-shadow: 0 4px 16px rgba(139,92,246,0.32);
  transform: translateX(2px);
}
.theory-path-step.active .path-num {
  background: linear-gradient(135deg, #8b5cf6, #5ba2ff);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(139,92,246,0.5);
}
.theory-path-step.active .path-label { color: #fff; font-weight: 800; }
.theory-path-step.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
.theory-path-step.locked .path-num { background: rgba(255,255,255,0.05); color: #6c7a96; }

/* Decoration at the bottom of the left "ścieżka nauki" column */
.theory-path-decoration {
  margin-top: auto;
  padding-top: 12px;
  display: grid; place-items: center;
}
.theory-path-decoration img {
  width: 100%;
  max-width: 200px;
  height: auto;
  opacity: 0.92;
  border-radius: 12px;
}
.theory-path-decoration .missing-asset { width: 100%; padding: 16px 8px; }

/* ── CENTER: parchment page ── */
.theory-book-page {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}
/* ─── OPEN BOOK FRAME ───────────────────────────────────────────────────
   The whole .theory-page-paper is now styled as a hardcover open book:
     • outer brown leather frame (border)
     • inner cream parchment surface (background)
     • visible center "spine" valley with shadow
     • subtle stacked-page edge stripes on left/right outer sides */
.theory-page-paper {
  position: relative;
  flex: 1;
  padding: 22px clamp(20px, 3vw, 38px) 22px;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  border-radius: 16px;
  /* dark brown wooden/leather hardcover frame */
  background:
    /* parchment in the middle */
    linear-gradient(180deg, #f7eed4 0%, #efe2bc 100%),
    #4a2e15;
  background-clip: padding-box, border-box;
  background-origin: padding-box, border-box;
  border: 10px solid;
  border-image: linear-gradient(135deg, #6b3f1a, #4a2812 45%, #6b3f1a 55%, #4a2812 100%) 1;
  box-shadow:
    /* leather rim highlights */
    inset 0 0 0 3px rgba(255, 220, 160, 0.18),
    inset 0 0 0 4px rgba(0, 0, 0, 0.42),
    /* parchment glow at edges */
    inset 0 0 28px rgba(120, 84, 36, 0.22),
    /* drop shadow under the book */
    0 22px 48px rgba(0, 0, 0, 0.55),
    0 8px 16px rgba(0, 0, 0, 0.4);
  color: #1f1408;
  scrollbar-width: auto;
  scrollbar-color: #8b5a2f rgba(255, 240, 200, 0.4);
}
/* WebKit scrollbar — brown leather styling, prominent so users see they
   can scroll if the page content is taller than the parchment. */
.theory-page-paper::-webkit-scrollbar {
  width: 14px;
}
.theory-page-paper::-webkit-scrollbar-track {
  background: rgba(255, 240, 200, 0.4);
  border-radius: 7px;
  margin: 6px 0;
}
.theory-page-paper::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #a06028, #6b3f1a);
  border-radius: 7px;
  border: 2px solid rgba(255, 240, 200, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.5);
}
.theory-page-paper::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #b97030, #8b5a2f);
}
/* Decorative paper-stack edges — thin stripes on left/right just inside
   the leather cover, suggesting many pages stacked underneath. */
.theory-page-paper::before {
  content: "";
  position: absolute;
  top: 4px; bottom: 4px; left: -8px;
  width: 6px;
  background:
    repeating-linear-gradient(180deg,
      rgba(180, 138, 74, 0.42) 0px, rgba(180, 138, 74, 0.42) 1px,
      rgba(245, 230, 195, 0.85) 1px, rgba(245, 230, 195, 0.85) 3px);
  box-shadow: inset 1px 0 0 rgba(120, 84, 36, 0.6), 1px 0 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  border-radius: 2px 0 0 2px;
}
.theory-page-paper::after {
  content: "";
  position: absolute;
  top: 4px; bottom: 4px; right: -8px;
  width: 6px;
  background:
    repeating-linear-gradient(180deg,
      rgba(180, 138, 74, 0.42) 0px, rgba(180, 138, 74, 0.42) 1px,
      rgba(245, 230, 195, 0.85) 1px, rgba(245, 230, 195, 0.85) 3px);
  box-shadow: inset -1px 0 0 rgba(120, 84, 36, 0.6), -1px 0 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  border-radius: 0 2px 2px 0;
}
/* Center spine — wraps the parchment with a vertical valley.
   Done via an extra layered background gradient now so a separate
   element isn't needed. Inserted inside content's scroll area would
   move with content, so we render it as a sticky overlay div instead. */
.theory-page-paper .theory-page-content {
  position: relative;
}
/* Center "book spine" shadow removed — user request. */
/* "Bookmark ribbon" — falls down from the top edge of the parchment.
   Two CSS pieces: the main rectangular flag + a notched bottom. */
.theory-page-counter {
  position: absolute;
  top: -14px;
  left: 28px;
  padding: 12px 14px 16px;
  background: linear-gradient(180deg, #8b5cf6 0%, #6d5dfc 50%, #5a4ad8 100%);
  color: #fff;
  font-weight: 900;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  min-width: 42px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.55), inset 1px 0 0 rgba(255,255,255,0.22), inset -1px 0 0 rgba(0,0,0,0.18);
  z-index: 2;
  /* notched bottom — pointed v-shape inward */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}

/* Theory content typography on parchment — strong override of base .theory-section */
.theory-page-content { color: #1f1408; }
.theory-page-paper .theory-section,
.theory-page-paper .theory-section.ai-wait-panel,
.theory-page-paper div.theory-section {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  color: #1f1408 !important;
  margin-top: 12px;
}
body.dark .theory-page-paper .theory-section,
body.dark .theory-page-paper .theory-section h3,
body.dark .theory-page-paper .theory-section p { background: transparent !important; border: 0 !important; color: #1f1408 !important; }
.theory-page-paper .theory-section h3 { color: #2a1810 !important; }
.theory-page-paper .theory-section .example { background: rgba(255, 240, 180, 0.55) !important; border-left: 4px solid #b48a4a !important; color: #3a2a10 !important; }

/* ─── Illustrated example cards ────────────────────────────────────────
   Replaces certain "real-life examples" bullet lists in the theory body
   with a row of small painted-tile cards (matches Nauka_docelowa.png
   "W sklepie / W drodze / W grach" pattern). */
.theory-example-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 10px 0 12px;
}
.theory-example-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(2.45em, auto);
  gap: 5px;
  justify-items: center;
  padding: 0 10px 10px;
  border-radius: 14px;
  border: 3px solid #6b4520;
  box-shadow:
    0 8px 22px rgba(60, 36, 12, 0.45),
    inset 0 0 0 1px rgba(255, 230, 180, 0.4);
  text-align: center;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.18s ease;
  background:
    linear-gradient(180deg, rgba(255, 245, 215, 0.95), rgba(240, 220, 160, 0.95));
  /* dark fallback shows only inside the scene area (covered by .example-icon) */
}
.theory-example-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 14px 30px rgba(60, 36, 12, 0.55),
    inset 0 0 0 1px rgba(255, 240, 200, 0.55),
    inset 0 0 24px rgba(120, 84, 36, 0.3);
}
/* The painted "scene" inside each card — full-width strip at the top
   above the title/description. Each child uses a different palette
   simulating its theme (market / road / chess). */
.theory-example-card .example-icon {
  width: calc(100% + 20px);   /* bleed beyond the inner padding */
  height: 96px;
  margin: 0 -10px 12px;
  display: grid; place-items: center;
  font-size: 1.8rem;
  border-radius: 0;            /* full-width strip, not a circle */
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  position: relative;
  background-size: cover;      /* crop the scene to the slot's ratio */
  background-position: center 60%;
  background-repeat: no-repeat;
}
/* When a painted scene image is bound, hide the gradient stack and
   keep only the image (set as background-image via inline style). */
.theory-example-card.has-scene .example-icon,
.theory-example-card.has-scene:nth-child(5n+1) .example-icon,
.theory-example-card.has-scene:nth-child(5n+2) .example-icon,
.theory-example-card.has-scene:nth-child(5n+3) .example-icon,
.theory-example-card.has-scene:nth-child(5n+4) .example-icon,
.theory-example-card.has-scene:nth-child(5n+5) .example-icon {
  background-color: #2a1a0a;
  background-size: cover;
  background-position: center 60%;
  background-repeat: no-repeat;
  background-image: var(--scene-url);
}
.theory-example-card.has-scene .example-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 60%;
  border-radius: inherit;
}
.theory-example-card.has-scene .example-icon::after { display: none; }
.theory-example-card .example-icon::after {
  /* dotted starlight overlay so the scene reads as a magical night vignette */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.55) 0.6px, transparent 1px),
    radial-gradient(circle at 75% 35%, rgba(255, 255, 255, 0.45) 0.6px, transparent 1px),
    radial-gradient(circle at 55% 70%, rgba(255, 255, 255, 0.4) 0.6px, transparent 1px),
    radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.5) 0.6px, transparent 1px);
  pointer-events: none;
}
/* per-position palette: 1st = market (warm orange), 2nd = road (deep
   blue), 3rd = games/chess (warm brown), 4th = home (rose), 5th = goal
   (gold) — rotates through 5 themes. */
.theory-example-card:nth-child(5n+1) .example-icon {
  background:
    radial-gradient(ellipse at 50% 85%, rgba(255, 200, 120, 0.45), transparent 65%),
    linear-gradient(180deg, #6c3c18 0%, #b96a2c 55%, #f0a050 100%);
}
.theory-example-card:nth-child(5n+2) .example-icon {
  background:
    radial-gradient(ellipse at 50% 88%, rgba(255, 215, 130, 0.55), transparent 60%),
    linear-gradient(180deg, #1c2a52 0%, #3a4c82 60%, #6b7eb0 100%);
}
.theory-example-card:nth-child(5n+3) .example-icon {
  background:
    radial-gradient(ellipse at 50% 60%, rgba(255, 215, 150, 0.4), transparent 65%),
    linear-gradient(180deg, #3a2412 0%, #6e4220 55%, #a87040 100%);
}
.theory-example-card:nth-child(5n+4) .example-icon {
  background:
    radial-gradient(ellipse at 50% 75%, rgba(255, 200, 200, 0.45), transparent 60%),
    linear-gradient(180deg, #4a1f3a 0%, #8b3a5c 55%, #c87090 100%);
}
.theory-example-card:nth-child(5n+5) .example-icon {
  background:
    radial-gradient(ellipse at 50% 80%, rgba(255, 230, 140, 0.55), transparent 60%),
    linear-gradient(180deg, #5a3a10 0%, #b08020 55%, #f4c850 100%);
}
/* Title/description live on a separate parchment band below the scene */
.theory-example-card strong,
.theory-example-card small {
  position: relative;
  z-index: 1;
}
.theory-example-card strong {
  display: block;
  width: 100%;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255, 242, 196, 0.78);
  color: #2a1810 !important;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.2;
  min-height: 1.2em;
}
.theory-example-card small {
  color: #5a3a16 !important;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.24;
  display: block;
  min-height: 2.5em;
  padding: 0 2px 2px;
  overflow-wrap: anywhere;
}
/* Override the global .theory-lead callout (dark navy) to match parchment */
.theory-page-paper .theory-lead,
body.dark .theory-page-paper .theory-lead {
  position: relative;
  background: rgba(255, 240, 180, 0.5) !important;
  border: 1px solid rgba(180, 138, 74, 0.45) !important;
  border-radius: 12px !important;
  padding: 12px 16px 12px 52px !important;
  color: #2a1810 !important;
}
/* 💡 lightbulb hint icon before the lead paragraph (matches nowy_layout reference) */
.theory-page-paper .theory-lead::before {
  content: "💡";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #ffd07a, #f0a040);
  border-radius: 50%;
  font-size: 0.92rem;
  box-shadow: 0 2px 8px rgba(180, 138, 74, 0.5);
}
.theory-page-paper .theory-lead p,
.theory-page-paper .theory-lead strong,
body.dark .theory-page-paper .theory-lead p { color: #2a1810 !important; }
.theory-page-paper .theory-story,
body.dark .theory-page-paper .theory-story {
  background: rgba(255, 240, 180, 0.38) !important;
  border: 1px solid rgba(180, 138, 74, 0.38) !important;
  border-left: 4px solid rgba(180, 138, 74, 0.72) !important;
  border-radius: 12px !important;
  color: #2a1810 !important;
  padding: 12px 16px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.38);
}
.theory-page-paper .theory-story p,
.theory-page-paper .theory-story li,
.theory-page-paper .theory-story strong,
body.dark .theory-page-paper .theory-story p,
body.dark .theory-page-paper .theory-story li,
body.dark .theory-page-paper .theory-story strong {
  color: #2a1810 !important;
}
/* Other potential overlay/callout helpers inside theory */
.theory-page-paper .theory-tip-card,
.theory-page-paper .theory-callout,
.theory-page-paper .theory-info {
  background: rgba(255, 240, 180, 0.55) !important;
  border-left: 4px solid #b48a4a !important;
  color: #3a2a10 !important;
}
/* Override .theory-tip (the inline "🦉 Sowa radzi: ..." callout in body) */
.theory-page-paper .theory-tip,
body.dark .theory-page-paper .theory-tip {
  background: rgba(255, 208, 120, 0.42) !important;
  border: 1px solid rgba(180, 138, 74, 0.55) !important;
  border-left: 4px solid #b48a4a !important;
  color: #2a1810 !important;
  padding: 10px 14px !important;
  border-radius: 12px !important;
}
.theory-page-paper .theory-tip strong { color: #1a0a02 !important; }
/* Override .theory-term-cloud chips */
.theory-page-paper .theory-term-cloud { margin-top: 14px; }
.theory-page-paper .theory-term-cloud span,
body.dark .theory-page-paper .theory-term-cloud span {
  background: linear-gradient(180deg, #4a3a78, #3b2e5e) !important;
  color: #fff !important;
  border: 1px solid rgba(139,92,246,0.5) !important;
  padding: 6px 14px !important;
  border-radius: 999px !important;
  font-weight: 800;
  font-size: 0.84rem;
}
.theory-page-content h3 {
  margin: 0 0 14px;
  color: #2a1810;
  font-size: 1.55rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.15;
}
.theory-page-content h4 {
  color: #2a1810;
  font-size: 1.1rem;
  font-weight: 800;
  margin: 16px 0 8px;
}
.theory-page-content p {
  color: #2a1810;
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.55;
  margin: 8px 0;
}
.theory-page-content strong, .theory-page-content b { color: #1a0a02; font-weight: 900; }
.theory-page-content em { color: #5a3a16; }
.theory-page-content ul,
.theory-page-content ol { color: #2a1810; padding-left: 22px; margin: 8px 0; }
.theory-page-content li { margin: 4px 0; font-weight: 600; }
.theory-page-content code, .theory-page-content pre {
  background: rgba(120, 84, 36, 0.12);
  color: #5a3a16;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
}
.theory-page-content .example,
.theory-page-content blockquote {
  background: rgba(255, 240, 180, 0.55);
  border-left: 4px solid #b48a4a;
  padding: 10px 14px;
  border-radius: 10px;
  margin: 12px 0;
  color: #3a2a10;
  font-weight: 600;
}
.theory-page-content a { color: #6c43a0; text-decoration: underline; }

/* Summary view (parchment variant) */
.theory-page-content .muted-note { color: #6a5a40; font-style: italic; font-weight: 600; }
.theory-summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}
.theory-term-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 2px solid rgba(124, 85, 42, 0.34);
  background: linear-gradient(180deg, #fff0bd, #e7c779);
  color: #2a1810;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.18s ease;
  box-shadow: 0 5px 12px rgba(92, 54, 24, 0.16), inset 0 1px 0 rgba(255,255,255,0.55);
}
.theory-term-chip small {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(92, 54, 24, 0.12);
  color: #6b4520;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}
.theory-term-chip.is-saved {
  border-color: rgba(47, 130, 83, 0.58);
  background: linear-gradient(180deg, #e0f7c8, #b9dd83);
  color: #173b24;
  box-shadow: 0 5px 12px rgba(47, 130, 83, 0.18), inset 0 1px 0 rgba(255,255,255,0.55);
}
.theory-term-chip.is-saved small {
  background: rgba(47, 130, 83, 0.14);
  color: #245b38;
}
.theory-term-chip.is-missing {
  border-color: rgba(181, 119, 36, 0.58);
  background: linear-gradient(180deg, #ffe4a3, #e8b85f);
  color: #3b2500;
}
.theory-term-chip.is-missing small {
  background: rgba(120, 84, 36, 0.16);
  color: #6b4520;
}
.theory-term-chip:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.32); }
.theory-term-chip.active {
  background: linear-gradient(135deg, #f9d98c, #e7a844);
  border-color: #7b4f18;
  color: #241509;
  box-shadow: 0 0 0 3px rgba(255,208,91,0.26), 0 8px 18px rgba(92,54,24,0.28);
}
.theory-term-explanation {
  margin-top: 16px;
  padding: 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 246, 218, 0.78), rgba(239, 216, 160, 0.7)),
    rgba(255, 240, 180, 0.55);
  border: 1px solid rgba(124, 85, 42, 0.34);
  border-left: 5px solid #b48a4a;
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.42), 0 8px 18px rgba(92, 54, 24, 0.14);
}
.theory-term-explanation-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px 10px;
  margin-bottom: 8px;
}
.theory-term-explanation-head span {
  color: #6b4520;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.theory-term-explanation-head strong {
  color: #1a0a02;
  font-size: 1.08rem;
  font-weight: 950;
}
.theory-term-explanation-head small {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(47, 130, 83, 0.14);
  color: #245b38;
  font-size: 0.7rem;
  font-weight: 950;
}
.theory-term-editor {
  margin-top: 18px;
  padding: 12px;
  background: rgba(120, 84, 36, 0.08);
  border-radius: 12px;
  font-size: 0.85rem;
}
.theory-term-editor summary { cursor: pointer; font-weight: 800; color: #3a2a10; }
.theory-term-editor .summary-term-form,
.theory-term-editor .term-explanation-edit { margin-top: 10px; }
.theory-term-editor input,
.theory-term-editor textarea {
  background: rgba(255, 246, 218, 0.82) !important;
  color: #2a1810 !important;
  border-color: rgba(124, 85, 42, 0.38) !important;
}

/* Pagination dots — numbered round buttons that jump to that page. */
.theory-page-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 6px 0;
}
.theory-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.22);
  color: #e0e8f7;
  font-size: 1rem;
  font-weight: 900;
  font-family: inherit;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  line-height: 1;
  padding: 0;
  transition: background 0.18s ease, transform 0.15s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.theory-dot:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  transform: translateY(-2px);
}
.theory-dot.active {
  background: linear-gradient(135deg, #8b5cf6, #5ba2ff);
  border-color: rgba(255,255,255,0.55);
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.6), inset 0 1px 0 rgba(255,255,255,0.32), 0 0 0 3px rgba(139, 92, 246, 0.22);
  transform: scale(1.08);
}

/* ── RIGHT: Sowa radzi + Ciekawostka ── */
.theory-book-side {
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
  max-height: 100%;
  scrollbar-width: thin;
  scrollbar-color: rgba(150,190,255,0.32) transparent;
}
.theory-side-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(8,18,44,0.78), rgba(5,11,30,0.86));
  border: 1px solid rgba(150,190,255,0.18);
  box-shadow: 0 8px 22px rgba(0,0,0,0.34);
}
.theory-side-card header {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffd07a;
  display: flex; align-items: center; gap: 6px;
}
.theory-side-tip { align-items: center; text-align: center; }
.theory-side-owl {
  width: 110px; height: 110px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #f8eed8, #d9c8a8);
  border: 3px solid rgba(255,208,91,0.55);
  box-shadow: 0 8px 18px rgba(0,0,0,0.42), 0 0 28px rgba(255,208,91,0.28);
}
.theory-side-owl img { width: 110%; height: 110%; object-fit: cover; object-position: 50% 32%; }
.theory-side-tip p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: #e0e8f7;
  line-height: 1.4;
}
.theory-side-fact .brain-icon {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  font-size: 1.05rem;
  background: linear-gradient(135deg, #5ba2ff, #6d5dfc);
  border-radius: 8px;
  box-shadow: 0 0 14px rgba(91,162,255,0.45);
  overflow: hidden;
  flex-shrink: 0;
}
.theory-side-fact .brain-icon img { width: 100%; height: 100%; object-fit: cover; }
.theory-side-fact .brain-icon .missing-asset { background: transparent; border: 0; padding: 0; font-size: 0.42rem; color: #fff; min-width: 0; }
.theory-side-fact p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #cfdcf3;
  line-height: 1.5;
}

/* Stronger readability pass for the learning book. Generated theory HTML
   sometimes brings muted utility colors that are too weak on parchment. */
.theory-page-content table,
.theory-page-content th,
.theory-page-content td {
  color: #241509;
}
.theory-page-content .muted,
.theory-page-content .text-muted,
.theory-page-content [style*="var(--muted)"] {
  color: #5a3a16 !important;
}
.theory-page-content h3 {
  font-size: clamp(1.42rem, 2.1vw, 1.85rem);
}
.theory-page-content p,
.theory-page-content li {
  font-size: clamp(1rem, 1.35vw, 1.08rem);
}
.theory-mission-visual {
  width: min(340px, 48%);
  margin: 0 auto 18px;
  border-radius: 18px;
  overflow: hidden;
  border: 4px solid #6b4520;
  background: #2a1a0a;
  box-shadow: 0 14px 28px rgba(60, 36, 12, 0.42), inset 0 0 0 1px rgba(255, 230, 180, 0.35);
}
.theory-mission-visual img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #17213d;
}
.theory-side-tip p,
.theory-side-fact p {
  font-size: 0.96rem;
  font-weight: 850;
  color: #f1f6ff;
  line-height: 1.45;
  text-shadow: 0 2px 10px rgba(0,0,0,0.42);
}

/* ── Footer with actions ── */
.theory-book-footer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-top: 1px solid rgba(150,190,255,0.16);
  background: linear-gradient(0deg, rgba(255,255,255,0.04), transparent);
}
.theory-foot-btn {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-auto-rows: auto;
  align-items: center;
  gap: 4px 10px;
  padding: 12px 22px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.theory-foot-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.theory-foot-btn .foot-label { line-height: 1; }
.theory-foot-btn small {
  grid-column: 2;
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.78;
  align-self: start;
}
.theory-foot-btn .quill-icon {
  grid-row: span 2;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.18);
  font-size: 1rem;
  overflow: hidden;
  flex-shrink: 0;
}
.theory-foot-btn .quill-icon img { width: 100%; height: 100%; object-fit: cover; }
.theory-foot-btn .quill-icon .missing-asset { background: transparent; border: 0; padding: 0; font-size: 0.4rem; color: #fff; min-width: 0; }
.theory-foot-primary {
  background: linear-gradient(135deg, #5ba2ff, #4a6dff);
  color: #fff;
  border: 0;
  box-shadow: 0 8px 22px rgba(74,109,255,0.42), 0 0 22px rgba(91,162,255,0.32);
  justify-self: start;
}
.theory-foot-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(74,109,255,0.55); }
.theory-foot-ghost,
.theory-foot-secondary {
  background: rgba(255,255,255,0.08);
  color: #d8e4ff;
  border: 1px solid rgba(255,255,255,0.18);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.theory-foot-ghost { grid-template-columns: none; }
.theory-foot-ghost:hover { background: rgba(255,255,255,0.14); }
.theory-foot-secondary:hover:not(:disabled) {
  background: rgba(91,162,255,0.18);
  border-color: rgba(91,162,255,0.45);
}
/* Circular icon badges on either side of the ghost/secondary labels */
.theory-foot-ghost > span:first-child,
.theory-foot-secondary > span:last-child {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}
.theory-foot-secondary > span:last-child {
  background: linear-gradient(135deg, #5ba2ff, #4a6dff);
  border-color: rgba(255,255,255,0.32);
  color: #fff;
  box-shadow: 0 2px 8px rgba(74,109,255,0.4);
}

.theory-ai-info {
  text-align: center;
  font-size: 0.74rem;
  color: rgba(150,190,255,0.7);
  padding: 4px 22px 12px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .theory-book-body { grid-template-columns: 200px minmax(0,1fr) 200px; gap: 14px; padding: 14px; }
  .theory-page-paper { padding: 22px 24px 18px; }
}
@media (max-width: 900px) {
  /* Stack the three columns and let the whole body scroll as one unit
     (instead of squeezing the parchment into a sliver). */
  .theory-book-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .theory-book-path,
  .theory-book-side { max-height: none; overflow: visible; }
  .theory-book-side { flex-direction: row; }
  .theory-side-card { flex: 1; }
  /* Parchment grows to its content; the body is the scroll container. */
  .theory-book-page { min-height: 0; }
  .theory-page-paper {
    flex: none;
    max-height: none;
    overflow: visible;
  }
  /* Save vertical space: drop the decorative forest path under the steps. */
  .theory-path-decoration { display: none; }
}
@media (max-width: 640px) {
  .theory-book-footer { grid-template-columns: 1fr; }
  .theory-foot-btn { width: 100%; justify-self: stretch; }
  .theory-book-side { flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Onboarding — one-time welcome from Pan Sowa for new students
   ═══════════════════════════════════════════════════════════════════════ */
.onboarding-overlay { z-index: 1200; }
.onboarding-card {
  position: relative;
  width: min(440px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  padding: 56px 28px 24px;
  margin-top: 44px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 0%, rgba(139,92,246,0.28), transparent 55%),
    linear-gradient(180deg, #14225200, #0e1a40 30%, #0a1228 100%);
  border: 1px solid rgba(150,190,255,0.28);
  box-shadow: 0 30px 70px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
  color: #f3f7ff;
  animation: onbPop 0.35s ease;
}
@keyframes onbPop { 0% { transform: translateY(14px) scale(0.96); opacity: 0; } 100% { transform: none; opacity: 1; } }
.onboarding-owl {
  position: absolute;
  top: -44px; left: 50%;
  transform: translateX(-50%);
  width: 96px; height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #f8eed8, #d9c8a8);
  border: 4px solid rgba(255,208,91,0.6);
  box-shadow: 0 10px 26px rgba(0,0,0,0.5), 0 0 36px rgba(255,208,91,0.4);
}
.onboarding-owl img { width: 110%; height: 110%; object-fit: cover; object-position: 50% 32%; }
.onboarding-card h2 { margin: 2px 0 8px; font-size: 1.5rem; font-weight: 900; color: #fff; }
.onboarding-lead { color: #c8d6f0; font-weight: 700; margin: 0 0 18px; }
.onboarding-steps { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 12px; text-align: left; }
.onboarding-steps li {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
}
.onboarding-steps .ob-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5cf6, #5ba2ff);
  font-size: 1.1rem; font-weight: 900; color: #fff;
  box-shadow: 0 4px 12px rgba(139,92,246,0.4);
}
.onboarding-steps strong { display: block; color: #fff; font-size: 0.98rem; }
.onboarding-steps span { color: #aebdda; font-size: 0.84rem; font-weight: 600; }
.onboarding-start { width: 100%; height: 52px; font-size: 1.1rem; }
.onboarding-skip {
  margin-top: 10px;
  background: none; border: 0;
  color: #8ea2c8; font-weight: 700; font-size: 0.9rem;
  cursor: pointer;
}
.onboarding-skip:hover { color: #c8d6f0; text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════════
   Empty states — friendly Pan Sowa panel instead of bare muted text
   ═══════════════════════════════════════════════════════════════════════ */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px 24px;
  text-align: center;
}
.empty-state-owl {
  width: 92px; height: 92px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #f8eed8, #d9c8a8);
  border: 3px solid rgba(255,208,91,0.5);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4), 0 0 26px rgba(255,208,91,0.28);
  margin-bottom: 4px;
}
.empty-state-owl img { width: 110%; height: 110%; object-fit: cover; object-position: 50% 32%; }
.empty-state h3 { color: #fff; font-size: 1.15rem; font-weight: 900; margin: 0; }
.empty-state p { color: var(--muted); font-weight: 700; margin: 0; max-width: 420px; }
.empty-state .btn-primary,
.empty-state .btn-ghost { margin-top: 10px; }
.empty-state-compact {
  padding: 24px 16px;
  border: 1px solid rgba(124,108,255,0.28);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(124,108,255,0.18), transparent 58%),
    rgba(8, 18, 42, 0.42);
}
.empty-state-compact .empty-state-owl {
  width: 62px;
  height: 62px;
  border-width: 2px;
}
.empty-state-compact h3 { font-size: 1rem; }
.empty-state-compact p { font-size: 0.9rem; }
.empty-state-mini {
  grid-template-columns: 34px minmax(0, 1fr);
  justify-items: start;
  align-items: center;
  gap: 10px;
  padding: 10px 0 2px;
  text-align: left;
}
.empty-state-mini .empty-state-owl {
  width: 34px;
  height: 34px;
  border-width: 1px;
  margin: 0;
}
.empty-state-mini p {
  font-size: 0.82rem;
  line-height: 1.35;
}

/* ═══════════════════════════════════════════════════════════════════════
   Missing-asset placeholders — secondary spots in other UI areas
   ═══════════════════════════════════════════════════════════════════════ */

/* Map pin icon — when the icon-<subject>.png is missing, the existing
   emoji fallback shows inside the realm-art square with a dashed amber
   border, and the title attribute says which file is missing. */
.map-shell .realm-art.asset-missing {
  border: 2px dashed rgba(255,208,91,0.7);
  background: rgba(255,208,91,0.08);
}
/* Fallback emoji span — default hidden, .map-shell .realm-art.asset-missing
   reveals it when the icon PNG can't load. Outside map-shell it's allowed to
   show inline since legacy rewards/section views still use the emoji. */
.realm-art-fallback { display: none; }
:not(.map-shell) .realm-art .realm-art-fallback { display: inline; }

/* Quiz energy bar — small icon slot */
.energy-icon {
  display: inline-flex;
  width: 22px; height: 22px;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 6px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
}
.energy-icon img { width: 100%; height: 100%; object-fit: cover; }
.energy-icon .missing-asset { background: transparent; border: 0; padding: 0; font-size: 0.4rem; min-width: 0; }

/* Daily challenge header icon */
.challenge-head-inner { display: inline-flex; align-items: center; gap: 8px; }
.challenge-icon {
  display: inline-flex;
  width: 28px; height: 28px;
  border-radius: 8px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8b5cf6, #5fa3ff);
  box-shadow: 0 0 12px rgba(139,92,246,0.32);
}
.challenge-icon img { width: 100%; height: 100%; object-fit: cover; }
.challenge-icon .missing-asset { background: transparent; border: 0; padding: 0; font-size: 0.4rem; min-width: 0; color: #fff; }

/* Reward chip coin icon */
.reward-coin-icon {
  display: inline-flex;
  width: 18px; height: 18px;
  border-radius: 50%;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 4px;
}
.reward-coin-icon img { width: 100%; height: 100%; object-fit: cover; }

/* Student room card — bg image variant */
.student-room-card { position: relative; overflow: hidden; }
.student-room-bg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 0.55;
  border-radius: inherit;
}
.student-room-card > .missing-asset {
  position: absolute;
  inset: 8px;
  z-index: 0;
}
.student-room-card .student-room-text { position: relative; z-index: 1; }

/* ════════════════════════════════════════════════════════════════════
   LIGHT THEME — additive override layer.
   Every rule is scoped under `body.light`, so dark mode (body.dark) is
   completely unaffected. The 2.0 UI is "dark-baked" (navy backgrounds and
   light text hardcoded in base rules); here we re-skin the dashboard/screen
   surfaces to light and flip their text to ink. Immersive student modals
   (Nauka / Quiz / Czas / Fiszki / Pary) are intentionally dark in BOTH themes
   and are deliberately NOT touched here. Mission/realm artwork keeps dark
   variants until the light assets (`*-light.png`) are generated.
   ════════════════════════════════════════════════════════════════════ */

body.light {
  --light-surface: #ffffff;
  --light-surface-2: #f4f6f3;
  --light-raise: #fbfcfb;
  --light-line: #dfe6e0;
  --light-ink: #243a2e;
  --light-muted: #5d7065;
}

/* ── App frame: topbar, nav, sidebars ─────────────────────────────── */
body.light .topbar,
body.light .topbar-nav,
body.light .topbar-hud,
body.light .more-dropdown,
body.light .logo-wrap,
body.light .user-pill,
body.light .tabs,
body.light .app-sidebar-left,
body.light .app-sidebar-right,
body.light .sidebar-player-card,
body.light .sidebar-wallet,
body.light .knowledge-energy {
  background: var(--light-surface);
  border-color: var(--light-line);
  color: var(--light-ink);
}
body.light .topbar-nav .tab,
body.light .topbar-hud,
body.light .topbar-hud strong,
body.light .topbar-hud small,
body.light .user-pill,
body.light .user-pill *,
body.light .sidebar-player-card,
body.light .sidebar-player-card strong,
body.light .sidebar-player-card small,
body.light .sidebar-wallet,
body.light .sidebar-wallet strong,
body.light .more-dropdown,
body.light .more-dropdown button {
  color: var(--light-ink);
}
body.light .app-sidebar-left,
body.light .app-sidebar-right { box-shadow: var(--panel-shadow); }

/* ── Generic screen panels that hardcode navy ─────────────────────── */
body.light .realm-level-card,
body.light .realm-summary div,
body.light .map-quick-nav,
body.light .map-quick-nav span,
body.light .map-daily-card,
body.light .map-treasure-card,
body.light .reward-side-nav,
body.light .reward-hero,
body.light .reward-card,
body.light .reward-collection-panel,
body.light .reward-league-card,
body.light .reward-shop-panel,
body.light .recent-unlocks-panel,
body.light .stat-chip {
  background: var(--light-surface);
  border-color: var(--light-line);
  color: var(--light-ink);
}
body.light .realm-summary div strong,
body.light .realm-summary div small,
body.light .reward-card strong,
body.light .reward-card small,
body.light .reward-collection-panel h3,
body.light .reward-shop-panel h3,
body.light .recent-unlocks-panel h3,
body.light .map-quick-nav strong { color: var(--light-ink); }

/* ── Realm screen: wyprawy & adventures ───────────────────────────── */
body.light .level-board,
body.light .level-card,
body.light .level-card.open .level-card-main,
body.light .level-missions,
body.light .adventure-prep,
body.light .adventure-mission-card {
  background-image: none;
  background-color: var(--light-surface);
  border-color: var(--light-line);
  color: var(--light-ink);
}
body.light .level-missions {
  background-color: var(--light-surface-2);
}
body.light .adventure-prep {
  background-color: var(--light-surface-2);
}
body.light .level-content strong,
body.light .level-content small,
body.light .level-progress-line b,
body.light .level-progress-line small,
body.light .adventure-mission-card .mission-title,
body.light .adventure-mission-card .mission-meta,
body.light .adventure-prep-copy strong,
body.light .adventure-prep-copy small,
body.light .level-board-head h3,
body.light .level-board-head p,
body.light .level-board-head span { color: var(--light-ink); }
body.light .adventure-prep-copy span { color: #1d6f4f; }
body.light .level-state { color: #1d6f4f; }
/* keep mission card action buttons colored (unchanged) */

/* ── Tool screens (teacher/admin) ─────────────────────────────────── */
body.light .student-report-card {
  background-image: none;
  background-color: var(--light-surface);
  border-color: var(--light-line);
  color: var(--light-ink);
}
body.light .report-card-head,
body.light .report-card-head h3,
body.light .report-card-head strong,
body.light .chart-label,
body.light .chart-label span,
body.light .report-summary h4 { color: var(--light-ink); }
body.light .wisdom-box { background: var(--light-surface-2); border-color: var(--light-line); }
body.light .wisdom-box p,
body.light .wisdom-box strong { color: var(--light-ink); }
body.light .tool-screen td,
body.light .tool-screen th,
body.light .users-table td,
body.light .users-table th { color: var(--light-ink); }
body.light .tool-screen .btn-ghost { color: var(--light-ink); border-color: var(--light-line); }

/* ── Tables on dark cards that turn light ─────────────────────────── */
body.light .users-table tr,
body.light .summary-table th,
body.light .summary-table td { border-color: var(--light-line); }

/* Tool-screen table cells hardcode a navy background — lighten them so the
   ink text is readable. */
body.light .tool-screen td {
  background: var(--light-surface-2);
  border-color: var(--light-line);
}
body.light .tool-screen th { color: var(--light-muted); }

/* ── Stats / "Kronika postępów" screen ────────────────────────────── */
body.light .stats-hero,
body.light .stats-orb-card,
body.light .student-metric-panel {
  background-image: none;
  background-color: var(--light-surface);
  border-color: var(--light-line);
  color: var(--light-ink);
}
body.light .stats-hero .hero-content h2,
body.light .stats-hero-lead,
body.light .stats-orb-card,
body.light .stats-orb-card strong,
body.light .stats-orb-card small,
body.light .stats-level-track small,
body.light .student-metric-panel h3,
body.light .report-stat-row,
body.light .report-stat-row strong { color: var(--light-ink); }

/* ── Map screen extras ────────────────────────────────────────────── */
body.light .map-treasure-card,
body.light .map-treasure-card small,
body.light .map-shell .map-treasure-card small { color: var(--light-ink); }
body.light .student-room-card {
  background-image: none;
  background-color: var(--light-surface-2);
  border-color: var(--light-line);
}

/* ── Right sidebar widgets (progress, class stats, achievements) ──── */
body.light .side-progress-card,
body.light .side-teacher-panel,
body.light .achievement-card,
body.light .side-class-stats {
  background-image: none;
  background-color: var(--light-surface);
  border-color: var(--light-line);
  color: var(--light-ink);
}
body.light .side-card-head,
body.light .side-card-head *,
body.light .side-progress-card strong,
body.light .side-progress-card small,
body.light .achievement-item,
body.light .achievement-item *,
body.light .side-stat-cell strong,
body.light .side-stat-cell small,
body.light .badge-count { color: var(--light-ink); }
body.light .side-stat-cell { background: var(--light-surface-2); }
