/* css/style.css — Base: colour tokens (:root), body, icons, toasts, header/nav, modals, Settings. The CSS is split into several files linked in this order from index.html (style, adventure, zones, party-entourage, party-tabs, overlays, mobile): the split is purely by position, so the cascade is identical to the old single file — keep the order. */

/* border-box everywhere so padding never adds to an element's declared width —
   without this, fixed-width boxes throughout this file overflow their containers
   on narrow (mobile) viewports. */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Mobile Safari draws button and select text (and the icons inside, which use currentColor) in its system blue unless a
   colour is set; every other browser uses black. Black everywhere, so the game looks the same on an iPhone. A button
   with its own class still sets its own colour on top of this (a class beats a plain element selector). */
button,
select {
  color: var(--color-black);
}

/* A visible focus ring on every keyboard-focused interactive element (buttons,
   inputs, textareas, links) — :focus-visible only fires for keyboard/programmatic
   focus, not a mouse click, so clicking a button still shows no ring while Tabbing
   to it does. Nothing in this file set any focus styling before this, so a
   keyboard-only player previously had no way to see which element was focused. */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-active-border);
  outline-offset: 2px;
}

/* Calm motion: the Settings "Reduce motion" switch (default: the device's prefers-reduced-motion) puts
   .reduce-motion on <html> (ui/settings-store.js). Transitions and animations finish instantly, so floating text,
   toasts, bar fills and hover effects still show their end state without moving. */
/* Always keep room for the page's scroll bar, so the whole layout doesn't slide left when a long panel makes the bar
   appear (and back when it goes). */
html {
  scrollbar-gutter: stable;
}

html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Color tokens — every raw hex color this file uses, named once here so a
   color can be changed in one place instead of hunting every literal hex
   value down. Mechanical extraction: same hex values, no visual change — see
   tools/extract-css-vars.py for how this mapping was derived. Grouped by the
   role the colors share, not alphabetically. */
