/* ============================================================
   369craft — antique naturalist plate theme
   Aged parchment, sepia ink, muted botanical accents,
   old-print engraving typography. No image assets — the paper
   grain is an inline SVG turbulence filter.
   ============================================================ */

:root {
  --pixel-font: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --logo-font: 'IM Fell English SC', Georgia, 'Times New Roman', serif;

  --paper: #e9dfc6;
  --paper-hi: #f3ead4;
  --paper-lo: #d8c9a4;
  --ink: #3a2d1c;
  --ink-soft: #5c4a33;
  --oxblood: #7c3128;
  --olive: #5d6b3e;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.23 0 0 0 0 0.18 0 0 0 0 0.11 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14100a;
  font-family: var(--pixel-font);
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* the aged-print color grade for the whole 3D world */
  filter: sepia(0.26) saturate(0.78) contrast(0.95) brightness(1.02);
}

/* sepia vignette over the world (HUD and menus sit above it) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  background:
    var(--grain),
    radial-gradient(ellipse at center, transparent 52%, rgba(58, 42, 22, 0.36) 100%);
  mix-blend-mode: multiply;
}

.hidden { display: none !important; }

/* ======================= overlays ======================= */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#pause-menu, #options-menu, #controls-menu {
  background: rgba(32, 25, 14, 0.55);
  backdrop-filter: blur(1px);
}

/* the cover page: a full antique scrapbook plate */
#title-screen {
  pointer-events: auto;
  background:
    var(--grain),
    radial-gradient(ellipse at center, rgba(120, 90, 40, 0) 45%, rgba(120, 90, 40, 0.22) 100%),
    linear-gradient(#f1e9d4, #e6d9ba);
  box-shadow: inset 0 0 0 6px #ece2c8, inset 0 0 0 8px rgba(74, 58, 38, 0.55);
  overflow: hidden;
}

/* procedural pixel curios scattered on the page */
.t-deco {
  position: absolute;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(2px 3px 0 rgba(74, 58, 38, 0.18));
}
.td-moth-big { top: 3%; left: 5%; width: 170px; transform: rotate(-10deg); }
.td-wheel { top: 33%; left: 3%; width: 180px; transform: rotate(8deg); }
.td-stein { bottom: 3%; left: 5%; width: 150px; transform: rotate(-3deg); }
.td-moth-red { top: 13%; right: 6%; width: 130px; transform: rotate(-8deg); }
.td-bf-blue { bottom: 9%; right: 9%; width: 105px; transform: rotate(6deg); }
.td-swallow { bottom: 1%; left: 47%; width: 120px; transform: rotate(-4deg); }
.td-card-king { top: 37%; right: 7%; width: 130px; transform: rotate(9deg); }
.td-card-boat { top: 41%; right: 1.5%; width: 130px; transform: rotate(18deg); }

/* ======================= buttons ======================= */

.mc-button {
  font-family: var(--pixel-font);
  font-size: 21px;
  letter-spacing: 1px;
  color: var(--ink);
  background: linear-gradient(var(--paper-hi), #e0d2b0);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 252, 240, 0.55), 2px 3px 0 rgba(40, 30, 16, 0.35);
  padding: 7px 18px;
  min-width: 300px;
  cursor: pointer;
}
.mc-button:hover {
  background: var(--ink);
  color: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(255, 252, 240, 0.2), 2px 3px 0 rgba(40, 30, 16, 0.35);
}
.mc-button:active { transform: translateY(1px); }
.mc-button.small { min-width: 0; font-size: 18px; padding: 5px 12px; white-space: nowrap; }
.mc-button.toggle { min-width: 230px; }

/* ======================= title screen ======================= */

.title-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(620px, 94vw);
  padding: 10px 0;
  z-index: 1;
}

.mc-logo {
  font-family: var(--logo-font);
  font-size: clamp(54px, 11vw, 104px);
  color: #443628;
  letter-spacing: 2px;
  line-height: 1;
  text-shadow:
    0 1px 0 rgba(255, 252, 240, 0.55),
    3px 4px 0 rgba(58, 45, 28, 0.3),
    5px 7px 0 rgba(58, 45, 28, 0.14);
}

.mc-sublogo {
  font-family: 'VT323', var(--pixel-font);
  font-size: clamp(20px, 3.4vw, 30px);
  color: #4a3a26;
  letter-spacing: 5px;
  text-transform: uppercase;
  margin-top: -4px;
}

