/* ============================================================
   Philosophy Quest — theme
   Dark "ink & marble" with gold accents. Mobile-first.
   ============================================================ */
:root {
  /* warm "ink on parchment" — antique, scholarly, not a cool AI dark-mode */
  --bg: #17130d;
  --bg-2: #1f1911;
  --panel: #241d13;
  --panel-2: #2d251a;
  --line: #3e3324;
  --ink: #efe7d5;
  --ink-dim: #c6ba9f;
  --muted: #9c9078;
  --gold: #d7b24a;
  --gold-soft: #ead18a;
  --good: #86b562;
  --bad: #d5765f;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 760px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 800px at 50% -10%, #2c2013 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;   /* never let a stray wide element sideways-scroll the app */
}
/* fine paper grain — a little tactile warmth so it doesn't read as a flat template */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: .1px; line-height: 1.18; }
/* headings get programmatically focused on navigation for screen readers — no visible ring */
[tabindex="-1"]:focus { outline: none; }
::selection { background: var(--gold); color: #201a08; }

/* ---- App bar ------------------------------------------------ */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: rgba(23,19,13,.84);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; background: none; border: 0; color: var(--ink); padding: 4px; }
.brand-glyph {
  font-family: var(--serif); font-size: 26px; line-height: 1;
  color: var(--gold); text-shadow: 0 0 18px rgba(215,178,74,.5);
}
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.appbar-stats { display: flex; align-items: center; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; font-size: 14px; color: var(--ink-dim);
}
.chip b { color: var(--ink); }
.streak-chip { padding: 5px 8px; gap: 3px; flex: none; }
.streak-chip b { color: var(--gold-soft); font-weight: 700; }
.level-chip { flex-direction: column; align-items: stretch; gap: 3px; padding: 5px 10px; }
.lvl { font-size: 12px; color: var(--gold-soft); font-weight: 700; text-align: center; }
.lvl-bar { width: 54px; height: 4px; background: #0e0c14; border-radius: 3px; overflow: hidden; }
.lvl-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); }

/* ---- Layout ------------------------------------------------- */
.screen {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px calc(40px + env(safe-area-inset-bottom));
  animation: fade .28s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Home --------------------------------------------------- */
.home-hero {
  text-align: center;
  padding: 14px 8px 6px;
}
.home-title {
  font-size: clamp(30px, 8vw, 46px);
  margin: 6px 0 4px; color: var(--ink);
  letter-spacing: .2px; font-weight: 800;
}
.home-title::after {
  content: ""; display: block; width: 42px; height: 2px; margin: 13px auto 0;
  background: var(--gold); border-radius: 2px; opacity: .8;
}
.home-tag {
  color: var(--muted); margin: 0 auto 20px; max-width: 34ch;
  font-style: italic; font-family: var(--serif); font-size: 15.5px;
}
/* The grand Greek temple emblem in the hero (replaces the old stat boxes). */
.home-temple { margin: 2px auto 16px; max-width: 280px; }
.temple-art { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.section-head { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin: 24px 4px 12px; }

.study-tile {
  position: relative; text-align: left; width: 100%;
  display: flex; gap: 12px; align-items: center;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  padding: 16px; color: var(--ink);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.study-tile:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.05); }
.study-tile:active { transform: translatey(0) scale(.99); }
.tile-glyph { font-size: 30px; flex: none; filter: drop-shadow(0 2px 8px rgba(0,0,0,.4)); }
.tile-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile-title { font-family: var(--serif); font-size: 18px; }
.tile-desc { font-size: 13px; color: var(--ink-dim); }
.tile-arrow { margin-left: auto; font-size: 22px; color: var(--gold); }

.home-foot { text-align: center; margin-top: 26px; color: var(--muted); font-size: 14px; }
.link-btn { background: none; border: 0; color: var(--gold-soft); text-decoration: underline; font-size: 14px; }

/* ---- The Journey: world cards on the home hub ---- */
.home-continue { width: auto; min-width: 260px; max-width: 440px; margin: 6px auto 2px; display: block; }
.world-list { display: flex; flex-direction: column; gap: 13px; }
.world-card {
  position: relative; text-align: left; width: 100%;
  display: flex; gap: 15px; align-items: center;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-left: 5px solid var(--accent, var(--gold));
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 17px 18px; color: var(--ink);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.world-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,.42); }
.world-card:active { transform: translateY(0) scale(.995); }
.world-glyph { font-size: 36px; flex: none; filter: drop-shadow(0 2px 8px rgba(0,0,0,.45)); }
.world-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.world-name { font-family: var(--serif); font-size: 18px; color: var(--ink); line-height: 1.2; }
.world-sub { font-size: 13px; color: var(--ink-dim); font-style: italic; font-family: var(--serif); line-height: 1.45; }
.world-progress { margin-top: 4px; }
.world-arrow { flex: none; align-self: center; font-size: 22px; color: var(--accent, var(--gold)); }
/* the per-world accent tints the progress fill (var(--accent) is set inline) */
.world-card .progress-fill,
.world-banner-prog .progress-fill,
.path .progress-fill { background: linear-gradient(90deg, var(--accent, var(--gold)), var(--accent-soft, var(--gold-soft))); }