:root {
  /* Neutral grays — borders, muted text, disabled/locked backgrounds */
  --color-border-dark: #333; /* Strong 2px box border used everywhere (slot/zone/tutorial/skill boxes, etc.) — also doubles as a few dark-on-light text colors (skill-formula, dashboard-stat-label, action-label, class-hexagon-label). */
  --color-border-light: #ccc; /* Light 1-2px border — dividers, most *-locked border-colors, modal dividers. */
  --color-build-progress-edge: #8fc983; /* Darker leading edge (and glow) of that same construction fill. */
  --color-build-progress: #cfe6c9; /* Left-to-right fill of a Foreman Build action row while it is under construction. */
  --color-enchant-top: #9a6b00; /* Text of an enchant roll in the top tenth of its range (gear cards). */
  --color-text-muted: #999; /* Muted/disabled text and border color — nav/zone/skill/class *-locked states, hp-track border. */
  --color-bg-disabled: #eee; /* Light grey background paired with color-text-muted/color-border-light on every *-locked box. */
  --color-text-secondary: #555; /* Secondary body text — flavor lines, hints, captions across most panels. */
  --color-text-tertiary: #666; /* Slightly darker secondary text — settings labels, feedback status message. */
  --color-text-quiet: #6f6f6f; /* Quietest secondary text — market tier hint, dashboard empty-state hint. */
  --color-text-locked-party: #777; /* Locked party-switcher button's own text color. */
  --color-black: #000; /* Pure black — HP text, floating-number outline, class-level-heading. */
  --color-portrait-halo: #d2b48c; /* Soft tan glow around the big Party > Hero portrait, softening its pixel outline. */
  --color-portrait-halo-heal: #22c55e; /* Portrait halo flash when an actor is healed. */
  --color-portrait-halo-hurt: #ef4444; /* Portrait halo flash when an actor takes damage. */
  --color-white: #fff; /* Pure white — modal background, toast text, several opaque box backgrounds. */
  --color-bg-soft: #fafafa; /* Very light grey background — combat log. */
  --color-bg-panel: #f7f7f7; /* Light panel background — adventure header box, zone-difficulty block. */
  --color-bg-chip: #f5f5f5; /* Light chip background — resource summary items, arena's un-medaled badge. */

  /* Success/safe (green) */
  --color-success-border: #2a6; /* Green border for every safe/active/selected/success state — by far the most-reused accent color in the file. */
  --color-success-bg: #eafaf0; /* Pale green background paired with color-success-border everywhere it's used. */
  /* Skill tag bubbles (data/damage-tags.js): a background/text pair per tag, text at 4.5:1 or better. */
  --color-tag-physical-bg: #ece7e0;
  --color-tag-physical-text: #4a3d2a;
  --color-tag-magic-bg: #e6e0f7;
  --color-tag-magic-text: #4b2f8a;
  --color-tag-heal-bg: #e0f5e0;
  --color-tag-heal-text: #146b3a;
  --color-tag-buff-bg: #dcecfa;
  --color-tag-buff-text: #1d4f86;
  --color-tag-debuff-bg: #fbe0e0;
  --color-tag-debuff-text: #a12222;
  --color-tag-ice-bg: #dff3fb;
  --color-tag-ice-text: #0b5b7a;
  --color-tag-fire-bg: #fde5d3;
  --color-tag-fire-text: #9a3a05;
  --color-tag-holy-bg: #fff6cc;
  --color-tag-holy-text: #7a5b00;
  --color-tag-dark-bg: #2f2a3d;
  --color-tag-dark-text: #e8e2f7;
  --color-tag-family-bg: #e3eef0; /* Enemy creature-family bubble (Beast, Undead, ...) on the enemy card. */
  --color-tag-family-text: #1f4a52; /* Text on the creature-family bubble (AA on its background). */
  --color-tag-unknown-bg: #eeeeee; /* An enemy trait not learned yet ("??? element") or "No element". */
  --color-tag-unknown-text: #555555; /* Text on the unknown-trait bubble. */
  --color-buff-bg: #e0f5e0; /* Buff status-effect badge background. */
  --color-buff-text: #146b3a; /* Buff status-effect badge text (dark enough for 4.5:1 on color-buff-bg). */

  /* Danger/debuff (red) */
  --color-danger-border: #c33; /* Red border/text for danger states, insufficient-funds flashes, and the armed Reset button. */
  --color-danger-bg: #fbe9e9; /* Pale red background paired with color-danger-border everywhere it's used. */
  --color-debuff-text: #a33; /* Debuff status-effect badge text (buff/debuff badges use a slightly different red pair than danger above). */
  --color-debuff-bg: #fbe0e0; /* Debuff status-effect badge background, also reused by the zone-tag-fought badge. */
  --color-gold-lost-text: #ff8a8a; /* The "-N gold" floating number after a lost gamble. */
  --color-damage-text: #e33; /* Floating damage number / a spent-resource floating number. */

  /* Info/explore (blue) */
  --color-info-text: #369; /* Exploration-mode nav button / item-status-effect (blue) badge text. */
  --color-info-bg: #e0edfb; /* Pale blue background paired with color-info-text, also reused by the zone-tag-explored badge. */
  --color-active-border: #2266cc; /* The currently-open top-nav tab's border, and the party-switcher's own Explore-mode color. */
  --color-active-bg: #cfe3fb; /* Pale blue background paired with color-active-border (active nav tab only). */
  --color-explore-bg: #e8f0fc; /* Party-switcher's own Explore-mode active background (a distinct, slightly different blue from color-info-bg). */
  --color-fill-blue: #a8c8f0; /* Follower/zone-level progress bar fill color. */
  --color-chart-accent: #4682e6; /* Class growth hexagon chart's data polygon/dot color. */

  /* War zone (purple) */
  --color-party-selected-border: #e0a800; /* The selected party's switcher button border (a clear gold ring). */
  --color-war-border: #96c; /* War Zone's own selected-box/party-switcher color. */
  --color-war-bg: #f3ecfa; /* Pale purple background paired with color-war-border. */
  --color-item-purple-text: #739; /* Order Feast's own item-status-effect badge text. */
  --color-item-purple-bg: #f0e0fb; /* Pale purple background paired with color-item-purple-text. */

  /* Exploration buffs (teal) */
  --color-exploration-buff-text: #0e7c7b; /* Gear Up (exploration/gathering buffs) status-effect badge text. */
  --color-exploration-buff-bg: #ddf3f2; /* Pale teal background paired with color-exploration-buff-text. */

  /* Battle (party switcher's own darker red/green text pair) */
  --color-battle-text: #c0392b; /* Party-switcher's own Battle-mode color. */
  --color-battle-bg: #fbeae8; /* Party-switcher's own Battle-mode active background. */
  --color-party-safe-text: #1a7a3c; /* Party-switcher's own Safe-mode text color (darker than color-success-border, text needs more contrast than a border does). */

  /* Pending / "Click to unlock" (gold) */
  --color-pending-border: #d90; /* Crystal-slot-pending border, and the crystal-equip-hint text color. */
  --color-pending-bg: #fff6e5; /* Pale gold background paired with color-pending-border, also reused by the random-event box. */
  --color-random-event-text: #a66a00; /* Random-event status line text. */
  --color-unlock-border: #e0a800; /* "Click to unlock" highlight's own border color. */
  --color-unlock-bg: #fff3cc; /* "Click to unlock" highlight's own background. */
  --color-unlock-text: #7a5200; /* "Click to unlock" highlight's own text color. */
  --color-unlock-kicker-text: #b07d00; /* The unlock intro modal's own small kicker label text. */

  /* Currency icons */
  --color-currency-gold: #c8a00c; /* Gold icon's fixed accent color. */
  --color-currency-dust: #9b59b6; /* Crystal Dust icon's fixed accent color. */
  --color-currency-gold-outline: #5a5750; /* The thin grey border around the gold icon, so it reads on any background. */
  --color-currency-dust-outline: #4b4357; /* The thin grey-violet border around the crystal dust icon. */

  /* HP/combat fill */
  --color-fill-green: #b6f2b6; /* HP bar / action-progress bar fill color (light green so black text stays readable on top). */

  /* Floating numbers (non-damage) */
  --color-heal-text: #3c3; /* Floating heal number / floating dust-gain number. */
  --color-defense-text: #d6ecff; /* Floating Evade/Parry/Block word (very pale blue, readable under the black outline). */
  --color-critical-text: #e0b400; /* Floating critical-hit damage number (gold instead of red). */
  --color-fame-text: #b366ff; /* Floating Fame-gain number. */
  --color-entourage-xp-text: #7fd4ff; /* Floating Entourage XP-gain number. */

  /* Actor name rarity */
  --color-rarity-magic: #1a3fa0; /* Magic-rarity actor name color. */
  --color-rarity-rare: #b35900; /* Rare-rarity actor name color. */
  --color-rarity-legendary: #6a1fa0; /* Legendary-rarity actor name color. */
  --color-boss-text: #ff0000; /* Boss actor name color (distinct from Legendary's purple). */

  /* Zone tags */
  --color-tag-returned-bg: #dff3e4; /* "Returned" zone-visit tag background. */
  --color-tag-returned-text: #1c7a3c; /* "Returned" zone-visit tag text. */
  --color-tag-fought-text: #a12222; /* "Fought" zone-visit tag text (background reuses color-debuff-bg). */
  --color-tag-explored-text: #2a62a8; /* "Explored" zone-visit tag text (background reuses color-info-bg). */

  /* Arena medal badges */
  --color-medal-platinum-border: #5b9bd5; /* Platinum medal badge border. */
  --color-medal-platinum-bg: #e8f2fc; /* Platinum medal badge background. */
  --color-medal-platinum-text: #2f5f8f; /* Platinum medal badge text. */
  --color-medal-gold-border: #c9a227; /* Gold medal badge border. */
  --color-medal-gold-bg: #fdf6df; /* Gold medal badge background. */
  --color-medal-gold-text: #8a6d10; /* Gold medal badge text. */
  --color-medal-bronze-border: #b8722f; /* Bronze medal badge border. */
  --color-medal-bronze-bg: #fbebdc; /* Bronze medal badge background. */
  --color-medal-bronze-text: #7a4a1d; /* Bronze medal badge text. */
  --color-medal-silver-bg: #f2f2f2; /* Silver medal badge background (border/text reuse color-text-muted/color-text-secondary). */

  /* Misc single-use */
  --color-skill-status-text: #a52a2a; /* A skill's own status-effect summary line text. */

  /* Home screen (js/ui/home-screen-ui.js) */
  --color-speech-bg: #fffdf6; /* Speech bubble over a portrait (ui/speech-bubbles-ui.js): a parchment white... */
  --color-speech-text: #2b2418; /* ...with dark brown text (well above 4.5:1). */
  --color-speech-border: #5a4a2e; /* The bubble's outline and tail. */
  --color-home-veil: rgba(10, 12, 24, 0.55); /* Dark wash over the cycling zone art, so the white text stays readable. */
  --color-home-text: #fdfaf2; /* Title, tagline and slot text on the dark home screen (well above 4.5:1 on the veil). */
  --color-home-button-bg: rgba(20, 22, 38, 0.82); /* Slot and secondary button background. */
  --color-home-button-border: #d9b65c; /* Gold edge of the home screen's buttons. */
  --color-home-button-hover-bg: rgba(60, 50, 24, 0.9); /* Button background on hover/focus. */
  --color-title-gold-mid: #e8c060; /* The game's title (js/ui/game-title-ui.js): its gold... */
  --color-tint-battle: rgba(255, 205, 205, 0.9); /* The bottom of the red fade behind a fight (js/ui/adventure-ui.js's updateAdventureTint). */
  --color-tint-gather: rgba(200, 220, 255, 0.9); /* The bottom of the blue fade behind a resource encounter. */
  --color-ceremony-banner-bg: rgba(20, 16, 10, 0.88); /* Boss / layer banner over the enemy row (js/ui/ceremony-ui.js). */
  --color-ceremony-banner-text: #fff3d6; /* Text on that banner (AA on its dark background). */
  --color-ceremony-boss-accent: #ef4444; /* The boss banner's red edge. */
  --color-ceremony-death-flash: #ef4444; /* A fallen enemy's red flash as its box fades. */
  --color-ceremony-boss-flash: #ffffff; /* A fallen boss's white flash. */
  --color-ceremony-class-silver: #c8d0dc; /* A Class level-up's silver glow (a Player level-up glows gold). */
  --color-title-edge: #2a1606; /* ...its dark bottom edge... */
  --color-title-glow: rgba(255, 210, 110, 0.55); /* ...and its soft glow. */
  --color-home-delete-border: #b5524a; /* Edge of a slot's Delete button (white text on the dark button stays above 4.5:1). */
  --color-home-delete-bg: #8e2a22; /* Delete button on hover, and once armed (white text on it is above 4.5:1). */
}


