:root {
  --color-sea: #47aab4;
  --color-wood-dark: #3a2731;
  --color-cream: #f4e7d0;
  --color-gold: #f3b340;
  --color-red: #e04a3f;
  --color-blue: #4aa0dd;
  --color-green: #5d9c46;
  --color-quality-fine: #4a8fc4;   /* backpack rim for FINE items */
  --color-paper: #fff6e4;          /* HUD slot fill */
  --color-muted: #7a5b32;          /* secondary HUD text */
  --font-pixel: 'Press Start 2P', 'Courier New', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--color-sea);
  overflow: hidden;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  /* Scaled by JS to fit window while keeping 5:3 aspect ratio */
  image-rendering: pixelated;
  display: block;
}

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 43, 52, 0.55);
  z-index: 10;
}

.overlay.hidden { display: none; }

/* Scene change cover (fadeScene in game.js): sits above every overlay */
#scene-fade {
  position: absolute;
  inset: 0;
  background: #14202a;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;   /* reveal: slower, so the new scene eases in */
  z-index: 50;
}

/* New version ribbon (checkForNewBuild): top centre, above overlays, under the scene fade */
.update-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--color-cream);
  background: var(--color-wood-dark);
  border-radius: 8px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.update-banner.hidden { display: none; }

#scene-fade.is-active {
  opacity: 1;
  pointer-events: auto;   /* swallow clicks while the scene swaps */
  transition: opacity 0.6s ease-in;
}

@media (prefers-reduced-motion: reduce) {
  #scene-fade { transition-duration: 0.12s; }
}

/* Global "hide" utility — also covers buttons/inputs that get .hidden toggled */
.hidden { display: none !important; }

.panel {
  background: var(--color-cream);
  border: 6px solid var(--color-wood-dark);
  border-radius: 14px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
  padding: 40px 56px;
  text-align: center;
  font-family: var(--font-pixel);
  color: var(--color-wood-dark);
}

.panel h1 {
  font-size: 32px;
  margin-bottom: 30px;
  text-shadow: 3px 3px 0 var(--color-gold);
}

.panel .subtitle {
  font-size: 13px;
  margin: -16px 0 28px;
  color: #7a5c44;
}

.panel .controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 11px;
  margin-bottom: 18px;
  line-height: 1.6;
}

.panel .hint {
  font-size: 9px;
  color: #9b7e63;
  margin-bottom: 26px;
}

/* Start-screen note: 2 lines, breathing room from buttons, no panel widening */
.start-hint {
  max-width: 390px;
  margin: 20px auto 0;
  line-height: 1.9;
}

.btn {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #fff;
  background: var(--color-blue);
  border: 4px solid var(--color-wood-dark);
  border-radius: 10px;
  box-shadow: 0 5px 0 var(--color-wood-dark);
  padding: 14px 36px;
  cursor: pointer;
  transition: transform 0.05s;
}

.btn:hover { filter: brightness(1.1); }

.btn:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 var(--color-wood-dark);
}

/* War spoils banked to the kingdom, shown on the end-of-run screens */
.panel .spoils {
  font-size: 10px;
  color: #4e8f43;
  margin: 6px 0 14px;
  min-height: 12px;
}

.panel .best {
  font-size: 11px;
  color: var(--color-gold);
  text-shadow: 1px 1px 0 var(--color-wood-dark);
  margin: -12px 0 22px;
  min-height: 11px;
}

/* ---------- Upgrade picker ---------- */

.upgrade-row {
  display: flex;
  gap: 18px;
  justify-content: center;
}

.upgrade-btn {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  min-width: 170px;
  padding: 18px 16px;
  font-size: 12px;
}

.upgrade-btn .up-desc {
  font-size: 9px;
  color: #dceeff;
}

/* Build menu (adventure plots) reuses the upgrade-card layout; options the
   player can't afford stay visible but muted */
.upgrade-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.build-funds {
  font-size: 10px;
  color: var(--color-gold);
  text-shadow: 1px 1px 0 var(--color-wood-dark);
  margin: 18px 0;
}

/* Mode gate confirm panel (Story/Survival entered via world NPCs) */
.gate-panel { max-width: 560px; }

.gate-panel h1 {
  font-size: 26px;
  margin-bottom: 12px;
}

/* The shared .subtitle tucks itself under a big h1 with a negative margin;
   here the speaker's name sits in between, so give it room back */
.gate-panel .subtitle {
  margin-top: 0;
  line-height: 1.7;
}

.gate-avatar {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 6px;
  image-rendering: pixelated;
}

.gate-name {
  font-size: 10px;
  color: var(--color-gold);
  text-shadow: 1px 1px 0 var(--color-wood-dark);
  margin-bottom: 14px;
}


.btn-row {
  display: flex;
  gap: 18px;
  justify-content: center;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
}

.btn-stack-item { min-width: 280px; }

.btn-primary {
  background: var(--color-gold);
  color: var(--color-wood-dark);
}

.btn-secondary {
  font-size: 12px;
  padding: 12px 28px;
  box-shadow: 0 4px 0 var(--color-wood-dark);
}

/* ---------- Mode picker ---------- */

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
}

.mode-card {
  font-family: var(--font-pixel);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 460px;
  max-width: 100%;
  padding: 22px 26px;
  color: #fff;
  background: var(--color-blue);
  border: 4px solid var(--color-wood-dark);
  border-radius: 12px;
  box-shadow: 0 6px 0 var(--color-wood-dark);
  cursor: pointer;
  transition: filter 0.1s;
}

.mode-card-red { background: var(--color-red); }
.mode-card-green { background: var(--color-green); }

.mode-card:not(:disabled):hover { filter: brightness(1.1); }

.mode-card:not(:disabled):active {
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--color-wood-dark);
}

/* ---------- Adventure ledger (key I) ---------- */

.ledger-panel { min-width: 720px; }
.ledger-panel-wide { min-width: 980px; }

.ledger-hint {
  font-size: 8px;
  color: rgba(58, 39, 49, 0.6);
  margin: 0 0 8px;
}

.btn-tiny {
  font-size: 8px;
  padding: 6px 10px;
  border-width: 2px;
  box-shadow: 0 2px 0 var(--color-wood-dark);
}

.btn-tiny:active { transform: translateY(2px); box-shadow: 0 0 0 var(--color-wood-dark); }

.btn-tiny:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.ledger-cols {
  display: flex;
  gap: 44px;
  justify-content: center;
  text-align: left;
  margin: 26px 0 22px;
}

.ledger-col { width: 280px; }

.ledger-col h2 {
  font-size: 12px;
  margin: 18px 0 10px;
  color: var(--color-wood-dark);
}

.ledger-col h2:first-child { margin-top: 0; }

.ledger-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  padding: 5px 0;
}

.ledger-row img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.ledger-label { flex: 1; line-height: 1.6; }

