* { margin: 0; padding: 0; box-sizing: border-box; }

/* Nightwood skin (Claude Design handoff). Selectors unchanged; main.js untouched. */
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/Alegreya-400.woff2') format('woff2'); }
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/Alegreya-500.woff2') format('woff2'); }
@font-face { font-family: 'Alegreya'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/Alegreya-700.woff2') format('woff2'); }
@font-face { font-family: 'Alegreya SC'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/AlegreyaSC-700.woff2') format('woff2'); }
@font-face { font-family: 'Averia Serif Libre'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/AveriaSerifLibre-400.woff2') format('woff2'); }
@font-face { font-family: 'Averia Serif Libre'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/AveriaSerifLibre-700.woff2') format('woff2'); }

:root {
  --bg: #050505;
  --timber-bd: #0c0906;
  --timber-hi: #6b5436;
  --cream: #f0e6cf;
  --cream2: #f0e2c0;
  --text: #e8dcc0;
  --muted: #94886d;
  --label: #c8b894;
  --gold: #e8c96a;
  --goldnum: #f3d57a;
  --golddim: #c2982f;
}

html, body { height: 100%; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--goldnum); }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.5 "Alegreya", Georgia, serif;
}

/* Nightwood top nav (matches the DB site header) */
.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 16px;
  background: linear-gradient(180deg, #2c2318 0, #201812 44%, #171009 100%);
  border-bottom: 3px solid #050403;
  box-shadow: inset 0 2px 0 #4a3a26, inset 0 -3px 0 #0e0a05, 0 4px 0 rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 40;
}
.tn-brand { display: flex; align-items: center; justify-content: center; gap: 9px; flex: none; width: 324px; }
.tn-brand img { height: 38px; width: auto; image-rendering: pixelated; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.6)); }
.tn-brand span {
  align-self: flex-end;
  margin-bottom: 2px;
  font-family: "Averia Serif Libre", serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
}
.tn-links { display: flex; gap: 2px; margin-left: auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tn-links::-webkit-scrollbar { display: none; }
.tn-links a {
  padding: 6px 11px;
  font-family: "Averia Serif Libre", serif;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--label);
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}
.tn-links a:hover { color: var(--cream); }
.tn-links a.active {
  background: linear-gradient(180deg, #b07a2a, #7e4f14);
  border: 2px solid #050403;
  box-shadow: inset 0 2px 0 #d8a850, inset 0 -2px 0 #5a380c;
  color: #ffe9b0;
  text-shadow: 1px 1px 0 #3a2406;
  padding: 4px 9px;
}

.app { display: flex; height: calc(100vh - 56px); height: calc(100dvh - 56px); }

/* wooden plank sidebar */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: repeating-linear-gradient(180deg, #453020 0 26px, #3a2818 26px 29px, #4a3424 29px 55px, #38261a 55px 58px);
  border-right: 3px solid var(--timber-bd);
  box-shadow: inset 0 0 0 2px var(--timber-hi), inset -6px 0 14px rgba(10, 5, 0, 0.5);
  padding: 16px 16px 18px;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar::-webkit-scrollbar { display: none; }
.app.collapsed .sidebar { display: none; }

.brand { text-align: center; }
.brand .logo {
  width: 210px;
  max-width: 100%;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.6));
}
.brand-title {
  font-family: "Averia Serif Libre", serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
  margin-top: 4px;
}
.brand .sub {
  color: var(--label);
  font-size: 13.5px;
  margin-top: 8px;
  font-weight: 500;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

/* dark inset wells replace the old 9-slice panels */
.panel {
  background: radial-gradient(140% 130% at 50% -30%, #332e26, #221e18 60%, #1c1812);
  border: 2px solid #0e0b07;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35), inset 0 2px 0 rgba(160, 140, 110, 0.2), inset 0 -12px 26px rgba(0, 0, 0, 0.5);
  padding: 12px;
}

.controls label {
  display: block;
  font-family: "Averia Serif Libre", serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--label);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
  margin: 0 0 5px 1px;
  font-weight: 700;
}
.controls input[type="text"], .controls select {
  background: #181410;
  border: 2px solid #050403;
  box-shadow: inset 0 3px 6px #000, inset 0 0 0 2px rgba(0, 0, 0, 0.4);
  color: var(--cream);
  border-radius: 0;
  outline: none;
  font-family: "Averia Serif Libre", serif;
  font-size: 15px;
  width: 100%;
  padding: 0 10px;
  height: 42px;
}
.controls select {
  background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="10" height="6"%3E%3Cpath d="M1 1l4 4 4-4" stroke="%23e8c96a" stroke-width="1.6" fill="none"/%3E%3C/svg%3E');
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
  appearance: none;
}
.controls select option { background: #181410; color: var(--cream); }
.controls input[type="text"]:focus, .controls select:focus { box-shadow: inset 0 3px 6px #000, inset 0 0 0 2px rgba(216, 168, 80, 0.45); }
/* feedback line under the seed box; collapses away when there is nothing to say */
.seed-note { margin-top: 7px; font-size: 13px; line-height: 1.4; color: var(--label); }
.seed-note:empty { display: none; }

/* size + evil are stacked full-width rows (each renders a 3-button segment) */
.controls .two { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.controls .two > div { flex: none; min-width: 0; }

/* stone bevel buttons; #generate gets the green variant */
button {
  background: linear-gradient(180deg, #56524a, #3b3833);
  border: 2px solid #15120d;
  box-shadow: inset 0 2px 0 #7a756a, inset 0 -2px 0 #23211c, 0 3px 0 rgba(0, 0, 0, 0.4);
  color: var(--cream);
  border-radius: 0;
  outline: none;
  font-family: "Averia Serif Libre", serif;
  text-shadow: 1px 1px 0 #000;
  cursor: pointer;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: 0.45; cursor: default; filter: none; }

.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions button {
  padding: 10px 6px;
  font-size: 14.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex: 1;
}
#generate {
  background: linear-gradient(180deg, #5f9c48, #39702a);
  border-color: #0c0906;
  box-shadow: inset 0 2px 0 #8cc26e, inset 0 -2px 0 #245217, 0 3px 0 rgba(0, 0, 0, 0.4);
  color: #ffeccf;
  text-shadow: 1px 1px 0 #123407;
}
button.ghost { color: var(--label); }
button.small { font-size: 12px; margin-top: 10px; flex: none; width: 100%; padding: 7px 6px; text-transform: uppercase; letter-spacing: 0.06em; }
/* small buttons sharing an .actions row split it instead of each demanding full width */
.actions button.small { flex: 1 1 0; width: auto; margin-top: 0; }
#generate { flex: 1.7; }

/* segmented stone toggles (size/evil enhancement) */
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  padding: 7px 0;
  font-family: "Alegreya", serif;
  font-size: 13.5px;
  color: var(--label);
  text-shadow: 1px 1px 0 #000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.seg button img { width: 16px; image-rendering: pixelated; }
.seg button.on {
  background: linear-gradient(180deg, #b07a2a, #7e4f14);
  border-color: #050403;
  box-shadow: inset 0 2px 0 #d8a850, inset 0 -2px 0 #5a380c, 0 3px 0 rgba(0, 0, 0, 0.4);
  color: #ffe9b0;
  text-shadow: 1px 1px 0 #3a2406;
}

.progress {
  height: 12px;
  background: #16120c;
  border: 2px solid #0a0805;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  margin-top: 14px;
}
#progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(180deg, #8cc26e, #39702a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22);
  transition: width 0.15s linear;
}
.progress-label { color: var(--muted); font-size: 12.5px; margin-top: 6px; min-height: 18px; }

.section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Averia Serif Libre", serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cream);
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 9px;
}
.section h2::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: none;
  background: var(--golddim);
  transform: rotate(45deg);
  box-shadow: 1px 1px 0 #000;
}
.section h2::after {
  content: "";
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.5) 0 6px, transparent 6px 12px);
}

.facts .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 1px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 0 rgba(160, 140, 110, 0.08);
  font-size: 13.5px;
}
.facts .row:last-child { border-bottom: 0; box-shadow: none; }
.facts .row span {
  font-family: "Alegreya SC", serif;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts .row b { font-weight: 700; font-family: "Averia Serif Libre", serif; color: var(--goldnum); text-shadow: 1px 1px 0 #000; }

.check { display: flex; align-items: center; gap: 8px; padding: 4px 1px; font-size: 14px; cursor: pointer; color: var(--label); }
.check input { accent-color: #7e4f14; }
.textures-check { margin-top: 10px; }

.marker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.marker-size { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--label); }
/* the default range control reads as browser chrome inside a wooden panel, so give it the
   same sunken track the progress bar uses and a gold slug for the thumb */
#marker-size { width: 100%; height: 16px; background: transparent; -webkit-appearance: none; appearance: none; }
#marker-size:focus { outline: none; }
#marker-size::-webkit-slider-runnable-track {
  height: 8px;
  background: #16120c;
  border: 2px solid #0a0805;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.75);
}
#marker-size::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 16px;
  margin-top: -6px;
  background: var(--golddim);
  border: 2px solid #0a0805;
}
#marker-size::-moz-range-track {
  height: 8px;
  background: #16120c;
  border: 2px solid #0a0805;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.75);
}
#marker-size::-moz-range-thumb {
  width: 12px;
  height: 16px;
  border-radius: 0;
  background: var(--golddim);
  border: 2px solid #0a0805;
}
.marker-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  font-family: "Alegreya", serif;
  cursor: pointer;
  flex: none;
  text-align: left;
  color: var(--text);
  padding: 2px;
  background: none;
  border: none;
  box-shadow: none;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}
