/* Base: reset, typography, shell layout, utilities. */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: var(--info); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.01em; margin: 0; line-height: 1.15; }

h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); }

h2 { font-size: clamp(1.3rem, 2.4vw, 1.75rem); }

h3 { font-size: 1.15rem; }

p { margin: 0.35rem 0; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); }

.faint { color: var(--faint); }

.small { font-size: 0.85rem; }

.tiny { font-size: 0.75rem; }

.eyebrow { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.row { display: flex; align-items: center; gap: 0.6rem; }

.row.wrap { flex-wrap: wrap; }

.row.between { justify-content: space-between; }

.stack { display: flex; flex-direction: column; gap: 0.6rem; }

.grow { flex: 1; }

.center { text-align: center; }

.mt { margin-top: 1rem; }

.mt-sm { margin-top: 0.5rem; }

.mb { margin-bottom: 1rem; }

.hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 1rem; }

.boot-shelf { display: flex; gap: 8px; align-items: flex-end; justify-content: center; border-bottom: 4px solid var(--text); padding: 0 8px 0; width: 120px; margin: 0 auto; }

.boot-shelf span { width: 18px; background: var(--accent); border-radius: 4px 4px 0 0; animation: stock 1s ease-in-out infinite; }

.boot-shelf span:nth-child(1) { height: 28px; background: #FF6B6B; animation-delay: 0s; }

.boot-shelf span:nth-child(2) { height: 40px; background: #38BDF8; animation-delay: 0.15s; }

.boot-shelf span:nth-child(3) { height: 22px; background: #A3E635; animation-delay: 0.3s; }

.boot-shelf span:nth-child(4) { height: 34px; background: #A78BFA; animation-delay: 0.45s; }

/* ---------- shell ---------- */
.app { min-height: 100vh; }

.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }

.nav {
  position: sticky; top: 0; height: 100vh; padding: 1.1rem 0.9rem; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg)); display: flex; flex-direction: column; gap: 0.3rem;
}

.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0.5rem 1rem; text-decoration: none; color: var(--text); }

.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--bg-2); border: 1px solid var(--line-strong); display: grid; place-items: center; }

.brand-mark svg { width: 24px; height: 24px; }

.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; line-height: 1; }

.brand-sub { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }

.nav-link {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.7rem; border-radius: 10px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 0.95rem; border: 1px solid transparent; transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--surface); color: var(--text); }

.nav-link.active { background: var(--surface-2); color: var(--text); border-color: var(--line); }

.nav-link .ico { width: 22px; text-align: center; font-size: 1.05rem; }

.nav-link .badge { margin-left: auto; }

.nav-foot { margin-top: auto; padding: 0.6rem; border-top: 1px solid var(--line); }

.main { min-width: 0; padding: 1.25rem clamp(1rem, 3vw, 2.5rem) 5rem; max-width: 1180px; width: 100%; margin: 0 auto; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }

.xpbar { display: flex; align-items: center; gap: 0.7rem; background: var(--surface); border: 1px solid var(--line); padding: 0.45rem 0.8rem; border-radius: 999px; }

.xpbar .bar { width: 120px; }

.bottom-nav { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav { display: none; }
  .main { padding: 0.9rem 1rem 6rem; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--bg-2); border-top: 1px solid var(--line);
    padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom)); justify-content: space-around;
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0.3rem 0.5rem; color: var(--muted); text-decoration: none; font-size: 0.62rem; font-weight: 700; border-radius: 10px; min-width: 52px; }
  .bottom-nav a .ico { font-size: 1.2rem; }
  .bottom-nav a.active { color: var(--text); background: var(--surface-2); }
}

/* ---------- misc ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

.divider { height: 1px; background: var(--line); margin: 1rem 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }

.page-head p { color: var(--muted); max-width: 60ch; }

.back { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; }

.back:hover { color: var(--text); }

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

:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }

/* ===== Game layer: softer surfaces, motion, map, lessons, visuals ===== */

/* --- de-boxing & atmosphere --- */
body { background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%), radial-gradient(900px 500px at 110% 10%, rgba(56, 189, 248, 0.12), transparent 60%), radial-gradient(800px 600px at 50% 110%, rgba(167, 139, 250, 0.1), transparent 60%), var(--bg); background-attachment: fixed; }