.ledger-val { color: #7a5b32; white-space: nowrap; }

.skill-bar {
  height: 10px;
  background: rgba(58, 39, 49, 0.22);
  border: 2px solid var(--color-wood-dark);
  border-radius: 4px;
  margin: 2px 0 10px;
  overflow: hidden;
}

.skill-fill { height: 100%; background: var(--color-gold); }

.ledger-date {
  font-size: 8px;
  color: rgba(58, 39, 49, 0.6);
  margin: 0 0 8px;
}

.quest-done .ledger-label,
.quest-done .ledger-val { color: #3a7d44; }

.quest-reward {
  font-size: 8px;
  color: rgba(58, 39, 49, 0.6);
  margin: 0 0 10px;
}

/* ---------- Adventure HUD (HTML over the canvas) ----------
   z-index 4: above the canvas, under the touch controls (5) and every menu
   overlay (10). The layer ignores the pointer; only its buttons take clicks. */

.hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  font-family: var(--font-pixel);
  color: var(--color-wood-dark);
}

.hud.hidden { display: none; }

.hud img { image-rendering: pixelated; }

.hud-card {
  background: var(--color-cream);
  border: 4px solid var(--color-wood-dark);
  border-radius: 12px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

.hud-bar {
  display: block;
  height: 7px;
  border: 2px solid var(--color-wood-dark);
  border-radius: 4px;
  background: rgba(58, 39, 49, 0.18);
  overflow: hidden;
}

.hud-bar i { display: block; height: 100%; background: var(--color-gold); }

/* 1 — profile card (see the profile block at the end of this file) */
.hud-avatar {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border: 3px solid var(--color-wood-dark);
  border-radius: 10px;
  background: #8fbf5a url('assets/avatar_knight.png') center / cover;
  image-rendering: pixelated;
}

.hud-name { font-size: 11px; }
.hud-region { font-size: 8px; color: var(--color-muted); min-height: 8px; }
/* Players online: a green dot and the count (watchOnline in game.js) */
.hud-online { font-size: 7px; color: var(--color-green); }
.hud-online:not(:empty)::before,
.online-count::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  vertical-align: 1px;
  background: var(--color-green);
  border-radius: 50%;
}
.online-count { font-size: 9px; color: var(--color-green); margin: 4px 0 0; }
.online-count.hidden { display: none; }

/* 3 — menu buttons */
.hud-menu {
  position: absolute;
  right: 16px;
  top: 206px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hud-btn {
  position: relative;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.08s;
}

.hud-btn:hover { transform: translateY(-2px); }
.hud-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.hud-btn img { width: 46px; height: 46px; }

.hud-key {
  position: absolute;
  left: -9px;
  bottom: -9px;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--color-cream);
  background: var(--color-wood-dark);
  border: 2px solid var(--color-cream);
  border-radius: 6px;
}

.hud-dot {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-red);
  border: 3px solid var(--color-cream);
}

.hud-dot.hidden { display: none; }

/* 4 — tool hotbar */
.hud-hotbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 9px;
}

.hud-slot {
  position: relative;
  width: 68px;
  height: 68px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--color-paper);
  border: 3px solid var(--color-wood-dark);
  border-radius: 10px;
  cursor: pointer;
  pointer-events: auto;
}

.hud-slot.on { background: var(--color-gold); transform: translateY(-4px); }

/* Home perks: the build confirm's perk line, and perks not active yet in the ledger */
.build-perk { margin: 12px 0 0; font-family: var(--font-body); font-size: 14px; color: var(--color-wood-dark); }
.build-perk b { font-family: var(--font-pixel); font-size: 9px; color: #b07d1e; }
.perk-off .ledger-label, .perk-off .ledger-val { opacity: 0.55; }

/* Build mode: "< COTTAGE  30 WOOD  40 GOLD >" over the hotbar */
.build-pill {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  white-space: nowrap;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--color-cream);
  background: var(--color-wood-dark);
  border-radius: 8px;
  pointer-events: auto;
}
.build-pill-name { color: var(--color-gold); }
.build-pill-body { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.build-pill-row { display: flex; gap: 10px; }
.build-pill-perk { font-size: 7px; color: #9fe07a; }
.build-pill-short { color: #ff8a7a; }
.build-pill-step {
  width: 30px;
  height: 30px;
  padding: 0;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--color-wood-dark);
  background: var(--color-paper);
  border: 2px solid var(--color-wood-dark);
  border-radius: 6px;
  cursor: pointer;
}
.build-pill-step:active { background: var(--color-gold); }
.hud-slot img { width: 52px; height: 52px; }

.hud-slot-n {
  position: absolute;
  top: 4px;
  left: 6px;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--color-wood-dark);
}

/* 5 — notice ribbons */
.hud-notices {
  position: absolute;
  top: 128px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hud-notice {
  padding: 10px 22px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--color-cream);
  background: var(--color-wood-dark);
  border: 3px solid var(--color-gold);
  border-radius: 10px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}

/* 6 — minimap */
.hud-minimap {
  position: absolute;
  left: 16px;
  bottom: 16px;
  padding: 8px;
}

.hud-minimap canvas { display: block; width: 192px; height: 132px; border-radius: 6px; }
.hud-mm-label { margin-top: 6px; font-size: 7px; text-align: center; min-height: 7px; }

/* Map screen (key M) */
.map-panel { width: min(720px, 94vw); }

#map-canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 10px 0 12px;
  border: 4px solid var(--color-wood-dark);
  border-radius: 10px;
  image-rendering: pixelated;
}

/* Smaller screens and phones: compact player card (skills live in the
   ledger), minimap tucked under it so the joystick keeps the bottom-left */
@media (max-width: 900px), (max-height: 560px) {
  .hud-menu { top: 150px; gap: 9px; }
  .hud-btn { width: 50px; height: 50px; }
  .hud-btn img { width: 36px; height: 36px; }
  .hud-slot { width: 54px; height: 54px; }
  .hud-slot img { width: 40px; height: 40px; }
  .hud-minimap { left: 16px; top: 146px; bottom: auto; padding: 5px; }
  .hud-minimap canvas { width: 128px; height: 88px; }
  .hud-mm-label { display: none; }
}

/* Short screens (phones in landscape): smaller menu buttons, still a column
   on the right (four buttons clear the touch action button) */
@media (max-height: 560px) {
  .hud-btn { width: 44px; height: 44px; }
  .hud-btn img { width: 32px; height: 32px; }
  .hud-key { min-width: 18px; height: 18px; font-size: 7px; left: -6px; bottom: -6px; }
  .hud-notices { top: 74px; }
}

/* Hotbar slot with a crafted tool: tier badge + durability bar */
.hud-slot-tier {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 3px;
  font-family: var(--font-pixel);
  font-size: 6px;
  color: #fff;
  border-radius: 3px;
}

.hud-slot-dur {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 5px;
  height: 5px;
  border-radius: 3px;
  background: rgba(58, 39, 49, 0.25);
  overflow: hidden;
}

.hud-slot-dur i { display: block; height: 100%; }

/* ---------- Smith Brann's forge ---------- */

.forge-panel { width: min(760px, 94vw); }

.forge-tabs { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.forge-tab { opacity: 0.6; }
.forge-tab.active { opacity: 1; }

.forge-finest {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 8px;
  margin-bottom: 10px;
}

.forge-finest.hidden { display: none; }

.forge-body { max-height: 52vh; overflow-y: auto; text-align: left; margin-bottom: 12px; }

.forge-row,
.gear-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(58, 39, 49, 0.06);
  border: 3px solid rgba(58, 39, 49, 0.25);
  border-radius: 8px;
}

.gear-row.equipped { background: rgba(243, 179, 64, 0.18); }

