html, body {
  margin: 0;
  padding: 0;
  background: #05060a;
  overflow: hidden;
  height: 100%;
}

#map-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: pointer;
}

/* ---- Title / save-load screen ---- */

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #05060a;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1.3s ease, filter 1.3s ease;
}

#start-screen.hidden { display: none; }

/* Leaving the menu: blur and fade away, revealing the map beneath. */
#start-screen.leaving {
  opacity: 0;
  filter: blur(18px);
  pointer-events: none;
}

/* The map view blur-fades in as the menu leaves. */
#map-canvas, #party, #hud, #location {
  transition: filter 1.5s ease, opacity 1.5s ease;
}
body.game-entering #map-canvas,
body.game-entering #party,
body.game-entering #daynight,
body.game-entering #daynight-label,
body.game-entering #hud,
body.game-entering #location,
body.game-entering #to-menu {
  filter: blur(20px);
  opacity: 0;
}

#to-menu {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  background: rgba(13, 15, 20, 0.8);
  border: 1px solid #2c2a24;
  color: #9a9282;
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: 18px;
  letter-spacing: 0.04em;
  padding: 5px 15px 8px;
  cursor: pointer;
  transition: filter 1.5s ease, opacity 1.5s ease,
    background 0.15s, border-color 0.15s, color 0.15s;
}

#to-menu:hover {
  background: rgba(28, 39, 33, 0.9);
  border-color: #6f9f7a;
  color: #d8cfbc;
}

/* The title art on its own layer (behind everything) so it can drift and
   take a chromatic-aberration filter without moving the menu. A slow
   breath scales it ~4.5% (a few dozen px) in and out over ~16s. */
#start-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url('../assets/ui/title.png') center / cover no-repeat;
  transform-origin: center;
  filter: url(#title-chroma);
  animation: titleDrift 16s ease-in-out infinite;
}

@keyframes titleDrift {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.075); }
}

@media (prefers-reduced-motion: reduce) {
  #start-screen::after { animation: none; }
}

/* Darken the lower half so the title and menu stay legible over the art. */
#start-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to bottom,
    rgba(5, 6, 10, 0.15) 0%,
    rgba(5, 6, 10, 0.55) 55%,
    rgba(5, 6, 10, 0.92) 100%);
}

#start-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(520px, 90vw);
  height: 100%;
  padding: 11vh 0 10vh;
  box-sizing: border-box;
}

/* Title rides up into the eye of the vortex; the menu sinks to the lower
   third (auto top margin pushes it down). */
#start-menu { margin-top: auto; }

/* Small BETA + version line beneath the title. */
#start-version {
  margin-top: 6px;
  font-family: 'Bebas Neue', 'Oswald', Georgia, sans-serif;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.34em;
  text-indent: 0.34em; /* re-centre against the letter-spacing */
  color: rgba(216, 196, 150, 0.5);
}

/* A save too old to load — dimmed, ember-tinted; only burnable. */
#start-menu .start-load.incompatible {
  opacity: 0.78;
  color: rgba(214, 142, 110, 0.92);
  font-style: italic;
}

#start-title {
  position: relative;
  margin: 0;
  font-family: 'Bebas Neue', 'Oswald', Georgia, sans-serif;
  text-transform: uppercase;
  font-weight: 400;
  font-size: clamp(64px, 13vw, 132px);
  letter-spacing: 0.12em;
  line-height: 0.9;
  color: #e8e0cc;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8),
    0 0 50px rgba(90, 200, 140, 0.35);
  /* Never quite in focus — a faint blur that wavers, so the title feels
     slightly wrong. Kept small enough to stay legible. */
  will-change: filter;
  animation: titleHaze 7.3s ease-in-out infinite;
}

/* As it blurs, a cyan/magenta chromatic split flashes across the title,
   settling back to the verge-green glow when it sharpens. */
