/* Critical Path: "cartographer's notebook" style.
   Paper and ink, ruled lines instead of boxes, square corners, no soft shadows.
   Fonts: Spectral (body), Caveat (handwritten notes), Return of Ganon (pixel titles). */
@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Caveat:wght@500;700&display=swap');

/* "Return of Ganon" by codeman38: a pixel font on a 16 px grid, so it's only used at 16 / 32 / 48 px to stay crisp. */
@font-face { font-family: 'Return of Ganon'; src: url('/app/fonts/ReturnofGanon.ttf') format('truetype'); font-display: swap; }

:root {
  --paper-base: #f3ead4; --paper-2: #e9dec2; --ink: #2b2118; --ink-2: #6b5840; --ink-3: #8f7b5d;
  --rule: #a8946d; --rule-soft: #d3c4a0; --grid: rgba(110, 85, 40, .075);
  --red: #b0382a; --gold: #946410; --blue: #2e5786; --brown: #7a5232;
  --display: 'Return of Ganon', Georgia, serif;
  --serif: 'Spectral', Georgia, 'Times New Roman', serif;
  --hand: 'Caveat', 'Segoe Print', cursive;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper-base: #1b1813; --paper-2: #232019; --ink: #ebe0c8; --ink-2: #b6a789; --ink-3: #8c7f66;
    --rule: #6a5c44; --rule-soft: #3b3427; --grid: rgba(235, 224, 200, .035);
    --red: #ec8c76; --gold: #e2b65d; --blue: #9dbbe2; --brown: #d4ad84;
    color-scheme: dark;
  }
}