.ca-badge {
  font-family: var(--logo-font);
  font-size: 20px;
  letter-spacing: 3px;
  color: var(--oxblood);
  border: 2px solid var(--oxblood);
  outline: 1px solid var(--oxblood);
  outline-offset: 2px;
  padding: 4px 16px;
  margin-top: 4px;
  transform: rotate(-2deg);
  animation: ca-pulse 2.2s ease-in-out infinite;
}
@keyframes ca-pulse {
  0%, 100% { opacity: 0.78; }
  50% { opacity: 1; }
}

/* torn parchment banner pinned at the sublogo's right end */
.wave-clock {
  font-family: 'VT323', var(--pixel-font);
  font-size: 19px;
  letter-spacing: 1px;
  color: var(--olive);
  background: rgba(233, 223, 198, 0.7);
  border: 1px solid rgba(93, 107, 62, 0.55);
  padding: 3px 14px;
  margin-top: 2px;
}
.wave-clock b { color: var(--oxblood); }
.wave-clock:empty { display: none; }

.find-feed {
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.4;
}
.find-feed:empty { display: none; }

/* ink-drawn plate decorations */
.plate-deco {
  position: absolute;
  color: var(--ink);
  opacity: 0.5;
  pointer-events: none;
}
.deco-bf-tl {
  top: auto;
  bottom: -36px;
  left: -16px;
  transform: rotate(-14deg);
  animation: deco-flutter 5.5s ease-in-out infinite;
}
.deco-bf-bl {
  bottom: -54px;
  left: 40%;
  transform: rotate(10deg);
  opacity: 0.38;
  animation: deco-flutter 7s ease-in-out infinite reverse;
}
.deco-fern-br {
  bottom: -50px;
  right: -10px;
  transform: rotate(6deg);
  opacity: 0.42;
}
@keyframes deco-flutter {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50% { translate: 2px -4px; rotate: 5deg; }
}

.menu-buttons {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* wood-plank buttons with a bronze coin medallion hanging off the left */
.title-stack .mc-button {
  position: relative;
  font-family: 'VT323', var(--pixel-font);
  font-size: 28px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #2c2014;
  text-shadow: 0 1px 0 rgba(255, 240, 210, 0.35);
  background: linear-gradient(#a8845c, #8a6844 55%, #7a5a38);
  border: 3px solid #3a2c1a;
  box-shadow:
    inset 0 0 0 2px rgba(40, 28, 14, 0.45),
    inset 0 0 0 4px rgba(255, 240, 210, 0.16),
    3px 4px 0 rgba(58, 45, 28, 0.3);
  padding: 9px 20px;
  min-width: min(420px, 78vw);
}
.title-stack .mc-button:hover {
  background: linear-gradient(#b8946a, #9a7850 55%, #8a6a44);
  color: #1c1408;
}
.title-stack .mc-button.small {
  min-width: 0;
  font-size: 21px;
  letter-spacing: 2px;
  padding: 8px 14px;
}
.title-stack .mc-button::before {
  content: '';
  position: absolute;
  left: -36px;
  top: 50%;
  width: 74px;
  height: 74px;
  translate: 0 -50%;
  background: var(--coin-url) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(58, 45, 28, 0.3));
  pointer-events: none;
}
.title-stack .mc-button.small::before { width: 56px; height: 56px; left: -28px; }
.title-stack .mc-button:active { transform: translateY(2px); }

.seed-row { display: flex; gap: 10px; align-items: stretch; }

/* riveted steel seed plate */
#seed-input {
  font-family: 'VT323', var(--pixel-font);
  font-size: 20px;
  letter-spacing: 1px;
  width: 200px;
  background: linear-gradient(#c2c2c4, #969698);
  color: #26262a;
  border: 3px solid #3a3a3e;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3), 3px 4px 0 rgba(58, 45, 28, 0.3);
  padding: 6px 10px;
  outline: none;
}
#seed-input::placeholder { color: #54545a; }
#seed-input:focus { border-color: #1c1c20; }


/* ======================= menus ======================= */

.menu-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 26px 22px;
  background: var(--paper);
  background-image: var(--grain);
  border: 2px solid var(--ink);
  box-shadow:
    inset 0 0 0 4px var(--paper),
    inset 0 0 0 5px var(--ink),
    inset 0 0 50px rgba(120, 90, 40, 0.22),
    0 14px 40px rgba(0, 0, 0, 0.5);
}
.menu-stack.wide { width: min(580px, 92vw); }

.menu-title {
  font-family: var(--logo-font);
  font-size: 30px;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 252, 240, 0.6);
  margin-bottom: 10px;
}

.opt-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--ink);
  font-size: 19px;
}
.opt-row input[type="range"] {
  width: 100%;
  accent-color: var(--oxblood);
  cursor: pointer;
}
.opt-row.checks {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 8px 0;
}

