:root {
  --bg: #0b0a09;
  --bg-2: #14110f;
  --panel: #1b1714;
  --line: #3a2f27;
  --text: #e8dfd2;
  --muted: #a3968a;
  --blood: #b3121b;
  --blood-d: #6e0a10;
  --gold: #c9a24a;
  --herb: #4c8b3a;
  --paper: #d9cbb0;
  --ink: #2a2118;
  --font-title: "Cinzel", Georgia, serif;
  --font-type: "Special Elite", "Courier New", monospace;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
  cursor: crosshair;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
code, kbd {
  font-family: var(--font-type);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0 .35em;
  border-radius: 3px;
}

/* Atmosphere overlays */
.grain, .vignette { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.grain {
  opacity: .07;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); }
}
.vignette { background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.75)); }

/* Nav */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem clamp(1rem, 4vw, 3rem);
  background: linear-gradient(rgba(11,10,9,.95), rgba(11,10,9,0));
  transition: background .3s;
}
.nav.solid { background: rgba(11,10,9,.96); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--font-title); font-weight: 900; font-size: 1.4rem; text-decoration: none; letter-spacing: .08em; }
.brand span { color: var(--blood); }
.brand small { font-family: var(--font-type); font-weight: 400; font-size: .75rem; color: var(--muted); letter-spacing: .15em; margin-left: .3rem; }
.nav-links { display: flex; gap: 1.6rem; }
.nav-links a { font-family: var(--font-type); text-decoration: none; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; font-size: .85rem; transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--blood); }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.5rem; cursor: pointer; }

/* Hero */
.hero {
  position: relative; min-height: 100vh; display: grid; place-items: center; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(179,18,27,.35), transparent 60%),
    radial-gradient(ellipse at 50% 0%, #2a1f18, var(--bg) 70%);
  text-align: center; padding: 6rem 1rem 4rem;
}
.hero::before { /* treeline silhouette */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 38%;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 300' preserveAspectRatio='none'><path fill='%23050404' d='M0 300V180l30-60 20 50 25-90 30 100 20-40 30 30 25-120 30 110 40-40 20 60 30-150 35 140 25-30 30 40 40-100 30 90 35-50 25 60 30-130 40 120 30-20 25 50 35-110 30 100 40-60 30 70 25-140 35 130 30-40 40 50 30-90 25 80 40-30 30 40 35-120 30 110 25-50 30 60 40-100 30 90 35 30V300z'/></svg>") bottom/100% 100% no-repeat;
  z-index: 1;
}
.hero-inner { position: relative; z-index: 3; }
.eyebrow { font-family: var(--font-type); color: var(--gold); letter-spacing: .2em; text-transform: uppercase; font-size: .9rem; min-height: 1.6em; }
.title { font-family: var(--font-title); font-weight: 900; margin: .2rem 0; line-height: .9; text-shadow: 0 0 40px rgba(179,18,27,.5); }
.title span { display: block; font-size: clamp(2.2rem, 7vw, 5rem); letter-spacing: .12em; }
.title .big { font-size: clamp(7rem, 26vw, 16rem); color: var(--blood); animation: flicker 6s infinite; }
@keyframes flicker {
  0%, 92%, 100% { opacity: 1; } 93% { opacity: .4; } 94% { opacity: 1; } 96% { opacity: .6; } 97% { opacity: 1; }
}
.tag { color: var(--muted); font-size: 1.1rem; }
.hero-cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }
.fog { position: absolute; inset: -20%; z-index: 2; pointer-events: none; opacity: .35;
  background: radial-gradient(ellipse at 20% 70%, rgba(200,190,180,.18), transparent 40%),
              radial-gradient(ellipse at 80% 60%, rgba(200,190,180,.14), transparent 45%); }
.fog-1 { animation: drift 40s linear infinite; }
.fog-2 { animation: drift 60s linear infinite reverse; opacity: .25; }
@keyframes drift { from { transform: translateX(-10%); } to { transform: translateX(10%); } }
.drips { position: absolute; top: 0; left: 0; right: 0; height: 120px; z-index: 4; pointer-events: none; }
.drips i { position: absolute; top: 0; width: 6px; background: linear-gradient(var(--blood-d), var(--blood)); border-radius: 0 0 6px 6px; animation: drip 4s ease-in infinite; }
@keyframes drip { 0% { height: 0; opacity: 1; } 70% { opacity: 1; } 100% { height: 110px; opacity: 0; } }
.scroll-hint { position: absolute; bottom: 1.5rem; z-index: 5; color: var(--blood); text-decoration: none; animation: bob 2s infinite; }
@keyframes bob { 50% { transform: translateY(8px); } }

