/* ===========================================================================
   The Mythic Chronicles — UI theme
   An "ancient illuminated spellbook" aesthetic: gilded edges, parchment pages,
   glowing arcane HUD. Palette: forest greens, arcane purples, golden stone,
   glowing blue magic, mystical fog.
   =========================================================================== */

:root {
  --green-deep: #0c2a23;
  --green: #1f5a3a;
  --green-bright: #4fd27a;
  --purple: #6a3aa8;
  --purple-bright: #b98aff;
  --gold: #caa84d;
  --gold-bright: #ffd76b;
  --blue-magic: #7fc8ff;
  --parchment: #e9dcbf;
  --parchment-dark: #d8c8a0;
  --ink: #3a2a1a;
  --fog: rgba(120, 160, 150, 0.15);

  --font-title: 'Cinzel', 'Trajan Pro', Georgia, 'Times New Roman', serif;
  --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #05100e;
  font-family: var(--font-body);
  color: var(--parchment);
  user-select: none;
  cursor: default;
}

#canvas-wrap { position: fixed; inset: 0; will-change: transform; background: #04030a; }
#game-canvas {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated;            /* keep the upscaled pixels crisp */
  image-rendering: crisp-edges;
}

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui button, #ui input, #ui .inv-item, #ui .spell-entry, #ui .beast-entry,
#ui .quest-entry, #ui .region-entry, #ui .spell-slot, #ui .dlg-choice {
  pointer-events: auto;
}

.hidden { display: none !important; }

/* ===========================================================================
   Shared headings
   =========================================================================== */
.game-title {
  font-family: var(--font-title);
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(255, 215, 107, 0.55), 0 4px 10px #000;
  text-align: center;
}
.game-title.small { font-size: clamp(1.4rem, 4vw, 2.2rem); }
.game-subtitle {
  font-family: var(--font-title);
  font-size: clamp(1.1rem, 3vw, 1.8rem);
  letter-spacing: 0.34em;
  color: var(--purple-bright);
  text-shadow: 0 0 14px rgba(185, 138, 255, 0.6);
  text-align: center;
  margin-top: 0.2em;
}

/* ===========================================================================
   HUD — vitals
   =========================================================================== */
.hud { position: absolute; inset: 0; }

#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 7px; height: 7px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 8px var(--blue-magic), 0 0 2px #000;
}