.controls-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 28px;
  color: var(--ink);
  font-size: 19px;
  background: var(--paper-lo);
  border: 2px solid var(--ink-soft);
  padding: 14px 20px;
}
.controls-grid span:nth-child(odd) { color: var(--olive); }
.controls-note { color: var(--oxblood); font-style: italic; font-size: 17px; }

/* ======================= loading ======================= */

#loading-screen {
  background: linear-gradient(#e3d7b6, #c9b98e);
}
#loading-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grain), radial-gradient(ellipse at center, transparent 45%, rgba(90, 66, 30, 0.3) 100%);
  pointer-events: none;
}

.loading-stack { display: flex; flex-direction: column; align-items: center; gap: 16px; position: relative; }
.loading-text {
  font-family: var(--logo-font);
  color: var(--ink);
  font-size: 30px;
  text-shadow: 0 1px 0 rgba(255, 252, 240, 0.5);
}
.loading-bar {
  width: min(420px, 80vw);
  height: 12px;
  border: 2px solid var(--ink);
  background: var(--paper-hi);
  padding: 2px;
}
#loading-fill { height: 100%; width: 0%; background: var(--olive); transition: width 0.15s linear; }
.loading-tip { color: var(--ink-soft); font-style: italic; font-size: 19px; }

/* ======================= HUD ======================= */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: #ddd;
}
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }

/* --------- diviner's compass --------- */

#compass {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 104px;
  height: 104px;
  padding: 4px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 252, 240, 0.5), 2px 3px 0 rgba(40, 30, 16, 0.35);
  opacity: 0.95;
}
#minimap-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
.mm-north {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--logo-font);
  font-size: 11px;
  color: var(--ink);
  background: rgba(233, 223, 198, 0.8);
  padding: 0 4px;
  line-height: 1.1;
}
body.touch #compass { width: 76px; height: 76px; padding: 3px; }

#compass-dist {
  position: absolute;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'VT323', var(--pixel-font);
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--paper-hi);
  background: rgba(20, 16, 10, 0.5);
  padding: 0 8px;
  white-space: nowrap;
}
#compass-dist.near { color: #f0d9a0; }
body.touch #compass-dist { top: 80px; font-size: 15px; }

/* sits to the RIGHT of the minimap, clear of the buttons at the far edge */
#goal-banner {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(50% + 64px);
  max-width: calc(50% - 64px - 76px);
  text-align: left;
  line-height: 1.3;
  font-family: var(--pixel-font);
  font-style: italic;
  font-size: 16px;
  color: var(--ink);
  background: rgba(233, 223, 198, 0.92);
  border: 1px solid #a8842f;
  box-shadow: 0 0 10px rgba(212, 170, 60, 0.45), 2px 3px 0 rgba(40, 30, 16, 0.3);
  padding: 4px 10px;
  pointer-events: none;
  animation: ca-pulse 2s ease-in-out infinite;
}
#goal-banner b { color: var(--oxblood); font-style: normal; }
body.touch #goal-banner {
  top: calc(14px + env(safe-area-inset-top));
  left: calc(50% + 46px);
  max-width: calc(50% - 46px - 64px);
  font-size: 13px;
  padding: 3px 8px;
}
@keyframes compass-near {
  0%, 100% { filter: drop-shadow(2px 3px 2px rgba(20, 14, 6, 0.45)); }
  50% { filter: drop-shadow(0 0 10px rgba(232, 198, 110, 0.95)); }
}

/* --------- hotbar --------- */

#hotbar {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: rgba(233, 223, 198, 0.82);
  border: 2px solid var(--ink);
  outline: 1px solid rgba(233, 223, 198, 0.5);
  outline-offset: 1px;
}

.hotbar-slot {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(58, 45, 28, 0.30);
  border-right-width: 1px;
  border-left-width: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.hotbar-slot img { width: 44px; height: 44px; image-rendering: auto; }
.hotbar-slot .slot-num {
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 13px;
  color: var(--ink-soft);
}
.hotbar-slot.selected {
  border: 3px solid var(--ink);
  outline: 2px solid rgba(243, 234, 212, 0.9);
  z-index: 2;
}

#item-name {
  position: absolute;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--paper-hi);
  font-style: italic;
  font-size: 23px;
  text-shadow: 1px 2px 0 rgba(20, 14, 6, 0.85);
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* --------- debug (F3) --------- */

#debug {
  position: absolute;
  top: 6px;
  left: 6px;
  color: var(--paper-hi);
  font-size: 16px;
  line-height: 1.3;
  text-shadow: 1px 1px 0 #1a140a;
  background: rgba(40, 31, 16, 0.55);
  padding: 6px 10px;
  white-space: pre;
}