.forge-icon,
.gear-row > img {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.forge-info { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.forge-name { font-size: 9px; }
.forge-stat { font-size: 7px; color: var(--color-muted); }

.forge-needs { display: flex; flex-wrap: wrap; gap: 4px 10px; }

.forge-need {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 8px;
  color: var(--color-red);
}

.forge-need.ok { color: var(--color-green); }
.forge-need img { width: 22px; height: 22px; image-rendering: pixelated; }

.gear-dur {
  display: block;
  width: 140px;
  height: 7px;
  border: 2px solid var(--color-wood-dark);
  border-radius: 4px;
  background: rgba(58, 39, 49, 0.18);
  overflow: hidden;
}

.gear-dur i { display: block; height: 100%; }

/* Forge GEAR tab: repair / upgrade / salvage stacked on the right */
.forge-actions { display: flex; flex-direction: column; align-items: stretch; gap: 5px; }
.forge-actions .btn-tiny { display: inline-flex; align-items: center; justify-content: center; gap: 3px; }
.forge-actions img { width: 16px; height: 16px; image-rendering: pixelated; }

.forge-odds { width: 100%; border-collapse: collapse; font-size: 7px; }
.forge-odds th, .forge-odds td { padding: 7px 4px; text-align: center; border-bottom: 2px solid rgba(58, 39, 49, 0.15); }
.forge-odds td:first-child { text-align: left; color: var(--color-muted); }
.forge-note { font-size: 7px; line-height: 2; margin-top: 12px; color: var(--color-muted); }

.gear-list { max-height: 26vh; overflow-y: auto; margin-bottom: 14px; text-align: left; }

/* ---------- The Old Mine (dungeon) ---------- */

.dungeon-panel { width: min(640px, 94vw); }

.dungeon-bag {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 10px;
  max-height: 34vh;
  overflow-y: auto;
}

.dungeon-loot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 4px;
  font-size: 9px;
  background: rgba(58, 39, 49, 0.08);
  border: 3px solid rgba(58, 39, 49, 0.3);
  border-radius: 8px;
}

.dungeon-loot img { width: 32px; height: 32px; image-rendering: pixelated; }

.dungeon-warning { font-size: 8px; color: var(--color-red); margin-bottom: 12px; min-height: 8px; }

/* Loot table on the Warden's gate screen */
.gate-extra:empty { display: none; }
.dungeon-table { max-height: 30vh; overflow-y: auto; margin: 4px 0 12px; text-align: left; }
.dungeon-band { font-size: 8px; margin: 10px 0 4px; color: var(--color-wood-dark); }
.dungeon-odds td { text-align: right; }
.dungeon-odds td:first-child { display: flex; align-items: center; gap: 6px; text-align: left; color: var(--color-wood-dark); }
.dungeon-odds img { width: 22px; height: 22px; image-rendering: pixelated; }

/* ---------- Backpack (key B) ---------- */

.backpack-panel { width: min(640px, 92vw); }

.backpack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
  max-height: 52vh;
  overflow-y: auto;
}

.bp-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  background: rgba(58, 39, 49, 0.08);
  border: 3px solid rgba(58, 39, 49, 0.35);
  border-radius: 8px;
}

.bp-slot img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

.bp-qty {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9px;
  color: var(--color-wood-dark);
}

.bp-name {
  font-size: 7px;
  line-height: 1.5;
  text-align: center;
  color: var(--color-wood-dark);
}

.bp-quality { font-size: 7px; }

/* Quality rims match the pickup glow colors in items.js (ITEM_QUALITIES) */
.bp-fine { border-color: var(--color-quality-fine); }
.bp-fine .bp-quality { color: var(--color-quality-fine); }
.bp-pristine {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 2px rgba(243, 179, 64, 0.35);
}
.bp-pristine .bp-quality { color: #b07d1e; }

/* Backpack section header (ITEM_GROUPS): spans the whole grid row */
.bp-group {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 6px 0 0;
  padding-bottom: 4px;
  border-bottom: 2px solid rgba(58, 39, 49, 0.2);
  font-size: 9px;
  font-weight: normal;
  color: var(--color-wood-dark);
}
.bp-group:first-child { margin-top: 0; }
.bp-group-from { font-family: var(--font-body); font-size: 13px; color: #6b5a52; }

/* Finer qualities of a grouped item, as small counts under its name */
.bp-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; }
.bp-chip { font-size: 7px; white-space: nowrap; }
.bp-chip-fine { color: var(--color-quality-fine); }
.bp-chip-pristine { color: #b07d1e; }

.backpack-empty {
  grid-column: 1 / -1;
  font-size: 9px;
  line-height: 1.9;
  color: rgba(58, 39, 49, 0.75);
  text-align: center;
  padding: 18px 8px;
}

/* ---------- Spinner wheel (key O) ---------- */

.wheel-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 24px auto 16px;
}

.wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 6px solid var(--color-wood-dark);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
  /* 6 segments matching ADV.spinner.prizes, alternating game palette colors */
  background: conic-gradient(
    var(--color-green)  0deg   60deg,
    var(--color-blue)   60deg  120deg,
    var(--color-red)    120deg 180deg,
    var(--color-gold)   180deg 240deg,
    var(--color-green)  240deg 300deg,
    var(--color-blue)   300deg 360deg
  );
  transition: transform 2.2s cubic-bezier(0.15, 0.85, 0.3, 1);
}

.wheel-pointer {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 20px solid var(--color-wood-dark);
}

.wheel-result {
  font-size: 12px;
  color: var(--color-gold);
  text-shadow: 1px 1px 0 var(--color-wood-dark);
  min-height: 14px;
  margin-bottom: 18px;
}

/* Locked "coming soon" mode card */
.mode-card-soon {
  position: relative;
  background: #8a8378;
  cursor: not-allowed;
  filter: saturate(0.6);
  opacity: 0.85;
}

.mode-card-soon .mode-desc { color: rgba(255, 255, 255, 0.85); }

.mode-soon-badge {
  position: absolute;
  top: -10px;
  right: -8px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--color-wood-dark);
  background: var(--color-gold);
  border: 3px solid var(--color-wood-dark);
  border-radius: 8px;
  padding: 5px 10px;
  transform: rotate(6deg);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.mode-card .mode-name {
  font-size: 16px;
  letter-spacing: 1px;
}

.mode-card .mode-desc {
  font-size: 10px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
}

/* ---------- Leaderboard & score submit ---------- */

.btn-small {
  font-size: 11px;
  padding: 12px 20px;
  box-shadow: 0 4px 0 var(--color-wood-dark);
}


.season-badge {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--color-wood-dark);
  background: var(--color-gold);
  border: 3px solid var(--color-wood-dark);
  border-radius: 8px;
  padding: 6px 12px;
  margin: -16px 0 22px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

/* Tilted "current season" flag on the start panel, styled like the
   coming-soon mode badge */
#start-screen .panel { position: relative; }

.season-flag {
  position: absolute;
  top: -14px;
  right: -12px;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--color-wood-dark);
  background: var(--color-gold);
  border: 3px solid var(--color-wood-dark);
  border-radius: 8px;
  padding: 6px 12px;
  transform: rotate(6deg);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.lb-tabs { margin-bottom: 22px; }

.lb-tabs .btn { opacity: 0.55; }
.lb-tabs .btn.active { opacity: 1; }

.lb-list {
  list-style: none;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 2.4;
  text-align: left;
  min-width: 380px;
  min-height: 120px;
  margin-bottom: 24px;
}

.lb-list li {
  display: flex;
  gap: 14px;
  border-bottom: 2px solid rgba(58, 39, 49, 0.12);
  padding: 2px 4px;
}

.lb-list .lb-rank { width: 34px; color: var(--color-gold); text-shadow: 1px 1px 0 var(--color-wood-dark); }
.lb-list .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list .lb-score { color: #7a5c44; }

/* Knight's Crest — $HAVEN holder flair (leaderboard rows + shop lock) */
.lb-crest {
  color: var(--color-gold);
  text-shadow: 1px 1px 0 var(--color-wood-dark);
  margin-right: 6px;
}

.crest-lock { color: #b08d3e; }

/* Herald's Purse winner flair (leaderboard rows) */
.lb-herald {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: -3px;
  image-rendering: pixelated;
}

.lb-list .lb-status {
  display: block;
  text-align: center;
  color: #9b7e63;
  border: none;
  padding-top: 40px;
}

.submit-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.submit-row.hidden { display: none; }

#player-name {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--color-wood-dark);
  background: #fff;
  border: 4px solid var(--color-wood-dark);
  border-radius: 10px;
  padding: 10px 14px;
  width: 220px;
  text-transform: uppercase;
}

#player-name:focus { outline: 3px solid var(--color-gold); }

/* ---------- Account / auth ---------- */

.account-line {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: #9b7e63;
  margin-top: 16px;
  min-height: 9px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.auth-form input {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--color-wood-dark);
  background: #fff;
  border: 4px solid var(--color-wood-dark);
  border-radius: 10px;
  padding: 12px 14px;
  width: 300px;
}

.auth-form input:focus { outline: 3px solid var(--color-gold); }

.auth-status {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: #a33b2e;
  min-height: 18px;
  max-width: 320px;
  line-height: 1.8;
}

.btn-ghost-link {
  background: transparent;
  color: var(--color-wood-dark);
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost-link:active { transform: none; }

/* ---------- Audio options ---------- */

.audio-opts {
  display: flex;
  gap: 26px;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--color-wood-dark);
  margin-bottom: 24px;
}

.audio-opts label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.panel input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-blue);
  cursor: pointer;
}