body {
  font-family: sans-serif;
  /* Left/right auto (rather than a fixed 1rem) centers the 1280px-capped content
     within the viewport on wider screens — the background (set on html, not body)
     still fills the full window on either side. Top/bottom keep the original 1rem. */
  margin: 1rem auto;
  /* A single stray oversized element could otherwise force the whole page to
     scroll sideways on a phone; panels that need their own horizontal scroll
     (tables, wide rows) opt into it individually via overflow-x: auto. */
  overflow-x: hidden;
  max-width: 1280px;
}

/* Shared monochrome icon primitive (see js/ui/icon-helpers.js's buildIconElement) —
   replaces plain Unicode emoji everywhere. width/height: 1em + inline-block is what
   actually fixes the original complaint (emoji glyphs render taller than
   surrounding text at the same font-size): sized purely off font-size, so it always
   matches the text around it exactly, on any screen. mask-image (set per-instance
   via JS, since it differs per icon) reveals background-color only where the
   source SVG's own icon shape is opaque — see icon-helpers.js's own comment on why
   its SVGs have their background square already stripped — so background-color
   IS the icon's visible color, defaulting to currentColor (inherits surrounding
   text color) unless overridden below. vertical-align nudges it up slightly so it
   optically centers against a text line's baseline rather than sitting flush with
   it (typical mask/inline-svg baseline quirk) — approximate, revisit once live. */