:root[data-theme="light"] body { background: radial-gradient(1200px 600px at 10% -10%, rgba(217, 119, 6, 0.1), transparent 60%), radial-gradient(900px 500px at 110% 10%, rgba(2, 132, 199, 0.08), transparent 60%), var(--bg); }

.nav { background: color-mix(in srgb, var(--bg-2) 85%, transparent); backdrop-filter: blur(10px); }

.view > * { animation: viewIn 0.38s cubic-bezier(.2,.8,.2,1) both; }

.xpbar .bar-fill { background: linear-gradient(90deg, var(--accent), #FFD58A); }

body {
  font-family: var(--font-body);
  font-size: 17px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(201, 162, 39, 0.10), transparent 60%),
    radial-gradient(700px 500px at 105% 15%, rgba(139, 30, 30, 0.14), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    var(--bg);
  background-attachment: fixed;
}

:root[data-theme="light"] body { background: radial-gradient(900px 500px at 15% -10%, rgba(139, 30, 30, 0.08), transparent 60%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.12 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"), var(--bg); }

h1 { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }

h2 { letter-spacing: 0.04em; }

.mono { font-family: var(--font-display); letter-spacing: 0.03em; }

/* ---------- nav as a standard pole ---------- */
.nav { background: linear-gradient(180deg, #1A1510, #110D0A); border-right: 1px solid rgba(0,0,0,0.7); box-shadow: inset -1px 0 0 rgba(234,219,192,0.06); }

.brand-mark { background: radial-gradient(circle at 40% 35%, #E3C76A, #8B6B1A 70%); border: 1px solid #3a2a08; color: #1A1206; }

.brand-mark svg { display: none; }

.brand-mark::after { content: 'SPQR'; font-family: var(--font-display); font-weight: 900; font-size: 0.55rem; letter-spacing: 0.08em; color: #1A1206; }

.nav-link { font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; border-radius: 4px; }

.nav-link.active { background: linear-gradient(90deg, rgba(139,30,30,0.6), rgba(139,30,30,0.15)); border-left: 3px solid var(--gold); color: #F6E7C8; }

.bottom-nav { background: #110D0A; border-top: 1px solid rgba(0,0,0,0.8); }

.bottom-nav a { font-family: var(--font-display); letter-spacing: 0.04em; font-size: 0.55rem; text-transform: uppercase; }

.bottom-nav a.active { background: rgba(139,30,30,0.45); }

.xpbar { background: linear-gradient(180deg, #3A322A, #2A241D); border: 1px solid rgba(0,0,0,0.6); box-shadow: inset 0 1px 0 rgba(234,219,192,0.1); border-radius: 6px; }

.xpbar .bar-fill { background: linear-gradient(90deg, #8B6B1A, var(--gold-2)); }

/* ---------- the battlefield behind the quiz ---------- */
.shell { position: relative; z-index: 1; }

.empty { border-color: rgba(234,219,192,0.25); }

.boot { color: var(--muted); }

.boot-shelf { border-bottom-color: var(--gold); }

.boot-shelf span { background: var(--crimson) !important; }

/* ---------- day march (light) legibility ---------- */
.nav, .bottom-nav { color: #EADBC0; }

.nav .brand-name, .nav .brand-sub, .nav .nav-foot, .nav .nav-link { color: #B4A58A; }

.nav .brand-name { color: #EADBC0; }

.nav .nav-link:hover { color: #F6E7C8; background: rgba(234,219,192,0.08); }

.nav .nav-link.active { color: #F6E7C8; }

.bottom-nav a { color: #B4A58A; }

.bottom-nav a.active { color: #F6E7C8; }

.nav .badge.quiet { background: rgba(234,219,192,0.12); color: #EADBC0; }

.shell { position: relative; z-index: 1; }

.page-head h1 { position: relative; display: inline-block; }

.page-head h1::after { content: ''; position: absolute; left: 0; right: 0; bottom: -8px; height: 3px; background: linear-gradient(90deg, var(--gold), transparent 70%); border-radius: 2px; }

/* ---------- nav: ribbon active state ---------- */
.nav-link.active { position: relative; border-left: 0; background: linear-gradient(90deg, #8B1E1E, #5E1313); clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%); box-shadow: none; }

.bottom-nav a.active { border-radius: 999px; }

.xpbar { border-radius: 999px; }