@keyframes titleHaze {
  0%   { filter: blur(0.4px); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8), 0 0 50px rgba(90, 200, 140, 0.35); }
  38%  { filter: blur(1px); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8), 3px 0 1px rgba(255, 45, 110, 0.5), -3px 0 1px rgba(60, 230, 255, 0.6), 0 0 38px rgba(60, 230, 255, 0.4); }
  55%  { filter: blur(0.6px); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8), 0 0 48px rgba(88, 204, 150, 0.37); }
  78%  { filter: blur(1.1px); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8), -3.5px 0 1px rgba(255, 45, 110, 0.5), 3.5px 0 1px rgba(60, 230, 255, 0.65), 0 0 36px rgba(60, 230, 255, 0.42); }
  100% { filter: blur(0.4px); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.8), 0 0 50px rgba(90, 200, 140, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  #start-title { animation: none; filter: blur(0.6px); }
}

/* Super-brief RGB-slice glitch (JS toggles .glitch intermittently): two
   offset, colour-shifted copies of the title sliced into shifting bands.
   See muffinman.io/blog/css-image-glitch/. */
#start-title.glitch::before,
#start-title.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  /* sit above the solid title so the coloured slices read clearly */
  z-index: 2;
  pointer-events: none;
}

#start-title.glitch::before {
  color: #ff2d6b; /* magenta channel */
  animation: glitchSlice1 0.3s steps(4) 1 both;
}

#start-title.glitch::after {
  color: #2de1ff; /* cyan channel */
  animation: glitchSlice2 0.3s steps(4) 1 both;
}

@keyframes glitchSlice1 {
  0%   { clip-path: inset(6% 0 80% 0);  transform: translateX(-10px); }
  25%  { clip-path: inset(58% 0 26% 0); transform: translateX(9px); }
  50%  { clip-path: inset(34% 0 50% 0); transform: translateX(-7px); }
  75%  { clip-path: inset(80% 0 6% 0);  transform: translateX(6px); }
  100% { clip-path: inset(0 0 100% 0);  transform: translateX(0); opacity: 0; }
}

@keyframes glitchSlice2 {
  0%   { clip-path: inset(72% 0 10% 0); transform: translateX(10px); }
  25%  { clip-path: inset(18% 0 64% 0); transform: translateX(-9px); }
  50%  { clip-path: inset(46% 0 36% 0); transform: translateX(7px); }
  75%  { clip-path: inset(4% 0 84% 0);  transform: translateX(-6px); }
  100% { clip-path: inset(100% 0 0 0);  transform: translateX(0); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #start-title.glitch::before, #start-title.glitch::after { content: none; animation: none; }
}

#start-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

#start-menu button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: rgba(13, 15, 20, 0.78);
  border: 1px solid #3a4a3e;
  color: #d8cfbc;
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: 22px;
  letter-spacing: 0.01em;
  line-height: 1.1;
  /* Jim Nightshade sits high in its line box — drop the text ~2px so it
     reads centred in the button (top padding +2, bottom -2; height holds). */
  padding: 12px 16px 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
}

/* Hovering softens the option into a faint, static blur — unsettling, in
   keeping with the title (no looping animation, just a held blur). */
#start-menu button:hover {
  background: rgba(28, 39, 33, 0.9);
  border-color: #6f9f7a;
  filter: blur(0.8px);
}

#start-menu .start-new {
  text-align: center;
  font-size: 26px;
  color: #e8e0cc;
  border-color: #6f8f5a;
}

#start-menu .start-label {
  margin: 12px 0 2px;
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a9486;
}

#start-menu .start-save {
  display: flex;
  gap: 8px;
}

#start-menu .start-save .start-load { flex: 1 1 auto; }

#start-menu .start-del {
  flex: 0 0 auto;
  width: 42px;
  text-align: center;
  color: #9a8a8a;
  /* nudge the ✕ ~2px down and left so it sits centred (top/left +2, the
     opposite sides -2 keep the button the same size) */
  padding: 14px 18px 6px 14px;
}

#start-menu .start-del:hover {
  background: rgba(58, 28, 28, 0.9);
  border-color: #845a5a;
  color: #e0c0c0;
}

