:root {
  --world: #d2e2ec;
  --paper: #fbf8f1;
  --paper-2: #f3eee2;
  --ink: #1d1b18;
  --body: #2b2822;
  --muted: #6f6a60;
  --hair: #e2dccd;
  --tablet: #0f151e;
  --gold: #c99a2e;
  --accent: #f4b740;
  --hud-ink: #fffdf6;
  --title: "Cormorant Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --serif: "Source Serif 4", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 30px 80px rgba(12, 18, 28, 0.35), 0 2px 8px rgba(12, 18, 28, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17191d; --paper-2: #1e2126; --ink: #f4efe4; --body: #e2ddd2; --muted: #a39d92; --hair: #33363c;
  }
}
:root[data-theme="dark"] { --paper: #17191d; --paper-2: #1e2126; --ink: #f4efe4; --body: #e2ddd2; --muted: #a39d92; --hair: #33363c; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--world); color: var(--body); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
a { color: inherit; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

.key { display: inline-block; min-width: 1.6em; padding: 0.05em 0.4em; margin-right: 0.45em; border: 1px solid currentColor; border-radius: 5px; font-size: 0.78em; font-weight: 600; text-align: center; opacity: 0.85; letter-spacing: 0.02em; }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; display: grid; place-content: center; gap: 18px; justify-items: center; background: radial-gradient(ellipse at 50% 40%, #f6ecd8, #c9dbe0 70%); z-index: 50; font-family: var(--title); font-size: 22px; color: #3b4a52; transition: opacity 0.8s; }
#loader.done { opacity: 0; pointer-events: none; }
.loader-mark { width: 54px; height: 54px; border: 2px solid #3b4a52; transform: rotate(45deg); animation: spin 2.4s cubic-bezier(.6,0,.4,1) infinite; }
@keyframes spin { to { transform: rotate(405deg); } }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 30; display: grid; align-items: end; padding: 0 clamp(16px, 6vw, 90px) clamp(28px, 8vh, 90px); background: linear-gradient(180deg, rgba(10,16,26,0) 25%, rgba(10,16,26,0.55) 100%), linear-gradient(90deg, rgba(10,16,26,0.45), rgba(10,16,26,0) 65%); color: var(--hud-ink); transition: opacity 1.2s ease; }
#title.leaving { opacity: 0; pointer-events: none; }
.title-inner { max-width: 760px; }
.title-kicker { font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.28em; font-size: 12px; opacity: 0.85; margin: 0 0 6px; }
#title h1 { font-family: var(--title); font-weight: 600; font-size: clamp(56px, 11vw, 132px); line-height: 0.9; margin: 0 0 18px; letter-spacing: -0.01em; text-shadow: 0 4px 40px rgba(0,0,0,0.35); }
.title-sub { font-family: var(--serif); font-size: clamp(16px, 2.1vw, 20px); line-height: 1.5; max-width: 640px; margin: 0 0 24px; text-shadow: 0 1px 12px rgba(0,0,0,0.4); }
.title-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.title-controls { font-size: 13px; opacity: 0.85; margin: 0 0 8px; }
.title-fine { font-size: 12px; opacity: 0.7; max-width: 620px; line-height: 1.5; margin: 0; }

.primary { background: var(--ink); color: var(--paper); border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: 14px; }
#title .primary { background: #fffaf0; color: #1d1b18; }
.primary.big { padding: 14px 28px; font-size: 16px; box-shadow: 0 10px 40px rgba(255, 220, 150, 0.35); }
.primary:disabled { opacity: 0.5; cursor: progress; }
.ghost { background: rgba(255,255,255,0.08); color: inherit; border: 1px solid rgba(255,255,255,0.6); border-radius: 999px; padding: 13px 22px; font-weight: 500; backdrop-filter: blur(6px); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; color: var(--hud-ink); text-shadow: 0 1px 3px rgba(0,0,0,0.55), 0 0 14px rgba(0,0,0,0.25); }
.tally { position: absolute; left: 20px; top: 18px; display: grid; gap: 6px; font-size: 14px; }
.tally-row { display: flex; align-items: center; gap: 8px; }
.tally-row b { font-variant-numeric: lining-nums tabular-nums; font-family: var(--title); font-size: 26px; font-weight: 600; line-height: 1; min-width: 1.2em; text-align: right; }
.glyph { width: 14px; height: 14px; display: inline-block; filter: drop-shadow(0 0 6px rgba(255,210,120,0.8)); }
.shrine-glyph { background: #ffd67a; transform: rotate(45deg) scale(0.85); border: 2px solid #fff6dc; }
.seed-glyph { background: radial-gradient(circle, #fff 0 25%, #9ff0ff 26% 45%, transparent 47%); }
.hud-actions { position: absolute; right: 16px; top: 14px; display: flex; gap: 8px; pointer-events: auto; }
.hud-actions button { background: rgba(14, 20, 30, 0.38); color: var(--hud-ink); border: 1px solid rgba(255,255,255,0.35); border-radius: 999px; padding: 7px 13px; font-size: 13px; backdrop-filter: blur(8px); }
.hud-actions button:hover { background: rgba(14, 20, 30, 0.6); }
#where { position: absolute; left: 20px; bottom: 18px; font-family: var(--title); font-size: 20px; font-weight: 600; letter-spacing: 0.02em; opacity: 0.92; }

#compass { position: absolute; top: 18px; left: 50%; width: min(520px, 46vw); height: 30px; transform: translateX(-50%); overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
.compass-track { position: absolute; inset: 0; border-bottom: 1px solid rgba(255,255,255,0.55); }
.compass-needle { position: absolute; left: 50%; bottom: -1px; width: 2px; height: 10px; background: #fff; transform: translateX(-50%); }
.cmark { position: absolute; top: 3px; transform: translateX(-50%); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; white-space: nowrap; }
.cmark.cardinal { font-family: var(--title); font-size: 17px; top: 1px; }
.cmark.tick { width: 1px; height: 6px; background: rgba(255,255,255,0.6); top: 22px; }
.cmark.target { width: 11px; height: 11px; top: 9px; transform: translateX(-50%) rotate(45deg); border: 2px solid #fff; box-shadow: 0 0 10px currentColor; }
.cmark.target.legendary { width: 15px; height: 15px; top: 7px; }

/* ---------- prompt ---------- */
#prompt { position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%); z-index: 12; background: rgba(14, 20, 30, 0.6); color: #fffdf6; border: 1px solid rgba(255,255,255,0.5); border-radius: 999px; padding: 10px 18px; font-size: 15px; backdrop-filter: blur(8px); animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- banners ---------- */
#region-banner { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 11; text-align: center; color: var(--hud-ink); text-shadow: 0 2px 20px rgba(0,0,0,0.5); pointer-events: none; width: min(680px, 92vw); animation: bannerIn 4.6s ease forwards; }
#region-banner small { display: block; text-transform: uppercase; letter-spacing: 0.32em; font-size: 12px; margin-top: 12px; opacity: 0.9; }
#region-banner h2 { font-family: var(--title); font-size: clamp(38px, 6vw, 64px); font-weight: 600; margin: 4px 0 4px; line-height: 1; }
#region-banner p { font-family: var(--serif); font-style: italic; font-size: 16px; margin: 0 0 12px; opacity: 0.92; }
.rb-line { height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.85), transparent); }
@keyframes bannerIn { 0% { opacity: 0; letter-spacing: 0.06em; } 12% { opacity: 1; letter-spacing: 0; } 78% { opacity: 1; } 100% { opacity: 0; } }

#discovery { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; text-align: center; color: #fff; text-shadow: 0 2px 30px rgba(0,0,0,0.55); pointer-events: none; }
#discovery small { text-transform: uppercase; letter-spacing: 0.4em; font-size: 13px; animation: fadeUp 0.8s ease both; }
#discovery h2 { font-family: var(--title); font-size: clamp(40px, 7vw, 84px); font-weight: 600; margin: 10px 0 6px; line-height: 1; max-width: 90vw; animation: fadeUp 0.9s 0.15s ease both; }
#discovery p { font-family: var(--serif); font-style: italic; font-size: 18px; margin: 0; animation: fadeUp 0.9s 0.35s ease both; }
#discovery.legendary small { color: #ffe4a0; }
.disc-rays { position: absolute; left: 50%; top: 50%; width: 140vmax; height: 140vmax; transform: translate(-50%, -50%); background: repeating-conic-gradient(from 0deg, rgba(255,240,200,0.14) 0deg 4deg, transparent 4deg 14deg); -webkit-mask-image: radial-gradient(circle, #000 0, transparent 55%); mask-image: radial-gradient(circle, #000 0, transparent 55%); animation: rays 6s linear infinite, fadeIn 0.6s ease both; z-index: -1; }
@keyframes rays { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }
@keyframes fadeIn { from { opacity: 0; } }
#flash { position: fixed; inset: 0; background: radial-gradient(circle, rgba(255,250,235,0.95), rgba(190,230,255,0.6)); opacity: 0; pointer-events: none; z-index: 19; }
#flash.on { animation: flash 1.4s ease; }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 13; max-width: min(560px, calc(100vw - 32px)); background: rgba(250, 247, 240, 0.97); color: #2b241a; border-radius: 14px; padding: 12px 14px 12px 16px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); font-size: 14px; line-height: 1.35; animation: rise 0.3s ease; }
#toast .t-k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: #7a6b55; }
#toast .t-title { font-family: var(--serif); font-weight: 600; }
#toast button { flex: none; background: #2b241a; color: #fbf6ea; border: 0; border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
#toast .t-star { flex: none; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle, #fff 0 22%, var(--accent) 24% 52%, transparent 54%); filter: drop-shadow(0 0 6px var(--accent)); }

/* ---------- Lumen and travelers ---------- */
#bubble { position: fixed; left: 0; top: 0; z-index: 14; max-width: 320px; transform: translate(-50%, calc(-100% - 18px)); background: rgba(255, 251, 238, 0.98); color: #2b241a; border-radius: 16px; padding: 12px 16px; font-family: var(--serif); font-size: 16.5px; line-height: 1.4; box-shadow: 0 10px 30px rgba(20, 24, 30, 0.25); pointer-events: none; animation: pop 0.25s ease; }
#bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 16px; height: 16px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 3px; }
#bubble b { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: #b8860b; margin-bottom: 2px; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, calc(-100% - 8px)) scale(0.9); } }
#dialogue { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 24; width: min(620px, calc(100vw - 24px)); background: var(--paper); color: var(--body); border-radius: 18px; padding: 18px 22px 16px; box-shadow: var(--shadow); animation: rise 0.3s ease; }
.dlg-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.dlg-head .ex-dot { align-self: center; }
#dlg-name { font-family: var(--title); font-size: 26px; font-weight: 600; color: var(--ink); }
#dlg-role { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
#dlg-text { font-family: var(--serif); font-size: 18px; line-height: 1.55; margin: 0 0 12px; min-height: 3.1em; }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }

/* ---------- explainer ---------- */
#explainer { position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100vw); z-index: 25; background: var(--paper); color: var(--body); box-shadow: var(--shadow); animation: slideIn 0.55s cubic-bezier(.2,.8,.2,1); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.ex-scroll { height: 100%; overflow-y: auto; padding: 22px clamp(18px, 4vw, 40px) 40px; overscroll-behavior: contain; }
.ex-head { display: flex; justify-content: space-between; align-items: center; }
.ex-kicker { display: flex; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); font-weight: 600; }
.ex-dot { width: 10px; height: 10px; transform: rotate(45deg); background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.ex-close { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--hair); background: transparent; color: var(--ink); font-size: 22px; line-height: 1; }
.ex-close:hover { background: var(--paper-2); }
.ex-tier { margin-top: 18px; font-size: 12px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.ex-tier.legendary { color: var(--gold); }
#explainer h1 { font-family: var(--title); font-weight: 600; font-size: clamp(34px, 5.4vw, 48px); line-height: 1.02; color: var(--ink); margin: 6px 0 12px; letter-spacing: -0.005em; }
.ex-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chip { font-size: 12px; border: 1px solid var(--hair); border-radius: 999px; padding: 4px 10px; color: var(--body); background: var(--paper); }
.chip.strong { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip.lean { border-color: #6a9d7a; color: #3f7a52; }
.chip.nolean { color: var(--muted); }
.ex-rank { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 18px; }
.rank { border: 1px solid var(--hair); border-radius: 12px; padding: 10px 12px; display: grid; gap: 6px; min-width: 0; }
.rank small { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.rank b { font-family: var(--title); font-size: 20px; font-weight: 600; color: var(--ink); line-height: 1.05; font-variant-numeric: lining-nums; }
.rank .pips { display: flex; gap: 3px; }
.rank .pips i { height: 4px; flex: 1; border-radius: 2px; background: var(--hair); }
.rank .pips i.on { background: var(--accent); }
.mode-toggle { display: inline-flex; border: 1px solid var(--ink); border-radius: 999px; padding: 3px; margin-bottom: 18px; }
.mode-toggle button { border: 0; background: transparent; color: var(--ink); border-radius: 999px; padding: 7px 16px; font-size: 13px; font-weight: 600; }
.mode-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tablet { margin: 0 0 22px; border-radius: 16px; background: radial-gradient(ellipse at 50% 0%, #1b2636, var(--tablet) 70%); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 14px 40px rgba(15, 21, 30, 0.25); overflow: hidden; aspect-ratio: 16 / 9; }
.tablet canvas { width: 100%; height: 100%; display: block; }
.ex-lede { font-family: var(--serif); font-size: 21px; line-height: 1.42; color: var(--ink); margin: 0 0 16px; font-weight: 600; }
.ex-body p { font-family: var(--serif); font-size: 17px; line-height: 1.62; margin: 0 0 14px; }
.ex-body sub, .ex-body sup { line-height: 0; }
.ex-stakes { margin: 22px 0; padding: 16px 18px; border-left: 3px solid var(--accent); background: var(--paper-2); border-radius: 0 12px 12px 0; }
.ex-stakes h3, .ex-papers h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-family: var(--sans); }
.ex-stakes p { font-family: var(--serif); font-size: 17px; line-height: 1.5; margin: 0; color: var(--ink); }
.ex-path { list-style: none; margin: 14px 0 0; padding: 0; }
.ex-path li { position: relative; padding: 10px 0 10px 18px; border-top: 1px solid var(--hair); font-size: 14.5px; line-height: 1.5; color: var(--body); }
.ex-path li::before { content: ''; position: absolute; left: 0; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.ex-path li.release::before { background: transparent; border: 1.5px dashed var(--accent); width: 5px; height: 5px; }
.ex-path b { display: block; font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-family: var(--sans); margin-bottom: 2px; }
.ex-link { display: inline-block; margin-top: 6px; font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--accent); background: transparent; color: var(--ink); cursor: pointer; }
.ex-link:disabled { border-color: var(--hair); color: var(--muted); cursor: default; }
.j-card.citadel.lit { background: linear-gradient(160deg, #fff6df, var(--paper)); }
.j-card.citadel.dark { background: linear-gradient(160deg, #e6e1d6, var(--paper)); }
.ex-facts { display: grid; grid-template-columns: 70px 1fr; gap: 10px 14px; margin: 0 0 22px; font-size: 14px; line-height: 1.5; }
.ex-facts dt { font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.14em; padding-top: 3px; }
.ex-facts dd { margin: 0; }
.ex-papers ul, #seed-papers { list-style: none; padding: 0; margin: 0 0 24px; }
.ex-papers li, #seed-papers li { border-top: 1px solid var(--hair); }
.ex-papers a, #seed-papers a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; text-decoration: none; font-size: 14px; }
.ex-papers a::after, #seed-papers a::after { content: "↗"; color: var(--muted); }
.ex-papers a:hover, #seed-papers a:hover { color: var(--gold); }
.ex-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--muted); }

#seed-card { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; z-index: 24; background: var(--paper); border-radius: 18px; padding: 20px 22px 6px; box-shadow: var(--shadow); animation: rise 0.35s ease; }
#seed-card .ex-close { position: absolute; right: 14px; top: 14px; }
#seed-card h2 { font-family: var(--title); font-size: 28px; line-height: 1.05; color: var(--ink); margin: 10px 40px 10px 0; font-weight: 600; }
#seed-summary { font-family: var(--serif); font-size: 16px; line-height: 1.55; margin: 0 0 10px; }
#seed-summary p { margin: 0 0 10px; }
.seed-meta { font-size: 12px; color: var(--muted); margin: 0 0 8px; }

/* ---------- map ---------- */
#map, #journal { position: fixed; inset: 0; z-index: 28; background: rgba(12, 18, 26, 0.55); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fadeIn 0.3s ease; }
.map-frame { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 0; width: min(1180px, 100%); height: min(820px, 100%); background: #efe6cf; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
#map-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.map-legend { padding: 22px 20px; background: #f7f0de; color: #2b2822; border-left: 1px solid #e0d4b6; overflow-y: auto; }
.map-legend h2 { font-family: var(--title); font-size: 30px; margin: 0 0 6px; font-weight: 600; }
.map-legend p { font-size: 13px; line-height: 1.5; color: #6f6a60; margin: 0 0 14px; }
.map-legend ul { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.map-legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.map-legend li i { width: 10px; height: 10px; transform: rotate(45deg); }
.map-legend li .unseen { color: #9a937f; font-style: italic; }
#map-pop { position: absolute; z-index: 2; background: var(--paper); color: var(--ink); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); width: 240px; font-size: 13px; }
#map-pop h3 { font-family: var(--title); font-size: 21px; margin: 0 0 8px; line-height: 1.05; }
#map-pop .row { display: flex; gap: 8px; }
#map-pop button { flex: 1; border-radius: 999px; padding: 7px 10px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-weight: 600; font-size: 12px; }
#map-pop button.primary { background: var(--ink); color: var(--paper); }

/* ---------- journal ---------- */
.journal-frame { width: min(980px, 100%); height: min(860px, 100%); background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.journal-frame header { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--hair); flex-wrap: wrap; }
.journal-frame h2 { font-family: var(--title); font-size: 32px; margin: 0; font-weight: 600; color: var(--ink); }
.journal-tabs { display: flex; gap: 4px; }
.journal-tabs button { border: 0; background: transparent; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.journal-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.reveal { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
#journal-body { overflow-y: auto; padding: 8px 20px 30px; }
.j-region { margin-top: 18px; }
.j-region h3 { display: flex; align-items: baseline; gap: 10px; font-family: var(--title); font-size: 24px; font-weight: 600; color: var(--ink); margin: 0 0 8px; }
.j-region h3 small { font-family: var(--sans); font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0.04em; }
.j-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.j-card { text-align: left; border: 1px solid var(--hair); background: var(--paper); border-radius: 12px; padding: 12px 14px; color: var(--body); display: grid; gap: 4px; min-height: 86px; position: relative; }
.j-card:hover:not(:disabled) { border-color: var(--ink); }
.j-card b { font-family: var(--title); font-size: 19px; line-height: 1.1; color: var(--ink); font-weight: 600; }
.j-card span { font-size: 12px; color: var(--muted); }
.j-card.legendary { background: linear-gradient(135deg, rgba(201, 154, 46, 0.12), transparent 60%); border-color: rgba(201, 154, 46, 0.5); }
.j-card.locked { cursor: default; background: var(--paper-2); }
.j-card.locked b { color: var(--muted); letter-spacing: 0.3em; }
.j-card .tier { position: absolute; right: 12px; top: 10px; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.j-seeds { columns: 2 320px; column-gap: 24px; }
.j-seed { break-inside: avoid; display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--hair); background: none; padding: 8px 0; color: var(--body); font-size: 14px; line-height: 1.35; }
.j-seed:hover { color: var(--gold); }
.j-seed em { font-style: normal; color: var(--muted); font-size: 12px; margin-right: 6px; }
.j-about { max-width: 680px; font-family: var(--serif); font-size: 17px; line-height: 1.6; }
.j-about h4 { font-family: var(--sans); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 22px 0 6px; }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
#stick { position: absolute; left: 26px; bottom: 34px; width: 128px; height: 128px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.55); background: rgba(14,20,30,0.18); pointer-events: auto; touch-action: none; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: rgba(255,255,255,0.75); }
#t-jump, #t-act { position: absolute; right: 26px; bottom: 40px; width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.7); background: rgba(14,20,30,0.3); color: #fff; font-size: 28px; pointer-events: auto; touch-action: none; }
#t-act { bottom: 130px; right: 40px; width: 62px; height: 62px; font-size: 20px; font-weight: 700; background: rgba(255, 210, 120, 0.4); }

.noscript { position: fixed; inset: 0; display: grid; place-content: center; padding: 24px; background: #f6ecd8; color: #2b241a; font-family: var(--serif); font-size: 18px; z-index: 100; }

@media (max-width: 760px) {
  .tally { left: 14px; top: 12px; font-size: 12px; }
  .tally-row b { font-size: 21px; }
  .hud-actions { right: 10px; top: 10px; }
  .hud-actions button { padding: 6px 10px; font-size: 12px; }
  .hud-actions .key, #btn-sound { display: none; }
  #compass { top: 64px; width: 70vw; }
  #where { display: none; }
  #explainer { top: 8vh; border-radius: 18px 18px 0 0; animation: sheetIn 0.5s cubic-bezier(.2,.8,.2,1); }
  @keyframes sheetIn { from { transform: translateY(60px); opacity: 0; } }
  .map-frame { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .map-legend { border-left: 0; border-top: 1px solid #e0d4b6; max-height: 34vh; }
  .map-legend p, .map-legend h2 { display: none; }
  #prompt { bottom: 30%; }
  #toast { bottom: auto; top: 104px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* Cormorant’s old-style figures read oddly in titles (1 looks like ı). */
#explainer h1, .j-card b, #seed-card h2, #card h2, #discovery h2, #region-banner h2, .map-legend h2, #map-pop h3 { font-variant-numeric: lining-nums; }
.j-card.legendary b { padding-right: 84px; }

/* ---------- prologue and finale ---------- */
#prologue { position: fixed; inset: 0; z-index: 31; display: grid; place-content: center; padding: 0 clamp(16px, 8vw, 120px); background: radial-gradient(ellipse at 50% 55%, rgba(10,16,26,0.25), rgba(10,16,26,0.7)); color: #fbf6ea; transition: opacity 1.2s ease; }
#prologue.leaving { opacity: 0; pointer-events: none; }
.prologue-lines { max-width: 720px; display: grid; gap: 22px; }
.prologue-lines p { margin: 0; font-family: var(--title); font-size: clamp(22px, 3.2vw, 34px); line-height: 1.3; text-align: center; text-shadow: 0 2px 24px rgba(0,0,0,0.55); opacity: 0; transform: translateY(8px); transition: opacity 1.6s ease, transform 1.6s ease; }
.prologue-lines p.shown { opacity: 1; transform: none; }
.prologue-lines .prologue-call { font-weight: 600; color: #ffe7b0; }
#prologue-skip { position: absolute; right: 20px; bottom: 20px; padding: 8px 16px; font-size: 13px; }
#finale { position: fixed; inset: 0; z-index: 32; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 40%, rgba(12,18,34,0.35), rgba(8,10,20,0.78)); animation: finale-in 1.4s ease both; }
@keyframes finale-in { from { opacity: 0; } to { opacity: 1; } }
.atlas-cover { width: min(560px, 100%); padding: clamp(28px, 6vw, 56px) clamp(22px, 5vw, 48px); text-align: center; color: #3a2a18; background: linear-gradient(160deg, #f6ecd2, #eadcb8); border-radius: 6px; box-shadow: 0 30px 90px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(120,90,40,0.35), inset 0 0 0 10px #f3e6c6, inset 0 0 0 11px rgba(150,110,50,0.45); }
.atlas-kicker { font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.3em; font-size: 12px; color: #8a6a35; margin: 0 0 10px; }
.atlas-cover h2 { font-family: var(--title); font-size: clamp(44px, 9vw, 72px); font-weight: 600; line-height: 0.95; margin: 0; }
.atlas-rule { width: 120px; height: 1px; margin: 20px auto; background: linear-gradient(90deg, transparent, #9a7a40, transparent); }
.atlas-edition { font-family: var(--title); font-size: 19px; font-variant-numeric: lining-nums; margin: 0 0 18px; color: #6b4f26; }
.atlas-body { font-family: var(--serif); font-size: 16px; line-height: 1.6; margin: 0 0 16px; }
.atlas-stats { font-size: 13px; color: #7a6040; margin: 0 0 24px; font-variant-numeric: lining-nums tabular-nums; }
.atlas-cover .primary { background: #3a2a18; color: #fbf3df; }

#hud.cinema { opacity: 0; transition: opacity 0.6s; pointer-events: none; }

.ghost { background: transparent; color: var(--ink); border: 1px solid var(--hair); border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer; }
.ghost:hover { border-color: var(--ink); }
.ex-actions { display: flex; gap: 8px; }
.seed-foot { display: flex; justify-content: flex-end; padding: 6px 0 16px; }
#card { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(20, 18, 14, 0.55); backdrop-filter: blur(4px); animation: rise 0.35s ease; }
.card-frame { position: relative; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--paper); border-radius: 20px; padding: 22px 22px 20px; box-shadow: var(--shadow); text-align: center; }
.card-frame .ex-close { position: absolute; right: 14px; top: 14px; }
.card-kicker { margin: 4px 0 0; font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
#card h2 { font-family: var(--title); font-weight: 600; font-size: clamp(26px, 4vw, 36px); margin: 6px 40px 14px; color: var(--ink); }
#card-canvas { width: 100%; border-radius: 12px; display: block; box-shadow: 0 6px 24px rgba(0,0,0,0.18); }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.j-cards { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }

.ex-apply { margin: 0 0 22px; padding: 14px 18px; border: 1px solid var(--hair); border-radius: 12px; }
.ex-apply h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-family: var(--sans); }
.ex-apply p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--body); }

/* A quiet sponsor signature, below the touch controls and clear of the skip button. */
.audio-credit {
  position: fixed; right: max(16px, env(safe-area-inset-right));
  bottom: max(9px, env(safe-area-inset-bottom)); z-index: 40;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 5px;
  color: var(--hud-ink); background: rgba(15, 21, 30, 0.72);
  font-family: var(--sans); font-size: 10px; line-height: 1.2;
  text-decoration: none; letter-spacing: 0.01em;
}
.audio-credit img { display: block; width: 94px; height: auto; }
.audio-credit:hover { background: rgba(15, 21, 30, 0.9); }
.audio-credit:focus-visible { outline: 2px solid var(--hud-ink); outline-offset: 3px; }
#prologue-skip { bottom: max(48px, calc(env(safe-area-inset-bottom) + 40px)); }
@media (max-width: 760px) {
  #title { padding-bottom: max(56px, calc(env(safe-area-inset-bottom) + 48px)); }
  #seed-card, #dialogue { bottom: max(48px, calc(env(safe-area-inset-bottom) + 40px)); }
}