/* ---- World banner (the path screen header) ---- */
.world-banner { text-align: center; padding: 6px 8px 20px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.world-banner-crest { font-size: 56px; line-height: 1; filter: drop-shadow(0 5px 16px rgba(0,0,0,.5)); }
.path-title { font-family: var(--serif); font-size: clamp(24px, 6.5vw, 34px); margin: 8px 0 4px; color: var(--accent-soft, var(--gold-soft)); }
.path-spirit { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 15.5px; max-width: 40ch; margin: 0 auto 12px; line-height: 1.5; }
.world-banner-blurb { color: var(--ink-dim); font-size: 15px; max-width: 54ch; margin: 0 auto 16px; line-height: 1.65; }
.world-banner-meta { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.wb-chip { font-size: 12px; color: var(--ink-dim); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 13px; }
.world-banner-prog { max-width: 320px; margin: 0 auto; }

/* ---- The winding path of philosopher nodes ---- */
.path { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 22px 0 10px; }
.path::before {
  content: ""; position: absolute; top: 40px; bottom: 46px; left: 50%;
  width: 3px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, var(--line) 0 11px, transparent 11px 22px);
}
.path-node {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: none; border: 0; color: var(--ink);
  padding: 12px 10px; width: min(320px, 84vw); cursor: pointer;
}
.path-node:nth-child(odd)  { transform: translateX(-17%); }
.path-node:nth-child(even) { transform: translateX(17%); }
.node-bubble {
  width: 76px; height: 76px; border-radius: 50%; font-size: 38px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 3px solid var(--line); box-shadow: 0 6px 0 rgba(0,0,0,.35);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.path-node:hover .node-bubble { transform: translateY(-3px); border-color: var(--accent, var(--gold)); }
.path-node:active .node-bubble { transform: translateY(0); }
.path-node:focus-visible { outline: none; }
.path-node:focus-visible .node-bubble { border-color: var(--accent, var(--gold)); box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 0 3px var(--gold-soft); }
.path-node.done .node-bubble { border-color: var(--accent, var(--gold)); }
.path-node.gold .node-bubble { border-color: var(--gold); box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 20px rgba(215,178,74,.4); }
.path-node.next .node-bubble { border-color: var(--accent, var(--gold)); animation: nodePulse 1.9s ease infinite; }
@keyframes nodePulse {
  0%, 100% { box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 0 0 var(--accent, var(--gold)); }
  55% { box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 0 11px transparent; }
}
.node-label { font-family: var(--serif); font-size: 15px; text-align: center; max-width: 22ch; line-height: 1.25; }
.node-sub { font-size: 12px; color: var(--muted); }
.node-crowns { font-size: 13px; min-height: 16px; line-height: 1; }
/* Boss face-off node */
.node-boss { margin-top: 4px; }
.node-boss .node-bubble { width: 92px; height: 92px; font-size: 42px; border-color: #7a4b3a; background: linear-gradient(160deg, #38271c, var(--panel)); }
.node-boss:hover .node-bubble { border-color: var(--bad); }
.node-boss .node-label { color: var(--gold-soft); font-size: 15.5px; }

.world-nav { display: flex; justify-content: space-between; gap: 10px; margin: 24px 0 8px; }

/* ---- Progress bar ------------------------------------------- */
.progress { position: relative; height: 12px; background: #0f0d16; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); transition: width .5s ease; }
.progress-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; color: var(--ink); text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* ---- Shared game chrome ------------------------------------- */
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.qcount { font-size: 13px; color: var(--muted); text-align: center; flex: 1; font-weight: 600; }
.ghost-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--gold); }
.primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #241c05; border: 0; font-weight: 700; font-size: 16px;
  padding: 14px 20px; border-radius: 12px; width: 100%;
  box-shadow: 0 6px 18px rgba(215,178,74,.25);
  transition: transform .1s ease, filter .1s ease;
}
.primary:hover { filter: brightness(1.05); }
.primary:active { transform: scale(.98); }
.danger-btn { background: rgba(215,106,99,.12); border: 1px solid var(--bad); color: #f0a9a4; padding: 12px 18px; border-radius: 12px; font-weight: 600; }
.tl-instr { color: var(--ink-dim); text-align: center; margin: 4px 0 16px; }

/* ---- Quiz --------------------------------------------------- */
.combo { font-size: 13px; color: var(--muted); min-width: 68px; text-align: right; font-weight: 700; }
.combo.hot { color: var(--gold-soft); }
.qbar { height: 5px; background: #0f0d16; border-radius: 3px; overflow: hidden; margin-bottom: 20px; }
.qbar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); transition: width .3s ease; }
.qprompt { font-size: clamp(20px, 5.2vw, 26px); line-height: 1.35; margin: 0 0 20px; }
.options { display: flex; flex-direction: column; gap: 11px; }
.option {
  text-align: left; background: var(--panel); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 16px; padding: 15px 16px; border-radius: 13px;
  transition: border-color .12s, background .12s, transform .08s;
}
.option:not(:disabled):hover { border-color: var(--gold); background: var(--panel-2); }
.option:not(:disabled):active { transform: scale(.99); }
.option:disabled { opacity: .95; cursor: default; }
.option.correct { border-color: var(--good); background: rgba(107,191,115,.16); color: #d7f5db; }
.option.wrong { border-color: var(--bad); background: rgba(215,106,99,.15); color: #f6cecb; }
.explain { margin-top: 18px; border-radius: 13px; padding: 14px 16px; border: 1px solid var(--line); animation: fade .25s ease; }
.explain.good { border-color: rgba(107,191,115,.5); background: rgba(107,191,115,.08); }
.explain.bad { border-color: rgba(215,106,99,.5); background: rgba(215,106,99,.08); }
.explain-head { font-weight: 700; font-family: var(--serif); margin-bottom: 4px; }
.explain.good .explain-head { color: var(--good); }
.explain.bad .explain-head { color: var(--bad); }
.explain-body { color: var(--ink-dim); font-size: 14.5px; }
.next-btn { margin-top: 16px; }

/* ---- Results ------------------------------------------------ */
.result-card { text-align: center; background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 20px; box-shadow: var(--shadow); }
.result-emoji { font-size: 54px; }
.result-card h2 { font-size: 40px; margin: 6px 0 2px; color: var(--gold-soft); }
.result-verdict { color: var(--ink-dim); margin: 0 0 18px; }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 6px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--serif); font-size: 20px; color: var(--gold-soft); font-weight: 700; }
.stat-lbl { font-size: 11px; color: var(--muted); }
.record-badge { color: var(--gold-soft); font-weight: 700; margin-bottom: 16px; animation: pop .4s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
.result-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---- Timeline ----------------------------------------------- */
.tl-list, .dlg-log { list-style: none; padding: 0; margin: 0; }
.tl-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.tl-card {
  display: flex; align-items: center; gap: 12px; position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--gold); border-radius: var(--radius-sm); padding: 12px 14px;
}
.tl-card:not(.tl-drag) { transition: transform .16s ease; }
.tl-drag { z-index: 5; box-shadow: 0 8px 22px rgba(0,0,0,.5); border-color: var(--gold); }
.tl-handle {
  flex: none; width: 32px; height: 42px; display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--muted); font-size: 21px; line-height: 1;
  cursor: grab; touch-action: none;
}
.tl-handle:active { cursor: grabbing; color: var(--gold-soft); }
.tl-handle:focus-visible { outline: 2px solid var(--gold); border-radius: 8px; }
.tl-glyph { font-size: 24px; flex: none; }
.tl-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tl-name strong { font-family: var(--serif); font-size: 17px; }
.tl-era { font-size: 12px; color: var(--muted); }
.tl-list.reveal .tl-card { border-left-width: 4px; }
.tl-card.ok { background: rgba(107,191,115,.1); }
.tl-card.miss { background: rgba(215,106,99,.1); }
.tl-mark { margin-left: auto; font-size: 18px; font-weight: 700; }
.tl-card.ok .tl-mark { color: var(--good); }
.tl-card.miss .tl-mark { color: var(--bad); }
.tl-score { text-align: center; font-size: 26px; margin: 6px 0 2px; color: var(--gold-soft); }
.check-btn { margin-top: 6px; }

/* ---- Quote Match -------------------------------------------- */
.qm-board { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.qm-col { display: flex; flex-direction: column; gap: 10px; }
.qm-quote {
  text-align: left; background: var(--panel); border: 1.5px solid var(--line);
  color: var(--ink); font-family: var(--serif); font-style: italic; font-size: 15.5px;
  padding: 14px 15px; border-radius: 12px; line-height: 1.4;
}
.qm-quote.active { border-color: var(--gold); background: var(--panel-2); box-shadow: 0 0 0 3px rgba(215,178,74,.18); }
.qm-quote.done { opacity: .4; border-style: dashed; }
.qm-name {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-2); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 15px; padding: 12px 14px; border-radius: 999px;
}
.qm-name:not(:disabled):hover { border-color: var(--accent, var(--gold)); }
.qm-name.done { opacity: .4; border-color: var(--good); background: rgba(107,191,115,.12); }
.qm-glyph { font-size: 18px; }
.qm-progress { text-align: center; color: var(--muted); font-size: 13px; }
@media (min-width: 620px) {
  .qm-board { grid-template-columns: 1.3fr 1fr; align-items: start; }
}

/* ---- Dialogue ----------------------------------------------- */
.dlg-grid { display: flex; flex-direction: column; gap: 12px; }
.dlg-choice {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-left: 4px solid var(--accent, var(--gold));
  border-radius: var(--radius); padding: 16px; color: var(--ink);
  transition: transform .12s, border-color .12s;
}
.dlg-choice:hover { transform: translateY(-2px); border-color: var(--gold); }
.dlg-glyph { font-size: 30px; flex: none; }
.dlg-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dlg-meta strong { font-family: var(--serif); font-size: 17px; }
.dlg-blurb { font-size: 13px; color: var(--ink-dim); }
.dlg-done { margin-left: auto; color: var(--good); font-size: 20px; font-weight: 700; }