/* --------- permanent map button (desktop; touch uses tb-guide) --------- */

#map-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 50px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: var(--logo-font);
  font-size: 24px;
  line-height: 1;
  color: var(--oxblood);
  background: rgba(233, 223, 198, 0.92);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 252, 240, 0.5), 2px 3px 0 rgba(40, 30, 16, 0.35);
  pointer-events: auto;
  cursor: pointer;
}

.hud-btn-label,
.tb-label {
  display: block;
  font-family: 'VT323', var(--pixel-font);
  font-size: 12px;
  letter-spacing: 1px;
  line-height: 1;
  color: var(--ink-soft);
}
#map-btn:hover { background: var(--paper-hi); }
body.touch #map-btn { display: none; }

#quest-btn {
  position: absolute;
  top: 76px;
  right: 12px;
  width: 50px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: var(--logo-font);
  font-size: 24px;
  line-height: 1;
  color: #8a6a20;
  background: rgba(233, 223, 198, 0.92);
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 252, 240, 0.5), 2px 3px 0 rgba(40, 30, 16, 0.35);
  pointer-events: auto;
  cursor: pointer;
}
#quest-btn:hover { background: var(--paper-hi); }
body.touch #quest-btn { display: none; }

/* ---- quest list ---- */
.quests-window { max-width: min(560px, 96vw); }
#quest-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px 2px;
}
.q-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--paper-hi);
  border: 2px solid var(--ink-soft);
}
.q-row.q-hunter { border-color: #a8842f; box-shadow: inset 0 0 14px rgba(212, 170, 60, 0.18); }
.q-row.q-legend { border-color: var(--oxblood); box-shadow: inset 0 0 16px rgba(124, 49, 40, 0.16); }
.q-prize {
  font-family: var(--logo-font);
  font-size: 28px;
  color: var(--ink);
  min-width: 74px;
  text-align: center;
}
.q-prize small { font-size: 15px; }
.q-legend .q-prize { color: var(--oxblood); }
.q-hunter .q-prize { color: #8a6a20; }
.q-info { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.q-info b { font-family: var(--logo-font); font-size: 16px; color: var(--ink); font-weight: normal; }
.q-info i { font-size: 14px; color: var(--ink-soft); }
.q-empty { font-style: italic; font-size: 15px; color: var(--ink-soft); text-align: center; padding: 6px; }
.q-row.q-free .q-prize { color: var(--olive); font-size: 24px; }
.q-row.q-active { background: #f6efdd; box-shadow: inset 0 0 0 2px var(--olive); }
.q-row.q-locked { opacity: 0.6; }
.q-sealed {
  font-family: 'VT323', var(--pixel-font);
  font-size: 16px;
  color: var(--ink-soft);
  white-space: nowrap;
  padding: 0 6px;
}
body.touch #tb-quests {
  top: calc(64px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 48px;
  height: 52px;
  font-size: 24px;
  line-height: 1;
  flex-direction: column;
  gap: 1px;
  font-family: var(--logo-font);
  color: #f0d9a0;
  border-color: rgba(232, 198, 110, 0.7);
}

/* --------- live bounty tracker --------- */

#bounty-tracker {
  position: absolute;
  top: 12px;
  left: 12px;
  font-family: 'VT323', var(--pixel-font);
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 1px;
  color: var(--ink);
  background: rgba(233, 223, 198, 0.85);
  border: 1px solid var(--ink-soft);
  box-shadow: 2px 3px 0 rgba(40, 30, 16, 0.3);
  padding: 5px 12px;
  pointer-events: auto;
  cursor: pointer;
}
#bounty-tracker:empty { display: none; }
#bounty-tracker b { color: var(--oxblood); }
body.touch #bounty-tracker {
  top: calc(64px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  font-size: 13px;
  max-width: 158px;
  white-space: normal;
}

/* --------- water / effects --------- */

#underwater-overlay {
  position: absolute;
  inset: 0;
  background: rgba(44, 74, 80, 0.30);
  opacity: 0;
  transition: opacity 0.2s;
}

#damage-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 120px rgba(150, 44, 24, 0.85);
  opacity: 0;
  transition: opacity 0.1s;
}

/* ======================= picker ======================= */

#picker { background: rgba(32, 25, 14, 0.5); pointer-events: auto; }

.picker-window {
  background: var(--paper);
  background-image: var(--grain);
  border: 2px solid var(--ink);
  box-shadow:
    inset 0 0 0 4px var(--paper),
    inset 0 0 0 5px var(--ink),
    inset 0 0 50px rgba(120, 90, 40, 0.22),
    0 14px 40px rgba(0, 0, 0, 0.5);
  padding: 16px 18px;
  max-width: min(640px, 94vw);
}

.picker-title {
  font-family: var(--logo-font);
  font-size: 23px;
  color: var(--ink);
  margin-bottom: 10px;
}
.picker-hint { font-family: var(--pixel-font); font-style: italic; font-size: 15px; color: var(--ink-soft); }

#picker-grid {
  display: grid;
  grid-template-columns: repeat(9, 52px);
  gap: 4px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--paper-lo);
  border: 2px solid var(--ink-soft);
  box-shadow: inset 2px 2px 0 rgba(90, 70, 40, 0.35), inset -2px -2px 0 rgba(255, 250, 235, 0.5);
}

