/* Quest engine styles (on top of assets/site.css). Same color jobs:
   blue = click, gold = earned, green = right/done, red = wrong/myth, amber = protect,
   cyan/violet/magenta = beginner/intermediate/advanced. */
.q-top { padding: 30px 0 10px; }
.q-tracks { display: flex; width: fit-content; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 22px; }
.q-tracks a { padding: 8px 14px; border-radius: 9px; color: var(--text); font-size: .92rem; font-weight: 600; text-decoration: none; }
.q-tracks a:hover { background: var(--accent-soft); color: var(--accent-strong); }
.q-tracks a.on { background: var(--accent); color: var(--on-accent); }

/* Color key: teaches the code once so it can do its job everywhere after */
.key { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .86rem; color: var(--muted); margin: 14px 0 4px; }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* HUD: gold = earned */
.hud { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 12px; margin: 18px 0 8px; }
.hud .card { padding: 14px 16px; }
.hud .k { font: 700 .72rem/1.3 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hud .v { font: 800 1.35rem/1.25 var(--sans); color: var(--text); }
.hud .rank { background: linear-gradient(135deg, var(--gold-soft), var(--panel) 70%); border-color: var(--gold-line); }
.hud .rank .v { font-family: var(--serif); color: var(--gold); }
.bar { height: 12px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-top: 8px; border: 1px solid var(--line-strong); }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-line), var(--gold-fill)); box-shadow: inset 0 0 0 1px var(--gold-line); border-radius: 999px; transition: width .6s ease; }
@media (max-width: 760px) { .hud { grid-template-columns: 1fr 1fr; } .hud .rank { grid-column: 1 / -1; } }

/* Map: level color = memory cue; ring fill = progress */
.map { position: relative; display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px 40px; margin: 30px 0 10px; }
.map::before { content: ""; position: absolute; left: 50%; top: 20px; bottom: 20px; width: 3px; background: repeating-linear-gradient(to bottom, var(--line-strong) 0 8px, transparent 8px 16px); transform: translateX(-1px); }
.realm { --lv: var(--accent); --lv-soft: var(--accent-soft); position: relative; z-index: 1; text-align: left; width: 100%; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--lv); border-radius: 16px; padding: 18px 18px 18px 88px; cursor: pointer; font: inherit; box-shadow: var(--shadow); transition: border-color .15s, transform .15s, box-shadow .15s; min-height: 112px; }
.realm.lvl-1 { --lv: var(--lvl-1); --lv-soft: var(--lvl-1-soft); }
.realm.lvl-2 { --lv: var(--lvl-2); --lv-soft: var(--lvl-2-soft); }
.realm.lvl-3 { --lv: var(--lvl-3); --lv-soft: var(--lvl-3-soft); }
.realm:nth-child(even) { margin-top: 64px; }
.realm:hover:not(.locked) { transform: translateY(-2px); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); border-color: var(--accent); border-left-color: var(--lv); }
.realm .num { position: absolute; left: 18px; top: 18px; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--lv) var(--p, 0%), var(--line) 0); }
.realm .num::after { content: attr(data-n); position: absolute; inset: 6px; border-radius: 50%; background: var(--lv-soft); color: var(--lv); display: grid; place-items: center; font: 800 1.15rem var(--sans); }
.realm h3 { margin: 0 0 4px; font-size: 1.08rem; }
.realm .tl { color: var(--muted); font-size: .94rem; margin: 0 0 10px; }
.realm .meta { font-size: .84rem; color: var(--text); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.realm .lvl { font-weight: 700; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--lv); background: var(--lv-soft); border-radius: 999px; padding: 4px 10px; }
.realm .go { color: var(--accent); font-weight: 700; margin-left: 4px; }
.realm .lockmsg { color: var(--muted); }
.realm.locked { background: var(--bg-2); border-left-color: var(--line-strong); box-shadow: none; cursor: not-allowed; }
.realm.locked h3, .realm.locked .tl { color: var(--muted); }
.realm.locked .num { background: var(--line); }
.realm.locked .num::after { background: var(--bg-2); color: var(--muted); }
.realm.locked .lvl { color: var(--muted); background: var(--panel); }
.realm.done { border-color: var(--gold-line); border-left-color: var(--lv); }
.realm.done .earned { color: var(--gold); font-weight: 700; }
@media (max-width: 760px) {
  .map { grid-template-columns: 1fr; } .map::before { left: 51px; } .realm:nth-child(even) { margin-top: 0; }
}

/* Badges: gold when earned, plain outline when not */
.badges { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 0; }
.badge { display: inline-flex; align-items: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: 999px; padding: 6px 12px 6px 6px; font-size: .86rem; color: var(--muted); background: var(--panel); }
.badge i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: .74rem; font-weight: 700; background: var(--bg-2); color: var(--muted); }
.badge.got { color: var(--text); border: 1px solid var(--gold-line); background: var(--gold-soft); font-weight: 600; }
.badge.got i { background: var(--gold-fill); color: var(--on-gold); box-shadow: 0 0 0 2px var(--gold-line); }