#start-menu .start-prompt {
  margin: 0 0 4px;
  color: #cfc6b2;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

#start-menu .start-signin {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  min-height: 44px;
}

#start-menu .start-mark {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 16px 9px; /* match the ~2px downward nudge */
}

#start-menu .start-mark .mark-name {
  color: #e8e0cc;
  letter-spacing: 0.02em;
  font-size: 21px;
}

/* Descriptive flavor stays in a readable serif, not the display script. */
#start-menu .start-mark .mark-desc {
  color: #9a9282;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 13px;
  font-style: italic;
  line-height: 1.45;
}

#start-menu .start-mark:hover .mark-desc { color: #b8b0a0; }

#start-menu .start-back {
  text-align: center;
  color: #8a8270;
  background: transparent;
  border-color: #2c2a24;
}

/* Rising-ember fire (BlackStar-style) for the "burn" controls. JS fills a
   .fire with .ember particles on hover; each floats up, fades, and shrinks. */
@keyframes rise {
  from { opacity: 0; transform: translateY(0) scale(1); }
  20% { opacity: 1; }
  to { opacity: 0; transform: translateY(-4em) scale(0); }
}

.fire {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  height: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 1;
}

.fire .ember {
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%,
    #ffe08a 0%, #ff9a2e 40%, rgba(255, 70, 0, 0.55) 68%, transparent 74%);
  filter: blur(2px);
  animation: rise linear infinite;
}

#start-menu .start-del,
.start-confirm-actions .confirm-yes { position: relative; }

/* Confirm dialog (e.g. deleting a save) */
.start-confirm {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 10, 0.72);
}

.start-confirm-panel {
  width: min(360px, 84vw);
  padding: 24px 26px 20px;
  background: rgba(13, 15, 20, 0.97);
  border: 1px solid #3a4a3e;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.start-confirm-panel p {
  margin: 0 0 18px;
  white-space: pre-line;
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: 22px;
  line-height: 1.35;
  color: #cfc6b2;
}

.start-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.start-confirm-actions button {
  flex: 1 1 0;
  background: rgba(13, 15, 20, 0.8);
  border: 1px solid #2c2a24;
  color: #c9c2b4;
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: 20px;
  padding: 8px 14px 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, filter 0.15s;
}

.start-confirm-actions button:hover { filter: blur(0.8px); }

.start-confirm-actions .confirm-yes:hover {
  background: rgba(58, 28, 28, 0.9);
  border-color: #845a5a;
  color: #e6c4c4;
}

.start-confirm-actions .confirm-no:hover {
  background: rgba(28, 39, 33, 0.9);
  border-color: #6f9f7a;
  color: #d8cfbc;
}

/* ---- Encounter modal (centre screen, blocking) ---- */

#encounter {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(5, 6, 10, 0.55);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

#encounter.hidden { display: none; }

/* The encounter card is an open journal: the book art is the background
   (behind the text, above the blurred map), and the text is dark ink on
   parchment. The box keeps the book's 4:3 ratio so it isn't distorted. */
#encounter-panel {
  position: relative;
  /* Fixed internal size (1180 × 1180·1086/1448). Everything inside is laid out
     against this constant box — % margins and px fonts alike never drift — and
     the whole panel is then uniformly scaled to fit the window by
     fitEncounterPanel() in main.js. So the book reads identically at any
     viewport size: same margins, same text arrangement. */
  width: 1180px;
  height: 885px;
  flex: none; /* keep the fixed box; the flex parent must not stretch it */
  transform-origin: center center;
  overflow-y: auto;
  box-sizing: border-box;
  /* Fixed px (≈ 8%/13%/9% of the 1180px panel). NOT percentages: % padding
     resolves against the parent (viewport) width, so it grew with the window
     and squeezed the text — the bug this replaces. */
  padding: 94px 183px 106px;
  background: url('../assets/ui/log4.png') center / 100% 100% no-repeat;
  border: none;
  box-shadow: none;
  font-family: 'Jim Nightshade', Georgia, serif;
  animation: encounterIn 0.35s ease both;
  /* no visible scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#encounter-panel::-webkit-scrollbar { width: 0; height: 0; }

@keyframes encounterIn {
  from { opacity: 0; transform: translateY(10px) scale(calc(var(--fit, 1) * 0.98)); }
  to { opacity: 1; transform: translateY(0) scale(var(--fit, 1)); }
}

/* Two pages of the open journal: narrative on the left, choices on the
   right, with a gutter standing in for the spine. */