.picker-cell {
  width: 52px;
  height: 52px;
  background: #d2c29a;
  border: 1px solid #b3a178;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.picker-cell:hover { background: #c2ae82; border-color: var(--ink-soft); }
.picker-cell img { width: 42px; height: 42px; }

.picker-hotbar {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 4px;
}
.picker-hotbar .hotbar-slot {
  background: #d2c29a;
  border: 2px solid var(--ink-soft);
  cursor: pointer;
}
.picker-hotbar .hotbar-slot.selected { border-color: var(--ink); background: #c2ae82; }

.picker-done { display: block; margin: 12px auto 0; }

/* tooltip */
.picker-cell::after {
  content: attr(data-name);
  position: absolute;
  bottom: 105%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper-hi);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 16px;
  padding: 2px 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.picker-cell:hover::after { opacity: 1; }

/* scrollbars */
#picker-grid::-webkit-scrollbar { width: 12px; }
#picker-grid::-webkit-scrollbar-track { background: #c2b186; }
#picker-grid::-webkit-scrollbar-thumb { background: #8a7450; border: 2px solid #6e5c3e; }

/* ======================= wayfarer's grimoire ======================= */

#grimoire { background: rgba(32, 25, 14, 0.66); pointer-events: auto; z-index: 24; }

.grimoire-window {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: min(960px, 96vw);
  max-height: 94vh;
  overflow-y: auto;
  padding: 22px 18px 18px;
  background: var(--paper);
  background-image: var(--grain);
  border: 2px solid var(--ink);
  box-shadow:
    inset 0 0 0 4px var(--paper),
    inset 0 0 0 5px var(--ink),
    inset 0 0 60px rgba(120, 90, 40, 0.25),
    0 18px 50px rgba(0, 0, 0, 0.55);
}

.grimoire-title {
  font-family: var(--logo-font);
  font-size: 32px;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 252, 240, 0.6);
}
.grimoire-sub { font-style: italic; font-size: 17px; color: var(--ink-soft); margin-top: -6px; }

.grimoire-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  padding: 8px 2px;
}

.g-card {
  position: relative;
  width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 14px 12px 12px;
  background: var(--paper-hi);
  background-image: var(--grain);
  border: 2px solid var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--paper-hi),
    inset 0 0 0 4px rgba(74, 58, 38, 0.55),
    3px 5px 0 rgba(58, 45, 28, 0.3);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.2s ease;
}
.g-card:hover { transform: rotate(0deg) translateY(-4px) scale(1.03); z-index: 2; }
.g-card-gold { border-color: var(--oxblood); }
.g-card-gold .g-num { color: var(--oxblood); border-color: var(--oxblood); }

.g-num {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: var(--logo-font);
  font-size: 15px;
  color: var(--ink-soft);
  border: 1px solid var(--ink-soft);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  line-height: 22px;
}

.g-art {
  width: 86px;
  height: 76px;
  color: var(--ink);
  opacity: 0.8;
  margin-top: 2px;
}
.g-card-gold .g-art { color: #8a6a20; opacity: 0.9; }

.g-name {
  font-family: var(--logo-font);
  font-size: 19px;
  color: var(--ink);
  line-height: 1.1;
}

.g-text {
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink-soft);
  min-height: 76px;
}
.g-text b { color: var(--oxblood); }

.g-word {
  font-family: 'VT323', var(--pixel-font);
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--ink);
  border: 1px dashed var(--ink-soft);
  padding: 2px 12px;
}
.g-word-gold { color: #8a6a20; border-color: #8a6a20; }

.g-travel { margin-top: 2px; width: 100%; }

.grimoire-note { font-style: italic; font-size: 15px; color: var(--ink-soft); }

.comp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.comp-label { font-size: 17px; color: var(--ink); }
.comp-sel {
  background: var(--olive) !important;
  color: var(--paper-hi) !important;
  border-color: var(--ink) !important;
}
.comp-hint { font-style: italic; font-size: 14px; color: var(--olive); margin-top: -4px; }

@media (max-width: 560px) {
  .grimoire-window { padding: 16px 10px 14px; }
  .grimoire-title { font-size: 25px; }
  .grimoire-cards { gap: 10px; }
  .g-card { width: 165px; }
  .g-text { font-size: 13px; min-height: 84px; }
}

/* ======================= character select ======================= */

#char-select { background: rgba(32, 25, 14, 0.7); pointer-events: auto; z-index: 25; }

.charsel-window { max-width: min(620px, 96vw); }

.charsel-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 6px 0;
}

