/* game-base.css: tokens, native controls, status bar, quick-nav, focus, toasts. Moved verbatim from css/game.css (TD-CONTENT-SPLIT-001); link order in index.html keeps the cascade. */
  :root {
    --focus-ring: 2px solid var(--color-active);
    /* VIS-002: dark, modern theme. The names are historical (parchment/wood
       from the old brown look) — they are kept because they are used ~200
       times; only the values changed. Read them as: parchment = base
       surface, parchment-dark = raised surface, surface-2 = bars/headers,
       wood = border, heading/text/muted = the three text levels. */
    --parchment: #151a21;
    --parchment-dark: #1c222b;
    --surface-2: #10141a;
    --wood: #39424f;
    --wood-dark: #10141a;
    --wood-light: #39424f;
    --heading: #e9edf3;
    --text: #dfe4ea;
    --muted: #9aa4b2;
    --on-accent: #141821;
    --gold: #d9b45c;
    --gold-light: #f0cd7a;
    --gold-dark: #a8862f;
    --green: #5fa34a;
    --red: #d9534f;
    /* UX-073: --red reads 4.0:1 as text on slate and 3.1:1 under light text;
       text-on-dark and filled danger surfaces use these AA-safe steps. */
    --red-text: #ec7f7b;
    --red-fill: #a8332f;

    /* VIS-002: semantic color pass -- gold was overloaded for plain hover/
       selected states (page tabs, resource rows, mode-select buttons,
       combat target marker) with zero mastery/prestige/achievement meaning;
       those states now use --color-active (reusing --green's own value per
       the audit's "Grøn = active/running/obtainable/ready" mapping) so gold
       reads as "special" again. --color-magic and --color-locked are new
       roles the audit calls for that nothing in the codebase served before;
       --color-locked's value matches .skill-tile.locked's own
       already-shipping background so tokenizing it doesn't change how it
       looks (same derive-from-observed approach as VIS-001). */
    --color-active: var(--green);
    --color-magic: #9b6bd9;
    --color-locked: #1e242d;

    /* VIS-001: spacing/typography/radius scale, derived from game.css's own
       already-observed values (grepped, not invented) so tokenizing a
       selector never visibly changes it. Foundation phase of the owner-
       supplied Visual Design System audit (2026-09-26) -- see
       claude/tasks.json VIS-001/002/003 for the follow-up phases. */
    --space-xs: 2px;
    --space-sm: 4px;
    --space-md: 8px;
    --space-lg: 12px;
    --space-xl: 16px;
    --font-size-xs: 12px;
    --font-size-sm: 12px;
    --font-size-md: 13px;
    --font-size-lg: 18px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
  }

  * { box-sizing: border-box; }
  /* UX-093: native controls (checkbox, select arrow, scrollbars) follow the dark cabinet. */
  :root { color-scheme: dark; accent-color: var(--color-active); }

  /* VIS-003: VIS-002 retimede alt der havde en regel, men et <select> uden en
     regel arver ingenting -- browserens default er sort på hvidt, og seks af
     dem stod tilbage som hvide kasser på det mørke tema (bl.a. #page-jump og
     #skill-jump, som ER navigationen på mobil). En basisregel her dækker dem
     alle, i stedet for at opremse id'er der skal vedligeholdes hver gang en
     ny <select> tilføjes. De klasser der har brug for anden padding eller
     flex (.inventory-filter-select m.fl.) lægger stadig oven på. */
  /* UX-079: tekst-, søge- og talfelter + textarea får samme mørke basis
     (DESIGN.md Inputs: Deep Well, 1px iron, 6px radius, serif). */
  select,
  input[type="search"],
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  textarea {
    font-family: inherit;
    border: 1px solid var(--wood);
    border-radius: 6px;
    background: var(--wood-dark);
    color: var(--heading);
  }
  input[type="search"],
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  textarea { padding: 4px 8px; }
  input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
  select:focus-visible,
  input:focus-visible,
  textarea:focus-visible { outline: var(--focus-ring); outline-offset: 1px; }

  /* Den åbne dropdown tegnes af styresystemet og arver ikke altid ovenstående;
     at sætte den eksplicit holder listen læsbar i stedet for lys-på-lys. */
  select option {
    background: var(--wood-dark);
    color: var(--heading);
  }

  /* UX-006: visible to assistive tech, not to the eye. */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #save-error {
    margin: 12px;
    padding: 12px 16px;
    border: 2px solid var(--red);
    background: var(--parchment);
    color: var(--red-text);
  }

  #recover-original-btn { margin: 0 12px 12px; }

  body {
    margin: 0;
    /* Phase 37/63: extra top padding clears the fixed status bar (see
       .status-bar below) so it never overlaps the title on load. The bar
       is two rows tall (main row + the page-tabs row below it), and the
       page-tabs row can itself wrap to 2 lines on narrow viewports — this
       padding has enough slack for that worst case, which is harmless
       (just a bit of extra whitespace on wider screens, never an overlap). */
    padding: 150px 24px 24px;
    font-family: Georgia, 'Times New Roman', serif;
    background: var(--parchment);
    color: var(--text);
    display: flex;
    justify-content: center;
  }

  .game {
    width: 100%;
    max-width: 640px;
  }

  /* Phase 37 ("A persistent status bar"): gold, HP, and current-activity
     progress used to live only in the scrolling column below — the page
     runs up to ~8 screens tall on mobile, so that information disappeared
     the moment you scrolled down to Talents or Quests. This bar is fixed
     to the very top of the viewport (not just `sticky`, which would still
     be pushed around by body's own padding) so it's always visible.
     Its three fields are pure mirrors of DOM the game already renders
     correctly elsewhere (renderGold(), the combat panel's player-hp-*
     elements, and action-label/action-bar) — see renderStatusBar() — so
     there's no second copy of any game-state calculation to keep in sync.
     UX-026: the header's own #gold-display line was removed as a pure
     duplicate of this bar's #status-gold — renderGold() now writes
     #status-gold directly from state.gold instead of the old header
     element mirroring the other way around. */
  .status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--surface-2);
    border-bottom: 2px solid var(--wood);
    padding: 8px 16px;
    display: flex;
    /* The quick-nav row sits below the main gold/HP/activity row
       (.status-bar-inner) — column stacking (instead of flex's default
       row) is what makes them sit one above the other rather than
       fighting for horizontal space, especially at narrow mobile widths. */
    flex-direction: column;
    align-items: center;
  }

  .status-bar-inner {
    width: 100%;
    max-width: 640px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
  }

  .status-gold {
    font-weight: bold;
    font-size: 13px;
    color: var(--gold-light);
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .status-hp {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
  }

  .status-hp.status-hidden {
    display: none;
  }

  .status-hp-label {
    font-size: 12px;
    font-weight: bold;
    color: var(--text);
    white-space: nowrap;
  }

  .status-hp-bar-outer {
    width: 60px;
    height: 8px;
    background: var(--surface-2);
    border: 1px solid var(--wood);
    border-radius: 4px;
    overflow: hidden;
    flex: 0 0 auto;
  }

  .status-hp-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--green), #8cc077);
    width: 0%;
  }

  .status-activity {
    cursor: pointer;
    flex: 1 1 auto;
    min-width: 0; /* lets text-overflow: ellipsis actually kick in inside a flex item */
  }

  .status-activity-label {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
  }

  .status-activity-label.blocked {
    color: #e88a8a; /* var(--red) is too dark to read on the status bar's own dark background */
    font-weight: bold;
  }

  /* VIS-007 / UX-077: VIS-004's single, frequently-updated delta lives in
     #toast-container (order: 1 puts it on top of the column-reverse stack).
     While faded out it leaves the flow so it never leaves a gap. */
  .status-activity-delta {
    order: 1;
    position: absolute;
    bottom: 0;
    right: 0;
    width: max-content;
    max-width: min(360px, calc(100vw - 32px));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    visibility: hidden;
  }

  .status-activity-delta.status-activity-delta-visible {
    position: static;
    visibility: visible;
  }

  /* UX-GAIN-001: one toast-styled pill per skill XP / item; each fades on its own. */
  .status-activity-line {
    overflow-wrap: anywhere;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--gold);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 1;
    transition: opacity 0.5s ease-in;
  }

  .status-activity-line.status-activity-line-fading { opacity: 0; }

  @media (prefers-reduced-motion: reduce) {
    /* Audit section 21: no animated transition -- the text simply appears
       and is overwritten/cleared on the next gain, never fades. */
    .status-activity-line { transition: none; }
  }

  .status-activity-bar-outer {
    height: 6px;
    background: var(--surface-2);
    border: 1px solid var(--wood);
    border-radius: 3px;
    overflow: hidden;
  }

  .status-activity-bar-inner {
    height: 100%;
    background: var(--color-active);
    width: 0%;
  }

  /* Quick-nav: added during the UX audit pass. The page runs 5800+px tall
     at desktop width across 9+ major panels with no in-page navigation —
     this is a pure jump-to-section aid, it never reads or writes game
     state, so it's safe to add without touching any gameplay logic. */
  .status-nav-row {
    width: 100%;
    max-width: 640px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--wood);
  }

  /* Phase 63 Part 2: replaces the old jump-to-section <select> — now that
     every major panel is reachable as its own tab, a scroll-to-it dropdown
     is redundant (see DESIGN_BACKLOG.md's "Does this replace the quick-nav
     dropdown" decision). Lives in the same sticky row the select used to
     occupy, so it's reachable without scrolling from anywhere in the page. */
  .page-tabs {
    width: 100%;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .page-tab-btn {
    flex: 0 1 auto;
    padding: 4px 10px;
    border: 1px solid var(--wood);
    border-radius: 4px;
    background: var(--parchment);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
  }

  .page-tab-btn:hover {
    background: var(--color-active);
    color: var(--on-accent);
  }

  .page-tab-btn.active {
    background: var(--color-active);
    border-color: var(--heading);
    color: var(--on-accent);
    font-weight: bold;
  }

  /* UX-006: visible keyboard focus across the app shell (tab row, desktop
     sidebar, combat panel). Native buttons/summaries are already reachable;
     what was missing was a ring you can see on the dark theme. */
  /* UX-022: the two nav selects are the ONLY way to move around below 540px,
     and they were the one thing the first slice's list of classes missed --
     they kept the UA default ring, a 1px near-black outline that is invisible
     on the dark status bar. They are also the first controls in tab order on
     a phone, so this was the first thing a keyboard user could not see. */
  .page-tab-btn:focus-visible,
  .sidebar-category-heading:focus-visible,
  .sidebar-skill-btn:focus-visible,
  .status-nav-row select:focus-visible,
  .resource-btn:focus-visible {
    outline: 3px solid var(--heading);
    outline-offset: 2px;
  }

  /* Phase 40 ("a feedback/juice pass"): a small toast stack for level-ups
     and quest completions — see showToast() in the script. Stacks bottom-up
     above the queue/combat panels rather than the fixed status bar, so it
     never competes with that bar's own always-visible info. */
  /* UX-072: anchored bottom-right (max 3, see showToast) so toasts no longer
     cover mid-screen Claim buttons and cards. */
  #toast-container {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    align-items: flex-end;
    pointer-events: none;
    max-width: min(360px, calc(100vw - 32px));
  }

  .toast {
    pointer-events: auto; /* UX-077: only the toast itself, never the container's empty box */
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--gold);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
  }

  /* UX-087: toasts never cover navigation. Desktop (>=1024px): bottom of
     the content column, right of the 280px sidebar. Phones: one toast at the
     bottom of the viewport (safe-area aware), clear of the top status bar
     and its page/skill selects; tap to dismiss (showToast). */
  @media (min-width: 1024px) {
    #toast-container { left: 304px; right: auto; align-items: flex-start; }
    .status-activity-delta { right: auto; left: 0; }
  }
  @media (max-width: 539px) {
    #toast-container { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); left: 8px; right: 8px; max-width: none; align-items: stretch; }
    #toast-container .toast:not(:last-child) { display: none; }
    /* UI-A11Y-001: the phone toast never blocks the queue/buttons under it; it auto-hides. */
    #toast-container .toast { pointer-events: none; opacity: 0.92; }
    #toast-container .toast, .status-activity-line {
      padding: 4px 10px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .status-activity-delta { left: 0; right: 0; max-width: none; width: auto; }
  }