.marker-btn:hover { filter: brightness(1.3); }
.marker-btn.off { opacity: 0.4; }
.marker-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
  flex: none;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.55));
}
.marker-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mapwrap { flex: 1; position: relative; min-width: 0; background: #000; }
#map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#map.pointable { cursor: pointer; }
#map:active { cursor: grabbing; }

.side-toggle {
  position: fixed;
  top: 66px; /* below the 56px top nav */
  left: 10px;
  z-index: 30;
  width: 38px;
  height: 38px;
  flex: none;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  color: var(--cream);
}
.app:not(.collapsed) .side-toggle { left: 348px; }
@media (max-width: 1000px) {
  .app:not(.collapsed) .side-toggle { left: calc(min(84vw, 340px) + 8px); }
}

/* HUD chip */
.hoverbar {
  position: absolute;
  left: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 24px);
  background: rgba(10, 8, 5, 0.82);
  border: 2px solid #050403;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 5px 10px;
  font-family: "Averia Serif Libre", serif;
  font-size: 12.5px;
  color: var(--label);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
  min-height: 0;
}
.hoverbar:empty { display: none; }

@media (max-width: 1000px) {
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(84vw, 340px);
    min-width: 0;
    z-index: 20;
    box-shadow: inset 0 0 0 2px var(--timber-hi), 6px 0 24px rgba(0, 0, 0, 0.6);
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .brand .logo { width: 180px; }
}