/* Buttons */
.btn {
  display: inline-block; font-family: var(--font-type); text-transform: uppercase; letter-spacing: .12em;
  padding: .8rem 1.6rem; border: 1px solid var(--blood); background: var(--blood); color: #fff;
  text-decoration: none; cursor: pointer; font-size: .9rem; transition: transform .15s, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(179,18,27,.45); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--blood); }
.btn.small { padding: .5rem .9rem; font-size: .75rem; }

/* Sections */
.section { padding: 6rem clamp(1rem, 5vw, 4rem); max-width: 1300px; margin: 0 auto; }
.section-title { font-family: var(--font-title); font-size: clamp(2rem, 5vw, 3.2rem); margin: 0; letter-spacing: .06em; }
.section-title::after { content: ""; display: block; width: 80px; height: 3px; background: var(--blood); margin-top: .6rem; }
.section-sub { color: var(--muted); font-family: var(--font-type); }

/* Case file */
.file { display: grid; grid-template-columns: 1.4fr 1fr; gap: 3rem; align-items: center; }
.paper {
  position: relative; background: var(--paper); color: var(--ink); padding: 2.5rem; font-family: var(--font-type);
  transform: rotate(-1deg); box-shadow: 0 20px 50px rgba(0,0,0,.6);
  background-image: linear-gradient(transparent 31px, rgba(42,33,24,.12) 32px); background-size: 100% 32px;
}
.paper h2 { margin-top: 0; font-size: 1.8rem; border-bottom: 2px solid var(--ink); padding-bottom: .4rem; }
.paper dl div { display: grid; grid-template-columns: 110px 1fr; gap: 1rem; margin: .4rem 0; }
.paper dt { text-transform: uppercase; opacity: .7; }
.paper dd { margin: 0; }
.note { margin-top: 1.2rem; font-size: .95rem; }
.stamp {
  position: absolute; top: 1.4rem; right: 1.2rem; transform: rotate(12deg);
  border: 3px solid var(--blood); color: var(--blood); padding: .2rem .6rem; font-size: 1.1rem; letter-spacing: .15em; opacity: .8;
}
.stats { display: grid; gap: 1rem; }
.stat { background: var(--panel); border-left: 3px solid var(--blood); padding: 1.2rem 1.4rem; display: flex; align-items: center; gap: 1.2rem; }
.stat .num { font-family: var(--font-title); font-size: 2.4rem; color: var(--gold); min-width: 3.2ch; }
.stat span:last-child { color: var(--muted); }

/* Gallery */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.5rem 0 2rem; }
.filters button {
  font-family: var(--font-type); background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  padding: .45rem 1rem; cursor: pointer; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem;
}
.filters button[aria-selected="true"], .filters button:hover { color: #fff; border-color: var(--blood); background: var(--blood-d); }
.grid { columns: 4 260px; column-gap: 1rem; }
.card {
  break-inside: avoid; margin-bottom: 1rem; position: relative; overflow: hidden; background: var(--panel);
  border: 1px solid var(--line); cursor: zoom-in; opacity: 0; transform: translateY(20px);
  transition: opacity .6s, transform .6s, border-color .2s;
}
.card.in { opacity: 1; transform: none; }
.card:hover { border-color: var(--blood); }
.card img { width: 100%; transition: transform .6s, filter .6s; filter: saturate(.85) contrast(1.05); }
.card:hover img { transform: scale(1.05); filter: saturate(1.1); }
.card .meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2rem .9rem .7rem;
  background: linear-gradient(transparent, rgba(0,0,0,.9)); transform: translateY(100%); transition: transform .3s;
}
.card:hover .meta, .card:focus-visible .meta { transform: none; }
.card h3 { margin: 0; font-family: var(--font-title); font-size: 1rem; }
.card small { color: var(--gold); font-family: var(--font-type); text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; }
.card.missing { cursor: default; aspect-ratio: 4 / 3; display: grid; place-items: center; text-align: center; padding: 1rem;
  background: repeating-linear-gradient(45deg, var(--panel), var(--panel) 12px, var(--bg-2) 12px, var(--bg-2) 24px); }