/* ---------- Pause menu & stats ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 12px 28px;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 11px;
  margin: 0 0 26px;
}

.stats-grid .stat-key {
  color: #9b7e63;
  text-align: right;
}

.stats-grid .stat-val {
  color: var(--color-wood-dark);
  text-align: left;
}

.stat-up {
  color: var(--color-gold);
  text-shadow: 1px 1px 0 var(--color-wood-dark);
}

.upgrade-stats {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: #9b7e63;
  margin: -10px 0 22px;
}

.btn-red { background: var(--color-red); }

/* ---------- Story dialog ---------- */

.dialog-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6vh;
  z-index: 12;
  /* Let the world stay visible; only the box catches clicks */
  background: transparent;
  pointer-events: none;
}

.dialog-wrap.hidden { display: none; }

.dialog-box {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  gap: 18px;
  align-items: center;
  width: min(720px, 86vw);
  padding: 22px 28px;
  background: var(--color-cream);
  border: 6px solid var(--color-wood-dark);
  border-radius: 14px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
  font-family: var(--font-pixel);
  color: var(--color-wood-dark);
}

.dialog-box img {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.dlg-body { flex: 1; }

#dlg-name {
  font-size: 12px;
  color: #a33b2e;
  margin-bottom: 10px;
}

#dlg-text {
  font-size: 11px;
  line-height: 1.8;
  min-height: 60px;
}

.dlg-hint {
  font-size: 8px;
  color: #9b7e63;
  text-align: right;
  margin-top: 8px;
}

/* The walkthrough's mentor (Elder Wren, guide.js): the same dialog box, but
   the world dims around it (lighter in the middle so the guide arrow still
   reads), a gold rim, the step tag over the name, and SKIP GUIDE */
.dlg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 8px; }
.dlg-foot .dlg-hint { margin-top: 0; }
.mentor-skip { display: none; }
.dialog-wrap.mentor { background: radial-gradient(ellipse at 50% 42%, rgba(22, 28, 46, 0.12), rgba(22, 28, 46, 0.6)); }
.dialog-wrap.mentor .dialog-box {
  width: min(760px, 94vw);
  border-color: #b07d1e;
  box-shadow: 0 0 0 4px var(--color-wood-dark), 0 8px 0 rgba(0, 0, 0, 0.35);
}
/* Wren stands in front of the box's left end instead of a framed portrait,
   low, his head breaking out over the top edge; the talk sheet (6 frames,
   256px) loops while the line plays, frame 1 at rest */
.dlg-figure { display: none; }
.dialog-wrap.mentor .dialog-box { position: relative; padding-left: 216px; }
.dialog-wrap.mentor .dialog-box img { display: none; }
.dialog-wrap.mentor .dlg-figure {
  display: block;
  position: absolute;
  left: -34px;
  bottom: -14px;   /* feet on the box's bottom rim (the frame has 8px under them) */
  z-index: 1;
  width: 256px;
  height: 256px;
  background: url('assets/npc_wren_talk.png') 0 0 / 1536px 256px no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
}
.dialog-wrap.mentor .dlg-figure.talking { animation: wren-talk 0.9s steps(6) infinite; }
@keyframes wren-talk { to { background-position: -1536px 0; } }
.dialog-wrap.mentor #dlg-text { min-height: 0; }
.dialog-wrap.mentor .dlg-foot { justify-content: space-between; }
.dialog-wrap.mentor .mentor-skip {
  display: inline;
  padding: 0;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: #8a7a6a;
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
}
.mentor-tag { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
@media (max-width: 700px) {
  .dialog-wrap.mentor .dialog-box { gap: 12px; padding: 14px; }
  .dialog-wrap.mentor .dialog-box { padding-left: 124px; }
  .dialog-wrap.mentor .dlg-figure { left: -38px; bottom: -11px; transform: scale(0.74); transform-origin: bottom left; }
  .dialog-wrap.mentor #dlg-text { font-size: 9px; }
}

/* ---------- Act-transition cinematic banner ---------- */

.banner-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 14;
  background: rgba(13, 23, 16, 0);
  pointer-events: none;
  animation: bannerBg 0.5s ease-out forwards;
}

.banner-wrap.hidden { display: none; }

.banner-content {
  text-align: center;
  font-family: var(--font-pixel);
  color: #fff;
  animation: bannerIn 0.7s cubic-bezier(0.25, 1.4, 0.4, 1) forwards;
}

.banner-eyebrow {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--color-gold);
  text-shadow: 3px 3px 0 var(--color-wood-dark);
  margin-bottom: 28px;
}

.banner-title {
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.3;
  text-shadow: 4px 4px 0 var(--color-wood-dark);
  margin: 0;
}

.banner-sub {
  font-size: 11px;
  color: var(--color-cream);
  text-shadow: 2px 2px 0 var(--color-wood-dark);
  margin-top: 32px;
  opacity: 0.9;
}

@keyframes bannerBg {
  from { background: rgba(13, 23, 16, 0); }
  to   { background: rgba(13, 23, 16, 0.55); }
}

@keyframes bannerIn {
  0%   { opacity: 0; transform: scale(0.65) translateY(40px); }
  55%  { opacity: 1; transform: scale(1.08) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- Touch controls (mobile) ---------- */
/* z-index 5: above the canvas, below every .overlay (10) — open menus
   automatically cover and block the controls */

canvas { touch-action: none; }

#touch-ui {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;   /* only the controls themselves take touches */
  font-family: var(--font-pixel);
}

#joystick {
  position: absolute;
  left: 34px;
  bottom: 34px;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: rgba(58, 39, 49, 0.28);
  border: 3px solid rgba(244, 231, 208, 0.55);
  pointer-events: auto;
  touch-action: none;
}

#joystick-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(244, 231, 208, 0.8);
  border: 3px solid var(--color-wood-dark);
}

#touch-act {
  position: absolute;
  right: 38px;
  bottom: 42px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 34px;
  line-height: 1;
  color: var(--color-wood-dark);
  background: rgba(243, 179, 64, 0.88);
  border: 4px solid var(--color-wood-dark);
  box-shadow: 0 5px 0 var(--color-wood-dark);
  pointer-events: auto;
  touch-action: none;
}

#touch-act:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--color-wood-dark); }

#touch-sys {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

#touch-sys button {
  min-width: 46px;
  height: 46px;
  font-family: var(--font-pixel);
  font-size: 15px;
  color: var(--color-cream);
  background: rgba(58, 39, 49, 0.72);
  border: 3px solid rgba(244, 231, 208, 0.55);
  border-radius: 10px;
  touch-action: none;
}

/* ---------- Responsive (overlays/panels) ----------
   None of the overlay panels were ever width-constrained to the viewport —
   several set a fixed min-width (the ledger's two-column layout assumed
   720-980px) that just runs off the edge of a phone screen with no way to
   scroll to the rest. Touch controls shipped mobile-capable; this is the
   matching pass for the HTML overlay panels on top of the canvas. */
@media (max-width: 700px) {
  .overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 22px 12px;
  }

  .panel {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 18px;
  }

  .panel h1 { font-size: 22px; margin-bottom: 16px; }
  .panel .subtitle { font-size: 10px; }

  /* Ledger: side-by-side columns don't fit — stack them */
  .ledger-panel,
  .ledger-panel-wide { min-width: 0; }
  .ledger-cols { flex-direction: column; gap: 20px; margin: 20px 0 16px; }
  .ledger-col { width: 100%; }

  /* Upgrade picker + build menu (shares .upgrade-btn) */
  .upgrade-row { flex-wrap: wrap; gap: 12px; }
  .upgrade-btn { min-width: 0; flex: 1 1 130px; }

  /* Gate confirm, leaderboard, name entry */
  .gate-panel { max-width: 100%; }
  .lb-list { min-width: 0; }
  .btn-stack-item { min-width: 0; }
  .submit-row { flex-wrap: wrap; }
  .auth-form input,
  #player-name { width: 100%; max-width: 280px; }
}