#encounter-panel .spread {
  display: flex;
  gap: calc(8% + 20px);
  align-items: stretch;
  height: 100%;
  margin-top: -20px; /* match the journal's text placement for consistency */
}

#encounter-panel .page-left,
#encounter-panel .page-right {
  flex: 1 1 0;
  min-width: 0;
}

#encounter-panel .page-left { overflow: hidden; }

#encounter-panel .page-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Floated medallion: title and body wrap around it from the top. */
#encounter-panel .page-left .medallion.enc-float {
  float: left;
  width: 78px;
  height: 78px;
  margin: 2px 14px 6px 0;
}
#encounter-panel .page-left h2 { text-align: left; margin-top: 0; }
#encounter-panel .page-left p,
#encounter-panel .page-left .action-result { text-align: left; }
#encounter-panel .choice-block { clear: both; }

/* Inventory tab: the art fills the page area; the PACK grid is HTML slots
   (count is data-driven) over a cream panel that hides the drawn grid.
   The left/top/width/height fractions are tuning knobs to line the grid up
   with the drawn PACK frame. */
/* The page-spread art (EQUIPMENT | PACK) insets over the book's pages, sitting
   inside the leather cover drawn by log3. Its aspect matches the panel, so
   `fill` doesn't distort. left/top/width/height line the pages up with the
   cover. */
#encounter-panel .inv-spread {
  position: absolute;
  left: 12.3%;
  top: 7.5%;
  width: 75.5%;
  height: 74.5%;
}
#encounter-panel .inv-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}
/* PACK slots laid over the blank right page. Count is data-driven (the lead's
   `pack`); --cols sets the columns. The fractions line the grid up with the
   PACK frame; each slot is the parchment tile. */
/* The five inventory regions. All share tile size/spacing (6 columns,
   closely spaced); each is positioned under its drawn header. Left/top are
   tuning knobs against the header rules in inventory-overlay.png. */
#encounter-panel .arms-grid,
#encounter-panel .materia-grid,
#encounter-panel .quick-grid,
#encounter-panel .anchors-grid,
#encounter-panel .relics-grid {
  position: absolute;
  width: 38%;
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), 1fr);
  gap: 4px; /* closely spaced */
  align-content: start;
}
/* Left page — nudged out toward the outer edge (away from the spine). */
#encounter-panel .arms-grid    { left: 4.2%; top: 12.2%; }
#encounter-panel .materia-grid { left: 4.2%; top: 55.2%; }
#encounter-panel .quick-grid   { left: 4.2%; top: 89.2%; }
/* Right page — nudged out toward the outer edge (away from the spine). */
#encounter-panel .anchors-grid { left: 57.2%; top: 12.2%; }
#encounter-panel .relics-grid  { left: 57.2%; top: 55.2%; }
#encounter-panel .pack-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  background: url('../assets/ui/inventory-tile.png') center / 100% 100% no-repeat;
}
/* Hover detail pane for an inventory item — parchment + dark ink, floated
   above the slot. */
.item-detail {
  position: fixed;
  z-index: 80;
  max-width: 320px;
  padding: 12px 16px;
  background: url('../assets/ui/tooltip-paper.png') center / cover;
  color: #3a2a18;
  border: 1px solid #8a6f43;
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(10, 6, 2, 0.45);
  font-family: 'Jim Nightshade', Georgia, serif;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.item-detail.show { opacity: 1; }
.item-detail-title {
  font-size: 25px;
  color: #2a1d0e;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(60, 40, 20, 0.35);
  padding-bottom: 4px;
}
.item-detail-body {
  font-size: 18px;
  font-style: italic;
  line-height: 1.5;
}

/* A carried item's icon, centred on the tile. Drawn larger than the cell so
   the art reads clearly (it overspills the tile border a little). */
#encounter-panel .slot-item {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 156%;
  height: 156%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}