.card.missing .meta { position: static; transform: none; background: none; padding: 0; }
.card.missing code { font-size: .7rem; word-break: break-all; }
.empty-note { color: var(--muted); font-family: var(--font-type); margin-top: 1rem; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5,4,4,.95); display: grid; grid-template-columns: 60px 1fr 60px; align-items: center; padding: 2rem 1rem; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-height: 80vh; margin: 0 auto; border: 1px solid var(--line); box-shadow: 0 0 60px rgba(179,18,27,.3); }
.lightbox figcaption { font-family: var(--font-type); color: var(--muted); margin-top: 1rem; }
.lightbox button { background: none; border: 0; color: var(--text); font-size: 3rem; cursor: pointer; }
.lightbox button:hover { color: var(--blood); }
.lb-close { position: absolute; top: 1rem; right: 1.4rem; font-size: 2rem !important; }

/* Attaché case */
.case-wrap { display: grid; grid-template-columns: auto 1fr; gap: 2rem; margin-top: 2rem; align-items: start; }
.case {
  position: relative; padding: 1.4rem; border-radius: 10px;
  background: linear-gradient(145deg, #3b2a1c, #22170f); border: 2px solid #5a4330;
  box-shadow: inset 0 0 30px rgba(0,0,0,.6), 0 20px 40px rgba(0,0,0,.6);
}
.case-handle { position: absolute; top: -18px; left: 50%; width: 120px; height: 22px; transform: translateX(-50%); border: 6px solid #5a4330; border-bottom: 0; border-radius: 14px 14px 0 0; }
.case-grid {
  --cell: clamp(30px, 6vw, 52px);
  position: relative; display: grid; grid-template-columns: repeat(10, var(--cell)); grid-template-rows: repeat(7, var(--cell));
  background: #0e1a24; border: 1px solid #000;
}
.cell { border: 1px solid rgba(120,160,190,.15); }
.cell.ok { background: rgba(76,139,58,.35); }
.cell.bad { background: rgba(179,18,27,.4); }
.placed {
  position: absolute; display: grid; place-items: center; font-size: calc(var(--cell) * .55);
  border: 1px solid rgba(255,255,255,.35); border-radius: 4px; cursor: context-menu; animation: pop .2s;
}
@keyframes pop { from { transform: scale(.8); } }
.placed span { font-family: var(--font-type); font-size: .6rem; position: absolute; bottom: 2px; left: 4px; color: rgba(255,255,255,.75); }
.tray { background: var(--panel); border: 1px solid var(--line); padding: 1.2rem; }
.tray h3 { font-family: var(--font-title); margin-top: 0; }
.tray-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.item-btn {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text); cursor: pointer; font-family: var(--font-type); font-size: .8rem; text-align: left;
}
.item-btn .sw { width: 14px; height: 14px; border-radius: 2px; flex: none; }
.item-btn[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.item-btn:disabled { opacity: .35; cursor: not-allowed; }
.tray-actions { display: flex; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }
.case-status { font-family: var(--font-type); color: var(--gold); min-height: 1.6em; }
.meter { height: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--herb), var(--gold)); transition: width .3s; }

/* Save room */
.save-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2rem; }
.typewriter { background: var(--panel); border: 1px solid var(--line); padding: 1.5rem; display: grid; gap: 1rem; font-family: var(--font-type); }
.typewriter label { display: grid; gap: .3rem; color: var(--muted); }
.typewriter input, .typewriter textarea {
  font-family: var(--font-type); font-size: 1rem; background: var(--bg-2); color: var(--text); border: 1px solid var(--line); padding: .6rem; resize: vertical;
}
.typewriter input:focus, .typewriter textarea:focus { outline: none; border-color: var(--gold); }
.ribbons { color: var(--gold); }
.slots { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; counter-reset: slot; }
.slots li { counter-increment: slot; background: var(--paper); color: var(--ink); padding: .8rem 1rem .8rem 3.2rem; position: relative; font-family: var(--font-type); }
.slots li::before { content: counter(slot, decimal-leading-zero); position: absolute; left: .9rem; top: .8rem; color: var(--blood); font-weight: bold; }
.slots li small { display: block; opacity: .6; font-size: .75rem; }
.slots .empty { background: var(--panel); color: var(--muted); }

.footer { border-top: 1px solid var(--line); padding: 2rem clamp(1rem, 5vw, 4rem); color: var(--muted); font-size: .8rem; text-align: center; }

/* Responsive */
@media (max-width: 900px) {
  .file, .save-wrap, .case-wrap { grid-template-columns: 1fr; }
  .case { justify-self: center; }
}
@media (max-width: 700px) {
  .nav-toggle { display: block; }
  .nav-links { position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 0; background: rgba(11,10,9,.98); display: none; border-bottom: 1px solid var(--line); }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 1rem 1.4rem; border-top: 1px solid var(--line); }
  .paper dl div { grid-template-columns: 1fr; gap: 0; }
  .card .meta { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card { opacity: 1; transform: none; }
}