.icon {
  display: inline-block;
  /* 1.25em (rather than a plain 1em) so the icon reads a bit bigger/more legible
     than the surrounding text's own line-height, while still scaling with each
     context's own font-size instead of a fixed pixel size everywhere. */
  width: 1.35em;
  height: 1.35em;
  vertical-align: -0.15em;
  /* Pixel-snapped: 1.35em is rarely a whole number of pixels, so identical icons beside names of
     different widths were anti-aliased differently and looked like different sizes. Browsers without
     round() ignore these lines and keep the em values above. */
  width: round(1.35em, 1px);
  height: round(1.35em, 1px);
  vertical-align: round(-0.15em, 1px);
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  flex-shrink: 0;
}

/* The two currency icons (see icon-helpers.js's buildGoldIcon/buildCrystalDustIcon)
   keep their own fixed accent color rather than inheriting surrounding text color
   like every other icon — they show up constantly (header, every cost string,
   floating numbers) and stay easier to spot at a glance in their own color
   regardless of what text they're sitting next to. */
/* They also get a thin dark outline so they stay readable on any background. A mask can't be
   outlined directly (filters run BEFORE the mask, so a drop-shadow on the masked element is
   masked away too), so the coloured, masked shape lives on a ::before and the element itself
   just carries the outline: four 1px drop-shadows on it trace the shape's edge. The inline
   mask-image icon-helpers.js sets on the span is switched off here (!important beats inline),
   and the two icon files are named below instead. */