.dlg-log { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.dlg-bubble {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--gold));
  padding: 12px 15px; border-radius: 12px; max-width: 92%;
  animation: fade .25s ease;
}
.dlg-bubble.me { align-self: flex-end; border-left: 0; border-right: 3px solid var(--gold); background: var(--panel-2); text-align: right; }
.dlg-bubble.dim { opacity: .5; }
.dlg-speaker { font-size: 12px; color: var(--gold-soft); font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.dlg-bubble.me .dlg-speaker { color: var(--muted); justify-content: flex-end; }
.dlg-bubble p { margin: 0; font-family: var(--serif); font-size: 16.5px; line-height: 1.45; }
.dlg-glyph-sm { font-size: 15px; }
.dlg-choices { display: flex; flex-direction: column; gap: 10px; }
.dlg-reply {
  text-align: left; background: var(--panel-2); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 15.5px; padding: 14px 16px; border-radius: 12px;
  transition: border-color .12s, transform .08s;
}
.dlg-reply:hover { border-color: var(--gold); }
.dlg-reply:active { transform: scale(.99); }
.dlg-takeaway {
  border: 1px solid var(--accent, var(--gold)); border-radius: var(--radius);
  background: rgba(215,178,74,.06); padding: 18px; margin: 8px 0 18px;
}
.dlg-takeaway-head { font-family: var(--serif); font-weight: 700; color: var(--gold-soft); margin-bottom: 6px; }
.dlg-takeaway p { margin: 0; color: var(--ink-dim); }
.dlg-xp { margin-top: 12px; font-weight: 700; color: var(--gold-soft); }

/* ---- Codex -------------------------------------------------- */
.codex-era { color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-size: 13px; margin: 22px 4px 10px; }
.codex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 560px) { .codex-grid { grid-template-columns: 1fr 1fr 1fr; } }
.codex-card {
  position: relative; text-align: center;
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-top: 3px solid var(--accent, var(--gold));
  border-radius: var(--radius); padding: 16px 10px 12px; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: transform .12s, box-shadow .12s;
}
.codex-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.codex-mastered { position: absolute; top: 8px; right: 10px; color: var(--gold); }
.codex-glyph { font-size: 34px; }
.codex-name { font-family: var(--serif); font-size: 15.5px; line-height: 1.2; }
.codex-years { font-size: 11.5px; color: var(--muted); }

.codex-hero { text-align: center; border-bottom: 1px solid var(--line); padding: 8px 0 20px; margin-bottom: 6px; }
.codex-hero-glyph { font-size: 60px; filter: drop-shadow(0 4px 16px rgba(0,0,0,.5)); }
.codex-hero h1 { font-size: clamp(26px, 7vw, 36px); margin: 6px 0 2px; color: var(--gold-soft); }
.codex-hero-sub { color: var(--ink-dim); font-size: 14px; }
.codex-hero-school { display: inline-block; margin-top: 8px; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent, var(--gold)); border: 1px solid var(--line); padding: 3px 12px; border-radius: 999px; }
.codex-hero-stars { margin-top: 10px; color: var(--gold); letter-spacing: 3px; font-size: 16px; display: flex; gap: 10px; align-items: center; justify-content: center; }
.codex-hero-badge { font-size: 11px; letter-spacing: 1px; color: var(--good); border: 1px solid var(--good); border-radius: 999px; padding: 2px 8px; }
.codex-hero-line { color: var(--ink); font-family: var(--serif); font-style: italic; font-size: 17px; max-width: 34ch; margin: 14px auto 0; }
.codex-section { margin: 20px 0; }
.codex-section h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.4px; margin: 0 0 10px; }
.codex-big { font-family: var(--serif); font-size: 20px; line-height: 1.4; color: var(--ink); }
.codex-ideas { margin: 0; padding-left: 20px; }
.codex-ideas li { margin-bottom: 8px; color: var(--ink-dim); }
.codex-quotes blockquote { margin: 0 0 12px; padding: 12px 16px; border-left: 3px solid var(--gold); background: var(--panel); border-radius: 0 12px 12px 0; font-family: var(--serif); font-style: italic; color: var(--ink); }
.codex-fact { color: var(--ink-dim); }
.codex-nav { display: flex; justify-content: space-between; gap: 10px; margin: 18px 0; }

/* ---- Prose (about / settings) ------------------------------- */
.prose { color: var(--ink-dim); }
.prose h2 { color: var(--ink); font-size: 22px; margin: 22px 0 8px; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose b { color: var(--ink); }
.muted { color: var(--muted); font-size: 13px; }

/* ---- Toasts ------------------------------------------------- */
#toast-host { position: fixed; left: 0; right: 0; bottom: calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); transition: .3s ease; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { border-color: var(--bad); color: #f6cecb; }

/* ---- Confetti ----------------------------------------------- */
.confetti-host { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 55; }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.4s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(680deg); opacity: .9; } }


/* ---- Floating mini-game dock (circular icons: rail upper-left, Talk upper-right).
   Modeled on Literature Quest: on desktop the icons live out in the wide side
   margins; on phones they shrink into the gutters and flow in only after you
   scroll past the temple, so they never crowd or squeeze the home screen. ---- */
.dock-rail {
  position: fixed; left: 10px; top: 72px; z-index: 40;
  display: flex; flex-direction: column; gap: 11px;
}
.dock-hidden .dock-rail, .dock-hidden .dock-talk { display: none; }
.dock-btn, .dock-talk {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0,0,0,.45); color: var(--ink);
  cursor: pointer; display: grid; place-items: center;
  transition: transform .12s ease, border-color .12s ease;
}
.dock-btn { position: relative; }
/* the left rail is staggered — every other icon steps to the right */
.dock-rail .dock-btn:nth-child(even) { margin-left: 26px; }
.dock-talk { position: fixed; right: 10px; top: 72px; z-index: 40; border-color: rgba(215,178,74,.5); }
.dock-btn:hover, .dock-talk:hover { transform: translateY(-2px); border-color: var(--gold); }
.dock-btn:active, .dock-talk:active { transform: scale(.94); }
.dock-ico { font-size: 28px; line-height: 1; }
/* hover/focus flyout label */
.dock-label {
  position: absolute; left: 66px; top: 50%; transform: translateY(-50%) translateX(-4px);
  white-space: nowrap; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 12px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease;
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.dock-label.left { left: auto; right: 66px; transform: translateY(-50%) translateX(4px); }
.dock-btn:hover .dock-label, .dock-btn:focus-visible .dock-label,
.dock-talk:hover .dock-label, .dock-talk:focus-visible .dock-label {
  opacity: 1; transform: translateY(-50%) translateX(0);
}

/* Phones & small tablets: small icons resting just under the sticky header,
   tucked into the side gutters. The home content is a narrower centered column
   (the .dock-on padding below), so the icons sit in the margins and never cover
   a card. They stay hidden while the temple is in view, then flow in from the
   screen edges once you scroll past it. Game/lesson screens keep full width. */
@media (max-width: 900px) {
  .dock-btn, .dock-talk { width: 42px; height: 42px; }
  .dock-ico { font-size: 20px; }
  .dock-rail { top: calc(env(safe-area-inset-top) + 80px); left: 6px; gap: 10px; }
  .dock-talk { top: calc(env(safe-area-inset-top) + 80px); right: 6px; }
  .dock-rail .dock-btn:nth-child(even) { margin-left: 0; } /* no stagger on phones */
  body.dock-on .screen { padding-left: 50px; padding-right: 50px; }
  /* flow-in: slide in from the edges + fade, and out the same way */
  .dock-rail, .dock-talk {
    transition: opacity .38s ease, transform .42s cubic-bezier(.2,.75,.25,1), visibility .42s;
  }
  .dock.dock-attop .dock-rail { opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(-78px); }
  .dock.dock-attop .dock-talk { opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(78px); }
}

/* ---- Story Mode centre card (the main game) ---- */
.story-center {
  width: 100%; position: relative; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 26px 16px;
  background:
    radial-gradient(130% 120% at 50% 0%, rgba(215,178,74,.16), transparent 60%),
    linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(215,178,74,.5); border-radius: var(--radius);
  color: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.3);
  transition: transform .12s, border-color .12s;
}
.story-center:hover { transform: translateY(-2px); border-color: var(--gold); }
.story-center-glyph { font-size: 46px; line-height: 1; }
.story-center-title { font-size: 22px; color: var(--gold-soft); }
.story-center-desc { font-size: 12.5px; color: var(--ink-dim); max-width: 20ch; line-height: 1.4; }
.story-center-badge {
  margin-top: 2px; font-size: 11px; font-weight: 700; color: #241c05;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  padding: 4px 11px; border-radius: 999px;
}
.story-center-cta { margin-top: 4px; font-size: 13px; font-weight: 800; color: var(--gold); }