.site-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.site-nav a {
  color: var(--label);
  text-decoration: none;
  font-family: "Averia Serif Libre", serif;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 1px 1px 0 #000;
  padding: 3px 8px;
}
.site-nav a:hover { color: var(--cream); }
.site-nav a.active {
  color: #ffe9b0;
  background: linear-gradient(180deg, #b07a2a, #7e4f14);
  border: 2px solid #050403;
  box-shadow: inset 0 2px 0 #d8a850, inset 0 -2px 0 #5a380c;
  text-shadow: 1px 1px 0 #3a2406;
  padding: 1px 8px;
}


/* topnav mobile: Menu panel instead of the link row (parity with the DB site) */
.tn-menu-btn { display: none; margin-left: auto; padding: 5px 12px; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.tn-panel {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  overflow-y: auto;
  padding: 14px 16px 32px;
  background: repeating-linear-gradient(180deg, #453020 0 26px, #3a2818 26px 29px, #4a3424 29px 55px, #38261a 55px 58px);
  border-top: 2px solid #0c0906;
  box-shadow: inset 0 0 0 2px var(--timber-hi), inset 0 6px 14px rgba(10, 5, 0, 0.5);
}
.tn-panel.open { display: block; }
.tn-panel a {
  display: block;
  padding: 9px 12px;
  font-family: "Averia Serif Libre", serif;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--label);
  text-shadow: 1px 1px 0 #000;
}
.tn-panel a.active { color: #ffe9b0; }
.tn-panel .tn-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 -1px 0 rgba(160, 140, 110, 0.15);
}
.tn-panel .tn-grouphead {
  padding: 0 12px 4px;
  font-family: "Alegreya SC", serif;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
@media (max-width: 1000px) {
  .tn-brand { width: auto; justify-content: flex-start; }
  .tn-brand img { height: 32px; }
}
@media (max-width: 768px) {
  .tn-links { display: none; }
  .tn-menu-btn { display: inline-flex; }
}

/* find and highlight panel */
.section input[type="text"] {
  background: #181410;
  border: 2px solid #050403;
  box-shadow: inset 0 3px 6px #000, inset 0 0 0 2px rgba(0, 0, 0, 0.4);
  color: var(--cream);
  border-radius: 0;
  outline: none;
  font-family: "Averia Serif Libre", serif;
  font-size: 15px;
  width: 100%;
  padding: 0 10px;
  height: 42px;
}
.section input[type="text"]:focus { box-shadow: inset 0 3px 6px #000, inset 0 0 0 2px rgba(216, 168, 80, 0.45); }
.find-results { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.find-results:empty, .find-presets:empty { display: none; }
.find-results button {
  text-align: left;
  padding: 6px 10px;
  font-size: 13.5px;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.6);
}
.find-results button:hover { background: rgba(216, 168, 80, 0.18); }
.find-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.find-presets button {
  padding: 7px 4px;
  font-family: "Alegreya", serif;
  font-size: 13px;
  color: var(--label);
  text-shadow: 1px 1px 0 #000;
}
.find-presets button:hover { filter: brightness(1.3); }
.find-nav { display: flex; gap: 6px; }
.find-nav button { flex: 1; }
.find-status { margin-top: 8px; font-size: 13px; color: var(--label); min-height: 16px; }

/* chest contents popup */
.chest-popup {
  position: absolute;
  z-index: 20;
  width: 280px;
  max-height: 60%;
  overflow-y: auto;
  background: rgba(14, 11, 8, 0.96);
  border: 2px solid #050403;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(160, 140, 110, 0.2);
  padding: 10px 12px;
}
.chest-popup h3 {
  font-family: "Alegreya SC", serif;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold, #e8c96a);
  margin: 0 0 6px;
}
.chest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13.5px;
  color: var(--cream, #f5e9c8);
  border-bottom: 1px solid rgba(160, 140, 110, 0.12);
}
.chest-item:last-child { border-bottom: 0; }
.chest-item img { width: 20px; height: 20px; object-fit: contain; image-rendering: pixelated; }
