@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces-var-latin.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-var-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --navy: #14213D; --navy-2: #1A2A4C; --navy-3: #22355C; --navy-4: #2C4170;
  --ivory: #F5F1E8; --ivory-dim: #D9D3C5;
  --brass: #B8913A; --brass-2: #D1AE5E; --brass-ink: #14213D;
  --slate: #5B6B7F; --slate-text: #AEB8C6;
  --sage: #5E8C6A; --amber: #D98E04;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(5, 10, 25, .35);
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--navy); color: var(--ivory); font-family: var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; font-size: 16px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.85rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
a { color: var(--brass-2); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brass-2); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brass); color: var(--navy); padding: 8px 12px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; padding: calc(18px + var(--safe-t)) 18px calc(96px + var(--safe-b)); outline: none; }
.screen.no-tabs { padding-bottom: calc(24px + var(--safe-b)); }
.boot { display: grid; place-items: center; gap: 12px; padding-top: 30vh; color: var(--slate-text); }

/* Tab bar */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(20, 33, 61, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--navy-4); padding: 6px 4px calc(6px + var(--safe-b)); z-index: 10; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--slate-text); text-decoration: none; font-size: .72rem; padding: 6px 0; border-radius: 10px; min-height: 48px; justify-content: center; }
.tabbar a span { font-size: 1.25rem; line-height: 1; }
.tabbar a[aria-current="page"] { color: var(--brass-2); }

/* Generic */
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--slate-text); }
.small { font-size: .85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 600; color: var(--brass-2); margin-bottom: 6px; }
.card { background: var(--navy-2); border: 1px solid var(--navy-4); border-radius: var(--radius); padding: 16px; }
.card.tap { display: block; width: 100%; text-align: left; cursor: pointer; text-decoration: none; color: inherit; transition: transform .12s, border-color .12s; }
.card.tap:hover { border-color: var(--slate); }
.card.tap:active { transform: scale(.985); }
.card.hero { background: linear-gradient(160deg, var(--navy-3), var(--navy-2)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-title { font-family: var(--serif); font-size: 1.15rem; margin: 22px 0 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--navy-3); border: 1px solid var(--navy-4); font-size: .78rem; color: var(--ivory-dim); }
.pill.brass { color: var(--brass-2); border-color: rgba(184,145,58,.5); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 20px; border-radius: 14px; border: 1px solid transparent; font-weight: 600; cursor: pointer; text-decoration: none; font-size: 1rem; }
.btn.primary { background: var(--brass); color: var(--brass-ink); }
.btn.primary:hover { background: var(--brass-2); }
.btn.ghost { background: transparent; border-color: var(--slate); color: var(--ivory); }
.btn.quiet { background: var(--navy-3); color: var(--ivory); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.danger { background: transparent; border-color: var(--amber); color: var(--amber); }
.iconbtn { background: none; border: 0; color: var(--ivory-dim); font-size: 1.4rem; min-width: 44px; min-height: 44px; border-radius: 10px; cursor: pointer; }
.iconbtn[aria-pressed="true"] { color: var(--brass-2); }

.bar { height: 8px; border-radius: 99px; background: var(--navy-4); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brass); border-radius: 99px; transition: width .4s ease; }
.bar.sage > i { background: var(--sage); }

/* Header & rank */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.rank-badge { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--brass); color: var(--brass-2); font-family: var(--serif); font-weight: 700; font-size: 1.35rem; background: radial-gradient(circle at 30% 30%, var(--navy-3), var(--navy)); flex: none; }
.rank-badge.lg { width: 96px; height: 96px; font-size: 2.2rem; border-width: 3px; }
.rank-badge.locked { border-color: var(--slate); color: var(--slate-text); }
.stat { text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 1.5rem; color: var(--ivory); }
.stat span { font-size: .78rem; color: var(--slate-text); }
.ring { width: 64px; height: 64px; flex: none; }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: var(--navy-4); } .ring .fg { stroke: var(--brass); stroke-linecap: round; transition: stroke-dashoffset .5s; }