/* ---- Who Am I? ---- */
.wa-score { font-size: 13px; font-weight: 700; color: var(--gold-soft); }
.wa-clues { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
.wa-clue {
  display: flex; gap: 10px; align-items: baseline;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 12px; padding: 10px 12px;
}
.wa-clue.fresh { animation: fadeUp .28s ease; }
.wa-clue-tag { flex: none; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--gold-soft); min-width: 62px; }
.wa-clue-text { font-size: 14px; color: var(--ink); line-height: 1.4; }
.wa-worth { text-align: center; font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 12px; }
.wa-suspects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.wa-suspect {
  display: flex; align-items: center; gap: 8px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); cursor: pointer;
  transition: transform .1s, border-color .1s;
}
.wa-suspect:hover { transform: translateY(-1px); border-color: var(--accent); }
.wa-suspect.out { opacity: .38; }
.wa-glyph, .oo-glyph, .qm-glyph { flex: none; }
.wa-name { font-size: 14px; font-weight: 700; }
.wa-reveal, .oo-reveal .primary { width: 100%; }
.wa-reveal {
  padding: 12px; border-radius: 14px; border: 1px dashed var(--line);
  background: transparent; color: var(--gold-soft); font-weight: 700; cursor: pointer;
}
.wa-reveal:hover { border-color: var(--gold); }
.wa-answer, .oo-reveal { text-align: center; animation: fadeUp .28s ease; padding: 18px 8px; }
.wa-answer-glyph { display: inline-flex; margin-bottom: 6px; transform: scale(1.4); }
.wa-answer-sub { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.wa-answer-line { font-size: 14px; color: var(--ink-dim); font-style: italic; max-width: 34ch; margin: 8px auto 16px; line-height: 1.45; }

/* ---- Odd One Out ---- */
.oo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.oo-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; color: var(--ink); cursor: pointer;
  transition: transform .1s, border-color .1s;
}
.oo-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.oo-glyph { transform: scale(1.25); margin-bottom: 4px; }
.oo-name { font-size: 14.5px; }
.oo-sub { font-size: 11px; color: var(--muted); }
.oo-why { font-size: 13.5px; color: var(--ink-dim); max-width: 36ch; margin: 8px auto 16px; line-height: 1.45; }

.learn-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.learn-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-left: 4px solid var(--accent, var(--gold));
  border-radius: var(--radius); padding: 15px; color: var(--ink);
  transition: transform .12s, border-color .12s;
}
.learn-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.learn-glyph { font-size: 30px; flex: none; }
.learn-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.learn-meta strong { font-family: var(--serif); font-size: 17px; }
.learn-hook { font-size: 13px; color: var(--ink-dim); font-style: italic; }
.learn-done, .learn-go { margin-left: auto; flex: none; font-size: 20px; }
.learn-go { color: var(--gold); }

/* lesson body shared */
.learn-body { animation: fade .25s ease; }
.learn-actions { margin-top: 18px; }
.learn-step { display: inline-block; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; font-weight: 700; }
.learn-tag { display: inline-block; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold-soft); font-weight: 700; margin-bottom: 6px; }

/* intro */
.learn-intro { text-align: center; border: 1px solid var(--line); border-top: 4px solid var(--accent, var(--gold)); border-radius: var(--radius); padding: 24px 18px; background: linear-gradient(160deg, var(--panel-2), var(--panel)); }
.learn-intro-glyph { font-size: 58px; filter: drop-shadow(0 4px 14px rgba(0,0,0,.5)); }
.learn-intro-name { font-size: clamp(26px, 7vw, 34px); margin: 6px 0 2px; color: var(--gold-soft); }
.learn-intro-sub { color: var(--muted); font-size: 13px; }
.learn-intro-hook { font-family: var(--serif); font-style: italic; font-size: clamp(18px, 4.6vw, 22px); line-height: 1.4; color: var(--ink); max-width: 32ch; margin: 16px auto; }
.learn-intro-big { text-align: left; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.learn-intro-big p { margin: 0; font-family: var(--serif); font-size: 17px; }

/* concept */
.learn-concept-head { margin-bottom: 10px; }
.learn-concept-name { font-size: clamp(22px, 5.5vw, 28px); margin: 2px 0 0; padding-left: 12px; border-left: 4px solid var(--accent, var(--gold)); }
.learn-plain { font-size: 17px; line-height: 1.6; color: var(--ink); }
.learn-example, .learn-meaning, .learn-takeaway {
  margin-top: 16px; background: rgba(215,178,74,.07);
  border: 1px solid rgba(215,178,74,.3); border-radius: 12px; padding: 14px 16px;
  animation: fade .25s ease;
}
.learn-example p, .learn-meaning p, .learn-takeaway p { margin: 0; color: var(--ink-dim); font-size: 15.5px; line-height: 1.55; }

/* thought experiment */
.learn-scenario {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--accent, var(--gold)); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.learn-scenario p { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.5; }
.learn-glyph-sm { font-size: 22px; flex: none; }
.learn-response {
  margin-top: 16px; background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--gold)); border-radius: 12px; padding: 12px 15px;
  animation: fade .25s ease;
}
.learn-response p { margin: 0; font-family: var(--serif); font-size: 16px; line-height: 1.5; }

/* quote */
.learn-quote {
  margin: 0; padding: 18px 20px; border-left: 4px solid var(--accent, var(--gold));
  background: var(--panel); border-radius: 0 12px 12px 0;
  font-family: var(--serif); font-style: italic; font-size: clamp(19px, 5vw, 24px);
  line-height: 1.4; color: var(--ink);
}

/* ---- Game juice: XP pop, mute, toggle ----------------------- */
.mute-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim);
  width: 34px; height: 34px; border-radius: 999px; font-size: 15px; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.mute-btn:hover { border-color: var(--gold); }