/* ==========================================================================
   UI kit — Tiny Swords style (assets/kit_*.png, drawn by video/gen/ui_kit.py)
   Kit art is 1 art pixel = 1 image pixel, shown at 2x via border-image
   (widths = slice x 2).
   This block sits last so it restyles the older flat panels/buttons above.
   ========================================================================== */

:root {
  --kit-navy: #161c2e;
  --kit-outline: 2px 0 0 #161c2e, -2px 0 0 #161c2e, 0 2px 0 #161c2e, 0 -2px 0 #161c2e,
    2px 2px 0 #161c2e, -2px 2px 0 #161c2e, 2px -2px 0 #161c2e, -2px -2px 0 #161c2e;
  --kit-outline-thin: 1px 0 0 #161c2e, -1px 0 0 #161c2e, 0 1px 0 #161c2e, 0 -1px 0 #161c2e,
    1px 1px 0 #161c2e;
  --panel-pad-top: 34px;
}

.overlay {
  overflow-y: auto;
  padding: 48px 16px;
  background: radial-gradient(ellipse at center, rgba(22, 28, 46, 0.35), rgba(22, 28, 46, 0.72));
}

/* ---------- Panel: a paper scroll between two wooden rods ---------- */
.panel {
  position: relative;
  margin: auto;   /* centres in the flex overlay, yet scrolls instead of clipping when tall */
  padding: var(--panel-pad-top) 38px 26px;
  background: none;
  border-radius: 0;
  box-shadow: none;
  border-style: solid;
  border-width: 16px;
  border-image: url('assets/kit_paper.png') 8 fill / 16px round;
  filter: drop-shadow(0 10px 0 rgba(22, 28, 46, 0.35));
  image-rendering: pixelated;
  color: var(--kit-navy);
}

/* Rods sit centred on the paper's top and bottom edges and overhang the sides */
.panel::before,
.panel::after {
  content: '';
  position: absolute;
  left: -30px;
  right: -30px;
  height: 22px;
  z-index: 1;
  border-style: solid;
  border-width: 0 18px;
  border-image: url('assets/kit_rod.png') 0 9 fill / 0 18px round;
  pointer-events: none;
}

.panel::before { top: -27px; }
.panel::after { bottom: -27px; }

/* ---------- Title ribbon (3x); the first title is pinned over the top rod ---------- */
.panel h1 {
  position: relative;
  z-index: 2;   /* above the rod */
  display: table;
  margin: 0 auto 22px;
  padding: 11px 6px;
  font-size: 18px;
  line-height: 20px;
  white-space: nowrap;
  color: var(--color-paper);
  text-shadow: var(--kit-outline);
  border-style: solid;
  border-width: 0 42px 9px;
  border-image: url('assets/kit_ribbon_blue.png') 0 14 3 fill / 0 42px 9px round stretch;
  image-rendering: pixelated;
}

/* Band centre (21px) lands on the paper edge: -(border 16 + padding) - 21 */
.panel > h1:first-child,
.panel > .season-flag + h1 {
  margin-top: calc(-37px - var(--panel-pad-top));
}

#start-screen h1,
#victory-screen h1,
#upgrade-screen h1 { border-image-source: url('assets/kit_ribbon_gold.png'); }
#gameover-screen h1 { border-image-source: url('assets/kit_ribbon_red.png'); }

.season-flag { top: auto; bottom: 18px; right: -34px; z-index: 3; }

.panel .subtitle { color: #6b5a52; }

/* Sword divider between panel sections */
.kit-divider {
  width: 78%;
  height: 18px;
  margin: 2px auto 18px;
  border-style: solid;
  border-width: 0 18px 0 32px;
  border-image: url('assets/kit_sword.png') 0 9 0 16 fill / 0 18px 0 32px round;
  image-rendering: pixelated;
}

/* ---------- Buttons: chunky pixel buttons with a pressable lip ---------- */
.btn,
.mode-card {
  --btn: url('assets/kit_btn_blue.png');
  --btn-press: url('assets/kit_btn_blue_press.png');
  background: none;
  border-radius: 0;
  box-shadow: none;
  border-style: solid;
  border-width: 6px 6px 8px;
  border-image: var(--btn) 3 3 4 fill / 6px 6px 8px stretch;
  color: #fff;
  text-shadow: var(--kit-outline);
  image-rendering: pixelated;
}

.btn { padding: 10px 26px 8px; }

.btn:hover,
.mode-card:not(:disabled):hover { filter: brightness(1.08); }

.btn:active,
.mode-card:not(:disabled):active {
  border-image-source: var(--btn-press);
  transform: translateY(2px);
  box-shadow: none;
}

.btn-red,
.mode-card-red {
  --btn: url('assets/kit_btn_red.png');
  --btn-press: url('assets/kit_btn_red_press.png');
  background: none;
}

.mode-card-green {
  --btn: url('assets/kit_btn_green.png');
  --btn-press: url('assets/kit_btn_green_press.png');
  background: none;
}

.btn-primary {
  --btn: url('assets/kit_btn_gold.png');
  --btn-press: url('assets/kit_btn_gold_press.png');
  color: var(--kit-navy);
  text-shadow: 0 2px 0 rgba(255, 246, 228, 0.55);
}

.btn:disabled,
.btn:disabled:active {
  --btn: url('assets/kit_btn_grey.png');
  --btn-press: url('assets/kit_btn_grey.png');
  transform: none;
  cursor: not-allowed;
  filter: none;
}

.btn-small { padding: 9px 18px 7px; box-shadow: none; }
.btn-secondary { padding: 9px 22px 7px; box-shadow: none; }

.btn-tiny {
  padding: 5px 9px 3px;
  border-width: 4px 4px 6px;
  border-image-width: 4px 4px 6px;
  box-shadow: none;
  text-shadow: var(--kit-outline-thin);
}

/* Tabs: grey when idle, gold when picked */
.forge-tab,
.lb-tabs .btn { opacity: 1; }

.forge-tab:not(.active),
.lb-tabs .btn:not(.active) {
  --btn: url('assets/kit_btn_grey.png');
  --btn-press: url('assets/kit_btn_grey_press.png');
}

.forge-tab.active,
.lb-tabs .btn.active {
  --btn: url('assets/kit_btn_gold.png');
  --btn-press: url('assets/kit_btn_gold_press.png');
  color: var(--kit-navy);
  text-shadow: none;
}

.btn-ghost-link,
.btn-ghost-link:active {
  border-image: none;
  border-color: transparent;
  color: var(--kit-navy);
  text-shadow: none;
  transform: none;
}

.btn-ghost-link:hover { text-decoration: underline; }

/* ---------- Keycaps ---------- */
.panel kbd,
.panel .controls b {
  display: inline-block;
  min-width: 26px;
  padding: 3px 5px 1px;
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: normal;
  line-height: 10px;
  text-align: center;
  color: var(--kit-navy);
  border-style: solid;
  border-width: 4px 4px 8px;
  border-image: url('assets/kit_key.png') 2 2 4 fill / 4px 4px 8px stretch;
  image-rendering: pixelated;
}

.key-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 10px 28px;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 22px;
  font-family: var(--font-pixel);
  font-size: 9px;
  text-align: left;
}

.key-list li { display: flex; align-items: center; gap: 8px; }

/* ---------- Checkboxes ---------- */
.panel input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  background: url('assets/kit_check_off.png') center / 100% 100%;
  image-rendering: pixelated;
}

.panel input[type='checkbox']:checked { background-image: url('assets/kit_check_on.png'); }

.panel input[type='checkbox']:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }

/* ---------- Resource chips (pause menu) ---------- */
.stats-res { display: flex; gap: 12px; justify-content: center; margin: 0 0 22px; }

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 6px;
  font-family: var(--font-pixel);
  font-size: 11px;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_slot.png') 3 fill / 6px stretch;
  image-rendering: pixelated;
}

.stat-chip img { width: 24px; height: 24px; margin-right: 4px; }

/* ---------- Inset slots: list rows, backpack, loot ---------- */
.forge-row,
.gear-row,
.bp-slot,
.dungeon-loot {
  background: none;
  border-radius: 0;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_slot.png') 3 fill / 6px stretch;
  image-rendering: pixelated;
}

.gear-row.equipped { background: none; outline: 3px solid var(--color-gold); outline-offset: -4px; }
.bp-fine { outline: 3px solid var(--color-quality-fine); outline-offset: -4px; }
.bp-pristine { outline: 3px solid var(--color-gold); outline-offset: -4px; box-shadow: none; }

/* ---------- Progress bars ---------- */
.skill-bar,
.hud-bar {
  border: 2px solid var(--kit-navy);
  border-radius: 0;
  background: #c4b2af;
  box-shadow: inset 0 2px 0 rgba(22, 28, 46, 0.25);
}

.skill-fill,
.hud-bar i {
  background: linear-gradient(#ffe896 0 2px, var(--color-gold) 2px calc(100% - 2px), #aa7028 calc(100% - 2px));
}

#map-canvas { border: 4px solid var(--kit-navy); border-radius: 0; }

/* ---------- Scrollbars: a wooden rod in a paper groove ---------- */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-button { display: none; }
::-webkit-scrollbar-corner { background: transparent; }

::-webkit-scrollbar-track {
  border-style: solid;
  border-width: 4px;
  border-image: url('assets/kit_track.png') 2 fill / 4px stretch;
}

::-webkit-scrollbar-thumb {
  min-height: 40px;
  border-style: solid;
  border-width: 8px 0;
  border-image: url('assets/kit_thumb.png') 4 0 fill / 8px 0 stretch;
}

/* Firefox has no scrollbar pseudo-elements: closest match in two colors */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-color: #b8743f #c4b2af; scrollbar-width: thin; }
}

.forge-body,
.gear-list,
.dungeon-bag,
.dungeon-table,
.backpack-grid { padding-right: 8px; }
/* MATERIALS / TOOLS tabs show one pane at a time */
.backpack-pane { min-height: 58vh; }   /* same height on both tabs, so the tabs don't jump */
.backpack-pane.hidden { display: none; }
.backpack-gear { max-height: 52vh; overflow-y: auto; margin: 14px 0 18px; padding-right: 8px; }

/* ---------- Adventure HUD ---------- */
.hud-card {
  background: none;
  border-radius: 0;
  box-shadow: none;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_card.png') 3 fill / 6px stretch;
  filter: drop-shadow(0 4px 0 rgba(22, 28, 46, 0.35));
  image-rendering: pixelated;
}


.hud-avatar { border-color: var(--kit-navy); border-radius: 0; }

.hud-btn {
  border-width: 6px 6px 8px;
  border-image: url('assets/kit_btn_blue.png') 3 3 4 fill / 6px 6px 8px stretch;
}

.hud-btn:active {
  border-image-source: url('assets/kit_btn_blue_press.png');
  box-shadow: none;
}

.hud-key {
  min-width: 24px;
  height: 24px;
  padding: 0 2px;
  color: var(--kit-navy);
  background: none;
  border-radius: 0;
  border-style: solid;
  border-width: 4px 4px 8px;
  border-image: url('assets/kit_key.png') 2 2 4 fill / 4px 4px 8px stretch;
  line-height: 1;
}

.hud-dot { border-color: var(--kit-navy); }

.hud-slot {
  background: none;
  border-radius: 0;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_slot.png') 3 fill / 6px stretch;
  image-rendering: pixelated;
}

.hud-slot.on { background: none; border-image-source: url('assets/kit_slot_on.png'); }

.hud-minimap canvas { border-radius: 0; border: 2px solid var(--kit-navy); }

/* Notices fly on a blue ribbon (2x) */
.hud-notice {
  padding: 9px 6px 8px;
  font-size: 10px;
  line-height: 11px;
  color: var(--color-paper);
  text-shadow: var(--kit-outline-thin);
  background: none;
  border-radius: 0;
  box-shadow: none;
  border-style: solid;
  border-width: 0 28px 6px;
  border-image: url('assets/kit_ribbon_blue.png') 0 14 3 fill / 0 28px 6px round stretch;
  filter: drop-shadow(0 4px 0 rgba(22, 28, 46, 0.3));
  image-rendering: pixelated;
}

/* ---------- Phones ---------- */
@media (max-width: 700px) {
  :root { --panel-pad-top: 20px; }

  .overlay { padding: 52px 12px 40px; }

  .panel {
    margin: auto;
    padding: var(--panel-pad-top) 10px 14px;
  }

  .panel h1 { font-size: 13px; }
  .btn-row { gap: 10px; }
  .btn-row .btn { font-size: 11px; padding: 9px 12px 7px; }
  .audio-opts { gap: 12px; font-size: 8px; flex-wrap: wrap; }
  .season-flag { bottom: -14px; }
  .key-list { grid-template-columns: 1fr; }
}

/* Touch screens have no keyboard: the key list is noise there */
@media (hover: none) and (pointer: coarse) {
  #pause-screen .key-list,
  #pause-screen .kit-divider { display: none; }
}

/* ==========================================================================
   Readability pass (2026-10-22): Press Start 2P stays for titles, labels,
   buttons and numbers; sentences and small print switch to Pixelify Sans,
   a pixel font that stays legible at 13-15px. Nothing in menus goes below
   9px Press Start / 13px Pixelify.
   ========================================================================== */

:root {
  --font-body: 'Pixelify Sans', 'Press Start 2P', monospace;
}

/* Sentences and explanations */
.panel .subtitle,
.panel .hint,
.ledger-hint,
.forge-note,
.quest-reward,
.ledger-date,
.upgrade-btn .up-desc,
.dungeon-warning,
.backpack-empty,
.account-line,
.auth-status,
.upgrade-stats,
.dlg-hint,
.forge-finest,
.start-hint {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0.2px;
}

.forge-note { color: #6b5a52; margin-top: 10px; }
.ledger-hint { color: #6b5a52; }
.forge-finest { display: inline-flex; align-items: center; gap: 8px; }

/* Small print that stays in the pixel font gets a floor */
.forge-name { font-size: 11px; }
.forge-stat { font-family: var(--font-body); font-size: 13px; color: #6b5a52; }
.forge-need { font-size: 10px; }
.forge-need img { width: 24px; height: 24px; }
.btn-tiny { font-size: 9px; }
.bp-qty { font-size: 10px; }
.bp-name { font-family: var(--font-body); font-size: 13px; line-height: 1.2; }
.bp-quality { font-family: var(--font-body); font-size: 12px; font-weight: 600; }
.bp-chip { font-family: var(--font-body); font-size: 12px; font-weight: 600; }
.dungeon-band { font-size: 10px; }
.dungeon-loot { font-size: 10px; }
.dungeon-odds { font-family: var(--font-body); font-size: 14px; }
.key-list { font-size: 10px; }
.ledger-row { font-size: 11px; }
.season-badge { font-size: 10px; }

/* HUD small print */
.hud-region { font-size: 9px; }
.hud-mm-label { font-size: 8px; }
.hud-slot-tier { font-size: 7px; }

/* ---------- Forge: rarity bars, odds page ---------- */
.forge-roll { display: block; margin-top: 2px; }

.odds-bar {
  display: flex;
  width: 160px;
  max-width: 100%;
  height: 8px;
  overflow: hidden;
  border: 2px solid var(--kit-navy);
  background: #c4b2af;
}

.odds-bar i { display: block; height: 100%; transition: width 0.15s; }
.odds-bar-big { width: 100%; height: 18px; margin: 10px 0 12px; }

.odds-section { padding: 4px 2px 14px; }
.odds-section + .odds-section { border-top: 2px dashed rgba(22, 28, 46, 0.18); padding-top: 14px; }

.odds-title {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--kit-navy);
  margin-bottom: 6px;
}

.odds-luck {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 10px;
}

.odds-luck b {
  min-width: 34px;
  padding: 4px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: normal;
  border-style: solid;
  border-width: 4px 4px 8px;
  border-image: url('assets/kit_key.png') 2 2 4 fill / 4px 4px 8px stretch;
  image-rendering: pixelated;
}

/* Pixel slider: groove track and a gold knob */
.odds-luck input[type='range'] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 14px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.odds-luck input[type='range']::-webkit-slider-runnable-track {
  height: 14px;
  border-style: solid;
  border-width: 4px;
  border-image: url('assets/kit_track.png') 2 fill / 4px stretch;
  image-rendering: pixelated;
}

.odds-luck input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 26px;
  margin-top: -10px;
  border-style: solid;
  border-width: 6px 6px 8px;
  border-image: url('assets/kit_btn_gold.png') 3 3 4 fill / 6px 6px 8px stretch;
  image-rendering: pixelated;
}

.odds-luck input[type='range']::-moz-range-track { height: 6px; background: #c4b2af; border: 2px solid var(--kit-navy); }
.odds-luck input[type='range']::-moz-range-thumb { width: 16px; height: 20px; background: var(--color-gold); border: 2px solid var(--kit-navy); border-radius: 0; }
.odds-luck input[type='range']:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 4px; }

.odds-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.odds-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 4px 4px;
  text-align: center;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_slot.png') 3 fill / 6px stretch;
  box-shadow: inset 0 4px 0 var(--rarity);
  image-rendering: pixelated;
}