/* Quest tab: Major / Minor headings and their entries. */
#encounter-panel .quest-head {
  margin: 0.5em 0 0.15em;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: 1.05em;
  border-bottom: 1px solid rgba(60, 40, 20, 0.35);
  opacity: 0.85;
}
#encounter-panel .quest-head:first-child { margin-top: 0; }
#encounter-panel .quest-empty { opacity: 0.6; font-style: italic; }
#encounter-panel .quest-item.done { opacity: 0.55; text-decoration: line-through; }
/* "About My Person" slot tiles on the Qualities page — small parchment tiles
   in normal flow (the inventory grids are absolutely positioned; this isn't).
   Hover gives the item's flavor via the shared .item-detail pane. */
#encounter-panel .person-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), 60px);
  gap: 6px;
  margin-top: 0.35em;
}
/* Fit the art to the tile here (no overspill) so the whole visible icon is the
   hover target — the global 156% overspill left dead space around small tiles.
   pointer-events:auto re-enables hover (.journal-content disables it so page
   text never swallows pager clicks — but these tiles must be hoverable). */
#encounter-panel .person-grid { pointer-events: auto; }
#encounter-panel .person-grid .slot-item { width: 100%; height: 100%; }

/* Qualities readout: tight rows pushed down a touch, each with hover flavor.
   pointer-events:auto overrides .journal-content's none so the hover fires. */
#encounter-panel .quality-list {
  margin-top: 30px;
  pointer-events: auto;
}
#encounter-panel .quality-row {
  margin: 0.08em 0;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1.3;
  cursor: help;
}

/* Ribbon tabs at the foot of the book (overlay the drawn ribbons). */
#encounter-panel .book-tab {
  position: absolute;
  bottom: 1%;
  width: 4.5%;
  height: 13%;
  transform: translateX(-50%);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* Dossier tabs (stats / quests / notes): one passage across two columns. */
#encounter-panel .journal-content {
  height: 100%;
  box-sizing: border-box;
  padding-top: 0;
  margin-top: -20px; /* raise the body text up on both pages */
  column-count: 2;
  column-gap: calc(8% + 20px);
  column-fill: auto;
  pointer-events: none; /* text isn't interactive — never swallow pager clicks */
}

/* Journal reader: entries flow continuously through page-wide columns. Each
   entry starts a new page (column); a long entry breaks onto the next page.
   The viewport clips to one spread (two columns); the flow is slid sideways
   to turn spreads. */
#encounter-panel .journal-viewport {
  position: relative;
  height: 100%;
  overflow: hidden;
  margin-top: -20px; /* raise the body text up on both pages */
}
#encounter-panel .journal-flow {
  height: 100%;
  column-count: 2;
  column-gap: calc(8% + 20px);
  column-fill: auto;
  pointer-events: none; /* text isn't interactive — never swallow pager clicks */
}
#encounter-panel .jrnl-entry { break-before: column; }
#encounter-panel .jrnl-entry:first-child { break-before: avoid; }

/* In the journal reader / dossier the columns are narrow, so the portrait is a
   small block above the text rather than a left float (a float would squeeze
   the title and body into a thin strip on the right). The encounter modal keeps
   its float — its page is much wider. */
#encounter-panel .journal-content .medallion.enc-float,
#encounter-panel .journal-flow .medallion.enc-float {
  float: left;
  width: 78px;
  height: 78px;
  margin: 2px 14px 6px 0;
}
#encounter-panel .journal-content h2,
#encounter-panel .journal-flow h2 { text-align: left; margin-top: 0; }
#encounter-panel .journal-content p,
#encounter-panel .journal-flow p { text-align: left; }