.xp-pop {
  position: fixed; z-index: 70; transform: translate(-50%, -50%);
  pointer-events: none; font-family: var(--serif); font-weight: 700;
  font-size: 22px; color: var(--gold-soft);
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
  animation: xpRise 0.95s ease-out forwards;
}
@keyframes xpRise {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  20%  { opacity: 1; transform: translate(-50%, -80%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}

.toggle-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  margin-bottom: 8px;
}
.toggle-btn:hover { border-color: var(--gold); }

/* ---- Proficiency tiers -------------------------------------- */
.prof { display: inline-flex; align-items: center; gap: 6px; }
.prof-label { font-size: 11px; color: var(--muted); font-weight: 700; }
.prof[data-tier="advanced"] .prof-label { color: #d9c07a; }
.prof[data-tier="master"] .prof-label { color: var(--gold-soft); }
.prof-pips { display: inline-flex; gap: 3px; }
.pip { width: 6px; height: 6px; border-radius: 2px; background: #3a3450; display: inline-block; }
.pip.on { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); }
.prof-next { font-size: 11px; color: var(--ink-dim); }

.learn-tier {
  margin-left: auto; flex: none; font-size: 11px; font-weight: 700; color: var(--gold-soft);
  background: rgba(215,178,74,.12); border: 1px solid rgba(215,178,74,.3);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}

/* ---- Browse toggle (segmented control) ---------------------- */
.seg { display: inline-flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 0 0 16px; }
.seg-btn { background: none; border: 0; color: var(--ink-dim); font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 999px; }
.seg-btn.on { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #241c05; }

/* ---- Disclaimer --------------------------------------------- */
.disclaimer { margin-top: 22px; font-size: 12.5px; color: var(--ink-dim); line-height: 1.55; border-top: 1px solid var(--line); padding-top: 14px; }
.codex-hero-school { background: none; cursor: pointer; }

/* ---- Accessibility ------------------------------------------ */
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--gold); color: #201a08; padding: 10px 16px; border-radius: 0 0 10px 0; font-weight: 700; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 2px; border-radius: 6px; }

/* ---- SEO / no-JS fallback (replaced by the app on load) ------ */
.seo-fallback { max-width: 60ch; margin: 0 auto; color: var(--ink-dim); }
.seo-fallback h1 { color: var(--gold-soft); font-size: clamp(28px, 7vw, 40px); }
.seo-fallback h2 { color: var(--ink); font-size: 18px; margin-top: 20px; }

/* ---- Ask a Philosopher (AI chat) ---------------------------- */
.chat-note {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: 12px; color: var(--muted); margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px;
}
.chat-note .chat-glyph { font-size: 15px; }
.chat-log {
  height: 56vh; min-height: 300px; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-intro {
  text-align: center; margin: auto; padding: 20px; color: var(--ink-dim);
}
.chat-intro-glyph { font-size: 46px; filter: drop-shadow(0 3px 12px rgba(0,0,0,.5)); }
.chat-intro strong { display: block; font-family: var(--serif); font-size: 20px; color: var(--gold-soft); margin: 6px 0 4px; }
.chat-intro p { margin: 4px 0; }
.chat-intro-hint { font-size: 13px; color: var(--muted); }

.chat-composer {
  position: sticky; bottom: calc(6px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--bg); padding-top: 4px;
}
.chat-input {
  flex: 1; resize: none; font-family: var(--sans); font-size: 16px; line-height: 1.4;
  color: var(--ink); background: var(--panel); border: 1.5px solid var(--line);
  border-radius: 14px; padding: 12px 14px; max-height: 140px;
}
.chat-input:focus { outline: none; border-color: var(--gold); }
.chat-send {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #241c05;
  border: 0; font-size: 18px; font-weight: 700;
}
.chat-send:disabled { opacity: .5; }

.chat-typing .dots { display: inline-flex; gap: 4px; }
.chat-typing .dots i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-dim); display: inline-block;
  animation: blink 1.2s infinite both;
}
.chat-typing .dots i:nth-child(2) { animation-delay: .2s; }
.chat-typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.chat-report { display: block; margin-top: 6px; background: none; border: 0; color: var(--muted); font-size: 11px; padding: 2px 0; text-decoration: underline; opacity: .7; cursor: pointer; }
.chat-report:hover { color: var(--bad); opacity: 1; }

/* ---- Quests (debate arenas) --------------------------------- */
.quest-grid { display: flex; flex-direction: column; gap: 12px; }
.quest-card {
  text-align: left; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-left: 4px solid var(--accent, var(--gold));
  border-radius: var(--radius); padding: 15px; color: var(--ink);
  transition: transform .12s, border-color .12s;
}
.quest-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.quest-card-top { display: flex; align-items: center; gap: 9px; }
.quest-glyph { font-size: 24px; flex: none; }
.quest-title { font-family: var(--serif); font-size: 17px; }
.quest-diff { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.diff-hard { background: rgba(215,106,99,.15); color: #f0a9a4; border: 1px solid rgba(215,106,99,.4); }
.diff-med { background: rgba(215,178,74,.14); color: var(--gold-soft); border: 1px solid rgba(215,178,74,.35); }
.quest-done { margin-left: auto; color: var(--good); font-size: 18px; font-weight: 700; }
.quest-goal-line { font-size: 14px; color: var(--ink); }
.quest-vs { font-size: 12px; color: var(--muted); }

.quest-goal {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: rgba(215,178,74,.08); border: 1px solid rgba(215,178,74,.35);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 10px;
}
.quest-goal.solved { background: rgba(107,191,115,.1); border-color: rgba(107,191,115,.5); }
.quest-goal-text { font-size: 14px; font-weight: 600; color: var(--ink); }
.quest-turns { flex: none; font-size: 12px; color: var(--muted); font-weight: 700; }
.quest-setup {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent, var(--gold));
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
}
.quest-setup p { margin: 0; font-family: var(--serif); font-size: 15px; line-height: 1.45; }
.quest-hint { text-align: center; font-size: 13px; color: var(--muted); font-style: italic; padding: 6px 0; }
.quest-won-badge { color: var(--good); font-size: 13px; font-weight: 700; white-space: nowrap; }
.quest-win { margin-top: 14px; }

.build-stamp { margin-top: 10px; font-size: 10px; letter-spacing: .3px; color: var(--muted); opacity: .65; text-align: center; }

/* ---- Deep Story Mode course --------------------------------- */

/* Level stars: one per level, greyed until that level is complete. */
.level-stars { display: inline-flex; gap: 3px; margin-top: 5px; font-size: 14px; line-height: 1; }
.level-stars .lstar { color: var(--muted); opacity: .35; }
.level-stars .lstar.lit { color: var(--gold); opacity: 1; text-shadow: 0 0 8px rgba(215,178,74,.45); }
.cs-hero .level-stars { font-size: 18px; margin-top: 8px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.course { display: flex; flex-direction: column; min-height: calc(100dvh - 110px); }
.course-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.course-x { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim); font-size: 14px; }
.course-bar { flex: 1; height: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.course-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); border-radius: 999px; transition: width .4s ease; }
.course-hearts { flex: none; display: inline-flex; gap: 2px; align-items: center; min-width: 46px; justify-content: flex-end; }
.course-hearts svg { width: 15px; height: 15px; }

.course-stage { flex: 1 1 auto; animation: fadeUp .28s ease; }
.course-foot { position: sticky; bottom: 0; padding: 14px 0 calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--bg) 34%); }
.course-next { width: 100%; padding: 15px; font-size: 16px; font-weight: 700; border-radius: 14px; border: 0; background: var(--gold); color: #1a1205; cursor: pointer; }
.course-next:disabled { opacity: .38; cursor: default; }

.course-chapter { text-align: center; padding: 26px 12px; }
.course-chapter-k { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.course-chapter h2 { font-family: var(--serif); font-size: 26px; color: var(--gold-soft); margin: 8px 0; }
.course-chapter p { color: var(--ink-dim); line-height: 1.5; }
.course-chapter-glyph { display: block; font-size: 56px; margin-top: 18px; filter: drop-shadow(0 3px 10px rgba(0,0,0,.4)); }

.course-teach-glyph { font-size: 40px; margin-bottom: 4px; }
.course-teach h3, .course-q { font-family: var(--serif); font-size: 20px; color: var(--ink); margin: 6px 0 12px; }
.course-teach p { font-size: 16px; line-height: 1.6; margin: 0 0 13px; color: var(--ink); }
.course-pull { border-left: 3px solid var(--accent, var(--gold)); padding: 8px 14px; margin: 10px 0; font-family: var(--serif); font-style: italic; color: var(--gold-soft); }

.course-quote { text-align: center; padding: 14px 6px; }
.course-quote-mark { display: block; font-family: var(--serif); font-size: 56px; color: var(--accent, var(--gold)); line-height: .5; }
.course-quote-text { font-family: var(--serif); font-size: 21px; line-height: 1.5; color: var(--ink); margin: 6px 0; }
.course-quote-who { color: var(--muted); font-size: 13px; }
.course-quote-gloss { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 16px; font-size: 14px; line-height: 1.55; color: var(--ink-dim); }

.course-prompt { font-size: 15px; color: var(--ink-dim); margin: 0 0 13px; line-height: 1.5; }
.course-opts { display: flex; flex-direction: column; gap: 10px; }
.course-opts-wrap { flex-direction: row; flex-wrap: wrap; }
.course-opt {
  text-align: left; padding: 14px 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-size: 15px; line-height: 1.4; cursor: pointer; transition: border-color .1s;
  /* uniform height so option LENGTH can't be scanned as a tell */
  min-height: 3.6em; display: flex; align-items: center;
}
.course-opt:hover:not(:disabled) { border-color: var(--gold); }
.course-opt.right { border-color: var(--good); background: rgba(107,191,115,.14); color: #cdeccf; }
.course-opt.wrong { border-color: var(--bad); background: rgba(215,106,99,.12); opacity: .7; }
.course-opt.chosen { border-color: var(--gold); background: rgba(215,178,74,.12); }

.course-takeaway { margin-top: 14px; background: rgba(215,178,74,.08); border: 1px solid rgba(215,178,74,.3); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }

.course-fill { font-family: var(--serif); font-size: 19px; line-height: 1.75; margin: 6px 0 16px; }
.course-blank { display: inline-block; min-width: 70px; text-align: center; border-bottom: 2px dashed var(--gold-soft); color: var(--muted); padding: 0 6px; }
.course-blank.right { border-bottom-style: solid; border-color: var(--good); color: #cdeccf; }
.course-chip { padding: 11px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; }
.course-chip:hover:not(:disabled) { border-color: var(--gold); }
.course-chip.right { border-color: var(--good); background: rgba(107,191,115,.16); }
.course-chip.wrong { border-color: var(--bad); opacity: .55; }
.course-chip.used { opacity: .35; }


.course-match { display: flex; gap: 14px; }
.course-match-col { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.course-match-cell { padding: 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); font-size: 13px; line-height: 1.35; text-align: left; min-height: 54px; cursor: pointer; }
.course-match-cell.sel { border-color: var(--gold); background: rgba(215,178,74,.14); }
.course-match-cell.done { border-color: var(--good); background: rgba(107,191,115,.12); opacity: .7; }
.course-match-cell.miss { border-color: var(--bad); }

.course-checkpoint-head { text-align: center; margin-bottom: 10px; }
.course-checkpoint-head span { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--good); }
.course-checkpoint-head h3 { font-family: var(--serif); font-size: 20px; color: var(--ink); }
.course-cp-progress { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-align: center; }
.course-cp-done { text-align: center; font-size: 18px; font-weight: 700; color: var(--good); padding: 20px; }

.course-fb { margin-top: 12px; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; animation: fadeUp .25s ease; }
.course-fb.good { background: rgba(107,191,115,.12); border: 1px solid rgba(107,191,115,.4); color: #cdeccf; }
.course-fb.bad { background: rgba(215,106,99,.1); border: 1px solid rgba(215,106,99,.35); color: #f0b8b4; }
.course-fb.neutral { background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim); }

.course-done { text-align: center; padding: 24px 10px; }
.course-done-glyph { font-size: 60px; }
.course-done h2 { font-family: var(--serif); font-size: 24px; color: var(--gold-soft); margin: 8px 0; }
.course-done p { color: var(--ink-dim); line-height: 1.55; }
.course-done-msg { max-width: 32ch; margin: 6px auto 4px; }

/* ---- Story-Mode level select + understanding gauge ---------- */
.course-select { padding-bottom: 24px; }
.cs-hero { display: flex; align-items: center; gap: 14px; margin: 4px 0 6px; padding: 4px; }
.cs-glyph { font-size: 46px; flex: none; filter: drop-shadow(0 3px 8px rgba(0,0,0,.4)); }
.cs-name { font-family: var(--serif); font-size: 25px; color: var(--gold-soft); margin: 0; }
.cs-sub { font-size: 13px; color: var(--muted); }

.cs-gauge { display: flex; justify-content: center; margin: 6px 0 14px; }
.gauge { width: 240px; max-width: 78%; height: auto; }
.gauge-track { fill: none; stroke: var(--line); stroke-width: 15; stroke-linecap: round; }
.gauge-val { fill: none; stroke: var(--gold); stroke-width: 15; stroke-linecap: round; filter: drop-shadow(0 0 5px rgba(215,178,74,.4)); }
.gauge-num { fill: var(--gold-soft); font-family: var(--serif); font-size: 40px; font-weight: 700; }
.gauge-cap { fill: var(--muted); font-family: var(--sans); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; }

.cs-level {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px; margin-bottom: 11px; color: var(--ink);
}
.cs-level.open { border-left: 4px solid var(--accent, var(--gold)); }
.cs-level.done { border-left: 4px solid #67c98a; }
.cs-level.locked { opacity: .55; }
.cs-level:not(.locked):hover { border-color: var(--gold); }
.cs-level-badge {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700;
  background: var(--panel); border: 1.5px solid var(--line); color: var(--gold-soft);
}
.cs-level.done .cs-level-badge { background: #67c98a; color: #08210f; border-color: #67c98a; }
.cs-level-body { flex: 1; min-width: 0; }
.cs-level-body strong { display: block; font-size: 15.5px; margin-bottom: 3px; }
.cs-level-body span { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.cs-level-go { flex: none; font-size: 12.5px; color: var(--gold-soft); font-weight: 600; }
.cs-foot { display: flex; gap: 8px; margin-top: 8px; }
.cs-foot .ghost-btn { flex: 1; }

/* ---- Talk to a Thinker (chat + debate hub) ------------------ */
.talk-banner { display: flex; gap: 14px; align-items: center; background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-left: 4px solid var(--accent, var(--gold)); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.talk-banner-glyph { font-size: 44px; flex: none; filter: drop-shadow(0 3px 8px rgba(0,0,0,.4)); }
.talk-banner-name { font-family: var(--serif); font-size: 22px; color: var(--gold-soft); display: block; }
.talk-banner-sub { font-size: 12.5px; color: var(--muted); }
.talk-banner-line { margin: 6px 0 0; font-size: 14px; color: var(--ink-dim); line-height: 1.45; }

.talk-modes { display: flex; flex-direction: column; gap: 12px; }
.talk-mode { text-align: left; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); transition: transform .1s, border-color .1s; cursor: pointer; }
.talk-mode:hover { transform: translateY(-2px); border-color: var(--gold); }
.talk-mode.duel { border-left: 4px solid var(--accent, var(--gold)); }
.talk-mode-glyph { font-size: 26px; }
.talk-mode strong { display: block; font-family: var(--serif); font-size: 18px; margin: 4px 0 2px; }
.talk-mode-desc { font-size: 13.5px; color: var(--ink-dim); line-height: 1.45; }
.talk-best { display: inline-block; margin-top: 8px; font-size: 11px; font-weight: 700; color: var(--gold-soft); background: rgba(215,178,74,.12); border: 1px solid rgba(215,178,74,.35); border-radius: 999px; padding: 2px 9px; }

.diff-box { text-align: center; background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin-bottom: 18px; }
.diff-k { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.diff-readout { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin: 4px 0; }
.diff-num { font-family: var(--serif); font-size: 52px; font-weight: 700; color: var(--accent, var(--gold)); line-height: 1; }
.diff-of { font-size: 16px; color: var(--muted); }
.diff-name { display: block; font-family: var(--serif); font-size: 20px; color: var(--gold-soft); }
.diff-desc { font-size: 13.5px; color: var(--ink-dim); margin: 6px 0 14px; min-height: 34px; line-height: 1.4; }
.diff-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--gold-soft), var(--bad)); outline: none; }
.diff-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); border: 3px solid var(--accent, var(--gold)); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.diff-slider::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); border: 3px solid var(--accent, var(--gold)); cursor: pointer; }
.diff-ends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 8px; }

.prov-head { font-family: var(--serif); font-size: 17px; margin: 4px 0 10px; color: var(--ink); }
.prov-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.prov { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; color: var(--ink); cursor: pointer; transition: border-color .1s; }
.prov:hover { border-color: var(--gold); }
.prov.sel { border-color: var(--gold); background: rgba(215,178,74,.12); box-shadow: inset 0 0 0 1px var(--gold); }
.prov strong { display: block; font-size: 15px; }
.prov-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; font-style: italic; line-height: 1.4; }