.icon-currency-gold,
.icon-currency-dust {
  position: relative;
  background: none;
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

.icon-currency-gold {
  filter:
    drop-shadow(1px 0 0 var(--color-currency-gold-outline))
    drop-shadow(-1px 0 0 var(--color-currency-gold-outline))
    drop-shadow(0 1px 0 var(--color-currency-gold-outline))
    drop-shadow(0 -1px 0 var(--color-currency-gold-outline));
}

.icon-currency-dust {
  filter:
    drop-shadow(1px 0 0 var(--color-currency-dust-outline))
    drop-shadow(-1px 0 0 var(--color-currency-dust-outline))
    drop-shadow(0 1px 0 var(--color-currency-dust-outline))
    drop-shadow(0 -1px 0 var(--color-currency-dust-outline));
}

.icon-currency-gold::before,
.icon-currency-dust::before {
  content: "";
  position: absolute;
  inset: 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
}

.icon-currency-gold::before {
  background-color: var(--color-currency-gold);
  -webkit-mask-image: url("../data/images/icons/gold.svg");
  mask-image: url("../data/images/icons/gold.svg");
}

.icon-currency-dust::before {
  background-color: var(--color-currency-dust);
  -webkit-mask-image: url("../data/images/icons/crystalDust.svg");
  mask-image: url("../data/images/icons/crystalDust.svg");
}

.resources-summary-item-emoji {
  font-size: 1.35em;
}

/* Most basic mobile pass: below this width, shrink the primary nav tabs from
   their fixed 130px desktop size to something that comfortably wraps into
   multiple rows on a phone instead of overflowing/getting clipped, and trim
   the page margin so more content fits. Layout otherwise already relies on
   flex-wrap throughout this file, so this is the only breakpoint needed for
   a basic mobile uplift. */
@media (max-width: 600px) {
  body {
    margin: 0.5rem;
  }

  #main-nav button {
    width: auto;
    min-width: 90px;
    flex: 1 1 auto;
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
  }
}

#toast-container {
  position: fixed;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-border-dark);
  color: var(--color-white);
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

.toast-message {
  flex: 1 1 auto;
  text-align: center;
}

.toast-close {
  background: none;
  border: none;
  color: var(--color-white);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
}

.toast-close:hover {
  opacity: 1;
}

.toast-fade-out {
  opacity: 0;
}

/* .top-bar-row: page tabs on the left, gold/dust stats and the icon buttons on the right. */
.top-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.top-bar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

#main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

/* Larger than the browser's default button size — these are the primary page tabs,
   not the smaller "Go to last..." shortcuts next to them. A fixed
   width (rather than sizing to each label's own text) keeps "Adventure"/"Tutorial"/
   "???" etc. all reading as one consistent row of tabs. */
#main-nav button {
  margin-right: 0.5rem;
  font-size: 1.05rem;
  line-height: 1.3rem;
  padding: 0.5rem 1rem;
  width: 130px;
}

/* A tab's "Click to unlock" (css/overlays.css's .unlock-pending) in a smaller font on one line, with the line height of
   a normal tab, so the nav row keeps its height and nothing below it moves. */
#main-nav button.unlock-pending {
  font-size: 0.8rem;
  white-space: nowrap;
  line-height: 1.3rem;
}

/* The Entourage tab's bubble of finished timed upgrades (ui-main.js's updateEntourageNavBadge), same look as .header-badge. */
#main-nav button[data-badge] {
  position: relative;
}