/* Time-of-day subscript beneath an entry heading. */
#encounter-panel .entry-time {
  margin: -4px 0 10px;
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.05em;
  color: #6e5733;
}

/* Journal-reader navigation (prev / next / close), only in browse mode. */
#encounter-panel .jrnl-btn {
  position: absolute;
  z-index: 8; /* above the page text so the glyphs stay clickable */
  pointer-events: auto;
  background: none;
  border: none;
  color: #5a4326;
  font-family: Georgia, serif;
  line-height: 1;
  cursor: pointer;
  padding: 6px 10px;
}
#encounter-panel .jrnl-btn:hover { color: #2a1d0e; }
#encounter-panel .jrnl-btn:disabled { opacity: 0.22; cursor: default; }
#encounter-panel .jrnl-close { right: 5%; top: 6%; font-size: 22px; }

/* Journal pager: the page-count text in the bottom corners is the control.
   Spans (not buttons) so they size to the text and don't inherit .card
   button styling. Left turns back, right turns forward; only the active
   side reacts to hover and clicks. */
#encounter-panel .pager {
  position: absolute;
  bottom: 19%;
  z-index: 12;
  display: inline-block; /* hug the text, not the page width */
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: 15px;
  letter-spacing: 0.06em;
  font-style: italic;
  color: #6e5733;
  opacity: 0.5; /* inert at the ends */
  pointer-events: none;
  user-select: none;
}
#encounter-panel .pager-back { left: 15%; }
#encounter-panel .pager-fwd { right: 15%; }
#encounter-panel .pager.on {
  opacity: 0.85;
  pointer-events: auto;
  cursor: pointer;
}
#encounter-panel .pager.on:hover { opacity: 1; color: #2a1d0e; }

/* Encounter card: medallion stacked over centred ink text. */
#encounter-panel .med-header {
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#encounter-panel .medallion {
  width: 87px;
  height: 87px;
  border-color: #6b4f2a;
}

#encounter-panel .med-text { text-align: center; }
#encounter-panel .actions-label { text-align: center; color: #6e5733; }

/* Dark ink on the parchment, in the journal's script hand. */
#encounter-panel h2 { text-align: center; color: #43301c; font-size: 30px; letter-spacing: 0.03em; }
#encounter-panel p { color: #4a3a26; font-size: 19px; line-height: 1.4; }
#encounter-panel .actions-label { font-size: 15px; }
#encounter-panel button { font-size: 21px; }
#encounter-panel .action-result {
  color: #43301c;
  border-left-color: #8a6a32;
  background: rgba(120, 80, 24, 0.08);
  font-size: 19px;
}
#encounter-panel .challenge.win { color: #3e6f24; }
#encounter-panel .challenge.lose { color: #9a3722; }

#encounter-panel button {
  background: rgba(60, 42, 22, 0.1);
  border: 1px solid rgba(70, 50, 26, 0.45);
  color: #3a2a18;
}
#encounter-panel button:hover {
  background: rgba(60, 42, 22, 0.2);
  border-color: rgba(70, 50, 26, 0.8);
}

/* ---- UI hints (beige pointer + label, fades in/out) ---- */

/* Blocks all other clicks during a hint sequence; tooltips sit above it. */
.hint-blocker {
  position: fixed;
  inset: 0;
  z-index: 59;
  background: transparent;
  cursor: default;
}

.hint-tip {
  position: fixed;
  z-index: 60;
  display: flex;
  align-items: center;
  cursor: pointer;          /* click to dismiss / advance */
  opacity: 0;
  transition: opacity 0.4s ease;
}
.hint-tip.show { opacity: 1; }

.hint-cue {
  margin-top: 5px;
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.04em;
  color: #7a6a48;
}