.debate-hint { text-align: center; font-size: 12.5px; color: var(--muted); font-style: italic; padding: 8px 12px; margin: 4px 0; }

/* ---- The Web of Wisdom (spider-web influence map) ----------- */
.web-outer { position: relative; margin: 0 -6px; }
.web-svg {
  display: block; width: 100%; height: 70vh; min-height: 440px;
  background: rgba(255,255,255,.014);
  border: 1px solid var(--line); border-radius: 16px;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  overflow: hidden;
}
.web-svg:active { cursor: grabbing; }

/* threads = the strings connecting the thinkers (influence edges) */
.thread { stroke: rgba(215,178,74,.28); stroke-width: 1.6; transition: stroke .15s, stroke-width .15s; }
.thread.up { stroke: var(--gold-soft); stroke-width: 2.6; filter: drop-shadow(0 0 3px rgba(215,178,74,.6)); }
.thread.down { stroke: #66c2d0; stroke-width: 2.6; filter: drop-shadow(0 0 3px rgba(102,194,208,.5)); }
.thread.dim { stroke: rgba(255,255,255,.028); }

/* nodes */
.wnode { cursor: pointer; transition: opacity .15s; }
.wdot { fill: var(--accent, var(--gold)); stroke: var(--bg); stroke-width: 2.5; transition: stroke-width .12s; }
.wname {
  fill: var(--ink); font-family: var(--sans); font-size: 13px; font-weight: 600;
  text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--bg); stroke-width: 3.5px; stroke-linejoin: round;
}
.wnode:focus { outline: none; }
.wnode:focus-visible .wdot { stroke: var(--gold-soft); stroke-width: 4; }
.wnode.far { opacity: .26; }
.wnode.near .wdot { stroke: var(--gold-soft); stroke-width: 3.5; }
.wnode.near .wname { fill: var(--gold-soft); }
.wnode.sel .wdot { stroke: var(--gold-soft); stroke-width: 4.5; filter: drop-shadow(0 0 6px rgba(215,178,74,.7)); }
.wnode.sel .wname { fill: var(--gold-soft); }