#main-nav button[data-badge]::before {
  content: attr(data-badge);
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 1.1rem;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--color-danger-border);
  color: var(--color-white);
  font-size: 0.7rem;
  font-weight: bold;
  line-height: 1.1rem;
  text-align: center;
}

.nav-button-safe {
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
}

.nav-button-danger {
  border-color: var(--color-danger-border);
  background: var(--color-danger-bg);
}

/* Unsafe zone, but in Exploration mode (see state.zoneEncounterMode) rather than
   Battle — a neutral blue rather than danger red, since a resource node poses no
   threat. */
.nav-button-exploring {
  border-color: var(--color-info-text);
  background: var(--color-info-bg);
}

/* A locked nav button (currently just the Gods tab before Duolopolis is first visited
   — see ui-main.js's updateGodNavButtonLockState) — same greyed-out treatment as a
   locked zone box in the Zones tab (see zones-ui.js's .zone-box-locked). */
.nav-button-locked {
  cursor: default;
  color: var(--color-text-muted);
  border-color: var(--color-border-light);
}

/* Whichever top-nav tab is currently open (see ui-main.js's showPanel) — a distinct
   blue so the player always knows where they are at a glance, deliberately a
   stronger/bolder blue than .nav-button-exploring's pale one above so the two never
   read as the same state (Adventure skips this entirely — see showPanel's own
   comment). More specific than .nav-button-locked (a class comes after another class
   of equal specificity in source order) isn't relied on here since the two never
   apply to the same button in practice — a locked tab can't be the active one. */
.nav-button-active {
  border-color: var(--color-active-border);
  background: var(--color-active-bg);
  font-weight: bold;
}

/* Wraps #header-stats as its own flex item within .top-bar-row, so that row's
   justify-content: space-between still splits into just two groups (nav on the left,
   this on the right) rather than spreading items apart individually. */
.header-right-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

#header-stats {
  display: flex;
  gap: 1rem;
  font-weight: bold;
}

/* Permanent player-facing Tutorial/Feedback buttons (see index.html) — sits inside
   .header-right-group alongside #header-stats, deliberately smaller than the main
   #main-nav tabs so it doesn't compete with them for attention. */
#header-button-row {
  display: flex;
  gap: 0.5rem;
}

#header-button-row button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* The icon fills most of the 40x40 button (the shared .icon is em-sized, so it is set in pixels here). */
#header-button-row button .icon {
  width: 26px;
  height: 26px;
  vertical-align: middle;
}

/* Next Steps / Achievements buttons: a small red number badge pinned to the button's top-right corner
   (hidden at 0 via the [hidden] attribute). */
.header-badge-button {
  position: relative;
}

.header-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 1.1rem;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--color-danger-border);
  color: var(--color-white);
  font-size: 0.7rem;
  font-weight: bold;
  line-height: 1.1rem;
  text-align: center;
}

.header-badge[hidden] {
  display: none;
}

/* Dimmed backdrop + centered box, shared by every modal (just the feedback one so
   far). Hidden by default via display:none rather than the [hidden] attribute, so
   .open can switch it to flex (for centering) with a single class toggle. */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--color-white);
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.modal-box h3 {
  margin-top: 0;
}

.modal-box textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem;
  resize: vertical;
}

/* Room under the category dropdown, so the textarea's focus ring never overlaps it. */
#feedback-category {
  display: block;
  margin-bottom: 0.5rem;
}

.feedback-status-message {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--color-text-tertiary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Settings modal (js/ui/settings-ui.js). A wider box whose body scrolls (the Close button stays put); each section is a
   card; toggles are full-width rows with a switch; save slots and game speed are segmented controls; action buttons
   fill the row; Reset is the one red button. */
.settings-modal-box {
  max-width: 520px;
  width: 100%;
  padding: 1.25rem 1.5rem;
}

.settings-modal-box h3 {
  margin: 0 0 0.75rem;
  font-size: 1.3rem;
}

#settings-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.1rem;
}

.settings-section {
  border: 1px solid var(--color-border-light);
  border-radius: 8px;
  background: var(--color-bg-soft);
  padding: 0.6rem 0.8rem 0.8rem;
}

.settings-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.settings-toggle,
.settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.25rem;
  font-size: 0.95rem;
}

.settings-toggle {
  cursor: pointer;
}

.settings-toggle + .settings-toggle {
  border-top: 1px solid var(--color-border-light);
}