.hint-text {
  background: url('../assets/ui/tooltip-paper.png') center / cover;
  color: #2c2114;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.3;
  max-width: 230px;
  padding: 9px 14px;
  border: 1px solid #8a6f43;
  border-radius: 4px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

.hint-arrow { width: 0; height: 0; }

.hint-right { flex-direction: row; }
.hint-right .hint-arrow {
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 11px solid #cabd96;
}
.hint-left { flex-direction: row-reverse; }
.hint-left .hint-arrow {
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 11px solid #cabd96;
}
.hint-bottom { flex-direction: column; }
.hint-bottom .hint-arrow {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 11px solid #cabd96;
}
.hint-top { flex-direction: column-reverse; }
.hint-top .hint-arrow {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 11px solid #cabd96;
}

/* ---- Day/night dial (above the party, top-left) ---- */

#moons {
  position: fixed;
  left: 20px;            /* same 56px column as the dial → centred together */
  top: 90px;             /* shifted down to leave room for tooltips above */
  width: 56px;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 8px;
}
#moons canvas { cursor: help; transition: transform 0.6s ease; }
#moon-tip,
#hover-tip {
  position: fixed;
  z-index: 60;
  max-width: 240px;
  padding: 9px 13px;
  background: rgba(18, 14, 10, 0.92);
  border: 1px solid #4a4030;
  border-radius: 5px;
  color: rgba(238, 228, 204, 0.95);
  font: italic 13px/1.45 Georgia, 'Times New Roman', serif;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#moon-tip.show,
#hover-tip.show { opacity: 1; }
#party-remark {
  position: fixed;
  z-index: 60;
  transform: translateY(-50%);
  max-width: 220px;
  padding: 8px 12px;
  background: rgba(18, 14, 10, 0.92);
  border: 1px solid #4a4030;
  border-radius: 6px;
  color: rgba(238, 228, 204, 0.96);
  font: italic 15px/1.4 Georgia, 'Times New Roman', serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
#party-remark.show { opacity: 1; }
/* The eclipse sun glows behind the converging moons (z-index:-1 keeps it under
   the moon discs but above the map). */
#eclipse-sun {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
  pointer-events: none;
  cursor: default;
}

#daynight {
  position: fixed;
  left: 20px;
  top: 116px;
  width: 56px;
  height: 28px;          /* show only the upper half of the disc */
  overflow: hidden;
  z-index: 10;
  border-bottom: 1px solid rgba(216, 196, 150, 0.55); /* the horizon */
}

#daynight-disc {
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;          /* full disc; lower half is clipped, centre on horizon */
  transform-origin: 50% 50%;
  transition: transform 1.2s ease;
}

#daynight-label {
  position: fixed;
  left: 20px;
  top: 148px;
  width: 56px;
  z-index: 10;
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(216, 196, 150, 0.75);
}

/* ---- Party menu (left edge) ---- */

#party {
  position: fixed;
  left: 18px;
  top: 168px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  z-index: 10;
}

/* Travel pace toggle, under the party portraits — cycles Run/Walk/Sneak. */
.pace-toggle {
  align-self: center; /* centre the label under the portrait column */
  margin-top: 2px;
  background: rgba(13, 15, 20, 0.8);
  border: 1px solid #2c2a24;
  color: #9a9282;
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: 16px;
  letter-spacing: 0.03em;
  padding: 3px 11px 5px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pace-toggle:hover { background: rgba(28, 39, 33, 0.9); border-color: #6f9f7a; color: #d8cfbc; }

.party-icon {
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #2c2a24;
  background-color: #0d0f14;
  background-size: cover;
  background-position: center 22%;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.party-icon:hover {
  transform: scale(1.07);
  border-color: #5a6f84;
}

.party-icon.active {
  border-color: #d8b878;
  box-shadow: 0 0 0 1px rgba(216, 184, 120, 0.4),
    0 2px 16px rgba(0, 0, 0, 0.7);
}

/* ---- Location medallion (top-right) ---- */

#location {
  position: fixed;
  right: 24px;
  top: 24px;
  width: min(440px, 88vw);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  z-index: 10;
}

#location.hidden {
  display: none;
}

.card {
  background: rgba(13, 15, 20, 0.92);
  border: 1px solid #2c2a24;
  padding: 22px 24px 20px;
  color: #c9c2b4;
  font-family: Georgia, 'Times New Roman', serif;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.7);
}