.hero-card {
  width: 102px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px 7px;
  background: var(--paper-hi);
  border: 2px solid var(--ink-soft);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.hero-card:hover { transform: translateY(-3px); }
.hero-card img {
  width: 64px;
  height: auto;
  image-rendering: pixelated;
}
.hero-card .hc-name {
  font-family: 'VT323', var(--pixel-font);
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--ink);
}
.hero-card.hero-sel {
  border-color: var(--oxblood);
  background: #f6efdd;
  box-shadow: 0 0 0 2px rgba(124, 49, 40, 0.35), 3px 4px 0 rgba(58, 45, 28, 0.3);
}

.charsel-namerow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
#username-input {
  font-family: 'VT323', var(--pixel-font);
  font-size: 21px;
  letter-spacing: 1px;
  width: 200px;
  background: var(--paper-hi);
  color: var(--ink);
  border: 2px solid var(--ink-soft);
  padding: 5px 10px;
  outline: none;
}
#username-input:focus { border-color: var(--oxblood); }

@media (max-width: 560px) {
  .hero-card { width: 84px; }
  .hero-card img { width: 52px; }
}

/* ======================= incantation console ======================= */

#console-bar {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: min(420px, 80vw);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  background-image: var(--grain);
  border: 2px solid var(--ink);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  padding: 7px 12px;
  z-index: 26;
}
.console-prompt {
  font-family: 'VT323', var(--pixel-font);
  font-size: 22px;
  color: var(--oxblood);
}
#console-input {
  flex: 1;
  font-family: 'VT323', var(--pixel-font);
  font-size: 21px;
  letter-spacing: 1px;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
}

/* ======================= bounty card ======================= */

#bounty-card, #bounty-intro { background: rgba(32, 25, 14, 0.6); pointer-events: auto; }

.intro-text { font-size: 18px; max-width: 360px; line-height: 1.45; }
.intro-text b { color: var(--oxblood); }

/* the 8-second quest sheet */
.intro-sheet { width: min(470px, 94vw); gap: 6px; }
.intro-rows {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  margin: 8px 0 6px;
  text-align: left;
}
.i-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 1px dashed rgba(92, 74, 51, 0.3);
  padding-bottom: 7px;
}
.i-row:last-child { border-bottom: none; padding-bottom: 0; }
.i-key {
  flex: 0 0 96px;
  font-family: var(--logo-font);
  font-size: 15px;
  color: var(--oxblood);
  text-align: right;
}
.i-txt { font-size: 15.5px; line-height: 1.3; color: var(--ink); }
.i-txt b { color: var(--oxblood); }
#intro-wave { color: var(--olive); }