/* Realm view */
.crumbs { font-size: .95rem; margin: 10px 0 18px; }
.crumbs button { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-weight: 600; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.crumbs button:hover { color: var(--accent-strong); }
.missions { display: grid; gap: 12px; }
.mcard { display: grid; grid-template-columns: 46px 1fr auto; gap: 14px; align-items: center; text-align: left; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; color: var(--text); font: inherit; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.mcard:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.mcard .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); font-weight: 800; }
.mcard.done .ic { background: var(--ok); color: #fff; }
.mcard h4 { margin: 0 0 3px; font-size: 1.02rem; }
.mcard p { margin: 0; color: var(--muted); font-size: .88rem; }
.chip { font-size: .78rem; font-weight: 700; border-radius: 999px; padding: 5px 12px; white-space: nowrap; background: var(--accent); color: var(--on-accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.boss { background: var(--gold-fill); color: var(--on-gold); }

/* Mission */
.stepper { display: flex; gap: 6px; margin: 6px 0 22px; flex-wrap: wrap; }
.stepper span { flex: 1 1 120px; font: 700 .76rem/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-top: 4px solid var(--line); padding-top: 8px; }
.stepper span.on { color: var(--accent-strong); border-color: var(--accent); }
.stepper span.past { color: var(--ok); border-color: var(--ok); }
.mission { max-width: 800px; }
.mission .lede { font-size: 1.12rem; }
.myth { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.myth div { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); }
.myth b { display: block; font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; }
.myth .m { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.myth .f { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.myth .m b { color: var(--bad); } .myth .f b { color: var(--ok); }
@media (max-width: 600px) { .myth { grid-template-columns: 1fr; } }
.protect { border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-left: 5px solid var(--warn); padding: 12px 16px; background: var(--warn-soft); border-radius: 10px; margin: 14px 0; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; }
.checks li { margin-bottom: 10px; }
.checks label { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 13px 14px; color: var(--text); font-size: 1rem; cursor: pointer; margin: 0; transition: border-color .15s, background .15s; }
.checks label:hover { border-color: var(--accent); }
.checks input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--ok); flex: none; }
.checks label:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); }
.practice { font-size: .97rem; }
.q { margin-bottom: 20px; }
.q h4 { font-size: 1.06rem; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; background: var(--panel); border: 2px solid var(--line-strong); color: var(--text); border-radius: 10px; padding: 12px 14px; font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.opt[disabled] { cursor: default; color: var(--muted); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); color: var(--text); font-weight: 600; }
.opt.right::before { content: "✓ "; color: var(--ok); font-weight: 800; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--text); text-decoration: line-through; text-decoration-color: var(--bad); }
.opt.wrong::before { content: "✗ "; color: var(--bad); font-weight: 800; }
.explain { font-size: .95rem; color: var(--text); margin-top: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.debrief { display: grid; gap: 10px; max-width: 520px; }
.debrief .btn { justify-content: flex-start; }
.src { font-size: .87rem; color: var(--muted); }
.src a { word-break: break-word; }

/* Reward overlay: the one place gold takes over */
.overlay { position: fixed; inset: 0; background: rgba(15,16,20,.6); display: grid; place-items: center; z-index: 100; padding: 20px; }
.reward { background: var(--panel); border: 2px solid var(--gold-line); border-radius: 18px; padding: 30px; max-width: 440px; width: 100%; text-align: center; animation: pop .35s ease; box-shadow: 0 0 0 8px var(--gold-soft), 0 30px 60px -20px rgba(0,0,0,.4); }
.reward .big { font-family: var(--serif); font-weight: 700; font-size: 1.9rem; color: var(--text); margin: 4px 0 12px; }
.reward .xp { display: inline-block; font: 800 1.4rem var(--sans); color: var(--on-gold); background: var(--gold-fill); border-radius: 999px; padding: 6px 16px; }
.reward .line { color: var(--text); }
.reward .line.badge-line { color: var(--gold); font-weight: 700; }
.reward .line.unlock { color: var(--accent-strong); font-weight: 700; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
canvas.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 101; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; z-index: 120; max-width: calc(100% - 32px); font-weight: 600; box-shadow: var(--shadow); }

/* Certificate */
.cert { background: #fffaf0; color: #1b1712; border: 10px double #b48a2c; border-radius: 6px; padding: 48px 32px; text-align: center; max-width: 820px; margin: 0 auto; }
.cert h1 { color: #1b1712; }
.cert .nm { font-family: var(--serif); font-size: 2.2rem; border-bottom: 2px solid #b48a2c; display: inline-block; padding: 0 20px 6px; margin: 10px 0 18px; }
@media print {
  .site-header, .site-footer, .no-print { display: none !important; }
  body { background: #fff; }
}
details.settings { margin-top: 26px; }
details.settings summary { cursor: pointer; color: var(--accent); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