.odds-label { font-size: 8px; color: var(--rarity); text-shadow: 1px 1px 0 rgba(22, 28, 46, 0.25); }
.odds-pct { font-size: 15px; color: var(--kit-navy); }
.odds-mult { font-family: var(--font-body); font-size: 13px; color: #6b5a52; }

.odds-tier-tabs { display: flex; gap: 8px; margin: 4px 0 12px; }

.up-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.up-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 6px;
  text-align: center;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_slot.png') 3 fill / 6px stretch;
  image-rendering: pixelated;
}

.up-step-n { font-size: 12px; color: var(--kit-navy); }
.up-step-chance { font-size: 15px; color: var(--color-green); }
.up-step-bar { display: block; width: 100%; height: 8px; border: 2px solid var(--kit-navy); background: #c4b2af; }
.up-step-bar i { display: block; height: 100%; background: var(--color-green); }
.up-step-cost { display: inline-flex; align-items: center; gap: 3px; font-size: 9px; }
.up-step-cost img { width: 18px; height: 18px; image-rendering: pixelated; }
.up-step-note { font-family: var(--font-body); font-size: 13px; color: #6b5a52; }

@media (max-width: 700px) {
  .odds-cards,
  .up-steps { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Marla's Wares: try-on preview + COLORS / HEADS / OUTFITS ---------- */
.shop-panel { width: min(760px, 94vw); }

.shop-layout { display: grid; grid-template-columns: 236px 1fr; gap: 20px; margin-top: 8px; text-align: center; }

.shop-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.shop-preview canvas,
.shop-card canvas {
  display: block;
  image-rendering: pixelated;
  background: #92b64a;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_slot.png') 3 fill / 6px stretch;
}

.shop-preview canvas { width: 224px; height: 224px; border-image-slice: 3; }   /* no fill: the grass shows */
.shop-pick { font-size: 12px; }
.shop-look { font-size: 8px; line-height: 1.6; color: var(--color-muted); min-height: 13px; }
.shop-preview .btn { width: 100%; }

.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-height: 46vh; overflow-y: auto; padding-right: 8px; }

.shop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 4px 8px;
  font-family: var(--font-pixel);
  color: var(--kit-navy);
  background: none;
  cursor: pointer;
  border-style: solid;
  border-width: 6px;
  border-image: url('assets/kit_slot.png') 3 fill / 6px stretch;
  transition: transform 0.08s;
}

.shop-card:hover { transform: translateY(-2px); }
.shop-card.on { border-image-source: url('assets/kit_slot_on.png'); }
.shop-card canvas { width: 84px; height: 84px; border: 0; }
.shop-card-name { font-size: 8px; line-height: 1.4; }
.shop-card-tag { font-size: 9px; color: #aa7028; }
.shop-card-tag.owned { color: var(--color-green); }

@media (max-width: 700px) {
  .shop-layout { grid-template-columns: 1fr; }
  .shop-preview canvas { width: 168px; height: 168px; }
  .shop-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- HUD right column (2026-10-22): stores, chips and menu stack in
   flow, so extra status chips push the menu down instead of overlapping it ---------- */
.hud-right {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.hud-right .hud-menu { position: static; top: auto; right: auto; }

/* ---------- HUD profile card (2026-10-22): player, isle, stores and status in
   one compact card top-left; the whole card opens the Kingdom Ledger ---------- */
.hud-profile {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 212px;
  padding: 6px 8px 6px 6px;
  font-family: var(--font-pixel);
  color: var(--kit-navy);
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.08s;
}

.hud-profile:hover { transform: translateY(-2px); }
.hud-profile:active { transform: translateY(1px); }

.hud-profile-head { display: flex; align-items: center; gap: 8px; }
.hud-profile .hud-avatar { width: 34px; height: 34px; border-width: 2px; }
.hud-profile-who { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hud-profile .hud-name { font-size: 10px; line-height: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-profile .hud-region { font-size: 7px; }

/* "I" keycap: the card is the ledger button */
.hud-profile-key {
  align-self: flex-start;
  min-width: 20px;
  padding: 2px 4px 0;
  font-size: 7px;
  line-height: 10px;
  text-align: center;
  border-style: solid;
  border-width: 3px 3px 6px;
  border-image: url('assets/kit_key.png') 2 2 4 fill / 3px 3px 6px stretch;
  image-rendering: pixelated;
}

.hud-profile-stores { display: flex; gap: 10px; padding-top: 6px; border-top: 2px dashed rgba(22, 28, 46, 0.15); }
.hud-profile .hud-res { display: inline-flex; align-items: center; gap: 4px; padding: 0; font-size: 10px; }
.hud-profile .hud-res img { width: 18px; height: 18px; }

.hud-profile-status { display: flex; gap: 12px; }
.hud-profile-status:empty { display: none; }
.hud-stat { display: inline-flex; align-items: center; gap: 5px; font-size: 8px; }
.hud-stat img { width: 18px; height: 18px; image-rendering: pixelated; }
.hud-stat .hud-bar { width: 44px; height: 6px; }
.hud-stat-favor { color: #8a5a10; }

/* ---------- Touch devices (body.is-touch, set by initTouchUI) ----------
   The joystick owns the bottom-left and the action button the bottom-right,
   at every screen size: the minimap moves under the profile card (tablets in
   landscape used to stack it on the joystick) and, where the bottom row is
   too narrow for joystick + hotbar + action button, the hotbar rises above
   the controls. */
.is-touch .hud-minimap { left: 16px; top: 146px; bottom: auto; padding: 5px; }
.is-touch .hud-minimap canvas { width: 128px; height: 88px; }
.is-touch .hud-mm-label { display: none; }

@media (max-width: 760px) {
  .is-touch .hud-hotbar { bottom: 176px; }
}

/* The combat pause button sits top-centre, over the canvas HP bar on
   narrow screens: tuck it top-right, under the wave counter */
@media (max-width: 700px) {
  #touch-sys { left: auto; right: 12px; top: 52px; transform: none; }
}

/* ---------- Minimap toggle (2026-10-22): closed by default, the header
   (map icon + region + caret) opens and closes it ---------- */
.hud-mm-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0 2px;
  font-family: var(--font-pixel);
  color: var(--kit-navy);
  background: none;
  border: 0;
  cursor: pointer;
  pointer-events: auto;
}

.hud-mm-toggle img { width: 22px; height: 22px; image-rendering: pixelated; }

.hud-mm-toggle .hud-mm-label {
  display: block;
  flex: 1;
  margin: 0;
  min-height: 0;
  text-align: left;
  white-space: nowrap;
}

/* Pixel caret: points right when closed, down when open */
.hud-mm-caret {
  width: 0;
  height: 0;
  border-left: 6px solid var(--kit-navy);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transform: rotate(90deg);
}

.hud-minimap canvas { margin-top: 6px; }
.hud-minimap.is-collapsed canvas { display: none; }
.hud-minimap.is-collapsed .hud-mm-caret { transform: none; }

/* Touch action button: names what a tap does right now (syncActHint) */
#touch-act.has-hint::after {
  content: attr(data-hint);
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translateX(-50%);
  padding: 4px 7px 3px;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1;
  color: var(--color-cream);
  background: var(--color-wood-dark);
  border: 2px solid var(--color-gold);
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}

/* Result screen: gear brought home, with an EQUIP button (renderNewGear) */
.dungeon-gear { display: flex; flex-direction: column; gap: 8px; margin: 4px auto 10px; max-width: 420px; }
.dungeon-gear:empty { display: none; }
.dungeon-gear-title { font-size: 10px; text-align: center; color: var(--color-wood-dark); }
.dungeon-gear-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  text-align: left;
  border: 3px solid;
  border-radius: 8px;
  background: rgba(58, 39, 49, 0.06);
}
.dungeon-gear-row img { width: 36px; height: 36px; image-rendering: pixelated; }
.dungeon-gear-name { flex: 1; font-size: 8px; line-height: 1.6; }
.gear-up { color: var(--color-green); }
.gear-down { color: var(--color-red); }

/* ---------- Boss treasure chest reveal (game.js openChest) ---------- */
.chest-panel { width: min(560px, 94vw); text-align: center; }
.chest-panel.flash { animation: chest-flash 0.5s ease-out; }
@keyframes chest-flash {
  0% { box-shadow: 0 0 0 0 rgba(255, 226, 138, 0.9), 0 0 60px 30px rgba(255, 226, 138, 0.7); }
  100% { box-shadow: 0 0 0 0 rgba(255, 226, 138, 0), 0 0 0 0 rgba(255, 226, 138, 0); }
}
#chest-canvas { display: block; width: 192px; height: 192px; margin: 4px auto 6px; image-rendering: pixelated; }
.chest-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 120px; margin-bottom: 14px; perspective: 600px; }
.chest-card {
  width: 104px;
  height: 116px;
  opacity: 0;
  transform: rotateY(90deg) scale(0.8);
  transition: opacity 0.15s, transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.chest-card.shown { opacity: 1; transform: none; }
.chest-card.instant { transition: none; }
.chest-card-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  padding: 6px 4px;
  font-family: var(--font-pixel);
  color: var(--kit-navy);
  background: var(--color-paper);
  border: 3px solid var(--tier);
  border-radius: 8px;
  box-shadow: 0 0 0 2px var(--kit-navy), 0 4px 0 2px rgba(22, 28, 46, 0.35);
}
.chest-card-face img { width: 40px; height: 40px; image-rendering: pixelated; }
.chest-card-face b { font-size: 10px; min-height: 10px; }
.chest-card-face span { font-size: 7px; line-height: 1.4; }
/* the best tiers glow */
.chest-card.tier-epic .chest-card-face,
.chest-card.tier-legendary .chest-card-face { box-shadow: 0 0 0 2px var(--kit-navy), 0 0 16px 4px var(--tier); }
@media (prefers-reduced-motion: reduce) {
  .chest-card { transition: opacity 0.15s; transform: none; }
  .chest-panel.flash { animation: none; }
}

/* ---------- Title screen (docs/mockups/title-screen.html) ---------- */
.title-panel { text-align: center; }
.title-tagline { margin: 0 0 10px; font-size: 10px; color: #6b5a52; }
.title-panel .online-count { margin: 0 0 18px; font-size: 8px; }
.title-stack { display: flex; flex-direction: column; align-items: stretch; gap: 12px; width: 330px; max-width: 100%; margin: 14px auto 0; }
.title-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
  padding-bottom: 16px;
}
.title-play-big { font-size: 16px; }
.title-play-sub { font-size: 7px; opacity: 0.85; white-space: nowrap; }
.wallet-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--color-wood-dark);
}
.wallet-chip.hidden { display: none; }
.wallet-chip-label::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  vertical-align: 0;
  background: var(--color-green);
  border-radius: 50%;
}
.wallet-chip-out {
  padding: 0;
  font-family: var(--font-pixel);
  font-size: 7px;
  color: #8a7a6a;
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}
.title-panel .start-hint { margin-top: 14px; }
.title-panel .best { margin: 8px 0 0; }
.title-panel .best:empty { display: none; }
.title-icons { display: flex; justify-content: center; align-items: flex-start; gap: 18px; margin: 18px 0 44px; }   /* room for the season flag */
.title-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--color-wood-dark);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
}
.title-icon.hidden { display: none; }
.title-icon .hud-btn { width: 56px; height: 56px; }
.title-icon .hud-btn img { width: 38px; height: 38px; image-rendering: pixelated; }
.title-icon:hover .hud-btn { transform: translateY(-2px); }
.label-short { display: none; }
.is-touch .label-long { display: none; }
.is-touch .label-short { display: inline; }
@media (max-width: 480px) {
  .title-stack { width: 250px; }
  .title-icons { gap: 10px; }
}