.bounty-window {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  width: min(440px, 92vw);
  padding: 30px 26px 24px;
  background: var(--paper);
  background-image: var(--grain);
  border: 2px solid var(--oxblood);
  box-shadow:
    inset 0 0 0 4px var(--paper),
    inset 0 0 0 5px var(--oxblood),
    inset 0 0 60px rgba(120, 90, 40, 0.25),
    0 18px 50px rgba(0, 0, 0, 0.55);
  animation: bounty-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bounty-in {
  from { transform: scale(0.6) rotate(-3deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.deco-bf-bounty {
  top: 10px;
  right: 12px;
  transform: rotate(12deg);
  opacity: 0.45;
  animation: deco-flutter 5s ease-in-out infinite;
}

.bounty-kicker {
  font-style: italic;
  font-size: 19px;
  color: var(--olive);
  letter-spacing: 2px;
}

.bounty-title {
  font-family: var(--logo-font);
  font-size: 40px;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 252, 240, 0.6), 2px 2px 0 rgba(58, 45, 28, 0.18);
}

.bounty-sub {
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
}

.bounty-prize-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 2px 12px;
}
.bounty-prize-row::before {
  content: '';
  position: absolute;
  inset: -14px -30px;
  background: radial-gradient(ellipse, rgba(198, 160, 70, 0.45), transparent 70%);
  animation: prize-glow 1.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes prize-glow {
  0%, 100% { opacity: 0.5; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.06); }
}

.bounty-prize {
  position: relative;
  font-family: var(--logo-font);
  font-size: 54px;
  line-height: 1.05;
  color: var(--oxblood);
  text-shadow: 0 1px 0 rgba(255, 252, 240, 0.55);
  animation: ca-pulse 2s ease-in-out infinite;
}

.bounty-spark {
  position: relative;
  font-size: 28px;
  color: #a8842f;
  animation: spark-twinkle 1.4s ease-in-out infinite;
}
.bounty-spark:last-child { animation-delay: 0.7s; }
@keyframes spark-twinkle {
  0%, 100% { opacity: 0.4; transform: scale(0.85) rotate(-8deg); }
  50% { opacity: 1; transform: scale(1.2) rotate(8deg); }
}

.bounty-code-label {
  font-size: 15px;
  letter-spacing: 3px;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin-top: 4px;
}

.bounty-code {
  font-family: var(--logo-font);
  font-size: 26px;
  letter-spacing: 5px;
  color: var(--ink);
  background: var(--paper-hi);
  border: 2px dashed var(--ink-soft);
  padding: 6px 16px;
  user-select: text;
  -webkit-user-select: text;
}

.bounty-note {
  font-size: 16px;
  font-style: italic;
  color: var(--ink-soft);
  max-width: 340px;
}

.bounty-count {
  font-size: 16px;
  color: var(--olive);
  margin-bottom: 4px;
}

.bounty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.share-btn {
  background: linear-gradient(#2c2c30, #161618);
  color: #f0e7d0;
  border-color: #000;
}
.share-btn:hover { background: #000; color: #fff; }

@media (max-width: 560px) {
  .bounty-title { font-size: 32px; }
  .bounty-prize { font-size: 44px; }
  .bounty-code { font-size: 21px; letter-spacing: 3px; }
}

/* ======================= touch controls ======================= */

.touch-row { display: none; }
body.touch .touch-row { display: block; }
body.touch .picker-hint { display: none; }

#touch-layer {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  touch-action: none;
}

.touch-look {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: none;
}

.touch-joy-zone {
  position: absolute;
  left: 0;
  bottom: calc(64px + env(safe-area-inset-bottom));
  width: 46%;
  height: 44%;
  pointer-events: auto;
  touch-action: none;
}

.touch-joy-base {
  position: fixed;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 2px solid rgba(233, 223, 198, 0.55);
  background: rgba(40, 31, 16, 0.28);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-joy-nub {
  position: fixed;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(233, 223, 198, 0.6);
  border: 2px solid rgba(58, 45, 28, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.touch-btn {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper-hi);
  font-family: var(--pixel-font);
  background: rgba(40, 31, 16, 0.45);
  border: 2px solid rgba(233, 223, 198, 0.5);
  text-shadow: 1px 1px 0 rgba(20, 14, 6, 0.8);
  user-select: none;
  -webkit-user-select: none;
}
.touch-btn.held { background: rgba(233, 223, 198, 0.35); }

#tb-jump {
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(132px + env(safe-area-inset-bottom));
  width: 78px;
  height: 78px;
  border-radius: 50%;
  font-size: 36px;
}

#tb-sneak {
  right: calc(112px + env(safe-area-inset-right));
  bottom: calc(104px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 26px;
}
#tb-sneak.on {
  background: rgba(93, 107, 62, 0.6);
  border-color: #d8e0b0;
}

#tb-pause {
  top: calc(10px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 48px;
  height: 44px;
  font-size: 17px;
}

#tb-inv {
  top: calc(10px + env(safe-area-inset-top));
  right: calc(70px + env(safe-area-inset-right));
  width: 48px;
  height: 44px;
  font-size: 24px;
}

#tb-guide {
  top: calc(10px + env(safe-area-inset-top));
  right: calc(128px + env(safe-area-inset-right));
  width: 48px;
  height: 52px;
  font-size: 24px;
  line-height: 1;
  flex-direction: column;
  gap: 1px;
  font-family: var(--logo-font);
  color: #f0d9a0;
  border-color: rgba(232, 198, 110, 0.7);
}
#tb-guide .tb-label, #tb-quests .tb-label { color: rgba(240, 231, 208, 0.85); font-size: 11px; }

/* left-side buttons (right side is pause/inv/guide, center is the compass) */
#tb-help {
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  width: 48px;
  height: 44px;
  font-size: 24px;
}

#tb-photo {
  top: calc(10px + env(safe-area-inset-top));
  left: calc(70px + env(safe-area-inset-left));
  width: 48px;
  height: 44px;
  font-size: 22px;
}

/* ======================= phone layout ======================= */

body.touch #hud { z-index: 14; }       /* hotbar above the touch layer */
body.touch #hotbar { pointer-events: auto; }
body.touch #crosshair { width: 18px; height: 18px; }