.web-controls { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 7px; }
.web-controls button {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-size: 19px; line-height: 1; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.web-controls button:hover { border-color: var(--gold); color: var(--gold-soft); }
.web-controls button:active { transform: translateY(1px); }

/* detail sheet */
.tree-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  max-width: var(--maxw); margin: 0 auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.4);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.tree-sheet-close { position: absolute; top: 10px; right: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--ink-dim); width: 30px; height: 30px; border-radius: 50%; font-size: 13px; }
.tree-sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-left: 4px; }
.tree-sheet-glyph { font-size: 32px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.4)); }
.tree-sheet-head strong { font-family: var(--serif); font-size: 19px; display: block; color: var(--gold-soft); }
.tree-sheet-sub { font-size: 12.5px; color: var(--muted); }
.tree-sheet-row { margin-bottom: 10px; }
.tree-lbl { display: block; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.tree-none { font-size: 13px; color: var(--ink-dim); font-style: italic; }
.tree-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.tree-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent, var(--gold));
  color: var(--ink); font-size: 13px; padding: 5px 11px; border-radius: 999px;
}
.tree-chip:hover { border-color: var(--gold); }
.tree-sheet-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.tree-sheet-actions .primary { flex: 1; min-width: 140px; }

/* ---- app-bar economy: hearts + scroll tokens ----------------- */
.hearts-chip, .tokens-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 5px 9px; border-radius: 999px; cursor: pointer; color: var(--ink);
}
.hearts-chip { gap: 2px; }
.hearts-chip:hover, .tokens-chip:hover { border-color: var(--gold); }
.phheart { width: 15px; height: 15px; display: block; transition: transform .12s; }
.phheart.full path { fill: #d9584e; }
.phheart.empty path { fill: none; stroke: #6b5f4c; stroke-width: 2; }
.phscroll { width: 18px; height: 18px; display: block; }
.tokens-chip b { color: var(--gold-soft); font-size: 14px; font-weight: 700; }

/* ---- out-of-hearts overlay ----------------------------------- */
.course-out {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(10,8,5,.74); backdrop-filter: blur(4px);
  animation: fadeUp .2s ease;
}
.course-out-card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 22px; max-width: 340px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.course-out-heart { width: 46px; height: 46px; margin: 0 auto 8px; }
.course-out-heart .phheart { width: 46px; height: 46px; }
.course-out-heart .phheart path { fill: none; stroke: #d9584e; stroke-width: 2; }
.course-out-card h3 { font-family: var(--serif); font-size: 22px; margin: 2px 0 8px; }
.course-out-card p { color: var(--ink-dim); font-size: 14px; line-height: 1.5; }
.course-out-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* level in-progress marker */
.cs-level.resuming { border-color: var(--gold); }

/* ---- Ponder the owl ------------------------------------------ */
.ponder {
  position: fixed; right: 12px; bottom: 92px; z-index: 55;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.ponder > * { pointer-events: auto; }
.ponder-owl-btn {
  width: 60px; height: 60px; padding: 0; border: 0; background: none; cursor: pointer;
  filter: drop-shadow(0 0 9px rgba(215,178,74,.45)) drop-shadow(0 6px 12px rgba(0,0,0,.5));
  animation: ponder-bob 3.4s ease-in-out infinite;
}
.ponder.tucked { opacity: 0; pointer-events: none; transition: opacity .2s; }
/* Quiet mode (a question is on screen): the owl can't be tapped — no drawer,
   no misclicks near the answers — but his brief cheer bubbles still show. */
.ponder.quiet .ponder-owl-btn { pointer-events: none; cursor: default; opacity: .8; }
/* Lesson screens: smaller, translucent, tucked above the Continue bar. */
.ponder.compact { bottom: 150px; }
.ponder.compact .ponder-owl-btn { width: 44px; height: 44px; opacity: .88; }
.ponder.compact .ponder-owl-btn:hover { opacity: 1; }
.ponder.pop .ponder-owl-btn { animation: ponder-pop .5s ease; }
.ponder-owl { width: 100%; height: 100%; display: block; }
@keyframes ponder-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes ponder-pop { 0% { transform: scale(1); } 35% { transform: scale(1.18) rotate(-4deg); } 70% { transform: scale(.95); } 100% { transform: scale(1); } }
.ponder-bubble {
  position: relative; max-width: min(228px, 62vw);
  background: var(--panel-2); border: 1px solid var(--gold);
  border-radius: 13px; padding: 9px 26px 9px 12px;
  color: var(--ink); font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(8px) scale(.96); transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease;
}
.ponder-bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.ponder-bubble::after {
  content: ""; position: absolute; right: 22px; bottom: -8px;
  width: 14px; height: 14px; background: var(--panel-2);
  border-right: 1px solid var(--gold); border-bottom: 1px solid var(--gold);
  transform: rotate(45deg);
}
.ponder-text { margin: 0; }
.ponder-x {
  position: absolute; top: 5px; right: 7px; width: 20px; height: 20px;
  border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1;
}
.ponder-x:hover { color: var(--ink); }
.ponder-actions { display: flex; gap: 8px; margin-top: 11px; }
.ponder-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.ponder-btn.primary { background: var(--gold); border-color: var(--gold); color: #1c1710; font-weight: 700; }

/* ---- Ponder's help drawer (the slide-up chat) ------------------ */
.ponder-veil { position: fixed; inset: 0; z-index: 58; background: rgba(10,8,5,.35); }
.ponder-drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 59;
  max-width: 720px; margin: 0 auto;
  background: var(--panel-2); border: 1px solid var(--line); border-bottom: 0;
  border-top: 2px solid var(--gold);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -16px 44px rgba(0,0,0,.55);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .28s ease;
}
.ponder-drawer.open { transform: translateY(0); }
.ponder-d-head { display: flex; align-items: center; gap: 10px; }
.ponder-d-head .ponder-owl { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 2px 5px rgba(0,0,0,.4)); }
.ponder-d-title { display: flex; flex-direction: column; line-height: 1.2; }
.ponder-d-title strong { font-family: var(--serif); font-size: 16.5px; }
.ponder-d-title span { font-size: 11.5px; color: var(--muted); }
.ponder-d-x {
  margin-left: auto; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim);
  font-size: 13px; cursor: pointer;
}
.ponder-d-x:hover { border-color: var(--gold); color: var(--ink); }
.ponder-greet { margin: 8px 0; color: var(--ink-dim); font-size: 13.5px; line-height: 1.5; font-style: italic; }
.ponder-msgs {
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; max-height: 34vh; margin-bottom: 10px;
  overscroll-behavior: contain;
}
.ponder-msg {
  padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; max-width: 86%;
  white-space: pre-wrap;
}
.ponder-msg.me { align-self: flex-end; background: rgba(215,178,74,.15); border: 1px solid rgba(215,178,74,.4); }
.ponder-msg.owl { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.ponder-msg.typing { color: var(--muted); letter-spacing: 2px; animation: ponder-bob 1s ease-in-out infinite; }
.ponder-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ponder-chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim);
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
}
.ponder-chip:hover { border-color: var(--gold); color: var(--ink); }
.ponder-inrow { display: flex; gap: 8px; }
.ponder-in {
  flex: 1; min-width: 0; padding: 10px 13px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font-size: 14px;
}
.ponder-in:focus { outline: none; border-color: var(--gold); }
.ponder-send {
  border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer;
  background: var(--gold); color: #1c1710; font-weight: 700; font-size: 14px;
}
.ponder-send:disabled { opacity: .55; cursor: default; }

/* ---- first-visit welcome card -------------------------------- */
.ob-veil {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(10,8,5,.86); backdrop-filter: blur(5px);
  overflow-y: auto;
}
.ob-veil.out { opacity: 0; transition: opacity .25s; }
.ob-card {
  background: var(--panel-2); border: 1px solid var(--gold); border-radius: 20px;
  padding: 26px 24px; max-width: 400px; width: 100%;
  box-shadow: 0 28px 70px rgba(0,0,0,.6);
  margin: auto;
}
.ob-owl { width: 64px; height: 64px; margin: 0 auto 6px; }
.ob-owl .ponder-owl { width: 64px; height: 64px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.ob-title { font-family: var(--serif); font-size: 24px; text-align: center; margin: 0 0 6px; }
.ob-sub { color: var(--ink-dim); font-size: 13.5px; line-height: 1.5; text-align: center; margin: 0 0 14px; }
.ob-label { display: block; font-size: 12.5px; color: var(--gold-soft); font-weight: 600; margin: 12px 0 6px; letter-spacing: .3px; }
.ob-in, .ob-sel {
  width: 100%; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); font-size: 14px;
}
.ob-in:focus, .ob-sel:focus { outline: none; border-color: var(--gold); }
.ob-row { display: flex; gap: 8px; }
.ob-row .ob-sel { flex: 1; min-width: 0; }
.ob-err { color: var(--bad); font-size: 13px; margin: 10px 0 0; text-align: center; }
.ob-go { width: 100%; margin-top: 16px; }
.ob-cancel { width: 100%; margin-top: 8px; }

/* home welcome line */
.home-welcome {
  font-family: var(--serif); font-style: italic; font-size: 17px;
  color: var(--gold-soft); margin: 2px 0 4px;
}

/* ---- Story Mode sortable (order exercises) -------------------- */
.course-sort { list-style: none; margin: 14px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.course-sort-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; font-size: 14px; line-height: 1.4;
}
.course-sort-item.ok { border-color: var(--good); background: rgba(107,191,115,.1); }
.course-sort-item.miss { border-color: var(--bad); }
.course-sort-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); font-weight: 700;
}
.course-sort-item .tl-name { flex: 1; }
.course-sort-submit { width: 100%; margin-top: 2px; }

@media (max-width: 480px) {
  .brand-name { display: none; }
  .phheart { width: 13px; height: 13px; }
  .hearts-chip, .tokens-chip { padding: 5px 7px; }
  .ponder-owl-btn { width: 52px; height: 52px; }
  .ponder { right: 10px; bottom: 86px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .05s !important; }
}