/* Mode tiles */
.mode { display: flex; gap: 12px; align-items: center; }
.mode .glyph { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--navy-3); color: var(--brass-2); font-size: 1.3rem; flex: none; }
.mode h3 { margin: 0; font-size: 1.02rem; }
.mode p { margin: 0; font-size: .84rem; color: var(--slate-text); }
.mode.locked { opacity: .55; }
.count { margin-left: auto; min-width: 30px; padding: 2px 9px; border-radius: 99px; background: var(--brass); color: var(--navy); font-weight: 700; font-size: .85rem; text-align: center; }

/* Path */
.cat { margin-bottom: 16px; }
.cat-head { display: flex; gap: 12px; align-items: center; }
.cat-head .glyph { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--brass); display: grid; place-items: center; color: var(--brass-2); flex: none; }
.cat.locked .cat-head .glyph { border-color: var(--slate); color: var(--slate-text); }
.lawlist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.lawitem { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--navy-3); border: 1px solid transparent; text-decoration: none; color: inherit; width: 100%; text-align: left; cursor: pointer; }
.lawitem:hover { border-color: var(--slate); }
.lawitem .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; background: var(--navy); border: 1.5px solid var(--slate); flex: none; font-size: .9rem; }
.lawitem.done .num { border-color: var(--brass); color: var(--brass-2); }
.lawitem.mastered .num { background: var(--brass); color: var(--navy); border-color: var(--brass); }
.lawitem.locked { opacity: .5; cursor: not-allowed; }
.lawitem .t { flex: 1; min-width: 0; }
.lawitem .t b { display: block; font-weight: 600; font-size: .95rem; line-height: 1.3; }
.lawitem .t span { font-size: .78rem; color: var(--slate-text); }