@media (max-width: 560px) {
  .hotbar-slot { width: 42px; height: 42px; }
  .hotbar-slot img { width: 34px; height: 34px; }
  .hotbar-slot .slot-num { display: none; }
  #hotbar { bottom: calc(6px + env(safe-area-inset-bottom)); }
  #item-name { bottom: calc(58px + env(safe-area-inset-bottom)); font-size: 19px; }

  .mc-logo { letter-spacing: 1px; }
  .mc-button { min-width: 260px; font-size: 19px; }
  .mc-button.small { font-size: 15px; }
  .title-stack .mc-button { font-size: 22px; min-width: min(330px, 76vw); }
  .title-stack .mc-button.small { font-size: 16px; letter-spacing: 1px; padding: 8px 10px; }
  .title-stack .mc-button::before { width: 54px; height: 54px; left: -24px; }
  .title-stack .mc-button.small::before { display: none; }
  #seed-input { width: 118px; font-size: 16px; }

  /* fewer, smaller curios on a phone */
  .td-moth-big { width: 100px; top: 2%; left: 2%; }
  .td-wheel { width: 96px; top: auto; bottom: 20%; left: 2%; }
  .td-stein { width: 84px; bottom: 4%; left: 4%; }
  .td-moth-red { width: 84px; top: 9%; right: 3%; }
  .td-bf-blue { width: 70px; bottom: 22%; right: 4%; }
  .td-swallow { display: none; }
  .td-card-king { width: 86px; top: auto; bottom: 5%; right: 16%; }
  .td-card-boat { width: 86px; top: auto; bottom: 3%; right: 2%; }
  .menu-stack.wide { width: 94vw; }
  .menu-stack { padding: 20px 14px 18px; }
  .controls-grid { font-size: 16px; gap: 3px 16px; padding: 10px 14px; }

  #picker-grid { grid-template-columns: repeat(7, 46px); max-height: 44vh; }
  .picker-cell { width: 46px; height: 46px; }
  .picker-cell img { width: 38px; height: 38px; }
  .picker-window { padding: 12px; }
  .picker-hotbar .hotbar-slot { width: 38px; height: 38px; }
  .picker-hotbar .hotbar-slot img { width: 30px; height: 30px; }
}

#webgl-error .menu-title { color: var(--oxblood); }

/* --------- the Discovery Log (inside the Fast Travel book) --------- */

.disc-head {
  font-family: 'VT323', var(--pixel-font);
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--oxblood);
  margin-top: 10px;
}
.disc-head span { color: var(--ink); }
.disc-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 7px;
  max-width: 560px;
  margin-top: 6px;
}
.disc-chip {
  font-family: 'VT323', var(--pixel-font);
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--ink-soft);
  background: rgba(233, 223, 198, 0.55);
  border: 1px solid rgba(74, 58, 38, 0.35);
  padding: 1px 8px;
  opacity: 0.55;
}
.disc-chip.on {
  opacity: 1;
  color: var(--oxblood);
  border-color: #a8842f;
  box-shadow: 0 0 6px rgba(212, 170, 60, 0.35);
}

/* --------- the World Map plate --------- */

.map-window { max-width: min(98vw, 920px); }
.map-wrap { position: relative; margin-top: 6px; }
.map-zoom {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-zoom .mc-button.small {
  min-width: 0;
  width: 40px;
  font-size: 22px;
  padding: 2px 0;
  line-height: 1.1;
}
#worldmap-canvas {
  width: min(94vw, 80vh, 760px);
  height: min(94vw, 80vh, 760px);
  touch-action: none;
  image-rendering: pixelated;
  border: 2px solid var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 252, 240, 0.5), 2px 3px 0 rgba(40, 30, 16, 0.35);
  background: var(--paper-lo);
  cursor: grab;
}
.map-legend {
  font-family: 'VT323', var(--pixel-font);
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--ink-soft);
  display: flex;
  gap: 16px;
  margin-top: 4px;
}
.map-legend .lg-trial { color: #a8842f; }
.map-legend .lg-wonder { color: var(--oxblood); }
.map-btnrow { display: flex; gap: 10px; margin-top: 8px; }

/* a nameless traveller may not set forth */
#username-input.name-needed {
  border-color: #a03028 !important;
  animation: name-shake 0.4s;
}
@keyframes name-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* the public bounty pool, verifiable on-chain */
.pool-line { font-family: 'VT323', var(--pixel-font); font-size: 15px; color: var(--ink-soft); }
.pool-line a { color: var(--oxblood); }
.map-legend .lg-minor { color: var(--olive); }