/* --d is the current dungeon's colour (set on <body> by the app). It tints the paper and the ink accents. */
body {
  --d: #4a6b4f;
  --accent: color-mix(in srgb, var(--d) 85%, var(--ink));
  --wash: color-mix(in srgb, var(--d) 12%, transparent);
  --paper: color-mix(in srgb, var(--d) 6%, var(--paper-base));
}
@media (prefers-color-scheme: dark) {
  body { --accent: color-mix(in srgb, var(--d) 50%, #fff); --wash: color-mix(in srgb, var(--d) 22%, transparent); --paper: color-mix(in srgb, var(--d) 8%, var(--paper-base)); }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 64px; }
body {
  margin: 0; color: var(--ink); background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 50% 0%, transparent 55%, color-mix(in srgb, var(--ink) 6%, transparent) 100%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px, 24px 24px;
  background-attachment: fixed, local, local;
  font: 16px/1.55 var(--serif);
  display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh;
  transition: background-color .25s ease;
}
a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 400; }
h1 { font: 400 48px/1.05 var(--display); display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
h2 { font: 400 32px/1.1 var(--display); }
h3 { font: 600 .82rem/1.3 var(--serif); text-transform: uppercase; letter-spacing: .12em; }
.brand, h1, h2, .card h3, .summary b, .stat-strip b, .floor-title { font-synthesis: none; -webkit-font-smoothing: none; }
p { margin: 0; }
code { font: .85em var(--mono); }
.muted { color: var(--ink-2); font-weight: 400; }
.ic { width: 16px; height: 16px; fill: currentColor; flex: none; }

/* Stamps: Draft / Checked / Boss / Mini-boss */
.pill { display: inline-block; font: 700 .68rem/1 var(--serif); letter-spacing: .14em; text-transform: uppercase; padding: .3rem .45rem .25rem; border: 1.5px solid currentColor; transform: rotate(-3deg); white-space: nowrap; }
.pill.draft { color: var(--gold); }
.pill.ok { color: var(--accent); }
.pill.boss { color: var(--red); }
.pill.mini { color: var(--blue); }

/* ---------- Sidebar: the notebook's index ---------- */
#nav { position: sticky; top: 0; height: 100vh; overflow: auto; padding: 1.4rem 1rem 2rem 1.1rem; background: var(--paper-2); border-right: 3px double var(--rule); }
#nav a { color: var(--ink); text-decoration: none; }
.nav-toggle { display: none; }
.brand { display: flex; align-items: center; gap: .55rem; font: 400 32px/1 var(--display); padding: 0 .2rem 1.1rem; border-bottom: 2px solid var(--ink); margin-bottom: .6rem; }
.brand .ic { width: 22px; height: 22px; color: var(--accent); }
.nav-home { display: block; padding: .3rem .2rem; font-style: italic; }
.nav-home.active { text-decoration: underline wavy var(--accent) 1.5px !important; text-underline-offset: 4px; }
.nav-game { display: flex; justify-content: space-between; align-items: baseline; margin: 1.2rem .2rem .35rem; padding-bottom: .2rem; border-bottom: 1px solid var(--rule); font: 600 .72rem var(--serif); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.nav-year { letter-spacing: 0; font-style: italic; font-weight: 400; }
.nav-item { display: flex; align-items: center; gap: .5rem; padding: .22rem .2rem; font-size: .93rem; }
.nav-item:hover .nav-name { text-decoration: underline; text-decoration-color: var(--rule); }
.nav-item.active .nav-name { font-weight: 600; text-decoration: underline wavy var(--d) 1.5px; text-underline-offset: 4px; }
.nav-num { width: 1.3rem; text-align: right; color: var(--ink-3); font-variant-numeric: oldstyle-nums; font-size: .85rem; }
.nav-dot { width: 9px; height: 9px; flex: none; border: 1px solid color-mix(in srgb, var(--ink) 50%, transparent); }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-q { font: 700 1.05rem/1 var(--hand); color: var(--red); }
.nav-ok { color: var(--accent); }
.nav-empty { padding: .1rem .2rem .1rem 2.2rem; font-size: .88rem; color: var(--ink-3); font-style: italic; }

/* ---------- Page ---------- */
main { padding: 2.25rem 2.75rem 5rem; max-width: 1840px; width: 100%; margin: 0 auto; }
@media (min-width: 2000px) { main { padding-left: 3.5rem; padding-right: 3.5rem; } .section-nav { margin-left: -3.5rem !important; margin-right: -3.5rem !important; padding-left: 3.5rem !important; padding-right: 3.5rem !important; } }
.page-head { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 3px double var(--ink); }
.lede { color: var(--ink-2); font-size: 1.08rem; font-style: italic; max-width: 72ch; margin-top: .6rem; }
.crumbs { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin-bottom: .5rem; }
.crumbs a { color: inherit; }
section { margin-top: 3rem; }
section > h2, .section-head h2 { padding-bottom: .35rem; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 2px solid var(--ink); margin-bottom: .25rem; }
section > h2 { border-bottom: 2px solid var(--ink); margin-bottom: .25rem; }
.hint { font-size: .9rem; color: var(--ink-2); font-style: italic; margin: .35rem 0 1.1rem; }

/* Headings inside a column: small caps with a rule */
.panel { padding: 0; }
.panel h3 { display: flex; align-items: baseline; gap: .45rem; padding-bottom: .3rem; margin-bottom: .6rem; border-bottom: 1px solid var(--ink); }
.panel h3 .muted { margin-left: auto; font: 400 1rem var(--serif); letter-spacing: 0; text-transform: none; }

.callout { padding: .7rem .9rem; margin: 1rem 0; border: 1.5px dashed currentColor; }
.callout ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.errors { color: var(--red); }

/* Text tabs: "Cards / Table", floor filters */
.seg { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0; }
.seg button { font: 500 .95rem var(--serif); color: var(--ink-2); background: none; border: 0; padding: .2rem .55rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button:hover { color: var(--ink); }
.seg button.on { color: var(--ink); font-weight: 700; text-decoration: underline wavy var(--accent) 1.5px; text-underline-offset: 5px; }

/* ---------- Home ---------- */
.summary { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--ink); }
.summary > div { flex: 1 1 130px; padding: .7rem 1rem .6rem; border-right: 1px dotted var(--rule); }
.summary > div:last-child { border-right: 0; }
.summary b { display: block; font: 400 32px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.summary b small { font: italic 400 .95rem var(--serif); color: var(--ink-2); }
.summary span { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.summary .warn b { color: var(--red); }

.toolbar { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-end; margin: 1.75rem 0 1.25rem; }
.search { flex: 1 1 320px; display: flex; align-items: center; gap: .5rem; border-bottom: 1.5px solid var(--ink); color: var(--ink-2); }
.search input { flex: 1; min-width: 0; border: 0; background: none; font: italic 1rem var(--serif); color: var(--ink); padding: .45rem 0; outline: none; }
.search:focus-within { border-bottom-color: var(--accent); }
.toolbar select { font: 1rem var(--serif); padding: .35rem .2rem; border: 0; border-bottom: 1.5px solid var(--ink); background: transparent; color: var(--ink); }

.game-section + .game-section { margin-top: 2.75rem; }
.game-head { display: flex; align-items: baseline; gap: .9rem; margin-bottom: 0; padding-bottom: .4rem; border-bottom: 2px solid var(--ink); }
.game-head .muted { font-style: italic; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); border-left: 1px solid var(--rule); }
.card { display: flex; flex-direction: column; gap: .5rem; padding: 1rem 1.1rem 1rem 1.25rem; color: var(--ink); text-decoration: none;
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); box-shadow: inset 5px 0 0 var(--d); transition: background-color .15s ease; }
.card:hover { background: color-mix(in srgb, var(--d) 9%, transparent); text-decoration: none; }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.num-badge { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; border: 1.5px solid currentColor; font: 400 16px/1 var(--display); color: var(--d); }
.card h3 { font: 400 32px/1.05 var(--display); letter-spacing: 0; text-transform: none; }
.card-theme { font-size: .9rem; font-style: italic; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.card-facts { display: grid; gap: .2rem; font-size: .92rem; }
.card-facts div { display: flex; align-items: center; gap: .45rem; }
.card-facts .ic { color: var(--d); }
.card-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: auto; padding-top: .5rem; border-top: 1px dotted var(--rule); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.card-stats b { display: block; font: 600 1.1rem var(--serif); letter-spacing: 0; color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.card-q { font: 700 1.15rem/1 var(--hand); color: var(--red); display: flex; align-items: center; gap: .35rem; }
.card-q .ic { display: none; }
.empty-state { padding: 3rem; text-align: center; color: var(--ink-2); font-style: italic; border: 1.5px dashed var(--rule); }

.table-wrap { overflow-x: auto; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px dotted var(--rule); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--wash); }
th { font: 600 .72rem var(--serif); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); white-space: nowrap; border-bottom: 1px solid var(--ink); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .sort { margin-left: .3rem; color: var(--accent); }
.num { text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.t-name { display: flex; align-items: center; gap: .55rem; font-weight: 600; color: var(--ink); white-space: nowrap; text-decoration: none; }
.t-game { font-size: .78rem; font-style: italic; color: var(--ink-2); margin-left: 2.15rem; }
.bar-cell { position: relative; min-width: 84px; }
.bar-cell span { position: relative; z-index: 1; }
.bar-cell i { position: absolute; right: .7rem; bottom: .3rem; height: 3px; max-width: calc(100% - 1.4rem); background: repeating-linear-gradient(90deg, var(--accent) 0 3px, transparent 3px 5px); }

/* ---------- Dungeon page ---------- */
/* Title plate: the dungeon's map, tinted in its colour, inside a double map border. */
.hero { position: relative; overflow: hidden; isolation: isolate; color: #fff; padding: 1.6rem 1.8rem 1.5rem;
  background: linear-gradient(135deg, var(--d), color-mix(in srgb, var(--d) 55%, #000));
  border: 2px solid var(--ink); outline: 1px solid var(--ink); outline-offset: 4px; margin: 5px; }
.hero::before { content: ''; position: absolute; inset: -10%; z-index: -1; background: var(--hero) center / cover no-repeat; image-rendering: pixelated; opacity: .22; mix-blend-mode: luminosity; transform: rotate(-4deg) scale(1.15); }
.hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, color-mix(in srgb, var(--d) 70%, #000) 0%, transparent 75%); opacity: .8; }
.hero h1 { text-shadow: 0 2px 12px rgba(0, 0, 0, .25); }
.hero .lede { color: rgba(255, 255, 255, .9); }
.hero .crumbs, .hero .crumbs a { color: rgba(255, 255, 255, .78); }
.hero .pill { color: #fff; }
.hero .hero-tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.hero .hero-tags span { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; padding: .15rem .6rem; border: 1px solid rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .18); }
.hero .hero-tags .ic { width: 14px; height: 14px; }

/* Stats as ledger lines: "Rooms ........ 21" */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); column-gap: 2rem; margin-top: 1.4rem; padding: .3rem 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.stat-strip > div { display: flex; align-items: baseline; gap: .4rem; padding: .25rem 0; }
.stat-strip > div::before { content: ''; order: 2; flex: 1; border-bottom: 1.5px dotted var(--rule); transform: translateY(-.25em); }
.stat-strip span { order: 1; font-size: .95rem; }
.stat-strip b { order: 3; font: 400 32px/1 var(--display); font-variant-numeric: tabular-nums; }

.section-nav { position: sticky; top: 0; z-index: 5; display: flex; gap: 0; flex-wrap: wrap; align-items: baseline; margin: 1.25rem -2.75rem 0; padding: .55rem 2.75rem; background: var(--paper); border-bottom: 3px double var(--rule); }
.section-nav a { color: var(--ink); padding: .1rem .7rem; font-size: .95rem; text-decoration: none; }
.section-nav a + a { border-left: 1px solid var(--rule); }
.section-nav a:hover { text-decoration: underline wavy var(--accent) 1.5px; text-underline-offset: 5px; }
.section-nav a span { color: var(--ink-3); margin-left: .2rem; font-variant-numeric: oldstyle-nums; }
.section-nav a.q { margin-left: auto; border-left: 0; font: 700 1.2rem/1 var(--hand); color: var(--red); }

.overview { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 2.75rem; margin-top: 1.75rem; align-items: start; }
/* Facts: label in the margin, text beside it, hairline between */
.facts { display: grid; }
.fact { display: grid; grid-template-columns: 9.5rem 1fr; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--rule-soft); }
.fact:first-child { border-top: 2px solid var(--ink); }
.fact > .ic { display: none; }
.fact > div { display: contents; }
.fact-label { font: 600 .72rem/1.9 var(--serif); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.fact-body b { font-size: 1.12rem; }
.fact-body p { margin-top: .2rem; }
.minor { display: grid; grid-template-columns: 9.5rem 1fr; gap: .35rem 1rem; margin: 0; padding: .85rem 0; border-bottom: 2px solid var(--ink); font-size: .95rem; }
.minor dt { font: 600 .72rem/1.9 var(--serif); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.minor dd { margin: 0; }
.boss-sprite { float: right; width: 72px; height: 72px; margin: -.25rem 0 .25rem .75rem; }

.side { display: grid; gap: 1.75rem; }
/* "Needs checking": handwritten notes in red ink, in the margin */
.questions { position: relative; padding: .2rem 0 .2rem 1rem; border-left: 2px solid var(--red); color: var(--red); }
.questions h3 { border: 0; margin-bottom: .35rem; padding: 0; font: 700 1.6rem/1 var(--hand); letter-spacing: 0; text-transform: none; }
.questions h3 .ic { display: none; }
.questions h3::before { content: '✎'; font-family: var(--serif); font-size: 1.1rem; }
.questions ol { margin: 0; padding-left: 1.3rem; display: grid; gap: .45rem; font: 500 1.28rem/1.25 var(--hand); }
.ok-panel { font: 700 1.35rem var(--hand); color: var(--accent); display: flex; gap: .4rem; align-items: center; }
.ok-panel .ic { display: none; }
.ok-panel::before { content: '✓'; font-family: var(--serif); }

/* Hatched ink bars */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .93rem; }
.bars li { display: grid; grid-template-columns: minmax(0, 11rem) 1fr 2.6rem; gap: .7rem; align-items: center; }
.bar-label { display: flex; align-items: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 9px; border-bottom: 1px dotted var(--rule); }
.bar-track i { display: block; height: 100%; border: 1px solid var(--accent); background-image: linear-gradient(-45deg, transparent 35%, var(--accent) 35% 55%, transparent 55%); background-size: 5px 5px; }
.bar-n { text-align: right; font-variant-numeric: lining-nums tabular-nums; color: var(--ink-2); }

/* Door types: ink-stamped labels, colour = what opens it */
.door-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.door { display: inline-block; font: 600 .7rem/1.6 var(--serif); letter-spacing: .08em; text-transform: uppercase; padding: 0 .4rem; border: 1px solid currentColor; color: var(--ink-2); }
.door b { margin-left: .25rem; }
.door.small-key { color: var(--gold); }
.door.big-key { color: var(--red); }
.door.bombable { color: var(--brown); }
.door.shutter-clear, .door.shutter-switch { color: var(--blue); }

/* Rooms: notebook entries with a pasted map snippet */
.floor-group + .floor-group { margin-top: 2.25rem; }
.floor-title { font: 400 32px/1.1 var(--display); margin: 1rem 0 0; padding-bottom: .3rem; display: flex; gap: .7rem; align-items: baseline; border-bottom: 1px solid var(--ink); }
.floor-title .muted { font: italic 400 .95rem var(--serif); }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); column-gap: 2.75rem; align-items: start; }
.room { display: flex; gap: 1.1rem; padding: 1.1rem 0; border-bottom: 1px dashed var(--rule); scroll-margin-top: 80px; }
.room.is-boss .room-head h3 { color: var(--red); }
.thumb { flex: none; padding: 0; border: 1px solid var(--ink); outline: 1px solid var(--rule); outline-offset: 3px; margin: 4px; background-color: #000; background-repeat: no-repeat; image-rendering: pixelated; cursor: zoom-in; align-self: flex-start; transform: rotate(-.6deg); transition: transform .15s ease; }
.room:nth-child(even) .thumb { transform: rotate(.6deg); }
.thumb:hover { transform: rotate(0) scale(1.03); outline-color: var(--accent); }
.room-body { flex: 1; min-width: 0; }
.room-head { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; margin-bottom: .45rem; }
.room-head[role=button] { cursor: pointer; }
.room-head[role=button]:hover h3 { text-decoration: underline wavy var(--accent) 1.5px; text-underline-offset: 4px; }
.room-head h3 { font: 600 1.12rem/1.25 var(--serif); letter-spacing: 0; text-transform: none; }
.rid { font: 600 .74rem var(--mono); color: var(--accent); }
.rid::before { content: '§'; margin-right: .1rem; font-family: var(--serif); }
.room-rows { display: grid; grid-template-columns: 18px 1fr; gap: .3rem .55rem; margin: 0; font-size: .93rem; }
.room-rows dt { color: var(--ink-3); padding-top: .2rem; }
.room-rows dd { margin: 0; }
.tag b { font-variant-numeric: lining-nums tabular-nums; }
.tag.big { font-weight: 700; }
.tag.enemy { display: inline-flex; align-items: center; gap: .15rem; }
.cat { font: italic 600 .85rem var(--serif); color: var(--accent); margin-right: .2rem; }
.cat::after { content: ':'; }
.room-note { margin-top: .45rem; font-size: .9rem; font-style: italic; color: var(--ink-2); }
@keyframes flash { from { background: var(--wash); } to { background: transparent; } }
.room.flash { animation: flash 1.8s ease-out; }

/* Enemies: a specimen catalogue */
.bestiary { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); border-top: 1px solid var(--ink); border-left: 1px solid var(--rule-soft); }
.beast { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem; padding: .9rem .6rem .8rem; border-right: 1px solid var(--rule-soft); border-bottom: 1px solid var(--rule-soft); position: relative; }
.beast.is-boss::after { content: 'Boss'; position: absolute; top: .45rem; right: .45rem; font: 700 .6rem/1 var(--serif); letter-spacing: .14em; text-transform: uppercase; color: var(--red); border: 1.5px solid currentColor; padding: .2rem .3rem .15rem; transform: rotate(6deg); }
.beast-art { height: 76px; width: 100%; display: grid; place-items: center; margin-bottom: .25rem; }
.beast-name { font: 600 .95rem/1.25 var(--serif); }
.beast-n { font-size: .85rem; font-variant-numeric: lining-nums tabular-nums; }
.beast-n .muted { font-style: italic; }
.beast-rooms { display: flex; flex-wrap: wrap; justify-content: center; gap: .1rem .4rem; margin-top: .2rem; }
.beast-rooms a { font: .72rem var(--mono); color: var(--ink-2); }
.beast-rooms a:hover { color: var(--accent); }
.no-sprite .ic { width: 28px; height: 28px; color: var(--ink-3); }

/* Enemy sprites */
.sprite { image-rendering: pixelated; object-fit: contain; vertical-align: middle; }
.sprite.sm { width: 24px; height: 24px; margin-right: .35rem; }
.sprite.xs { width: 16px; height: 16px; margin-right: .2rem; opacity: .85; }
.item-sprite.sm { width: 20px; height: 20px; }
.sprite.lg { max-width: 96px; max-height: 68px; width: auto; height: auto; min-height: 40px; min-width: 24px; }
.card-facts .card-boss { width: 28px; height: 28px; margin-left: auto; }

/* Items: ledger with dotted leaders */
.item-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2.75rem; margin-top: 1.25rem; align-items: start; }
.item-list { list-style: none; margin: 0; padding: 0; display: grid; font-size: .95rem; }
.item-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 0 .4rem; padding: .35rem 0; border-bottom: 1px solid var(--rule-soft); }
.item-list li::before { content: ''; grid-column: 2; grid-row: 1; border-bottom: 1.5px dotted var(--rule); transform: translateY(-.25em); }
.item-name { font-weight: 600; grid-column: 1; grid-row: 1; }
.item-how { grid-column: 3; grid-row: 1; color: var(--ink-2); font-size: .85rem; font-style: italic; text-align: right; }
.item-room { grid-column: 1 / -1; font-size: .85rem; }

/* Maps: framed plates */
.maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.75rem; }
.maps figure { margin: 0; }
.map-thumb { display: block; width: 100%; padding: 0; border: 1px solid var(--ink); outline: 1px solid var(--rule); outline-offset: 3px; background: #000; cursor: zoom-in; overflow: hidden; aspect-ratio: 4 / 3; }
.maps img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: block; }
.maps figcaption { font-size: .9rem; font-style: italic; color: var(--ink-2); padding: .5rem .1rem 0; }

.sources { margin-top: 3.5rem; padding-top: 1rem; border-top: 3px double var(--rule); font-size: .88rem; color: var(--ink-2); }
.sources h2 { font: 600 .78rem var(--serif); letter-spacing: .12em; text-transform: uppercase; margin-bottom: .4rem; }
.sources ul { margin: 0 0 .75rem; padding-left: 1.1rem; }

/* ---------- Map viewer (dark, square) ---------- */
.viewer { position: fixed; inset: 0; z-index: 100; background: rgba(14, 12, 9, .95); display: flex; flex-direction: column; color: #ece3cf; font-family: var(--serif); }
.viewer-bar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; flex-wrap: wrap; border-bottom: 3px double rgba(236, 227, 207, .25); }
.viewer-tabs, .viewer-zoom { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.viewer-zoom { margin-left: auto; }
.viewer button { font: inherit; color: inherit; background: transparent; border: 1px solid rgba(236, 227, 207, .35); padding: .2rem .7rem; cursor: pointer; }
.viewer button:hover { background: rgba(236, 227, 207, .1); }
.viewer-tabs button.active { border-color: #ece3cf; background: rgba(236, 227, 207, .16); font-weight: 600; }
.viewer-hint { font-size: .85rem; font-style: italic; color: #a99e88; }
.zoom-level { min-width: 3.5rem; text-align: center; font-variant-numeric: tabular-nums; font-size: .9rem; }
.viewer-body { flex: 1; min-height: 0; display: flex; }
.viewer-stage { flex: 1; min-width: 0; position: relative; overflow: hidden; cursor: grab; touch-action: none; }
/* Side panel of the critical path viewer: the selected room's card on the page's own paper colours. */
.viewer-side { width: min(400px, 40vw); flex: none; overflow-y: auto; background: var(--paper, #f6f0e2); color: var(--ink, #222); padding: 1rem; border-left: 3px double rgba(236, 227, 207, .25); }
.viewer-side .thumb { display: none; }
.viewer-side .room-head { cursor: default; }
.viewer-side button { color: var(--ink, #222); border-color: currentColor; }
.vs-empty { font-style: italic; }
.vs-empty button { font-style: normal; }
.vs-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.vs-nav button { font-size: 1.1rem; padding: .15rem .7rem; }
.vs-nav button:disabled { opacity: .3; cursor: default; }
.vs-note { margin: 0 0 .5rem; padding: .4rem .6rem; border-left: 4px solid var(--accent, #940018); background: rgba(0, 0, 0, .05); font-weight: 600; }
.vs-visits { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .75rem; }
.vs-visits button { padding: .05rem .5rem; font-size: .85rem; }
.vs-visits button.on { background: var(--ink, #222); color: var(--paper, #fff); }
.viewer-canvas .path-map { width: 100%; max-width: none; }
.viewer-canvas .pm-room.hover { z-index: 3; outline: 3px dashed #fff; outline-offset: 3px; }
.viewer-canvas .pm-room.selected { z-index: 4; outline: 4px solid #fff; outline-offset: 3px; }
@media (max-width: 760px) {
  .with-side .viewer-body { flex-direction: column; }
  .viewer-side { width: auto; max-height: 48vh; border-left: 0; border-top: 3px double rgba(236, 227, 207, .25); }
}
.viewer-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; --s: 1; }
.viewer-canvas img { display: block; image-rendering: pixelated; user-select: none; max-width: none; }
.viewer-stage.over-room { cursor: pointer; }
.viewer-stage.dragging { cursor: grabbing; }
.viewer-rooms { position: absolute; inset: 0; pointer-events: none; }
.vr { position: absolute; border: calc(1.5px / var(--s)) dashed rgba(255, 255, 255, .25); }
.vr span { position: absolute; left: 0; top: 0; transform: translateY(-100%); font: 600 calc(12px / var(--s)) / 1.3 var(--mono); color: #fff; background: rgba(0, 0, 0, .6); padding: 0 calc(4px / var(--s)); opacity: .6; white-space: nowrap; }
.vr.hover { border: calc(2px / var(--s)) solid rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .06); }
.vr.hover span { opacity: 1; }
.vr.focus { border: calc(3px / var(--s)) solid #f2c14e; box-shadow: 0 0 0 calc(9999px) rgba(0, 0, 0, .35); }
.vr.focus span { background: #f2c14e; color: #1f1d1a; opacity: 1; }
.viewer-room { font-weight: 600; font-size: .95rem; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .overview { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; }
  #nav { position: static; height: auto; padding-bottom: 1rem; border-right: 0; border-bottom: 3px double var(--rule); }
  main { padding: 1.25rem 16px 3rem; }
  .section-nav { margin: 1rem -16px 0; padding: .5rem 16px; }
  h1 { font-size: 32px; }
  .hero { padding: 1.2rem; }
  .room { flex-direction: column; }
  .fact, .minor { grid-template-columns: 1fr; gap: .2rem; }
  .viewer-hint { display: none; }
}

/* Dark paper: give sprites a faint halo so very dark ones (e.g. Babusu) stay visible. */
@media (prefers-color-scheme: dark) {
  .sprite { filter: drop-shadow(0 0 1px rgba(235, 224, 200, .45)); }
}


/* ---------- Phones: sidebar becomes a top bar with a dropdown ---------- */
@media (max-width: 760px) {
  #nav { position: sticky !important; top: 0; z-index: 20; height: auto; max-height: 100vh; padding: .55rem 16px !important; overflow: auto; }
  .nav-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
  #nav .brand { border: 0 !important; margin: 0; padding: 0; font-size: 32px; }
  .nav-toggle { display: inline-flex; align-items: center; gap: .35rem; max-width: 55%; font: inherit; font-size: .95rem; color: inherit; background: transparent; border: 1px solid currentColor; padding: .3rem .6rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-list { display: none; padding: .5rem 0 .75rem; }
  #nav.open .nav-list { display: block; }
  .section-nav { top: 52px; }
  /* every style: single column on phones */
  body[data-theme] .overview, body[data-theme] .room-grid { grid-template-columns: 1fr !important; }
  body[data-theme] .fact, body[data-theme] .minor { grid-template-columns: 1fr !important; gap: .2rem; }
  body[data-theme] .room { flex-direction: column; }
  .hero h1 { font-size: 32px; }
}

/* Path viewer: steps of the selected progress stage */
.vs-back { margin-bottom: .6rem; font-size: .85rem; }
.vs-stage-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; padding-bottom: .5rem; border-bottom: 2px solid var(--ink, #222); }
.vs-stage-head > div { display: flex; flex-direction: column; }
.vs-stage-head span { font-size: .85rem; color: var(--ink-2, #555); }
.vs-stage-btn { display: inline-flex; align-items: center; gap: .15rem; font: 700 1rem var(--cond, sans-serif); border: 2px solid var(--ink, #222); color: var(--ink, #222); padding: .15rem .45rem; white-space: nowrap; }
.vs-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.viewer-side .vs-step { display: flex; align-items: flex-start; gap: .5rem; width: 100%; text-align: left; padding: .3rem .4rem; border: 0; border-left: 6px solid var(--pc, #999); background: rgba(0, 0, 0, .04); font: inherit; }
.viewer-side .vs-step:hover { background: rgba(0, 0, 0, .1); }
.vs-n { min-width: 1.8rem; font: 800 1rem/1.3 var(--cond, sans-serif); color: var(--pc, #555); }
.vs-room { display: flex; flex-direction: column; line-height: 1.3; }
.vs-room i { font-style: normal; color: var(--ink-2, #666); }
.vs-room small { font-size: .82rem; color: var(--ink-2, #555); }
.vs-next { margin: .8rem 0 0; font-size: .9rem; }
.vs-steps { gap: 1rem; }
.vs-item .room { margin-top: .4rem; }
.viewer-side .vs-step { cursor: pointer; }

/* About & credits */
.nav-about { display: block; padding: .3rem .2rem; margin-top: .8rem; font-size: .9rem; }
.nav-about.active { text-decoration: underline; text-underline-offset: 4px; }
.about { max-width: 46rem; }
.about .lead { font-size: 1.1rem; }
.about ul { padding-left: 1.2rem; }
.about li { margin-bottom: .35rem; }
.credits dt { font-weight: 700; margin-top: .8rem; }
.credits dd { margin: .15rem 0 0; }
.fan-note { margin-top: 2.5rem; font-size: .85rem; color: var(--ink-2, #666); }