/* The checkbox drawn as a switch. */
.settings-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 2.6rem;
  height: 1.45rem;
  margin: 0;
  border: 1px solid var(--color-border-dark);
  border-radius: 999px;
  background: var(--color-bg-disabled);
  cursor: pointer;
  transition: background 0.15s;
}

.settings-toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.45rem - 6px);
  height: calc(1.45rem - 6px);
  border-radius: 50%;
  background: var(--color-white);
  border: 1px solid var(--color-border-dark);
  transition: transform 0.15s;
}

.settings-toggle input[type="checkbox"]:checked {
  background: var(--color-success-border);
  border-color: var(--color-success-border);
}

.settings-toggle input[type="checkbox"]:checked::after {
  transform: translateX(1.15rem);
}

.settings-segmented {
  display: inline-flex;
}

.settings-segmented .settings-button {
  border-radius: 0;
  margin-left: -1px;
  min-width: 2.6rem;
}

.settings-segmented .settings-button:first-child {
  border-radius: 6px 0 0 6px;
  margin-left: 0;
}

.settings-segmented .settings-button:last-child {
  border-radius: 0 6px 6px 0;
}

.settings-button {
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  border: 1px solid var(--color-border-dark);
  border-radius: 6px;
  background: var(--color-white);
  color: var(--color-border-dark);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.settings-button:hover {
  background: var(--color-bg-disabled);
}

.settings-button.slot-active,
.settings-button.speed-active {
  position: relative; /* above its neighbours' overlapping borders */
  font-weight: bold;
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
  color: var(--color-buff-text);
}

/* A row of action buttons that share the full width equally. */
.settings-button-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.settings-button-row .settings-button {
  flex: 1 1 0;
}

.settings-button.settings-danger {
  border-color: var(--color-danger-border);
  color: var(--color-danger-border);
  background: var(--color-white);
}

.settings-button.settings-danger:hover {
  background: var(--color-danger-bg);
}

.settings-button.settings-danger.reset-armed {
  font-weight: bold;
  color: var(--color-white);
  background: var(--color-danger-border);
}

/* The inline "Replace Save N with ...?" question after choosing an import file. */
#settings-import-confirm:not(:empty) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-unlock-border);
  border-radius: 6px;
  background: var(--color-white);
  font-size: 0.85rem;
}

.settings-warning {
  color: var(--color-danger-border);
}

.settings-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.settings-version {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-tertiary);
  cursor: default;
  user-select: none;
}

#settings-status-message {
  min-height: 1.2rem;
  margin: 0.6rem 0 0.4rem;
  font-size: 0.85rem;
  color: var(--color-buff-text);
}

.settings-modal-box .modal-actions {
  display: block;
}

.settings-button.settings-close {
  width: 100%;
  background: var(--color-border-dark);
  color: var(--color-white);
}

.settings-button.settings-close:hover {
  background: var(--color-text-secondary);
}

/* Settings > Account (js/ui/settings-account-ui.js): login fields, one block per save slot, the inline comparison. */
.account-input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  font-size: 1rem; /* 16px+ keeps iOS from zooming the page when a field is focused */
}

.account-slot-row {
  margin-top: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  background: var(--color-white);
  font-size: 0.85rem;
}

.account-compare-line {
  margin-top: 0.15rem;
}

.account-compare:not(:empty) {
  margin-top: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-unlock-border);
  border-radius: 6px;
  background: var(--color-white);
  font-size: 0.85rem;
}

/* Keyboard shortcut hints (js/ui/shortcuts-ui.js): a tiny "[3]" in the bottom right of each top tab, only where a keyboard is
   likely (mouse devices). Drawn with CSS from data-shortcut so it is not lost when a tab's text is rewritten; hidden on a
   tab that is still locked ("???"). */
@media (hover: hover) and (pointer: fine) {
  button[data-shortcut] {
    position: relative;
  }

  button[data-shortcut]::after {
    content: "[" attr(data-shortcut) "]";
    position: absolute;
    right: 3px;
    bottom: 1px;
    font-size: 0.6rem;
    font-weight: normal;
    line-height: 1;
    opacity: 0.65;
    pointer-events: none;
  }

  button[data-shortcut].nav-button-locked::after {
    display: none;
  }
}