.card .med-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.card .medallion {
  flex: 0 0 auto;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background-color: #0d0f14;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border: 3px solid #d8b878;
  box-shadow: 0 0 0 1px #1a1712, 0 6px 28px rgba(0, 0, 0, 0.7),
    inset 0 0 34px rgba(0, 0, 0, 0.55);
}

.card .medallion.empty {
  border-style: dashed;
  border-color: #5a5443;
  opacity: 0.6;
}

.card .med-text {
  flex: 1 1 auto;
  min-width: 0;
}

.card .med-text p {
  margin: 0;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: normal;
  letter-spacing: 0.1em;
  color: #d8b878;
}

.card p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
}

.card .actions-label {
  margin: 16px 0 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a8270;
}

.card .action-result {
  display: none;
  margin: 12px 0 2px;
  padding: 11px 13px;
  border-left: 2px solid #d8b878;
  background: rgba(216, 184, 120, 0.06);
  font-size: 14px;
  font-style: italic;
  line-height: 1.6;
  color: #d8cdb4;
}

.card .action-result.show {
  display: block;
}

.card .challenge {
  margin: 12px 0 2px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.card .challenge.win { color: #9fe07a; }
.card .challenge.lose { color: #d98a7a; }

.card button.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.card button.ghost {
  background: transparent;
  border-color: #2c2a24;
  color: #8a8270;
}

.card button.ghost:hover {
  background: #14181f;
  border-color: #5a6f84;
}

/* ---- Qualities HUD (bottom-left) ---- */

#hud {
  position: fixed;
  left: 18px;
  bottom: 38px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
  font-family: Georgia, 'Times New Roman', serif;
}

#hud:empty { display: none; }

.hud-q {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-width: 132px;
  padding: 5px 12px;
  background: rgba(13, 15, 20, 0.86);
  border: 1px solid #2c2a24;
  color: #c9c2b4;
  font-size: 13px;
}

.hud-label { letter-spacing: 0.06em; color: #8a8270; }
.hud-val { color: #d8b878; }

.card .actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 6px;
}

.card button {
  display: block;
  width: 100%;
  text-align: left;
  background: #131a23;
  border: 1px solid #33404e;
  color: #c9c2b4;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 13px;
  cursor: pointer;
}

.card button:hover {
  background: #1c2733;
  border-color: #5a6f84;
}

.card .hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: #5d6672;
  font-style: italic;
}

/* Dip-to-black overlay for map transitions (enter/leave a location). */
#view-fade {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #05060a;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
#view-fade.show { opacity: 1; }

/* Current-district name, bottom-centre, semi-transparent — click for the spot's
   actions (enter / leave / opportunities). */
#district-name {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 30;
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: 30px;
  letter-spacing: 0.04em;
  color: rgba(232, 222, 196, 0.6);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.85);
  pointer-events: none; /* ambient label only — actions live on the node */
  user-select: none;
  white-space: nowrap;
  transition: opacity 0.4s ease;
}
#district-name.hidden { display: none; }

/* Hover list of NPCs sitting on a node — clickable labels to the node's right. */
.node-npcs {
  position: fixed;
  z-index: 40;
  display: none;
  flex-direction: column;
  gap: 4px;
  transform: translateY(-50%);
}
.node-npcs.show { display: flex; }
.node-npc {
  background: rgba(13, 15, 20, 0.92);
  border: 1px solid #4a5a4e;
  color: #e0d8c6;
  font-family: 'Jim Nightshade', Georgia, serif;
  font-size: inherit; /* set on the container so it scales with zoom */
  letter-spacing: 0.02em;
  padding: 3px 11px 5px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.node-npc:hover { background: rgba(28, 39, 33, 0.96); border-color: #8fbf8a; color: #fff0d0; }