/* Lesson */
.lesson-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.lesson-top .bar { flex: 1; }
.lcard { min-height: calc(100dvh - 170px - var(--safe-t) - var(--safe-b)); display: flex; flex-direction: column; animation: rise .25s ease; }
.lcard h1 { font-size: 1.7rem; }
.lcard .body { font-size: 1.06rem; line-height: 1.65; color: var(--ivory); }
.lcard .core { font-family: var(--serif); font-size: 1.25rem; line-height: 1.45; color: var(--ivory); border-left: 3px solid var(--brass); padding-left: 14px; margin: 18px 0; }
.lcard .takeaway { font-family: var(--serif); font-size: 1.5rem; line-height: 1.35; color: var(--brass-2); text-align: center; margin: 24px 0; }
.lcard .ethics { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(217,142,4,.08); border: 1px solid rgba(217,142,4,.4); font-size: .93rem; }
.lcard .lawno { font-family: var(--serif); font-size: 4rem; line-height: 1; color: var(--brass); opacity: .9; }
.footer-actions { position: sticky; bottom: 0; display: flex; gap: 10px; margin: 18px -18px 0; padding: 18px 18px calc(10px + var(--safe-b)); background: linear-gradient(to bottom, rgba(20,33,61,0), var(--navy) 35%); }
.footer-actions .btn { flex: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Quiz */
.q-prompt { font-family: var(--serif); font-size: 1.22rem; line-height: 1.45; margin: 6px 0 18px; }
.options { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 14px; border-radius: 14px; background: var(--navy-2); border: 1.5px solid var(--navy-4); cursor: pointer; font-size: .98rem; line-height: 1.4; min-height: 52px; color: var(--ivory); }
.opt:hover:not([disabled]) { border-color: var(--slate); }
.opt .key { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--slate); display: grid; place-items: center; font-size: .78rem; font-weight: 700; flex: none; color: var(--slate-text); }
.opt[disabled] { cursor: default; }
.opt.correct { border-color: var(--sage); background: rgba(94,140,106,.18); }
.opt.correct .key { background: var(--sage); border-color: var(--sage); color: var(--ivory); }
.opt.wrong { border-color: var(--amber); background: rgba(217,142,4,.12); }
.opt.wrong .key { background: var(--amber); border-color: var(--amber); color: var(--navy); }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid; animation: rise .2s ease; }
.feedback.good { border-color: var(--sage); background: rgba(94,140,106,.14); }
.feedback.bad { border-color: var(--amber); background: rgba(217,142,4,.10); }
.feedback h3 { margin: 0 0 4px; font-family: var(--sans); font-size: 1rem; }
.feedback.good h3 { color: #9CC9A8; } .feedback.bad h3 { color: var(--amber); }
.feedback p { margin: 0; font-size: .95rem; }
.timer { font-family: var(--serif); font-size: 1.4rem; color: var(--brass-2); font-variant-numeric: tabular-nums; }
.xp-pop { color: var(--brass-2); font-weight: 700; }

/* Results */
.result-hero { text-align: center; padding: 18px 0; }
.result-hero .big { font-family: var(--serif); font-size: 3.2rem; color: var(--brass-2); line-height: 1; }

/* Onboarding */
.onb { min-height: 86dvh; display: flex; flex-direction: column; }
.onb .grow { flex: 1; }
.onb .emblem { width: 120px; height: 120px; border-radius: 28px; margin: 6vh auto 18px; display: block; box-shadow: var(--shadow); }
.onb h1 { text-align: center; font-size: 2.2rem; }
.choice { display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--navy-2); border: 1.5px solid var(--navy-4); margin-bottom: 10px; cursor: pointer; color: var(--ivory); }
.choice b { display: block; font-family: var(--serif); font-size: 1.05rem; }
.choice span { font-size: .86rem; color: var(--slate-text); }
.choice[aria-pressed="true"], .choice[aria-checked="true"] { border-color: var(--brass); background: var(--navy-3); }
.dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--navy-4); }
.dots i.on { background: var(--brass); width: 22px; border-radius: 8px; }
.disclaimer { font-size: .78rem; color: var(--slate-text); text-align: center; line-height: 1.45; }
input[type="text"], input[type="search"] { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--navy-4); background: var(--navy-2); color: var(--ivory); font: inherit; }
input::placeholder { color: var(--slate-text); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow-x: visible; }
.ref, .lawitem .t .ref { display: block; font-family: var(--sans); font-size: .74rem; font-weight: 400; font-style: normal; letter-spacing: .01em; color: var(--slate-text); opacity: .9; margin-top: 2px; line-height: 1.35; }
h1 + .ref, h2 + .ref { margin: -4px 0 12px; }
.opt .opt-body { display: flex; flex-direction: column; text-align: left; }
.chip { flex: none; padding: 8px 12px; border-radius: 99px; border: 1px solid var(--navy-4); background: var(--navy-2); color: var(--ivory-dim); font-size: .82rem; cursor: pointer; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--brass); color: var(--navy); border-color: var(--brass); font-weight: 600; }

/* Ranks */
.ladder { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.ladder li { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 14px; background: var(--navy-2); border: 1px solid var(--navy-4); }
.ladder li.current { border-color: var(--brass); background: var(--navy-3); }
.ladder li.locked { opacity: .6; }

/* Law detail */
.detail section { margin: 18px 0; }
.detail h3 { color: var(--brass-2); font-family: var(--sans); text-transform: uppercase; letter-spacing: .1em; font-size: .78rem; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5,10,25,.7); display: grid; place-items: center; z-index: 50; padding: 24px; animation: rise .2s; }
.modal { background: var(--navy-2); border: 1.5px solid var(--brass); border-radius: 22px; padding: 26px; max-width: 380px; width: 100%; text-align: center; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 700px) { .screen { padding-left: 28px; padding-right: 28px; } }