.vitals {
  position: absolute; left: 22px; bottom: 22px;
  display: flex; align-items: center; gap: 12px;
}
.portrait {
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #2a5a8a, #0c1f2e);
  border: 3px solid var(--gold);
  box-shadow: 0 0 16px rgba(202, 168, 77, 0.5), inset 0 0 14px rgba(0,0,0,0.6);
  display: grid; place-items: center;
  position: relative;
}
#level-badge {
  font-family: var(--font-title); font-size: 1.6rem; font-weight: 700;
  color: var(--gold-bright); text-shadow: 0 0 8px #000, 0 2px 2px #000;
}
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; }
.bar {
  position: relative; width: 240px; height: 18px;
  background: linear-gradient(#0a1512, #050b0a);
  border: 2px solid rgba(202, 168, 77, 0.7);
  border-radius: 4px; overflow: hidden;
  box-shadow: inset 0 0 8px #000, 0 1px 2px rgba(0,0,0,0.6);
}
.bar.xp { height: 9px; }
.bar .fill { position: absolute; inset: 0; width: 100%; transition: width 0.18s ease-out; }
.bar.health .fill { background: linear-gradient(90deg, #8a1a1a, #ff5a4a); box-shadow: 0 0 10px rgba(255,90,74,0.6); }
.bar.mana .fill { background: linear-gradient(90deg, #1a3a8a, #5aa8ff); box-shadow: 0 0 10px rgba(90,168,255,0.6); }
.bar.xp .fill { background: linear-gradient(90deg, #6a4d00, #ffd76b); }
.bar-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000;
}
.shield-pip {
  font-size: 0.8rem; color: var(--blue-magic); margin-top: 2px;
  text-shadow: 0 0 6px var(--blue-magic);
}

/* HUD — spell hotbar */
.hotbar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.spell-slot {
  position: relative; width: 54px; height: 54px;
  background: radial-gradient(circle at 50% 35%, rgba(40,30,55,0.95), rgba(12,10,20,0.95));
  border: 2px solid var(--gold); border-radius: 8px;
  box-shadow: 0 0 12px rgba(0,0,0,0.6), inset 0 0 10px rgba(0,0,0,0.6);
  display: grid; place-items: center; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  overflow: hidden;
}
.spell-slot:hover { transform: translateY(-3px); box-shadow: 0 0 18px var(--purple-bright); }
.spell-slot.empty { border-color: rgba(202,168,77,0.3); opacity: 0.5; cursor: default; }
.spell-slot .key {
  position: absolute; top: 2px; left: 5px; font-size: 0.7rem;
  color: var(--gold-bright); font-weight: 700; text-shadow: 0 1px 2px #000;
}
.spell-slot .icon { font-size: 1.7rem; filter: drop-shadow(0 0 6px rgba(255,255,255,0.4)); }
.spell-slot .cooldown {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 0%;
  background: rgba(10, 10, 30, 0.72); pointer-events: none;
}

/* HUD — top-left gold + region */
.topleft { position: absolute; left: 22px; top: 18px; display: flex; flex-direction: column; gap: 8px; }
.gold-pill, .region-pill {
  background: linear-gradient(#241a10, #120c06);
  border: 2px solid var(--gold); border-radius: 20px;
  padding: 5px 14px; font-weight: 700; width: fit-content;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.gold-pill { color: var(--gold-bright); }
.region-pill { color: var(--green-bright); font-family: var(--font-title); letter-spacing: 0.08em; font-size: 0.85rem; }

/* HUD — quest tracker */
.quest-tracker {
  position: absolute; right: 22px; top: 210px; width: 260px;
  background: linear-gradient(160deg, rgba(20,14,30,0.82), rgba(8,6,14,0.82));
  border: 2px solid rgba(202,168,77,0.7);
  border-left: 4px solid var(--gold);
  border-radius: 6px; padding: 10px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
.qt-title { font-family: var(--font-title); color: var(--gold-bright); font-size: 0.95rem; margin-bottom: 6px; }
.quest-tracker ul { list-style: none; }
.quest-tracker li { font-size: 0.84rem; color: var(--parchment); margin: 3px 0; opacity: 0.92; }
.quest-tracker li.done { color: var(--green-bright); text-decoration: line-through; opacity: 0.7; }
.ready-tag {
  font-size: 0.6rem; background: var(--green-bright); color: #04140c;
  padding: 1px 6px; border-radius: 8px; vertical-align: middle; font-weight: 700;
}

/* HUD — minimap */
.minimap-frame {
  position: absolute; right: 22px; top: 18px; width: 170px; height: 170px;
}
#minimap {
  width: 170px; height: 170px; border-radius: 50%;
  box-shadow: 0 0 18px rgba(0,0,0,0.7);
}
.minimap-compass {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-title); color: var(--gold-bright);
  font-size: 0.8rem; text-shadow: 0 0 6px #000;
}

/* HUD — interaction prompt */
.interact-prompt {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(8,6,14,0.8); border: 1px solid var(--gold);
  padding: 8px 18px; border-radius: 20px; font-size: 0.95rem;
  color: var(--parchment); box-shadow: 0 0 14px rgba(202,168,77,0.4);
  animation: floatPulse 1.6s ease-in-out infinite;
}
.interact-prompt b { color: var(--gold-bright); }
@keyframes floatPulse { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }

/* HUD — hint bar (tutorial) */
.hint-bar {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  max-width: 640px; text-align: center;
  background: linear-gradient(rgba(20,14,40,0.88), rgba(10,8,20,0.88));
  border: 1px solid var(--purple-bright); border-radius: 10px;
  padding: 10px 22px; font-size: 0.95rem; color: var(--parchment);
  box-shadow: 0 0 22px rgba(185,138,255,0.4);
}
.hint-bar b { color: var(--gold-bright); }

/* HUD — controls reminder */
.controls-reminder {
  position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%);
  font-size: 0.72rem; color: rgba(233,220,191,0.5); white-space: nowrap;
}
.controls-reminder b { color: rgba(255,215,107,0.8); }

/* HUD — toasts */
.toast-stack {
  position: absolute; left: 50%; top: 130px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.toast {
  background: rgba(8,6,14,0.85); border: 1px solid var(--gold);
  border-radius: 16px; padding: 6px 18px; font-size: 0.9rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  animation: toastIn 0.25s ease-out;
  transition: opacity 0.4s;
}
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.gold { color: var(--gold-bright); border-color: var(--gold-bright); box-shadow: 0 0 14px rgba(255,215,107,0.35); }
.toast.warn { color: #ff8a6a; border-color: #ff8a6a; }
.toast.pickup { color: var(--green-bright); border-color: var(--green-bright); }
.toast.xp { color: var(--blue-magic); border-color: var(--blue-magic); }

/* HUD — banner */
.banner {
  position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%);
  font-family: var(--font-title); font-size: clamp(1.8rem, 5vw, 3.4rem);
  font-weight: 700; letter-spacing: 0.16em; color: var(--gold-bright);
  text-shadow: 0 0 24px rgba(255,215,107,0.7), 0 4px 12px #000;
  text-align: center; white-space: nowrap;
}
.banner-anim { animation: bannerPop 2.2s ease-out forwards; }
@keyframes bannerPop {
  0% { transform: translate(-50%,-50%) scale(0.7); opacity: 0; letter-spacing: 0.4em; }
  18% { transform: translate(-50%,-50%) scale(1); opacity: 1; letter-spacing: 0.16em; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

/* HUD — damage vignette */
.damage-vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.damage-vignette.flash {
  animation: dmgFlash 0.4s ease-out;
  box-shadow: inset 0 0 160px rgba(180, 20, 20, 0.85);
}
@keyframes dmgFlash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* HUD — floating damage numbers */
.dmg-layer { position: absolute; inset: 0; pointer-events: none; }
.dmg-number {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--font-title); font-weight: 700; font-size: 1.2rem;
  color: #ffd; text-shadow: 0 0 6px #000, 0 2px 2px #000;
}
.dmg-number.crit { color: var(--gold-bright); font-size: 1.7rem; text-shadow: 0 0 12px var(--gold-bright), 0 2px 3px #000; }

/* ===========================================================================
   Full-screen overlays (title, loading, menu, death)
   =========================================================================== */
#overlays { position: absolute; inset: 0; pointer-events: none; }
#overlays > * { pointer-events: auto; }

.title-card {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; padding-top: 14vh;
  background: radial-gradient(ellipse at center 30%, transparent 40%, rgba(0,0,0,0.35) 100%);
  animation: fadeIn 2s ease-out;
}
.title-hint { margin-top: 24px; color: rgba(233,220,191,0.5); font-size: 0.85rem; letter-spacing: 0.2em; }

.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at center, rgba(8,16,14,0.75), rgba(3,8,7,0.96));
  backdrop-filter: blur(2px);
}
.book-emblem { font-size: 3rem; color: var(--gold-bright); text-shadow: 0 0 24px var(--gold); animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-bar {
  width: min(420px, 70vw); height: 10px; border-radius: 6px;
  background: rgba(0,0,0,0.5); border: 1px solid var(--gold); overflow: hidden;
}
.loading-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green), var(--gold-bright)); transition: width 0.2s; }
.tip { color: rgba(233,220,191,0.7); font-style: italic; max-width: 540px; text-align: center; padding: 0 20px; }

/* Menus / buttons */
.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; min-width: 280px; }
.menu-btn {
  font-family: var(--font-title); font-size: 1.1rem; letter-spacing: 0.08em;
  color: var(--parchment);
  background: linear-gradient(160deg, rgba(40,30,22,0.95), rgba(18,12,8,0.95));
  border: 2px solid var(--gold); border-radius: 8px;
  padding: 12px 26px; cursor: pointer;
  transition: all 0.15s ease-out;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
}
.menu-btn:hover {
  color: var(--gold-bright); border-color: var(--gold-bright);
  box-shadow: 0 0 20px rgba(255,215,107,0.5); transform: translateY(-2px);
}
.menu-btn.primary { border-color: var(--purple-bright); color: #fff; background: linear-gradient(160deg, rgba(60,30,90,0.95), rgba(24,12,40,0.95)); }
.menu-btn.primary:hover { box-shadow: 0 0 24px var(--purple-bright); }
.menu-btn.danger { border-color: #b04a3a; color: #ff9a8a; }
.menu-btn.danger:hover { box-shadow: 0 0 18px rgba(176,74,58,0.6); border-color: #ff6a4a; }
.menu-btn.small { font-size: 0.9rem; padding: 8px 16px; }
.footer-note { margin-top: 26px; color: rgba(233,220,191,0.45); font-style: italic; font-size: 0.85rem; }

/* Death screen */
.death { background: radial-gradient(ellipse at center, rgba(40,8,8,0.7), rgba(4,2,2,0.97)); }
.death-title {
  font-family: var(--font-title); font-size: clamp(2.4rem, 7vw, 4.5rem);
  color: #ff5a4a; text-shadow: 0 0 30px rgba(255,40,40,0.7), 0 4px 10px #000; letter-spacing: 0.1em;
}
.death-sub { color: rgba(233,220,191,0.8); font-style: italic; }

/* ===========================================================================
   The Book modal (inventory / spellbook / map / settings / journal / pause)
   =========================================================================== */
.book-modal {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(3,6,5,0.78); backdrop-filter: blur(3px);
  /* Resting state is fully visible; the fade-in is re-triggered via .show on
     open (a CSS entry animation on a persistent display:none element can
     otherwise get stuck at its first keyframe). */
}
.book-modal.show { animation: fadeIn 0.2s ease-out; }
.book {
  position: relative; display: flex;
  width: min(940px, 94vw); height: min(620px, 88vh);
  background:
    linear-gradient(90deg, rgba(0,0,0,0.25), transparent 8%, transparent 92%, rgba(0,0,0,0.25)),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.015) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 0%, #efe3c6, #d8c69e 70%, #c2ac7e 100%);
  border: 10px solid #4a3520;
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--gold), 0 30px 70px rgba(0,0,0,0.7), inset 0 0 60px rgba(120,90,40,0.25);
  color: var(--ink);
  overflow: hidden;
}
.book-spine {
  width: 6px; background: linear-gradient(#7a5a30, #3a2a16);
  box-shadow: 0 0 14px rgba(0,0,0,0.5);
}
.book-page {
  flex: 1; padding: 26px 30px; overflow-y: auto;
  position: relative;
}
.book-page.left { box-shadow: inset -22px 0 26px -18px rgba(80,55,25,0.5); }
.book-page.right { box-shadow: inset 22px 0 26px -18px rgba(80,55,25,0.5); }
.book-page::-webkit-scrollbar { width: 8px; }
.book-page::-webkit-scrollbar-thumb { background: rgba(120,90,40,0.5); border-radius: 4px; }

.book-tabs {
  position: absolute; top: -2px; left: 50%; transform: translate(-50%, -100%);
  display: flex; gap: 6px; z-index: 5;
}
.book-tab {
  font-family: var(--font-title); font-size: 0.8rem;
  background: linear-gradient(#3a2a16, #241a0e); color: var(--parchment);
  border: 2px solid var(--gold); border-bottom: none;
  border-radius: 8px 8px 0 0; padding: 6px 12px; cursor: pointer;
  transition: all 0.12s;
}
.book-tab:hover { color: var(--gold-bright); }
.book-tab.active { background: linear-gradient(#6a4d20, #4a3518); color: var(--gold-bright); transform: translateY(2px); }

.book-close {
  position: absolute; top: 8px; right: 12px; z-index: 6;
  width: 32px; height: 32px; border-radius: 50%;
  background: #4a3520; color: var(--parchment); border: 2px solid var(--gold);
  font-size: 1rem; cursor: pointer; transition: all 0.12s;
}
.book-close:hover { background: #b04a3a; color: #fff; transform: rotate(90deg); }

/* Page typography */
.page-title { font-family: var(--font-title); font-size: 1.6rem; color: #5a3a14; border-bottom: 2px solid rgba(90,58,20,0.4); padding-bottom: 6px; margin-bottom: 6px; }
.page-flourish { font-style: italic; color: #7a5a30; margin-bottom: 14px; font-size: 0.9rem; }
.sub-title { font-family: var(--font-title); color: #5a3a14; margin: 14px 0 6px; font-size: 1.05rem; }
.empty-note { color: #8a6a40; font-style: italic; padding: 16px 0; }
.hint-line { margin-top: 12px; color: #6a4a20; font-style: italic; font-size: 0.85rem; }
.locked-line { color: #9a3a2a; }

/* Inventory */
.inv-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.inv-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(90,58,20,0.12); border: 1px solid rgba(90,58,20,0.3);
  border-radius: 6px; padding: 7px 10px; transition: all 0.12s;
}
.inv-item.usable { cursor: pointer; }
.inv-item.usable:hover { background: rgba(90,58,20,0.25); border-color: var(--gold); }
.inv-icon { font-size: 1.4rem; }
.inv-name { flex: 1; font-weight: 600; color: var(--ink); }
.inv-count { color: #7a5a30; font-weight: 700; }
.inv-use { color: var(--green); font-weight: 700; font-size: 0.85rem; }

.char-sheet { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.char-row { display: flex; justify-content: space-between; padding: 5px 8px; border-bottom: 1px dotted rgba(90,58,20,0.3); }
.char-row span { color: #7a5a30; }
.char-row b { color: var(--ink); }
.relic-list { list-style: none; }
.relic-list li { padding: 6px 0; font-size: 0.88rem; color: var(--ink); border-bottom: 1px dotted rgba(90,58,20,0.25); }

/* Spellbook */
.spell-list, .beast-list, .quest-list, .region-list { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.spell-entry, .beast-entry, .quest-entry, .region-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  background: rgba(90,58,20,0.08); border: 1px solid transparent; transition: all 0.12s;
}
.spell-entry:hover, .beast-entry:hover, .quest-entry:hover, .region-entry:hover {
  background: rgba(90,58,20,0.2); border-color: var(--gold);
}
.spell-entry.locked { opacity: 0.55; }
.spell-school {
  width: 38px; height: 38px; display: grid; place-items: center;
  font-size: 1.4rem; border-radius: 8px;
  background: rgba(0,0,0,0.08); border: 2px solid var(--c, #888);
  box-shadow: 0 0 10px var(--c, #888);
}
.spell-meta { flex: 1; }
.spell-name { font-weight: 700; color: var(--ink); }
.spell-school-name { font-size: 0.8rem; color: #7a5a30; }
.tier { font-size: 0.7rem; background: var(--green); color: #fff; padding: 1px 7px; border-radius: 8px; }
.lock { font-size: 0.7rem; background: #9a3a2a; color: #fff; padding: 1px 7px; border-radius: 8px; }
.spell-desc { color: var(--ink); line-height: 1.5; margin: 8px 0; }
.spell-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.spell-stats span { background: rgba(90,58,20,0.16); border-radius: 6px; padding: 4px 10px; font-size: 0.82rem; color: var(--ink); }
.upgrade-box { background: rgba(60,40,100,0.14); border-left: 3px solid var(--purple); padding: 8px 12px; border-radius: 4px; color: var(--ink); margin-top: 8px; }

/* Bestiary */
.beast-entry.unknown { opacity: 0.5; font-style: italic; }
.beast-dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.beast-name { font-weight: 600; color: var(--ink); }

/* Journal */
.quest-tag { font-size: 0.62rem; padding: 2px 8px; border-radius: 8px; font-weight: 700; min-width: 52px; text-align: center; }
.quest-tag.available { background: var(--gold); color: #2a1c08; }
.quest-tag.active { background: var(--blue-magic); color: #06243a; }
.quest-tag.ready { background: var(--green-bright); color: #04140c; }
.quest-tag.completed { background: #7a5a30; color: #fff; }
.quest-name { font-weight: 600; color: var(--ink); }
.quest-entry.completed { opacity: 0.6; }
.quest-summary { color: var(--ink); font-weight: 600; margin: 6px 0; }
.obj-list { list-style: none; margin: 6px 0; }
.obj-list li { padding: 3px 0; color: var(--ink); }
.obj-list li.done { color: var(--green); text-decoration: line-through; opacity: 0.7; }

/* Region map */
.region-orb { width: 22px; height: 22px; border-radius: 50%; background: var(--c, #888); box-shadow: 0 0 12px var(--c, #888); }
.region-entry.locked { opacity: 0.5; cursor: not-allowed; }
.region-entry.current { border-color: var(--green); background: rgba(40,120,70,0.15); }
.region-name { font-weight: 700; color: var(--ink); }
.region-sub { font-size: 0.8rem; color: #7a5a30; }
.here { font-size: 0.65rem; background: var(--green); color: #fff; padding: 1px 7px; border-radius: 8px; }

/* Settings */
.settings-list { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.set-row { display: flex; flex-direction: column; gap: 4px; color: var(--ink); font-weight: 600; }
.set-row.checkbox { flex-direction: row; align-items: center; gap: 10px; }
.set-row input[type="range"] { width: 100%; accent-color: var(--purple); }
.set-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); }
.settings-buttons { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.controls-table { width: 100%; border-collapse: collapse; }
.controls-table td { padding: 5px 8px; border-bottom: 1px dotted rgba(90,58,20,0.3); color: var(--ink); }
.controls-table td:first-child { color: #5a3a14; white-space: nowrap; }
.god-list { list-style: none; margin-top: 6px; }
.god-list li { padding: 5px 0; color: var(--ink); font-size: 0.85rem; border-bottom: 1px dotted rgba(90,58,20,0.25); }

.pause-buttons { min-width: auto; }
.pause-buttons .menu-btn { font-size: 0.95rem; padding: 9px 18px; }

/* ===========================================================================
   Dialogue
   =========================================================================== */
.dialogue {
  position: absolute; left: 0; right: 0; bottom: 0; top: 0;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 8vh; background: linear-gradient(transparent 60%, rgba(0,0,0,0.4));
  pointer-events: none;
}
.dialogue-box {
  pointer-events: auto;
  width: min(760px, 92vw);
  background: linear-gradient(160deg, rgba(28,20,42,0.96), rgba(12,9,20,0.97));
  border: 3px solid var(--gold); border-radius: 14px;
  box-shadow: 0 0 36px rgba(0,0,0,0.7), inset 0 0 40px rgba(90,60,140,0.2);
  padding: 18px 24px;
}
.dialogue-box.show { animation: dlgIn 0.25s ease-out; }
@keyframes dlgIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.speaker {
  font-family: var(--font-title); font-size: 1.25rem; color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(255,215,107,0.4); margin-bottom: 8px;
  border-bottom: 1px solid rgba(202,168,77,0.4); padding-bottom: 6px;
}
.dlg-text { font-size: 1.02rem; line-height: 1.6; color: var(--parchment); min-height: 3em; }
.dlg-text b { color: var(--gold-bright); }
.dlg-choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.dlg-choice {
  font-family: var(--font-body); font-size: 0.95rem;
  background: rgba(50,36,72,0.9); color: var(--parchment);
  border: 2px solid rgba(202,168,77,0.6); border-radius: 8px;
  padding: 8px 18px; cursor: pointer; transition: all 0.12s;
}
.dlg-choice:hover { border-color: var(--gold-bright); color: var(--gold-bright); transform: translateY(-2px); }
.dlg-choice.primary { background: linear-gradient(160deg, rgba(70,38,110,0.95), rgba(30,16,52,0.95)); border-color: var(--purple-bright); color: #fff; }
.dlg-choice.primary:hover { box-shadow: 0 0 16px var(--purple-bright); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Small screens */
@media (max-width: 720px) {
  .bar { width: 160px; }
  .quest-tracker { width: 200px; top: 190px; }
  .minimap-frame, #minimap { width: 120px; height: 120px; }
  .controls-reminder { display: none; }
  .spell-slot { width: 46px; height: 46px; }
}

/* ===========================================================================
   The Citadel hub — castle hotspot, corridor, fog, Marin's apothecary, loom
   =========================================================================== */

/* Clickable castle on the main menu (upper-right, over the drawn citadel). */
.castle-hotspot {
  position: absolute; top: 8%; right: 6%;
  width: clamp(240px, 46vw, 620px); height: clamp(200px, 54vh, 500px);
  background: transparent; border: none; border-radius: 12px;
  cursor: pointer; transition: all 0.2s; z-index: 5;
  display: flex; align-items: flex-start; justify-content: center;
}
.castle-hotspot:hover { box-shadow: inset 0 0 80px rgba(255,215,107,0.12); }
.castle-label {
  font-family: var(--font-title); font-size: 1.35rem; letter-spacing: 0.08em;
  color: var(--gold-bright); background: rgba(8,6,14,0.55);
  border: none; border-radius: 16px; padding: 10px 26px;
  margin-top: 26px; opacity: 0.96; transition: transform 0.2s, opacity 0.2s;
  text-shadow: 0 0 14px rgba(255,215,107,0.85), 0 2px 4px #000; white-space: nowrap;
  animation: castlePulse 2s ease-in-out infinite;
}
.castle-hotspot:hover .castle-label { transform: scale(1.08); opacity: 1; }
@keyframes castlePulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 0 10px rgba(255,215,107,0.3); }
  50% { transform: translateY(-5px); box-shadow: 0 0 22px rgba(255,215,107,0.6); }
}

/* Scene overlays */
.scene-overlay {
  position: fixed; inset: 0; z-index: 30; pointer-events: auto;
  background: #05040a; display: grid; place-items: center; overflow: hidden;
  animation: fadeIn 0.25s ease-out;
}
.scene-stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
}
.scene-bg {
  width: 100%; height: 100%; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
}

/* Door hotspots (positioned over the drawn doors within the 16:9 stage) */
.door-hotspot {
  position: absolute; background: transparent; border: 2px solid transparent;
  border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.door-wizard { left: 9%; top: 19%; width: 25%; height: 60%; }
.door-changing { left: 65%; top: 24%; width: 26%; height: 54%; }
.door-hotspot:hover { border-color: rgba(255,235,150,0.8); box-shadow: inset 0 0 26px rgba(255,235,150,0.35); }
.door-label {
  position: absolute; left: 50%; top: -8px; transform: translate(-50%, -100%);
  white-space: nowrap; padding: 4px 10px; border-radius: 6px;
  font-family: 'Press Start 2P', var(--font-title), monospace; font-size: 0.5rem;
  letter-spacing: 0.04em; opacity: 0.92;
}
.door-label.wiz {
  color: #ff7ad0; background: rgba(10,8,20,0.85); border: 1px solid #7a3a8a;
  text-shadow: 0 0 6px #ff7ad0, 0 0 12px #9a4dff;
}
.door-label.chg {
  color: #e8d6a0; background: #3a2a18; border: 1px solid #5a4226;
  text-shadow: 0 1px 1px #000;
}
.door-hotspot:hover .door-label { opacity: 1; transform: translate(-50%, -100%) scale(1.06); }

.scene-back {
  position: fixed; top: 18px; left: 18px; z-index: 32;
  font-family: var(--font-title); font-size: 0.85rem; color: var(--parchment);
  background: rgba(8,6,14,0.85); border: 2px solid var(--gold);
  border-radius: 8px; padding: 8px 16px; cursor: pointer; transition: all 0.15s;
}
.scene-back:hover { color: var(--gold-bright); border-color: var(--gold-bright); box-shadow: 0 0 16px rgba(255,215,107,0.4); }

.scene-hint {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 32;
  font-family: var(--font-body); color: rgba(233,220,191,0.7); font-style: italic;
  background: rgba(8,6,14,0.7); padding: 6px 16px; border-radius: 16px;
}
.scene-hint.flash { color: var(--gold-bright); }

/* Fog transition — kept fully hidden (no compositing) until it plays, so the
   expensive backdrop blur only runs during the brief wipe. */
.scene-fog {
  position: fixed; inset: 0; z-index: 35; pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity 0.36s ease-in-out;
  background:
    radial-gradient(circle at 30% 40%, rgba(180,190,210,0.9), transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(160,175,200,0.9), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(200,205,225,0.95), transparent 60%),
    linear-gradient(rgba(150,165,190,0.85), rgba(120,135,165,0.92));
}
.scene-fog.show { opacity: 1; visibility: visible; backdrop-filter: blur(6px); }

/* Shop overlay UI */
.shop-gold {
  position: fixed; top: 18px; right: 22px; z-index: 32;
  font-family: 'Press Start 2P', monospace; font-size: 0.8rem; color: var(--gold-bright);
  background: rgba(8,6,14,0.85); border: 2px solid var(--gold); border-radius: 8px;
  padding: 8px 14px; text-shadow: 0 0 8px rgba(255,215,107,0.5);
}
.shop-marin-line {
  position: fixed; top: 15%; left: 50%; transform: translateX(-50%); z-index: 32;
  max-width: 60%; text-align: center; font-style: italic; color: var(--parchment);
  background: rgba(10,8,20,0.6); padding: 6px 16px; border-radius: 14px;
  text-shadow: 0 1px 3px #000;
}
.shop-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 32;
  background: linear-gradient(rgba(8,6,14,0), rgba(8,6,14,0.92) 30%);
  padding: 26px 16px 16px;
}
.shop-title {
  text-align: center; font-family: var(--font-title); color: var(--gold-bright);
  letter-spacing: 0.1em; margin-bottom: 10px; text-shadow: 0 0 10px rgba(255,215,107,0.4);
}
.shop-counter {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  max-width: 1000px; margin: 0 auto;
}
.shop-item {
  width: 168px; text-align: left; cursor: pointer; transition: all 0.15s;
  background: linear-gradient(160deg, rgba(40,30,55,0.95), rgba(14,10,22,0.95));
  border: 2px solid var(--gold); border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px; color: var(--parchment);
}
.shop-item:hover { transform: translateY(-4px); border-color: var(--gold-bright); box-shadow: 0 0 20px rgba(255,215,107,0.4); }
.shop-item.loom { border-color: var(--purple-bright); }
.shop-item.loom:hover { box-shadow: 0 0 22px var(--purple-bright); }
.si-icon { font-size: 1.5rem; }
.si-name { font-family: var(--font-title); color: var(--gold-bright); font-size: 0.95rem; }
.si-desc { font-size: 0.74rem; color: rgba(233,220,191,0.75); line-height: 1.3; min-height: 2.4em; }
.si-price { font-weight: 700; color: var(--gold-bright); font-family: 'Press Start 2P', monospace; font-size: 0.6rem; margin-top: 4px; }

/* Enchanted Loom (upload + tear) */
.tapestry-modal {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center;
  background: rgba(3,4,10,0.85); backdrop-filter: blur(4px); animation: fadeIn 0.2s;
  pointer-events: auto;   /* re-enable the canvas/select/label inside #ui */
}
.tapestry-box {
  position: relative; width: min(640px, 94vw); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(30,20,44,0.98), rgba(12,9,20,0.99));
  border: 3px solid var(--purple-bright); border-radius: 14px; padding: 22px;
  box-shadow: 0 0 40px rgba(120,80,200,0.5);
}
.tapestry-box h2 { font-family: var(--font-title); color: var(--purple-bright); text-shadow: 0 0 12px rgba(185,138,255,0.5); }
.tap-sub { color: rgba(233,220,191,0.8); font-style: italic; margin: 6px 0 14px; }
.tap-close {
  position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border-radius: 50%;
  background: #3a2452; color: var(--parchment); border: 2px solid var(--purple-bright); cursor: pointer;
}
.tap-close:hover { background: #b04a3a; }
.tap-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.tap-upload {
  background: linear-gradient(160deg, rgba(70,38,110,0.95), rgba(30,16,52,0.95));
  border: 2px solid var(--purple-bright); border-radius: 8px; padding: 8px 14px;
  color: #fff; cursor: pointer; font-family: var(--font-title); font-size: 0.85rem;
}
.tap-upload input { display: none; }
.tap-sel { color: var(--parchment); font-size: 0.85rem; }
.tap-sel select, .tap-btn {
  background: rgba(40,30,55,0.9); color: var(--parchment); border: 1px solid var(--gold);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font-family: var(--font-body);
}
.tap-btn:hover { border-color: var(--gold-bright); color: var(--gold-bright); }
.tap-count { color: var(--parchment); font-size: 0.85rem; margin-left: auto; }
.tap-count b { color: var(--gold-bright); }
.tap-stage { position: relative; display: grid; place-items: center; }
#tap-canvas {
  width: min(512px, 84vw); height: min(512px, 84vw); image-rendering: pixelated;
  background: repeating-conic-gradient(#1a1622 0% 25%, #221c2e 0% 50%) 0 0 / 24px 24px;
  border: 2px solid #3a2c52; border-radius: 6px; cursor: pointer;
}
.tap-empty {
  position: absolute; color: rgba(233,220,191,0.5); font-style: italic; pointer-events: none; text-align: center;
}
.tap-foot { text-align: center; color: rgba(233,220,191,0.6); font-size: 0.82rem; margin-top: 8px; }

/* ---- Custom image overrides (assets/*.png) ------------------------------- */
/* A full-scene image fills the 16:9 stage; door hotspots overlay it. */
.scene-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: fill; image-rendering: pixelated; image-rendering: crisp-edges;
}

/* Custom main-menu background image, behind the menu content. */
.menu-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; image-rendering: pixelated;
}
.has-menu-bg #main-menu { background: rgba(0,0,0,0.18); backdrop-filter: none; }
.has-menu-bg #main-menu > *:not(.menu-bg):not(.castle-hotspot) { position: relative; z-index: 1; }
/* The supplied art usually has its own title baked in — hide the DOM title. */
.has-menu-bg #main-menu .game-title,
.has-menu-bg #main-menu .game-subtitle { display: none; }

/* The supplied corridor art has its own door signs — hide the DOM labels. */
.has-corridor-img .door-label { display: none; }

/* Marin's pixel sprite standing in his shop, over the photo background. */
.marin-sprite {
  position: absolute; left: 47%; top: 26%;
  height: 42%; width: auto; transform: translateX(-50%);
  image-rendering: pixelated; image-rendering: crisp-edges;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
}

/* Marin's character portrait in the shop (assets/marin.png). */
.marin-portrait {
  position: fixed; left: 3%; bottom: 18%; z-index: 33;
  height: min(50vh, 440px); width: auto; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
  border: none; background: transparent; border-radius: 0;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.7));
}
@media (max-width: 720px) { .marin-portrait { height: 34vh; left: 2%; bottom: 34%; } }

/* ===========================================================================
   Path (boss map), Boss battle, Character select
   =========================================================================== */
#path-bosses { position: absolute; inset: 0; }
.boss-hotspot {
  position: absolute; width: 16%; height: 28%;
  background: transparent; border: 2px solid transparent; border-radius: 12px;
  cursor: pointer; transition: all 0.15s; display: grid; place-items: center;
}
.boss-hotspot:hover {
  border-color: rgba(255,90,90,0.85);
  box-shadow: 0 0 26px rgba(255,90,90,0.4), inset 0 0 30px rgba(255,90,90,0.18);
}
.boss-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -4px);
  background: rgba(8,6,14,0.9); border: 1px solid #b03a3a; border-radius: 8px;
  color: #ffd0c0; font-family: 'Press Start 2P', monospace; font-size: 0.5rem;
  line-height: 1.5; padding: 5px 9px; white-space: nowrap; text-align: center;
  opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.boss-hotspot:hover .boss-tip { opacity: 1; }
.boss-check {
  position: absolute; top: 4px; right: 6px; color: #7fe06b; font-size: 1.3rem;
  text-shadow: 0 0 8px #000; opacity: 0;
}
.boss-hotspot.defeated .boss-check { opacity: 1; }
.boss-hotspot.defeated { opacity: 0.7; }

.path-castle {
  position: absolute; right: 1%; top: 4%; width: 17%; height: 44%;
  background: transparent; border: 2px dashed rgba(255,215,107,0.25); border-radius: 10px;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: flex-end; justify-content: center;
}
.path-castle:hover { border-color: rgba(255,215,107,0.85); box-shadow: inset 0 0 40px rgba(255,215,107,0.16); }
.path-castle span {
  font-family: var(--font-title); font-size: 0.8rem; color: var(--gold-bright);
  background: rgba(8,6,14,0.85); border: 1px solid var(--gold); border-radius: 14px;
  padding: 5px 12px; margin-bottom: 10px; text-shadow: 0 0 8px rgba(255,215,107,0.6); white-space: nowrap;
}

/* Boss battle */
.boss-battle {
  position: fixed; inset: 0; z-index: 40; background: #05040a;
  display: grid; place-items: center; overflow: hidden; pointer-events: auto;
}
#bb-canvas {
  width: min(98vw, calc(94vh * 16 / 9)); height: auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
}
.bb-flee {
  position: fixed; top: 16px; left: 16px; z-index: 42;
  font-family: var(--font-title); font-size: 0.85rem; color: var(--parchment);
  background: rgba(8,6,14,0.85); border: 2px solid var(--gold); border-radius: 8px;
  padding: 7px 14px; cursor: pointer;
}
.bb-flee:hover { color: var(--gold-bright); border-color: var(--gold-bright); }
.bb-hint {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 42;
  color: rgba(233,220,191,0.7); font-size: 0.8rem; background: rgba(8,6,14,0.6);
  padding: 5px 14px; border-radius: 14px;
}
.bb-result {
  position: fixed; inset: 0; z-index: 43; display: grid; place-items: center; align-content: center;
  background: rgba(3,4,10,0.8); gap: 10px; text-align: center; animation: fadeIn 0.3s;
}
.bb-result h1 {
  font-family: var(--font-title); font-size: clamp(2.4rem, 7vw, 4.5rem); letter-spacing: 0.12em;
}
.bb-result h1.win { color: var(--gold-bright); text-shadow: 0 0 30px rgba(255,215,107,0.7); }
.bb-result h1.lose { color: #ff5a4a; text-shadow: 0 0 30px rgba(255,40,40,0.7); }
.bb-result p { color: rgba(233,220,191,0.85); font-style: italic; margin-bottom: 8px; }
.bb-result-btns { display: flex; gap: 12px; justify-content: center; }

/* Character select */
.char-modal {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center;
  background: rgba(3,4,10,0.85); backdrop-filter: blur(4px); animation: fadeIn 0.2s; pointer-events: auto;
}
.char-box {
  position: relative; width: min(880px, 94vw); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(28,20,42,0.98), rgba(12,9,20,0.99));
  border: 3px solid var(--gold); border-radius: 14px; padding: 24px;
  box-shadow: 0 0 40px rgba(0,0,0,0.7);
}
.char-box h2 { font-family: var(--font-title); color: var(--gold-bright); text-shadow: 0 0 10px rgba(255,215,107,0.4); }
.char-box code { color: var(--green-bright); }
.char-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px; margin-top: 16px;
}
.char-card {
  background: rgba(40,30,55,0.6); border: 2px solid rgba(202,168,77,0.4); border-radius: 10px;
  padding: 8px; cursor: pointer; transition: all 0.15s; color: var(--parchment);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.char-card:hover { border-color: var(--gold-bright); transform: translateY(-3px); box-shadow: 0 0 16px rgba(255,215,107,0.35); }
.char-card.selected { border-color: var(--green-bright); box-shadow: 0 0 18px rgba(79,210,122,0.5); background: rgba(40,90,60,0.35); }
.char-card.empty { opacity: 0.5; cursor: default; }
.char-card.empty:hover { transform: none; box-shadow: none; border-color: rgba(202,168,77,0.4); }
.char-thumb {
  width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: #0c0a14; display: grid; place-items: center;
}
.char-thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.char-thumb.soon, .char-thumb.noimg { font-size: 2rem; color: rgba(233,220,191,0.4); }
.char-hero { font-size: 2.4rem; }
.char-name { font-family: var(--font-title); font-size: 0.8rem; text-align: center; color: var(--gold-bright); }
.char-card.empty .char-name { color: rgba(233,220,191,0.5); }