/* A small round "?" that explains something on hover (dom-helpers.js's buildHelpHint; a tap on touch screens). */
.help-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 0.75rem;
  font-weight: bold;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}

/* ---- Home screen (js/ui/home-screen-ui.js) -------------------------------------------------------------------------
   A full-window layer above the game and below every .modal-overlay (z-index 2000), so Settings opens on top of it.
   Two stacked background layers cross-fade between the active save's unlocked danger zones. */
#home-screen {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-black);
  color: var(--color-home-text);
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
}

#home-screen[hidden] {
  display: none;
}

/* While the home screen is up, the page underneath must not scroll behind it. */
body.home-screen-open {
  overflow: hidden;
}

.home-background-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.5s ease;
}

.home-background-layer.home-background-visible {
  opacity: 1;
}

/* The dark veil sits between the art and the buttons. */
#home-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-home-veil);
}

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

/* The game's title (js/ui/game-title-ui.js): IM Fell English SC (a serif when it can't load) in gold with a soft glow,
   over a canvas of drifting golden motes (and, on the prologue's teleport card, turning light rays). */
.game-title-block {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 2.5rem;
}

.game-title-light {
  position: absolute;
  inset: -40% -30%;
  width: 160%;
  height: 180%;
  pointer-events: none;
  /* The light fades out towards the canvas's edges instead of stopping at a rectangle. */
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 35%, transparent 100%);
}

.game-title {
  position: relative;
  margin: 0;
  font-family: "IM Fell English SC", Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: 3.6rem;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--color-title-gold-mid);
  text-shadow: 0 2px 0 var(--color-title-edge), 0 0 18px var(--color-title-glow);
}


/* One line, centred over the slots even when it is wider than them; it shrinks on a narrow window. */
.home-tagline {
  margin: 0 0 0.75rem 0;
  font-style: italic;
  font-size: clamp(0.75rem, 2.6vw, 1rem);
  white-space: nowrap;
  text-shadow: 0 1px 6px var(--color-black);
}

#home-slot-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.home-slot-button,
.home-secondary-button {
  background: var(--color-home-button-bg);
  color: var(--color-home-text);
  border: 2px solid var(--color-home-button-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.home-slot-button:hover,
.home-slot-button:focus-visible,
.home-secondary-button:hover,
.home-secondary-button:focus-visible {
  background: var(--color-home-button-hover-bg);
}

.home-slot-button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 0.6rem 1rem;
  text-align: left;
}

/* The save that was played last stands out a little. */
.home-slot-button-active {
  border-width: 3px;
}

/* A slot and its Delete button side by side. */
.home-slot-row {
  display: flex;
  gap: 0.4rem;
  width: 100%;
}

/* The slot picked by the first click: brighter, with "Click again to ..." under its summary. */
.home-slot-button-selected {
  background: var(--color-home-button-hover-bg);
  box-shadow: 0 0 0 2px var(--color-home-button-border), 0 0 14px var(--color-home-button-border);
}

.home-slot-hint {
  min-height: 1.2em;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--color-home-button-border);
}

.home-slot-delete-button {
  flex: 0 0 4.5rem;
  box-sizing: border-box;
  padding: 0 0.6rem;
  font-size: 0.8rem;
  background: var(--color-home-button-bg);
  color: var(--color-home-text);
  border: 2px solid var(--color-home-delete-border);
  border-radius: 6px;
  cursor: pointer;
}

/* Stands in for the Delete button beside an empty slot, so every slot button is the same width. */
.home-slot-delete-spacer {
  visibility: hidden;
}

.home-slot-delete-button:hover,
.home-slot-delete-button:focus-visible,
.home-slot-delete-armed {
  background: var(--color-home-delete-bg);
}

/* A brand-new player's single big button. */
.home-slot-button-new {
  align-items: center;
  text-align: center;
  padding: 1rem;
}

.home-slot-button-new .home-slot-title {
  font-size: 1.4rem;
}

.home-slot-title {
  font-weight: bold;
  font-size: 1rem;
}

.home-slot-detail {
  font-size: 0.8rem;
  opacity: 0.9;
}

.home-secondary-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.home-secondary-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
}

.home-version {
  position: absolute;
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.5rem, env(safe-area-inset-bottom));
  z-index: 1;
  font-size: 0.75rem;
  opacity: 0.85;
}
