/* BasementDiary — Isaac style: dark basement, paper notes, ink, pixel HUD. */

@font-face { font-family: 'Rock Salt'; src: url(../fonts/rock-salt.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Gochi Hand'; src: url(../fonts/gochi-hand.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Patrick Hand'; src: url(../fonts/patrick-hand.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url(../fonts/pixelify-sans.woff2) format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  color-scheme: dark;
  --cellar: #17100b;
  --cellar-2: #241912;
  --cellar-3: #33241a;
  --stone: #3d2d22;
  --chalk: #efe3c8;
  --chalk-dim: #b8a585;
  --chalk-faint: #7d6a55;
  --paper: #dccaa3;
  --paper-2: #cdb68b;
  --paper-3: #bba174;
  --ink: #2b1c12;
  --ink-soft: #5a4330;
  --ink-faint: #8a7155;
  --blood: #a3181b;
  --blood-bright: #d7322f;
  --soul: #6d8fd0;
  --soul-dark: #3f5d97;
  --gold: #e3b23c;
  --gold-dark: #9c7518;
  --rot: #6f8a3a;
  --font-scrawl: 'Rock Salt', 'Gochi Hand', cursive;
  --font-hand: 'Gochi Hand', 'Patrick Hand', 'Comic Sans MS', cursive;
  --font-body: 'Patrick Hand', 'Gochi Hand', 'Segoe Print', cursive;
  --font-pixel: 'Pixelify Sans', ui-monospace, monospace;
  --radius-paper: 3px 7px 4px 6px / 6px 3px 7px 4px;
  --shadow-paper: 0 1px 0 rgba(255,255,255,.25) inset, 0 10px 24px -8px rgba(0,0,0,.75), 0 2px 4px rgba(0,0,0,.5);
  --gutter: clamp(16px, 3vw, 32px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--chalk);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.35;
  background-color: var(--cellar);
  /* Basement floor: rough stone tiles + grain. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .07 0 0 0 0 .05 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='120'%3E%3Cpath d='M0 60h160M80 0v60M0 0v120M160 0v120M40 60v60M120 60v60' stroke='%23000' stroke-opacity='.35' stroke-width='3' fill='none'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 20%, #2e2017 0%, var(--cellar) 70%);
  background-attachment: fixed;
}
/* The darkness at the edges of the screen, as in the game. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 55%, rgba(0,0,0,.55) 80%, rgba(0,0,0,.92) 100%);
  z-index: 50;
}

a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #ffd25e; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px dashed var(--gold); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- HUD header ---------- */
.hud {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 10px var(--gutter) 0;
  background: linear-gradient(var(--cellar) 70%, rgba(23,16,11,.0));
}
.hud-row { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 18px 28px; flex-wrap: wrap; }
.logo {
  font-family: var(--font-scrawl);
  font-size: clamp(20px, 3.2vw, 30px);
  color: var(--chalk);
  text-decoration: none;
  line-height: 1;
  letter-spacing: .5px;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
  transform: rotate(-2deg);
  white-space: nowrap;
}
.logo small { display: block; font-family: var(--font-hand); font-size: 14px; color: var(--chalk-dim); letter-spacing: 1px; margin: 4px 0 0 4px; text-shadow: none; }
.logo:hover { color: var(--chalk); }

.hearts { display: flex; flex-wrap: wrap; gap: 2px; max-width: 250px; }
.hearts svg { width: 18px; height: 16px; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 #000); }
.stats { display: flex; gap: 16px; font-family: var(--font-pixel); font-size: 18px; letter-spacing: 1px; }
.stat { display: flex; align-items: center; gap: 6px; text-shadow: 2px 2px 0 #000; white-space: nowrap; }
.stat svg { width: 20px; height: 20px; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 #000); }
.stat small { color: var(--chalk-faint); font-size: 13px; }
.hud-spacer { flex: 1; }
.sync-pill { font-family: var(--font-hand); font-size: 15px; color: var(--chalk-dim); display: flex; align-items: center; gap: 6px; }
.sync-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--rot); box-shadow: 0 0 6px var(--rot); }
.sync-pill.busy i { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.sync-pill.err i { background: var(--blood-bright); box-shadow: 0 0 6px var(--blood-bright); }

/* Tabs as torn scraps of paper. */
.tabs { max-width: 1240px; margin: 12px auto 0; display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  font-family: var(--font-hand);
  font-size: 19px;
  color: var(--ink);
  background: var(--paper-2);
  border: 0;
  padding: 6px 14px 5px;
  border-radius: var(--radius-paper);
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 10px -4px #000;
  transform: rotate(var(--r, -1deg)) translateY(2px);
  transition: transform .15s, background .15s;
}
.tab:nth-child(2n) { --r: 1.2deg; }
.tab:nth-child(3n) { --r: -.4deg; }
.tab:hover { transform: rotate(0) translateY(0); color: var(--ink); }
.tab[aria-current='page'] { background: var(--paper); transform: rotate(0) translateY(-2px); box-shadow: 0 6px 14px -4px #000, 0 0 0 2px var(--ink) inset; }

/* ---------- Page ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 8px var(--gutter) 64px; position: relative; z-index: 1; }
.view-title { font-family: var(--font-scrawl); font-size: clamp(22px, 3.5vw, 34px); margin: 14px 0 4px; text-shadow: 2px 2px 0 #000; font-weight: 400; transform: rotate(-1deg); transform-origin: left; }
.view-sub { color: var(--chalk-dim); margin: 0 0 18px; max-width: 70ch; }
.section-title { font-family: var(--font-hand); font-size: 24px; margin: 28px 0 10px; color: var(--chalk); text-shadow: 1px 1px 0 #000; font-weight: 400; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section-title small { font-family: var(--font-body); font-size: 16px; color: var(--chalk-faint); }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

/* ---------- Paper ---------- */
.paper {
  position: relative;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23p)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.18), transparent 60%),
    radial-gradient(ellipse at 90% 100%, rgba(120,80,30,.22), transparent 55%);
  border-radius: var(--radius-paper);
  box-shadow: var(--shadow-paper);
  padding: 16px 18px;
}
/* Wobbly ink border. */
.paper::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 2px solid var(--ink);
  border-radius: 6px 3px 7px 4px / 3px 7px 4px 6px;
  opacity: .55;
  pointer-events: none;
  filter: url(#wobble);
}
.paper.tilt-l { transform: rotate(-.6deg); }
.paper.tilt-r { transform: rotate(.5deg); }
.tape::after {
  content: '';
  position: absolute;
  top: -10px;
  left: calc(50% - 38px);
  width: 76px;
  height: 22px;
  background: rgba(235, 225, 190, .55);
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
  transform: rotate(-3deg);
  border-left: 2px dotted rgba(0,0,0,.08);
  border-right: 2px dotted rgba(0,0,0,.08);
}
.paper h3 { font-family: var(--font-hand); font-weight: 400; font-size: 24px; margin: 0 0 6px; line-height: 1.1; }
.paper h4 { font-family: var(--font-hand); font-weight: 400; font-size: 19px; margin: 12px 0 4px; }
.paper p { margin: 6px 0; }
.paper .muted { color: var(--ink-soft); }
.paper a { color: var(--blood); }
.paper a:hover { color: var(--blood-bright); }
.paper hr { border: 0; border-top: 2px dashed rgba(43,28,18,.25); margin: 12px 0; }
.ink-label { font-family: var(--font-hand); font-size: 14px; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-faint); }

/* Dark card (stone tablet) for secondary content. */
.slab {
  background: linear-gradient(180deg, rgba(61,45,34,.85), rgba(36,25,18,.9));
  border: 2px solid #120c08;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 8px 20px -10px #000;
  padding: 14px 16px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-hand);
  font-size: 18px;
  border: 2px solid var(--ink);
  background: var(--paper-2);
  color: var(--ink);
  padding: 6px 14px 4px;
  border-radius: 10px 4px 9px 5px / 5px 9px 4px 10px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--paper); color: var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn.blood { background: var(--blood); color: #fbe9d9; border-color: #3a0707; box-shadow: 0 3px 0 #3a0707; }
.btn.blood:hover { background: var(--blood-bright); color: #fff; }
.btn.ghost { background: transparent; color: var(--chalk); border-color: var(--chalk-faint); box-shadow: none; }
.btn.ghost:hover { border-color: var(--chalk); color: var(--chalk); }
.paper .btn.ghost { color: var(--ink); border-color: var(--ink-faint); }
.btn.small { font-size: 15px; padding: 3px 10px 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Status markers ---------- */
.badge {
  font-family: var(--font-hand);
  font-size: 14px;
  padding: 1px 8px 0;
  border-radius: 8px 3px 7px 4px;
  border: 1.5px solid currentColor;
  white-space: nowrap;
  line-height: 1.4;
}
.badge.done { color: #3e6a1f; background: rgba(111,138,58,.18); }
.badge.open { color: #8a5a00; background: rgba(227,178,60,.22); }
.badge.locked { color: #6b5848; background: rgba(0,0,0,.06); border-style: dashed; }
.badge.avoid { color: var(--blood); background: rgba(163,24,27,.1); }
.badge.mild { color: #8a4b2a; background: rgba(160,90,40,.1); border-style: dotted; }
.badge.hard { color: #fff; background: var(--blood); border-color: var(--blood); }
.slab .badge.locked { color: var(--chalk-faint); }
/* Item Quality: fill = dominant RGB of EID glyph {{QualityN}} (frames "Quality"
   0-4 in eid_inline_icons.png), with dark ink and border for contrast.
   Must stay equal to QUALITY_COLORS in unlock-info.js (tested). */
.badge.quality { font-variant-numeric: tabular-nums; color: var(--ink); border-color: var(--ink); background: var(--q, transparent); }
.badge.quality[data-quality="0"] { --q: #C2C2C2; }
.badge.quality[data-quality="1"] { --q: #90FF51; }
.badge.quality[data-quality="2"] { --q: #65D5FF; }
.badge.quality[data-quality="3"] { --q: #FF54EC; }
.badge.quality[data-quality="4"] { --q: #FFD100; }
/* Item-like unlock without collectible Quality (trinket, card, rune, ...). */
.badge.reward-type { color: var(--ink); border-style: dashed; background: rgba(0,0,0,.04); }

.bar { height: 10px; background: rgba(43,28,18,.15); border: 1.5px solid var(--ink); border-radius: 6px 3px 5px 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: repeating-linear-gradient(-45deg, var(--blood) 0 6px, #8c1215 6px 12px); }
.bar.gold > i { background: repeating-linear-gradient(-45deg, var(--gold) 0 6px, var(--gold-dark) 6px 12px); }

/* Drawn boss symbols: styling inherits through <use> down to the paths. */
.gl { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.map .ico { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Achievement icon ---------- */
.ach-ico { width: 40px; height: 40px; flex: none; border-radius: 4px; image-rendering: pixelated; background: var(--paper-3); box-shadow: 0 0 0 2px var(--ink); }
.ach-ico.locked { filter: grayscale(1) brightness(.55) contrast(1.2); }
.ach-ico.open { filter: grayscale(.65) brightness(.95); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.28);
  border: 1.5px solid rgba(43,28,18,.45);
  padding: 2px 8px 2px 3px;
  border-radius: 6px 3px 6px 4px;
  font-size: 16px;
  line-height: 1.1;
  color: var(--ink);
  cursor: pointer;
}
.chip img { width: 26px; height: 26px; border-radius: 3px; image-rendering: pixelated; }
.chip.avoid { border-color: var(--blood); background: rgba(163,24,27,.08); }
.chip.todo img { filter: grayscale(.85) brightness(.85); }
.chip.got { background: rgba(111,138,58,.16); border-color: rgba(62,106,31,.55); }
.chip.got::before { content: '✓'; order: 3; color: #3e6a1f; font-family: var(--font-pixel); font-size: 13px; }
.chip.avoid::after { content: '!'; font-family: var(--font-pixel); color: var(--blood); font-weight: 700; }

/* ---------- Dashboard ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
.next-run .who { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.next-run .who img { width: 64px; height: 64px; image-rendering: pixelated; border-radius: 6px; box-shadow: 0 0 0 2px var(--ink), 3px 4px 0 rgba(0,0,0,.25); transform: rotate(-3deg); }
.next-run .who .name { font-family: var(--font-scrawl); font-size: 22px; line-height: 1.1; }
.path { list-style: none; margin: 10px 0; padding: 0; counter-reset: p; }
.path li { counter-increment: p; position: relative; padding: 3px 0 3px 34px; }
.path li::before {
  content: counter(p);
  position: absolute;
  left: 0;
  top: 2px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 50% 45% 55% 48%;
  display: grid;
  place-items: center;
  font-family: var(--font-pixel);
  font-size: 13px;
  background: var(--paper-2);
}
.path li + li::after { content: ''; position: absolute; left: 11px; top: -6px; height: 9px; border-left: 2px dotted var(--ink-faint); }
.mark-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.mark-pill { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-hand); font-size: 15px; padding: 1px 8px 0 3px; border: 1.5px solid var(--ink); border-radius: 12px; background: rgba(255,255,255,.3); }
.mark-pill svg { width: 20px; height: 20px; }
.mark-pill.skip { opacity: .7; border-style: dashed; text-decoration: line-through; }

.runs { display: grid; gap: 10px; }
.run-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 6px; background: rgba(0,0,0,.18); border: 1px solid rgba(0,0,0,.35); cursor: pointer; text-align: left; color: var(--chalk); }
.run-row:hover { background: rgba(0,0,0,.3); }
.run-row img { width: 44px; height: 44px; image-rendering: pixelated; border-radius: 4px; }
.run-row b { font-family: var(--font-hand); font-weight: 400; font-size: 19px; display: block; line-height: 1.1; }
.run-row span { color: var(--chalk-dim); font-size: 15px; }
.run-row .score { font-family: var(--font-pixel); font-size: 14px; color: var(--gold); text-align: right; }

/* ---------- Custom route ---------- */
.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0 0 8px; }
.target { display: grid; grid-template-columns: 30px 1fr; column-gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--radius-paper); background: var(--paper-2); color: var(--ink); text-decoration: none; box-shadow: 0 4px 10px -4px #000; transition: transform .15s, background .15s; }
.target:hover { transform: translateY(-2px); }
.target[aria-current='true'] { background: var(--paper); box-shadow: 0 6px 14px -4px #000, 0 0 0 2px var(--ink) inset; }
.target svg { grid-row: span 2; width: 30px; height: 30px; }
.target b { font-family: var(--font-hand); font-weight: 400; font-size: 19px; line-height: 1.1; }
.target small { color: var(--ink-faint); font-size: 14px; line-height: 1.1; }
.target-pick .who { display: flex; gap: 14px; align-items: center; margin-bottom: 4px; }
.target-pick .who img { width: 56px; height: 56px; image-rendering: pixelated; border-radius: 6px; box-shadow: 0 0 0 2px var(--ink), 3px 4px 0 rgba(0,0,0,.25); transform: rotate(-3deg); }
.target-pick .who .name { font-family: var(--font-scrawl); font-size: 22px; line-height: 1.1; }
@media (max-width: 600px) { .target-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.quick { display: grid; gap: 10px; }
.quick-item { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; }
.quick-item img { width: 34px; height: 34px; border-radius: 3px; image-rendering: pixelated; }
.quick-item b { font-weight: 400; }
.quick-item .num { font-family: var(--font-pixel); font-size: 13px; color: var(--ink-soft); }

.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 16px; }
.log li { display: flex; gap: 8px; align-items: baseline; color: var(--chalk-dim); }
.log time { font-family: var(--font-pixel); font-size: 12px; color: var(--chalk-faint); flex: none; }

/* ---------- Characters: notes ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 232px), 1fr)); gap: 22px 18px; }
.note { padding: 14px 14px 12px; cursor: pointer; transition: transform .15s; }
.note:nth-child(3n) { transform: rotate(-.8deg); }
.note:nth-child(3n+1) { transform: rotate(.6deg); }
.note:hover { transform: rotate(0) translateY(-3px); }
.note-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.note-head img { width: 46px; height: 46px; image-rendering: pixelated; border-radius: 4px; box-shadow: 0 0 0 2px var(--ink); }
.note-head .n { font-family: var(--font-hand); font-size: 21px; line-height: 1; }
.note-head .c { font-family: var(--font-pixel); font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.marks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.mark {
  aspect-ratio: 1;
  border: 0;
  padding: 2px;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  position: relative;
  color: var(--ink);
}
.mark svg { width: 100%; height: 100%; display: block; }
.mark[data-level='0'] { color: rgba(43,28,18,.28); }
.mark[data-level='0'] svg { stroke-dasharray: 2.5 2.5; stroke-width: 1.8; }
.mark[data-level='1'] { color: var(--ink); }
.mark[data-level='2'] { color: var(--blood); }
.mark[data-level='2']::after { content: ''; position: absolute; inset: 1px; border: 2px solid var(--blood); border-radius: 48% 52% 45% 55%; opacity: .7; }
.mark.blocked { opacity: .45; cursor: help; }
.mark:hover { background: rgba(43,28,18,.08); }
.mark.pop { animation: holdup .45s cubic-bezier(.3,1.6,.6,1); }
.note.locked { background-color: var(--paper-3); }
.note.locked .note-head img { filter: grayscale(1) brightness(.4); }
.note.locked .marks { opacity: .35; }
.chain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.chain::before, .chain::after {
  content: '';
  position: absolute;
  left: -20%;
  right: -20%;
  top: 46%;
  height: 12px;
  background: repeating-linear-gradient(90deg, #4a3d33 0 14px, transparent 14px 18px, #6b5a4c 18px 30px, transparent 30px 34px);
  border-top: 2px solid rgba(0,0,0,.4);
  border-bottom: 2px solid rgba(0,0,0,.4);
  transform: rotate(-18deg);
  opacity: .8;
}
.chain::after { transform: rotate(16deg); top: 50%; }
.note .how { font-size: 15px; color: var(--ink-soft); margin-top: 8px; line-height: 1.25; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 18px; }
.seg { display: inline-flex; border: 2px solid var(--chalk-faint); border-radius: 10px 4px 9px 5px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 4px 12px 2px; font-family: var(--font-hand); font-size: 16px; color: var(--chalk-dim); cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--paper-2); color: var(--ink); }
.search { font: inherit; font-size: 17px; padding: 5px 12px 3px; border-radius: 10px 4px 9px 5px; border: 2px solid var(--chalk-faint); background: rgba(0,0,0,.35); color: var(--chalk); min-width: 0; flex: 1 1 220px; max-width: 360px; }
.search::placeholder { color: var(--chalk-faint); }
select.search { flex: 0 1 200px; }

/* ---------- Drawer (detail) ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; animation: fade .2s; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100%);
  z-index: 61;
  overflow-y: auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(28px + env(safe-area-inset-bottom, 0px));
  background: var(--cellar-2);
  box-shadow: -20px 0 40px rgba(0,0,0,.6);
  animation: slide .25s ease-out;
}
.drawer .close { position: sticky; top: 0; float: right; z-index: 2; }
.drawer .paper + .paper { margin-top: 16px; }
.mark-table { display: grid; gap: 4px; }
.mark-line { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 4px; border-bottom: 1.5px dashed rgba(43,28,18,.2); }
.mark-line:last-child { border-bottom: 0; }
.mark-line svg { width: 32px; height: 32px; }
.mark-line .t { font-family: var(--font-hand); font-size: 18px; line-height: 1.1; }
.mark-line .r { font-size: 14px; color: var(--ink-soft); }
.mark-line.flash { animation: markflash 1.4s ease-out; }
@keyframes markflash { 0%, 40% { background: rgba(255,209,0,.45); } 100% { background: transparent; } }
.tier4-list { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; }
.tier4-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tier4-list button.mark-pill { cursor: pointer; color: inherit; }
.lvl { display: inline-flex; border: 2px solid var(--ink); border-radius: 8px 3px 7px 4px; overflow: hidden; }
.lvl button { border: 0; background: transparent; padding: 3px 9px 1px; font-family: var(--font-hand); font-size: 15px; cursor: pointer; color: var(--ink); }
.lvl button + button { border-left: 1.5px solid var(--ink); }
.lvl button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.lvl button[aria-pressed='true'].h { background: var(--blood); }
.lvl button[disabled] { opacity: .35; cursor: not-allowed; }

.chain-list { list-style: none; margin: 6px 0; padding-left: 0; font-size: 16px; }
.chain-list ul { list-style: none; margin: 2px 0 2px 14px; padding-left: 12px; border-left: 2px dotted var(--ink-faint); }
.chain-list li { margin: 2px 0; }
.chain-list li::before { content: '← '; color: var(--blood); font-family: var(--font-pixel); }

/* ---------- Map (minimap) ---------- */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .map-wrap { grid-template-columns: 1fr; } }
.map-wrap > * { min-width: 0; }
.ink-label svg { width: 22px; height: 22px; vertical-align: -5px; }
.map-scroll { overflow-x: auto; border-radius: 10px; background: rgba(0,0,0,.45); border: 2px solid #0d0806; box-shadow: inset 0 0 40px #000; padding: 12px; }
.map { display: block; min-width: 860px; width: 100%; height: auto; }
.map .edge { stroke: #6e5a47; stroke-width: 6; stroke-linecap: square; }
.map .edge.lit { stroke: #e8dcc0; }
.map .room { cursor: pointer; }
.map .room rect { stroke-width: 4; }
.map .room.done rect { fill: #e8dcc0; stroke: #000; }
.map .room.open rect { fill: #4b3a2c; stroke: #e8dcc0; stroke-dasharray: 8 5; }
.map .room.locked rect { fill: #1c140f; stroke: #3d2f24; }
.map .room text { font-family: var(--font-hand); font-size: 15px; text-anchor: middle; pointer-events: none; }
.map .room.done text { fill: #1b120c; }
.map .room.open text { fill: #f1e6cc; }
.map .room.locked text { fill: #6f5c4b; }
.map .room .ico { pointer-events: none; }
.map .room:hover rect, .map .room.sel rect { stroke: var(--gold); stroke-dasharray: none; }
.map .room.sel rect { filter: drop-shadow(0 0 6px rgba(227,178,60,.8)); }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 15px; color: var(--chalk-dim); margin-top: 10px; }
.map-legend i { display: inline-block; width: 16px; height: 12px; vertical-align: -1px; margin-right: 6px; border: 2px solid; }

/* ---------- Secrets list ---------- */
.ach-list { display: grid; gap: 8px; }
.ach {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  content-visibility: auto;
  contain-intrinsic-size: auto 84px;
}
.ach .t { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ach .t b { font-family: var(--font-hand); font-weight: 400; font-size: 20px; line-height: 1.1; }
.ach .t .id { font-family: var(--font-pixel); font-size: 12px; color: var(--ink-faint); }
.ach .u { font-size: 15px; color: var(--ink-soft); font-style: italic; }
.ach .h { font-size: 16px; margin-top: 2px; }
.ach .blk { font-size: 14px; color: #6b4a2e; margin-top: 3px; }
.ach .blk b { font-weight: 400; color: var(--blood); }
.ach .prog { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-top: 5px; max-width: 360px; font-family: var(--font-pixel); font-size: 12px; }
.tick {
  appearance: none;
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--ink);
  border-radius: 6px 3px 7px 4px;
  background: rgba(255,255,255,.35);
  cursor: pointer;
  position: relative;
  margin: 2px 0 0;
}
.tick:checked::after {
  content: '';
  position: absolute;
  left: 7px;
  top: -3px;
  width: 10px;
  height: 22px;
  border: solid var(--blood);
  border-width: 0 4px 4px 0;
  transform: rotate(40deg);
  border-radius: 2px;
}
.tick:checked { animation: holdup .45s cubic-bezier(.3,1.6,.6,1); }
.list-more { text-align: center; margin: 16px 0; }

/* ---------- Route ---------- */
.phase { position: relative; margin: 0 0 22px; }
.phase-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.phase-head h3 { font-family: var(--font-scrawl); font-size: 20px; margin: 0; font-weight: 400; text-shadow: 1px 1px 0 #000; }
.phase-head p { margin: 0; color: var(--chalk-dim); font-size: 16px; }
.steps { display: grid; gap: 10px; }
.step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 12px 14px; }
.step .st { width: 30px; height: 30px; border: 2.5px solid var(--ink); border-radius: 50% 44% 52% 47%; display: grid; place-items: center; font-family: var(--font-pixel); font-size: 14px; }
.step.done { opacity: .72; }
.step.done .st { background: var(--ink); color: var(--paper); }
.step.current { box-shadow: var(--shadow-paper), 0 0 0 3px var(--gold), 0 0 24px rgba(227,178,60,.35); }
.step.current::after {
  content: 'YOU ARE HERE';
  position: absolute;
  top: -11px;
  right: 14px;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: 1px;
  background: var(--gold);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 3px;
  box-shadow: 2px 2px 0 #000;
}
.step h4 { margin: 0 0 4px; font-size: 20px; }
.src { font-size: 14px; color: var(--ink-faint); }
.src a { color: var(--ink-soft); }

/* ---------- Sync ---------- */
.drop {
  border: 3px dashed var(--ink-faint);
  border-radius: 12px 6px 10px 8px;
  padding: 22px;
  text-align: center;
  transition: background .15s, border-color .15s;
}
.drop.over { background: rgba(163,24,27,.12); border-color: var(--blood); }
.path-box { display: flex; gap: 8px; align-items: center; background: rgba(43,28,18,.1); border: 1.5px solid rgba(43,28,18,.3); border-radius: 6px; padding: 6px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; overflow-x: auto; }
.path-box code { white-space: nowrap; flex: 1; }
pre.cmd { background: #120c08; color: var(--chalk); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 13px; border: 1px solid #000; }
.diff-list { max-height: 280px; overflow-y: auto; margin: 8px 0; padding: 6px 10px; background: rgba(255,255,255,.2); border-radius: 6px; font-size: 16px; }
.diff-list li { margin: 2px 0; }
.plus { color: #3e6a1f; font-family: var(--font-pixel); }
.minus { color: var(--blood); font-family: var(--font-pixel); }

/* ---------- Lock (login) ---------- */
.lock {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 40%, #2b1e15, #0b0705 75%);
}
.door { width: min(360px, 100%); text-align: center; }
.door-art { width: 190px; height: auto; margin: 0 auto 8px; display: block; filter: drop-shadow(0 12px 18px #000); }
.door h1 { font-family: var(--font-scrawl); font-weight: 400; font-size: 24px; margin: 0 0 4px; text-shadow: 2px 2px 0 #000; }
.door p { color: var(--chalk-dim); margin: 0 0 14px; }
.auth-tabs { display: flex; justify-content: center; gap: 8px; margin: 0 0 12px; }
.auth-tabs button { font-family: var(--font-hand); font-size: 18px; background: none; color: var(--chalk-dim); border: 0; border-bottom: 2px solid transparent; padding: 4px 8px; cursor: pointer; }
.auth-tabs button[aria-selected="true"] { color: var(--chalk); border-bottom-color: var(--blood-bright); }
.auth-form { display: grid; gap: 6px; text-align: left; }
.auth-form label { color: var(--chalk-dim); font-family: var(--font-hand); font-size: 16px; }
.auth-form input { font: inherit; font-size: 17px; padding: 10px 12px; background: var(--paper-2); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px 4px 7px 5px; }
.auth-form .btn { margin-top: 10px; justify-self: center; }
.door .auth-hint { font-size: 14px; margin: 0; }
.session-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.session-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.pin-err { color: var(--blood-bright); min-height: 1.4em; margin-top: 12px; font-family: var(--font-hand); }
.shake { animation: shake .4s; }

/* ---------- Toasts (the "secret unlocked" note) ---------- */
.toasts { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 10px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; animation: drop .45s cubic-bezier(.2,1.4,.5,1); }
.toast img { width: 52px; height: 52px; image-rendering: pixelated; border-radius: 4px; box-shadow: 0 0 0 2px var(--ink); }
.toast .k { font-family: var(--font-pixel); font-size: 12px; letter-spacing: 2px; color: var(--blood); }
.toast .v { font-family: var(--font-hand); font-size: 20px; line-height: 1.1; }
.toast.out { animation: lift .3s forwards; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 65; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; }

footer { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter) 40px; color: var(--chalk-faint); font-size: 15px; position: relative; z-index: 1; text-align: center; }
footer a { color: var(--chalk-dim); }

.empty { text-align: center; color: var(--chalk-dim); padding: 30px 10px; }
.loading { display: grid; place-items: center; min-height: 50vh; font-family: var(--font-scrawl); font-size: 22px; color: var(--chalk-dim); }

@keyframes holdup { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-9px) scale(1.18); } 100% { transform: translateY(0) scale(1); } }
@keyframes drop { from { transform: translateY(-120%) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes lift { to { transform: translateY(-120%) rotate(3deg); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  .hud { position: relative; }
  .hearts { display: none; }
  .stats { gap: 12px; font-size: 16px; }
  .marks { gap: 2px; }
  .ach { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 9px; padding: 10px; }
  .ach-ico { width: 34px; height: 34px; }
}