/* ---------- First-play walkthrough card + highlights (guide.js) ---------- */
.guide-card {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 330px;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 10px 14px 12px;
  color: var(--color-wood-dark);
  pointer-events: auto;
  z-index: 6;
}
.guide-card.hidden { display: none; }
.is-touch .guide-card { top: 252px; width: 300px; }   /* under the profile card and minimap */
.guide-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.guide-step, .guide-sub { font-family: var(--font-pixel); font-size: 8px; color: #b07d1e; }
.guide-dots { display: flex; gap: 4px; }
.guide-dots i { width: 8px; height: 8px; background: rgba(58, 39, 49, 0.25); }
.guide-dots i.on { background: var(--color-gold); box-shadow: inset 0 0 0 2px var(--color-wood-dark); }
.guide-dots i.done { background: var(--color-green); }
.guide-text { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.35; }
.guide-text kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-pixel);
  font-size: 9px;
  vertical-align: 2px;
  background: #fff8e8;
  border: 2px solid var(--color-wood-dark);
  border-radius: 4px;
}
.guide-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.guide-skip {
  margin-left: auto;
  padding: 0;
  font-family: var(--font-pixel);
  font-size: 7px;
  color: #8a7a6a;
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}
/* The HUD element a step points at pulses with a gold ring (white on the gold action button) */
.guide-ring { animation: guide-pulse 1s ease-in-out infinite; }
@keyframes guide-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--kit-navy), 0 0 0 7px var(--color-gold); }
  50% { box-shadow: 0 0 0 3px var(--kit-navy), 0 0 0 7px var(--color-gold), 0 0 18px 8px rgba(243, 179, 64, 0.7); }
}
#touch-act.guide-ring { animation-name: guide-pulse-light; border-radius: 50%; }
#joystick.guide-ring { border-radius: 50%; }
@keyframes guide-pulse-light {
  0%, 100% { box-shadow: 0 0 0 3px var(--kit-navy), 0 0 0 7px #fff; }
  50% { box-shadow: 0 0 0 3px var(--kit-navy), 0 0 0 7px #fff, 0 0 18px 8px rgba(255, 255, 255, 0.8); }
}
@media (prefers-reduced-motion: reduce) {
  .guide-ring, #touch-act.guide-ring { animation: none; box-shadow: 0 0 0 3px var(--kit-navy), 0 0 0 7px var(--color-gold); }
}
