/* =====================================================================
   Harbor UI — shared design system (theme.css)
   Round 4 ("Harbor Bright", Agent EE): halfway between the round-3 field
   journal and first-party Pokémon/Nintendo UI (PMD Rescue Team DX, Legends:
   Arceus, Scarlet/Violet, Animal Crossing NH). Deep harbor-navy chrome with
   rounded corners and soft shadows, warm-white "paper" surfaces with navy
   ink, Pokémon yellow for value and the current choice, Pokémon blue for
   focus, a friendly rounded sans (Nunito) for UI, a book serif (EB Garamond)
   for story, and Caveat handwriting for the explorer's notes.
   Light surfaces re-scope the text tokens (see "surface scope" below), so any
   component dropped onto paper inherits readable ink automatically.
   Docs: docs/design/ui.md §10 · Gallery: /ui/_gallery.html
   Everything here is namespaced .ui-* so other modules can adopt it.
   ===================================================================== */

:root {
  /* ---------- type */
  --font-display: 'Nunito', 'M PLUS Rounded 1c', 'Noto Sans JP', 'Hiragino Maru Gothic ProN', 'Segoe UI', system-ui, sans-serif;
  --font-prose: 'EB Garamond', 'Shippori Mincho', 'Noto Serif JP', Garamond, Georgia, serif;
  --font-ui: 'Nunito', 'Noto Sans JP', 'Hiragino Maru Gothic ProN', 'Segoe UI', system-ui, sans-serif;
  --font-logo: 'Lilita One', 'Nunito', 'Arial Rounded MT Bold', sans-serif;
  --fs-2xs: 0.7rem; --fs-xs: 0.78rem; --fs-sm: 0.88rem; --fs-md: 1rem; --fs-lg: 1.18rem;
  --fs-xl: 1.45rem; --fs-2xl: 1.9rem; --fs-3xl: 2.6rem; --fs-hero: clamp(3.2rem, 9vw, 7rem);
  --track-caps: 0.08em; --track-wide: 0.16em;
  --fw-display: 900; --fw-head: 800;

  /* ---------- colour: brand accents (Pokémon-friendly, not neon) */
  --poke-yellow: #ffcb05; --poke-yellow-hi: #ffe36e; --poke-yellow-lo: #d9a300;
  --poke-blue: #3b72d9; --poke-blue-hi: #6f9cf0; --poke-blue-lo: #2a52a8; --poke-blue-deep: #1d3a80;
  --poke-red: #ec5446; --leaf: #5cc46a; --sky: #5cc6f0; --coral: #ff8d6b; --berry: #c86fd8;

  /* ---------- colour: harbor-navy chrome (panels, HUD plates) */
  --ink-950: #0a1229; --ink-900: #0f1a38; --ink-850: #152347; --ink-800: rgba(22, 36, 76, 0.6); --ink-700: #22346a;
  --ink-600: #30467e;
  /* text on chrome */
  --text: #fbf8f0; --text-dim: #c4cce2; --text-faint: #8d97b6; --text-ink: #1f2a4a;
  /* "gold" = Pokémon yellow: value, money, rarity, current tab, titles on chrome */
  --gold: #ffcb05; --gold-hi: #ffe27a; --gold-lo: #d9a300; --gold-deep: #8a6400;
  --gold-glow: rgba(255, 214, 60, 0.42);
  /* frame lines: soft white, rounded */
  --frame: rgba(255, 255, 255, 0.26); --frame-soft: rgba(255, 255, 255, 0.11); --frame-hi: rgba(255, 255, 255, 0.9);
  /* verdigris: still our signature for party / ally / positive, brightened to a friendly mint */
  --verd: #4fd1b5; --verd-hi: #a5f2df; --verd-lo: #1f8f7a; --verd-glow: rgba(79, 209, 181, 0.4);
  /* paper surfaces (dialogue, cards, tooltips, journals, maps) */
  --surface: #fffcf4; --surface-2: #f6eedb; --surface-3: #ece0c4; --surface-line: rgba(31, 42, 74, 0.14);
  --on-surface: #1f2a4a; --on-surface-dim: #556081; --on-surface-faint: #8a92aa;
  --parch: #fbf3df; --parch-2: #f1e5c6; --parch-edge: #d6c08e; --parch-ink: #2e2a2a;
  /* semantic (flat Pokémon HP colours) */
  --hp: #5fd46a; --hp-lo: #2fa043; --hp-warn: #ffc83a; --hp-crit: #f2554a;
  --belly: #ffa94d; --pp: #6fb7ff; --exp: #6fc4ff; --foe: #ff7a5c; --boss: #ff9a3c;
  --ally: var(--verd); --me: var(--gold-hi); --other: #8fe0c8; --npc: #ffd86a; --recruit: #a8ccff;
  --good: #7ee08a; --bad: #ff8c78; --info: #9fd0ff; --money: var(--gold);

  /* ---------- materials */
  --panel-bg: linear-gradient(180deg, rgba(30, 47, 96, 0.95) 0%, rgba(18, 30, 64, 0.96) 100%);
  --panel-bg-solid: linear-gradient(180deg, #1e2f60 0%, #121e40 100%);
  --panel-blur: blur(8px) saturate(1.1);
  --panel-line: 2px solid rgba(255, 255, 255, 0.14);
  --panel-hi: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  --ribbon-bg: linear-gradient(180deg, rgba(24, 38, 80, 0.88), rgba(15, 25, 54, 0.9));
  --ribbon-line: linear-gradient(90deg, rgba(255, 203, 5, 0) 0%, rgba(255, 203, 5, 0.85) 30%, rgba(255, 227, 110, 1) 50%, rgba(255, 203, 5, 0.85) 70%, rgba(255, 203, 5, 0) 100%);
  /* focus / selection: a Pokémon-blue pill with a yellow ▶ cursor */
  --sel-bg: linear-gradient(180deg, #4a82e6 0%, #3466cc 100%);
  --sel-lines: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 8px rgba(20, 50, 130, 0.35);
  --sel-text: #ffffff;
  --hover-bg: rgba(255, 255, 255, 0.08);
  --parch-bg: linear-gradient(180deg, #fffaf0 0%, #f6edd8 100%);
  --cursor: '▶';
  /* dark chrome as bare RGB so translucent plates can share it: rgba(var(--chrome-rgb), .9) */
  --chrome-rgb: 15, 25, 54; --chrome-rgb-2: 30, 47, 96;
  /* journal covers (menus, notebook panels, settings, map): a rounded navy satchel with a yellow running stitch */
  --cover-bg: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 4px), linear-gradient(180deg, #22376e 0%, #172a58 60%, #12224a 100%);
  --cover-line: 2px solid rgba(255, 255, 255, 0.14); --cover-r: var(--r-lg);
  --cover-shadow: var(--shadow-3), inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  --cover-stitch: 2px dashed rgba(255, 203, 5, 0.3);

  /* ---------- frame lines, radii, shadows */
  --line: 1px; --frame-inset: 5px;
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;
  --shadow-1: 0 2px 6px rgba(8, 16, 40, 0.28);
  --shadow-2: 0 8px 24px rgba(8, 16, 40, 0.32), 0 2px 6px rgba(8, 16, 40, 0.22);
  --shadow-3: 0 18px 48px rgba(8, 16, 40, 0.42), 0 4px 12px rgba(8, 16, 40, 0.26);
  --shadow-pop: 0 4px 0 rgba(10, 20, 50, 0.28);
  --text-shadow: 0 1px 2px rgba(6, 12, 30, 0.85), 0 0 8px rgba(6, 12, 30, 0.45);
  --text-outline: -1px -1px 0 #0f1a38, 1px -1px 0 #0f1a38, -1px 1px 0 #0f1a38, 1px 1px 0 #0f1a38, 0 2px 5px rgba(6, 12, 30, 0.7);

  /* ---------- spacing scale (rem, so it follows UI scale) */
  --sp-0: 0.125rem; --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem; --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem;
  --gutter: clamp(10px, 1.6vw, 56px);

  /* ---------- z layers */
  --z-world: 10; --z-hud: 20; --z-hud-hi: 30; --z-panel: 40; --z-dialog: 50; --z-modal: 60; --z-toast: 70; --z-tooltip: 80; --z-fade: 90; --z-screen: 100;

  /* ---------- motion: playful but restrained (a small overshoot on entry, nothing loops fast) */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-pop: cubic-bezier(0.3, 1.35, 0.5, 1);
  --t-fast: 120ms; --t-med: 220ms; --t-slow: 380ms; --t-xslow: 800ms;
}

/* ---------- surface scope: anything on warm-white paper reads in navy ink.
   Components that sit on paper (dialogue box, cards, tooltips, toasts, journal pages) add these tokens,
   so children styled with var(--text) / var(--text-dim) / var(--gold-hi) stay readable without per-child rules. */
.ui-on-paper, .ui-dialog, .ui-tooltip, .ui-toast, .ui-card, .fj-page, .ui-panel--parch {
  --text: var(--on-surface); --text-dim: var(--on-surface-dim); --text-faint: var(--on-surface-faint);
  --gold-hi: #b07a00; --gold: #c08a00; --gold-lo: #8a6400; --gold-glow: rgba(255, 190, 0, 0.3);
  --frame: rgba(31, 42, 74, 0.22); --frame-soft: rgba(31, 42, 74, 0.1); --frame-hi: rgba(31, 42, 74, 0.5);
  --verd: #1f9f86; --verd-hi: #13806b; --good: #23944a; --bad: #d24432; --info: #2f6fc0;
  --hover-bg: rgba(59, 114, 217, 0.08);
  --text-shadow: none; --text-outline: none;
}

/* UI scale. Height-led and proportional above 1080p so 4K is not "everything small" (the old 26px cap):
   15px at 720p · 18px at 1080p · 24px at 1440p · 36px at 2160p (CSS px). A width term keeps very wide-but-short
   and narrow windows sane; the portrait rule below handles phones. */
html { font-size: clamp(13px, min(max(calc(0.833vh + 9px), 1.667vh), calc(1.25vw + 4px)), 44px); }
@media (max-width: 720px) and (orientation: portrait) { html { font-size: clamp(13px, calc(2.1vw + 7px), 18px); } }

/* ===================================================================== base */
.ui-root, .ui-root * { box-sizing: border-box; }
.ui-text { font-family: var(--font-ui); color: var(--text); }
.ui-display { font-family: var(--font-display); letter-spacing: 0.02em; font-weight: var(--fw-display); }
.ui-prose { font-family: var(--font-prose); font-size: 1.12em; line-height: 1.45; }
.ui-caps { text-transform: uppercase; letter-spacing: var(--track-caps); font-size: var(--fs-xs); font-weight: 800; }
.ui-dim { color: var(--text-dim); } .ui-faint { color: var(--text-faint); }
.ui-gold { color: var(--gold); } .ui-verd { color: var(--verd); } .ui-good { color: var(--good); } .ui-bad { color: var(--bad); }
.ui-money { color: var(--money); font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.ui-money::after { content: ' P'; font-size: 0.8em; opacity: 0.8; }
.ui-num { font-variant-numeric: tabular-nums lining-nums; }
.ui-hidden { display: none !important; }

/* ornamental rule: a soft line with a small yellow pip */
.ui-rule { display: flex; align-items: center; gap: var(--sp-2); color: var(--gold); margin: var(--sp-2) 0; }
.ui-rule::before, .ui-rule::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--frame)); }
.ui-rule::after { background: linear-gradient(90deg, var(--frame), transparent); }
.ui-rule > i, .ui-diamond { display: inline-block; width: 7px; height: 7px; background: var(--gold); border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 203, 5, 0.25); flex: none; }
.ui-rule:empty::before { margin-right: 10px; } .ui-rule:empty { gap: 0; }
.ui-rule:empty::after { margin-left: 0; }

/* ===================================================================== panel (rounded navy card) */
.ui-panel {
  position: relative; color: var(--text); font-family: var(--font-ui);
  background: var(--panel-bg); -webkit-backdrop-filter: var(--panel-blur); backdrop-filter: var(--panel-blur);
  border: var(--panel-line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2), var(--panel-hi);
  padding: var(--sp-4) var(--sp-5);
}
/* a soft inner keyline (replaces the OT2 double hairline + brass gems) */
.ui-panel::before {
  content: ''; position: absolute; inset: var(--frame-inset); pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.06); border-radius: calc(var(--r-lg) - var(--frame-inset));
}
.ui-panel::after { content: none; }
.ui-panel > * { position: relative; }
.ui-panel--flat::before, .ui-panel--flat::after { display: none; }
.ui-panel--flat { box-shadow: var(--shadow-1); border-color: var(--frame-soft); }
.ui-panel--tight { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); }
.ui-panel--solid { background: var(--panel-bg-solid); }
.ui-panel--parch { background: var(--parch-bg); color: var(--parch-ink); border-color: var(--parch-edge); -webkit-backdrop-filter: none; backdrop-filter: none; }
.ui-panel--parch::before { border-color: rgba(120, 90, 50, 0.18); }

/* panel header: heavy rounded title + a short yellow underline pip */
.ui-panel__head { display: flex; align-items: center; gap: var(--sp-3); margin: calc(-1 * var(--sp-1)) 0 var(--sp-3); }
.ui-panel__title {
  position: relative; font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-xl); letter-spacing: 0.01em;
  color: var(--text); text-shadow: none; margin: 0; line-height: 1.1; white-space: nowrap; padding-bottom: 0.18em;
}
.ui-panel__title::after { content: ''; position: absolute; left: 0; bottom: -0.12em; width: 1.6em; height: 0.2em; border-radius: var(--r-pill); background: var(--poke-yellow); }
.ui-panel__title small, .ui-panel__sub { font-family: var(--font-ui); font-size: var(--fs-sm); letter-spacing: 0.01em; color: var(--text-dim); font-weight: 700; margin-left: var(--sp-2); }
.ui-panel__head::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--frame-soft), transparent); order: 1; }
.ui-panel__head > .ui-panel__tools { order: 2; display: flex; gap: var(--sp-2); align-items: center; }
.ui-panel__body { overflow-y: auto; overscroll-behavior: contain; }

/* ===================================================================== ribbon (location banner / toast / HUD strip): a rounded navy plate */
.ui-ribbon { position: relative; background: var(--ribbon-bg); padding: var(--sp-2) var(--sp-6); text-align: center; color: var(--text); border-radius: var(--r-pill); box-shadow: var(--shadow-2), var(--panel-hi); border: 2px solid rgba(255, 255, 255, 0.12); }
.ui-ribbon::before, .ui-ribbon::after { content: none; }

/* ===================================================================== buttons: rounded pills with a chunky "press" shadow */
.ui-btn {
  --b-c: var(--text); --b-line: rgba(255, 255, 255, 0.22); --b-fill: rgba(255, 255, 255, 0.1); --b-drop: rgba(5, 10, 30, 0.35); --ch: 0;
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: var(--font-ui); font-weight: 800; font-size: var(--fs-sm); letter-spacing: 0.02em; line-height: 1.2;
  color: var(--b-c); background: var(--b-fill); border: 2px solid var(--b-line); border-radius: var(--r-pill);
  clip-path: none; box-shadow: 0 3px 0 var(--b-drop);
  padding: 0.48em 1.3em; cursor: pointer; text-shadow: none;
  transition: color var(--t-fast), transform var(--t-fast) var(--ease-pop), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast), filter var(--t-med);
  outline: none; user-select: none; white-space: nowrap;
}
.ui-btn::before { content: none; }
.ui-btn:hover:not(:disabled), .ui-btn.is-focus, .ui-btn:focus-visible { --b-line: rgba(255, 255, 255, 0.55); --b-fill: var(--sel-bg); --b-drop: #1d3a80; color: var(--sel-text); transform: translateY(-1px); }
.ui-btn:focus-visible { box-shadow: 0 3px 0 var(--b-drop), 0 0 0 3px rgba(255, 203, 5, 0.75); }
.ui-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--b-drop); }
.ui-btn:disabled { opacity: 0.4; cursor: default; filter: saturate(0.4); }
.ui-btn--primary { --b-c: #1f2a4a; --b-line: #ffe36e; --b-fill: linear-gradient(180deg, #ffe066, var(--poke-yellow) 60%, #f5bb00); --b-drop: #b88a00; }
.ui-btn--primary:hover:not(:disabled), .ui-btn--primary.is-focus, .ui-btn--primary:focus-visible { --b-c: #1f2a4a; color: #1f2a4a; --b-line: #fff3b0; --b-fill: linear-gradient(180deg, #fff09a, #ffd52e 60%, #ffc400); --b-drop: #a87d00; filter: drop-shadow(0 0 10px var(--gold-glow)); }
.ui-btn--ghost { --b-line: transparent; --b-fill: transparent; --b-drop: transparent; }
.ui-btn--danger:hover:not(:disabled) { --b-line: rgba(255, 160, 140, 0.8); --b-fill: linear-gradient(180deg, #f06a58, #d2483a); --b-drop: #8e2a20; color: #fff; }
.ui-btn--sm { font-size: var(--fs-xs); padding: 0.34em 0.95em; }
.ui-btn--lg { font-size: var(--fs-md); padding: 0.68em 2em; letter-spacing: 0.06em; text-transform: uppercase; }
.ui-btn--icon { padding: 0.35em 0.75em; }
.ui-btn .ui-key { margin-left: -0.2em; }
/* on paper, the neutral button is a white pill with navy ink */
.ui-on-paper .ui-btn:not(.ui-btn--primary):not(.ui-btn--ghost), .fj-page .ui-btn:not(.ui-btn--primary):not(.ui-btn--ghost), .ui-card .ui-btn:not(.ui-btn--primary):not(.ui-btn--ghost), .ui-dialog .ui-btn:not(.ui-btn--primary):not(.ui-btn--ghost) {
  --b-c: var(--on-surface); --b-line: rgba(31, 42, 74, 0.16); --b-fill: #ffffff; --b-drop: rgba(31, 42, 74, 0.2); }
.ui-on-paper .ui-btn:not(.ui-btn--primary):hover:not(:disabled), .fj-page .ui-btn:not(.ui-btn--primary):hover:not(:disabled), .ui-card .ui-btn:not(.ui-btn--primary):hover:not(:disabled), .ui-dialog .ui-btn:not(.ui-btn--primary):hover:not(:disabled),
.ui-on-paper .ui-btn:not(.ui-btn--primary):focus-visible, .fj-page .ui-btn:not(.ui-btn--primary):focus-visible, .ui-card .ui-btn:not(.ui-btn--primary):focus-visible { --b-c: #fff; color: #fff; --b-line: #2a52a8; --b-fill: var(--sel-bg); --b-drop: #1d3a80; }

/* text input */
.ui-input {
  font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 700; color: var(--text);
  background: rgba(5, 12, 34, 0.45); border: 2px solid var(--frame-soft); border-radius: var(--r-sm);
  padding: 0.5em 0.75em; outline: none; transition: border-color var(--t-med), background var(--t-med), box-shadow var(--t-med);
}
.ui-input::placeholder { color: var(--text-faint); font-weight: 600; }
.ui-input:focus { border-color: var(--poke-yellow); background: rgba(5, 12, 34, 0.6); box-shadow: 0 0 0 3px rgba(255, 203, 5, 0.22); }
.ui-label { font-size: var(--fs-xs); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--gold); font-weight: 800; }

/* ===================================================================== key-prompt glyph (white keycap, navy legend) */
.ui-key {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em; height: 1.6em; padding: 0 0.42em;
  font-family: var(--font-ui); font-size: 0.78em; font-weight: 900; line-height: 1; color: #1f2a4a; letter-spacing: 0;
  background: linear-gradient(180deg, #ffffff, #e9eef8); border-radius: 0.45em;
  box-shadow: 0 2px 0 #9aa8c8, 0 3px 6px rgba(8, 16, 40, 0.35); text-shadow: none; vertical-align: 0.12em; white-space: nowrap;
}
.ui-key--dark { color: #fff; background: linear-gradient(180deg, #31477f, #22346a); box-shadow: 0 2px 0 #0f1a38, 0 2px 4px rgba(0, 0, 0, 0.4); }
.ui-key--round { border-radius: 50%; width: 1.7em; padding: 0; }   /* gamepad face button */
.ui-key--mouse::before { content: ''; width: 0.55em; height: 0.75em; border: 2px solid currentColor; border-radius: 0.3em; }

/* ===================================================================== lists & rows (menus) */
.ui-list { display: flex; flex-direction: column; gap: 3px; }
.ui-row {
  position: relative; display: flex; align-items: center; gap: var(--sp-3); min-height: 2.4em;
  padding: 0.35em 0.8em 0.35em 1.5em; border-radius: var(--r-sm); cursor: pointer; outline: none;
  border-bottom: 0;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.ui-row::before { /* the classic Pokémon ▶ menu cursor */
  content: ''; position: absolute; left: 0.5em; top: 50%; width: 0; height: 0; margin-top: -0.36em;
  border-left: 0.5em solid var(--poke-yellow); border-top: 0.36em solid transparent; border-bottom: 0.36em solid transparent;
  transform: translateX(-4px) scale(0); opacity: 0; transition: transform var(--t-med) var(--ease-back), opacity var(--t-fast);
  filter: drop-shadow(0 1px 0 rgba(10, 20, 50, 0.5));
}
.ui-row:hover { background: var(--hover-bg); }
.ui-row.is-sel, .ui-row:focus-visible, .ui-row.is-focus { background: var(--sel-bg); box-shadow: var(--sel-lines); color: var(--sel-text);
  --text: #fff; --text-dim: #dfe8ff; --text-faint: #b9c8ee; --gold: var(--poke-yellow-hi); --gold-hi: #fff2b0; }
.ui-row:focus-visible .ui-row__meta, .ui-row.is-sel .ui-row__meta, .ui-row:focus-visible .ui-row__sub, .ui-row.is-sel .ui-row__sub { color: #dfe8ff; }
.ui-row.is-sel::before, .ui-row:focus-visible::before, .ui-row.is-focus::before { transform: none; opacity: 1; animation: ui-nudge 1.1s var(--ease-inout) infinite; }
.ui-row.is-sel::after, .ui-row:focus-visible::after, .ui-row.is-focus::after { content: none; }
.ui-row.is-off { opacity: 0.45; }
.ui-row__icon { width: 1.75em; height: 1.75em; image-rendering: pixelated; flex: none; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
.ui-row__portrait { width: 2.6em; height: 2.6em; image-rendering: pixelated; flex: none; border-radius: var(--r-sm); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); background: #dfeaf8; }
.ui-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.05em; }
.ui-row__name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-row__sub { font-size: var(--fs-xs); color: var(--text-dim); }
.ui-row__meta { font-size: var(--fs-sm); color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ui-row__qty { font-variant-numeric: tabular-nums; color: var(--text-dim); font-weight: 800; font-size: var(--fs-sm); }
.ui-row__acts { display: flex; gap: var(--sp-1); flex: none; }
.ui-row__swatch { width: 5px; align-self: stretch; border-radius: 3px; flex: none; margin: 0.2em 0; }
.ui-row--compact { min-height: 1.9em; padding-top: 0.2em; padding-bottom: 0.2em; }

/* section heading inside lists */
.ui-section { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0 var(--sp-1); font-family: var(--font-display); font-weight: var(--fw-head); font-size: var(--fs-sm); color: var(--gold); letter-spacing: 0.04em; }
.ui-section::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--frame-soft), transparent); }

/* description / flavour box (prose serif, like a field journal note) */
.ui-desc { font-family: var(--font-prose); font-size: 1.08rem; line-height: 1.4; color: var(--text-dim); min-height: 1.4em; }
.ui-desc em, .ui-desc i { color: var(--text); }
.ui-note { font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.45; }
.ui-empty { text-align: center; padding: var(--sp-5) var(--sp-3); font-family: var(--font-prose); font-style: italic; color: var(--text-faint); font-size: 1.05rem; }

/* ===================================================================== tabs: a rounded segmented bar; the current tab is a yellow pill */
.ui-tabs { display: flex; align-items: center; gap: var(--sp-1); padding: 0.25rem; margin-bottom: var(--sp-3); flex-wrap: wrap; border-bottom: 0; border-radius: var(--r-pill); background: rgba(5, 12, 34, 0.35); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3); }
.ui-tab {
  position: relative; background: none; border: 0; color: var(--text-dim); cursor: pointer; outline: none; border-radius: var(--r-pill);
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: var(--fw-head); letter-spacing: 0.02em;
  padding: 0.4em 1em; transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast) var(--ease-pop);
}
.ui-tab::after { content: none; }
.ui-tab:hover, .ui-tab:focus-visible { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.ui-tab:focus-visible { box-shadow: 0 0 0 2px rgba(255, 203, 5, 0.7); }
.ui-tab.is-on { color: #1f2a4a; background: linear-gradient(180deg, #ffe066, var(--poke-yellow)); box-shadow: 0 2px 0 #b88a00; }
.ui-tab .ui-tab__n { font-family: var(--font-ui); font-size: 0.78em; color: inherit; opacity: 0.7; margin-left: 0.35em; letter-spacing: 0; }
.ui-tabs__spacer { flex: 1; }
.ui-tabs > .ui-money, .ui-tabs > .ui-tabs__extra { align-self: center; padding: 0 0.6em; }

/* ===================================================================== cards (reward drafts, starters, structures): warm-white paper cards */
.ui-card {
  --card-accent: var(--poke-yellow-lo);
  position: relative; display: flex; flex-direction: column; gap: var(--sp-2); text-align: left; color: var(--on-surface);
  background: linear-gradient(180deg, #fffdf7, var(--surface-2)); border: 2px solid #fff;
  border-radius: var(--r-md); padding: var(--sp-3); cursor: pointer; outline: none; font-family: var(--font-ui);
  box-shadow: var(--shadow-1), 0 0 0 1px rgba(31, 42, 74, 0.12); transition: transform var(--t-med) var(--ease-pop), border-color var(--t-med), box-shadow var(--t-med);
}
.ui-card::before { content: none; }
.ui-card:hover, .ui-card.is-focus, .ui-card:focus-visible { transform: translateY(-4px); border-color: #fff; box-shadow: var(--shadow-2), 0 0 0 3px var(--poke-blue-hi); }
.ui-card.is-sel { border-color: #fff; box-shadow: var(--shadow-2), 0 0 0 3px var(--poke-yellow), 0 0 22px var(--gold-glow); }
.ui-card.is-sel::after { content: ''; position: absolute; top: -0.55em; right: -0.55em; width: 1.5em; height: 1.5em; border-radius: 50%; background: var(--poke-yellow) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3.2L15 7' fill='none' stroke='%231f2a4a' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 72% no-repeat; box-shadow: 0 2px 0 #b88a00, 0 0 0 2px #fff; animation: ui-pop var(--t-slow) var(--ease-back) both; }
.ui-card.is-off { opacity: 0.5; cursor: default; transform: none; }
.ui-card__art { display: grid; place-items: center; aspect-ratio: 1.7; border-radius: var(--r-sm); background: radial-gradient(ellipse at 50% 70%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%), linear-gradient(180deg, #dcecfb, #c5ddf4); }
.ui-card__art img { width: min(6.5rem, 62%); height: auto; max-height: 86%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 3px 2px rgba(20, 40, 90, 0.3)); }
.ui-card__kicker { font-size: var(--fs-2xs); letter-spacing: var(--track-wide); text-transform: uppercase; color: var(--card-accent); font-weight: 900; }
.ui-card__title { font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-lg); letter-spacing: 0.01em; color: var(--on-surface); line-height: 1.15; }
.ui-card__body { font-size: var(--fs-sm); color: var(--on-surface-dim); line-height: 1.45; flex: 1; }
.ui-card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--on-surface-dim); border-top: 2px dashed rgba(31, 42, 74, 0.12); padding-top: var(--sp-2); }
.ui-card--common { --card-accent: #7d8597; } .ui-card--uncommon { --card-accent: #1f9f86; } .ui-card--rare { --card-accent: #2f6fd0; } .ui-card--epic { --card-accent: #9a4fd0; } .ui-card--legend { --card-accent: #c98a00; }
.ui-card--common, .ui-card--uncommon, .ui-card--rare, .ui-card--epic, .ui-card--legend { border-top: 5px solid var(--card-accent); }
.ui-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr)); gap: var(--sp-4); }
/* flip-in (reward reveal): add .ui-card--flip + style="--i:n" */
.ui-card--flip { animation: ui-card-flip 620ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 110ms); backface-visibility: hidden; transform-origin: 50% 60%; }
@keyframes ui-card-flip { 0% { opacity: 0; transform: perspective(900px) rotateY(-95deg) translateY(10px); } 60% { opacity: 1; } 100% { opacity: 1; transform: perspective(900px) rotateY(0) translateY(0); } }

/* ===================================================================== bars (HP / belly / EXP / progress): Pokémon-style, flat fill in a white-rimmed track */
.ui-bar {
  --v: 1; --c: var(--hp); --c2: var(--hp-lo);
  position: relative; height: 0.55em; min-width: 3em; border-radius: var(--r-pill); overflow: hidden;
  background: rgba(10, 18, 44, 0.72); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 1px 3px 1px rgba(8, 16, 40, 0.35);
}
.ui-bar > i { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--v)); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 72%, white 28%) 0 40%, var(--c) 40% 100%); transition: transform var(--t-med) var(--ease-out); border-radius: inherit; }
.ui-bar > b { /* ghost (recent damage) */ position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--g, var(--v))); background: rgba(255, 120, 90, 0.7); transition: transform 600ms 260ms var(--ease-out); border-radius: inherit; }
.ui-bar--warn { --c: var(--hp-warn); --c2: #c98f00; } .ui-bar--crit { --c: var(--hp-crit); --c2: #a8281e; }
.ui-bar--crit > i { animation: ui-pulse 0.9s ease-in-out infinite; }
.ui-bar--belly { --c: var(--belly); --c2: #c26a1a; } .ui-bar--exp { --c: var(--exp); --c2: #2f7fc0; } .ui-bar--pp { --c: var(--pp); --c2: #2f6fc0; }
.ui-bar--foe { --c: var(--foe); --c2: #b8402a; } .ui-bar--verd { --c: var(--verd); --c2: var(--verd-lo); }
.ui-bar--thin { height: 0.36em; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.8); } .ui-bar--thick { height: 0.75em; }
.ui-stat { display: inline-flex; align-items: baseline; gap: 0.3em; font-variant-numeric: tabular-nums; }
.ui-stat__k { font-size: var(--fs-2xs); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--gold); font-weight: 900; }
.ui-stat__v { font-weight: 900; }
.ui-stat__max { color: var(--text-dim); font-size: 0.8em; }

/* ===================================================================== cooldown ring (skill / move slot) */
.ui-ring { --cd: 0; position: relative; width: 2.4em; height: 2.4em; border-radius: 50%; }
.ui-ring::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(5, 10, 30, 0.72) calc(var(--cd) * 360deg), transparent 0); transition: background 60ms linear; }
.ui-ring::after { content: ''; position: absolute; inset: 0; border-radius: 50%; padding: 3px; background: conic-gradient(from 0deg, var(--poke-yellow) calc((1 - var(--cd)) * 360deg), rgba(255, 255, 255, 0.2) 0); -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
.ui-ring.is-ready::after { background: var(--poke-yellow); box-shadow: 0 0 10px var(--gold-glow); }

/* ===================================================================== type tag & chips: solid Pokémon type pills */
.ui-type { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.14em 0.65em; margin-right: 0.3em; border-radius: var(--r-pill); font-size: var(--fs-2xs); font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35); background: linear-gradient(180deg, color-mix(in srgb, var(--t, #888) 90%, white 10%), color-mix(in srgb, var(--t, #888) 92%, black 8%)); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16), 0 1px 2px rgba(8, 16, 40, 0.3); vertical-align: middle; }
.ui-type::before { content: none; }
.ui-chip { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.14em 0.6em; border-radius: var(--r-pill); font-size: var(--fs-2xs); font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text); background: rgba(255, 255, 255, 0.1); border: 1.5px solid rgba(255, 255, 255, 0.18); }
.ui-chip--gold { color: #1f2a4a; border-color: transparent; background: var(--poke-yellow); }
.ui-chip--verd { color: #0d3d33; border-color: transparent; background: var(--verd); }
.ui-chip--bad { color: #fff; border-color: transparent; background: var(--poke-red); }

/* ===================================================================== tooltip: a rounded paper card */
.ui-tooltip {
  position: fixed; z-index: var(--z-tooltip); max-width: min(22rem, 80vw); pointer-events: none;
  background: var(--surface); color: var(--on-surface); border: 2px solid #fff; border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3); font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 600; line-height: 1.4; box-shadow: var(--shadow-2), 0 0 0 1px rgba(31, 42, 74, 0.14);
  opacity: 0; transform: translateY(4px) scale(0.98); transition: opacity var(--t-fast), transform var(--t-fast) var(--ease-pop);
}
.ui-tooltip.is-on { opacity: 1; transform: none; }
.ui-tooltip b, .ui-tooltip strong { font-family: var(--font-display); font-weight: 900; letter-spacing: 0.01em; color: var(--poke-blue-lo); }

/* ===================================================================== toast / notification: a white pill that pops in */
.ui-toasts { position: absolute; top: clamp(56px, 9vh, 240px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); pointer-events: none; z-index: var(--z-toast); width: min(42rem, 92vw); }
.ui-toast {
  position: relative; display: flex; align-items: center; gap: var(--sp-3); justify-content: center; min-width: min(18rem, 90vw); max-width: 100%;
  padding: 0.55em 1.6em 0.55em 1.1em; background: var(--surface); color: var(--on-surface); border-radius: var(--r-pill); border: 2px solid #fff;
  box-shadow: var(--shadow-2), 0 0 0 1px rgba(31, 42, 74, 0.12);
  font-family: var(--font-ui); font-weight: 800; font-size: var(--fs-md); letter-spacing: 0.01em; text-align: center;
  animation: ui-toast-in var(--t-slow) var(--ease-pop) both;
  pointer-events: none;   /* display only: a toast must never swallow a click on the HUD under it (the co-op Rejoin pill) */
}
.ui-toast::before, .ui-toast::after { content: none; }
.ui-toast__gem { width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--poke-yellow); box-shadow: 0 0 0 3px rgba(255, 203, 5, 0.28); flex: none; }
.ui-toast__icon { width: 1.6em; height: 1.6em; image-rendering: pixelated; flex: none; }
.ui-toast--good .ui-toast__gem { background: var(--leaf); box-shadow: 0 0 0 3px rgba(92, 196, 106, 0.3); }
.ui-toast--bad .ui-toast__gem { background: var(--poke-red); box-shadow: 0 0 0 3px rgba(236, 84, 70, 0.28); }
.ui-toast--big { font-family: var(--font-display); font-size: var(--fs-xl); letter-spacing: 0.02em; font-weight: 900; padding: 0.55em 2.2em; color: #1f2a4a; background: linear-gradient(180deg, #ffe680, var(--poke-yellow)); border-color: #fff3b0; box-shadow: 0 4px 0 #b88a00, var(--shadow-2); }
.ui-toast.is-out { animation: ui-toast-out var(--t-slow) var(--ease-in) both; }
@keyframes ui-toast-in { from { opacity: 0; transform: translateY(-12px) scale(0.92); } 70% { transform: translateY(1px) scale(1.02); } to { opacity: 1; transform: none; } }
@keyframes ui-toast-out { to { opacity: 0; transform: translateY(-8px) scale(0.96); } }

/* ===================================================================== dialogue box: a warm-white rounded box, name tab, framed portrait (PMD DX / SV) */
.ui-dialog {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 0 var(--sp-4); align-items: start;
  padding: var(--sp-4) clamp(1.2rem, 3vw, 2.4rem) var(--sp-4); color: var(--on-surface);
  background: linear-gradient(180deg, #fffefa, #fbf5e7); border: 3px solid #fff; border-radius: var(--r-lg);
  box-shadow: 0 0 0 2px rgba(59, 114, 217, 0.55), var(--shadow-3);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.ui-dialog::before { /* faint ruled lines: a nod to the journal */
  content: ''; position: absolute; inset: 0.9rem 1.2rem; pointer-events: none; border-radius: inherit;
  background: repeating-linear-gradient(180deg, transparent 0 1.85rem, rgba(59, 114, 217, 0.07) 1.85rem calc(1.85rem + 1px));
}
.ui-dialog::after { content: none; }
.ui-dialog__portrait {
  grid-row: 1 / span 3; width: 5.6rem; height: 5.6rem; image-rendering: pixelated; border-radius: var(--r-md); background: linear-gradient(180deg, #e3effc, #c8dcf3);
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--poke-blue), var(--shadow-1); margin-top: -1.9rem; position: relative;
}
.ui-dialog__name {
  justify-self: start; position: relative; margin: -2.25rem 0 var(--sp-2) -0.2rem; padding: 0.22em 1.1em 0.26em;
  font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-lg); letter-spacing: 0.02em; color: #fff; text-shadow: 0 1px 0 rgba(10, 20, 60, 0.4);
  background: linear-gradient(180deg, var(--poke-blue-hi), var(--poke-blue)); border: 2px solid #fff; border-radius: var(--r-pill);
  box-shadow: 0 3px 0 var(--poke-blue-deep), var(--shadow-1); clip-path: none;
}
.ui-dialog__name:empty { display: none; }
.ui-dialog__text { position: relative; font-family: var(--font-ui); font-weight: 700; font-size: 1.28rem; line-height: 1.45; min-height: 2.9em; color: var(--on-surface); text-shadow: none; }
.ui-dialog__text b { color: var(--poke-blue-lo); font-weight: 900; }
.ui-dialog__text i { color: var(--on-surface-dim); }
.ui-dialog__more { position: absolute; right: clamp(1rem, 2.4vw, 2rem); bottom: 0.75rem; width: 0; height: 0; border: 0.45rem solid transparent; border-top: 0.6rem solid var(--poke-blue); border-bottom: 0; filter: drop-shadow(0 2px 0 rgba(255, 203, 5, 0.9)); animation: ui-bob 0.9s ease-in-out infinite; opacity: 0; transition: opacity var(--t-med); }
.ui-dialog.is-typing .ui-dialog__more { opacity: 0; }
.ui-dialog.is-waiting .ui-dialog__more { opacity: 1; }
.ui-dialog--noportrait { grid-template-columns: 1fr; }

/* choice list (dialog options, menus): white pills; the focused one turns Pokémon blue with the ▶ cursor */
.ui-choices { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-2); margin-top: var(--sp-3); }
.ui-choices--col { flex-direction: column; flex-wrap: nowrap; align-items: center; }
.ui-choice {
  --b-line: rgba(31, 42, 74, 0.16); --b-fill: #ffffff; --b-drop: rgba(31, 42, 74, 0.22); --ch: 0;
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: 0.6em; min-width: 9rem;
  font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 800; color: #1f2a4a; letter-spacing: 0.01em;
  background: var(--b-fill); border: 2px solid var(--b-line); border-radius: var(--r-pill); clip-path: none; box-shadow: 0 3px 0 var(--b-drop);
  padding: 0.5em 1.7em; cursor: pointer; outline: none; text-shadow: none;
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast) var(--ease-pop), box-shadow var(--t-fast), border-color var(--t-fast);
  animation: ui-rise var(--t-slow) var(--ease-pop) both; animation-delay: calc(var(--i, 0) * 60ms);
}
.ui-choice::before { content: ''; position: absolute; left: 0.75em; top: 50%; margin-top: -0.34em; width: 0; height: 0; border-left: 0.48em solid var(--poke-yellow); border-top: 0.34em solid transparent; border-bottom: 0.34em solid transparent; opacity: 0; transform: translateX(-4px); transition: opacity var(--t-fast), transform var(--t-med) var(--ease-back); z-index: 1; }
.ui-choice .ui-key { font-size: 0.72em; }
.ui-choice:hover:not(:disabled), .ui-choice:focus-visible, .ui-choice.is-focus { --b-line: #fff; --b-fill: var(--sel-bg); --b-drop: var(--poke-blue-deep); color: #fff; transform: translateY(-1px); filter: none; }
.ui-choice:focus-visible::before, .ui-choice.is-focus::before, .ui-choice:hover:not(:disabled)::before { opacity: 1; transform: none; }
.ui-choice:focus-visible::after, .ui-choice.is-focus::after { content: none; }
.ui-choice:disabled { opacity: 0.45; cursor: default; }

/* ===================================================================== objective tracker: a rounded navy card with a yellow spine */
.ui-objective { display: flex; flex-direction: column; gap: 0.25em; min-width: 14rem; max-width: 20rem; padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-4); color: var(--text); background: linear-gradient(180deg, rgba(24, 38, 80, 0.86), rgba(15, 25, 54, 0.86)); border: 2px solid rgba(255, 255, 255, 0.12); border-left: 5px solid var(--poke-yellow); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.ui-objective__kicker { font-size: var(--fs-2xs); letter-spacing: var(--track-wide); text-transform: uppercase; color: var(--gold); font-weight: 900; }
.ui-objective__title { font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-md); letter-spacing: 0.01em; color: var(--text); }
.ui-objective__step { display: flex; gap: 0.5em; align-items: baseline; font-size: var(--fs-sm); font-weight: 700; }
.ui-objective__step::before { content: ''; flex: none; width: 0.62em; height: 0.62em; border: 2px solid var(--gold); border-radius: 50%; transform: translateY(0.02em); }
.ui-objective__step.is-done { color: var(--text-faint); text-decoration: line-through; text-decoration-color: rgba(255, 203, 5, 0.5); }
.ui-objective__step.is-done::before { background: var(--verd); border-color: var(--verd); }
.ui-objective__step .ui-num { margin-left: auto; color: var(--text-dim); }
.ui-objective.is-pulse { animation: ui-glow 1.2s var(--ease-out); }

/* ===================================================================== minimap frame: rounded with a white rim */
.ui-minimap { position: relative; padding: 5px; border-radius: 50%; background: rgba(15, 25, 54, 0.85); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 0 5px rgba(59, 114, 217, 0.7), var(--shadow-2); }
.ui-minimap--rect { border-radius: var(--r-md); }
.ui-minimap > canvas, .ui-minimap > img { display: block; border-radius: calc(var(--r-md) - 4px); }
.ui-minimap__compass { position: absolute; top: -0.7em; left: 50%; transform: translateX(-50%); display: grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 900; color: #fff; background: var(--poke-red); box-shadow: 0 0 0 2px #fff, var(--shadow-1); text-shadow: none; }

/* ===================================================================== modal / side panel / scrim */
.ui-scrim { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 45%, rgba(10, 18, 44, 0.2), rgba(10, 18, 44, 0.62)); z-index: var(--z-modal); animation: ui-fade var(--t-med) both; }
.ui-modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(46rem, calc(100vw - 2 * var(--gutter))); max-height: min(86vh, 48rem); display: flex; flex-direction: column; z-index: var(--z-modal); animation: ui-panel-in var(--t-slow) var(--ease-pop) both; }
.ui-side { position: fixed; top: var(--gutter); bottom: var(--gutter); right: var(--gutter); width: min(24rem, calc(100vw - 2 * var(--gutter))); display: flex; flex-direction: column; z-index: var(--z-panel); animation: ui-side-in var(--t-slow) var(--ease-out) both; }
.ui-side--left { right: auto; left: var(--gutter); animation-name: ui-side-in-l; }
.ui-out { animation: ui-panel-out var(--t-med) var(--ease-in) both !important; }

/* ===================================================================== world-space (nameplates, bubbles, numbers, prompts) */
.ui-nameplate { font-family: var(--font-ui); font-weight: 900; font-size: 0.8rem; letter-spacing: 0.01em; color: var(--text); text-shadow: var(--text-outline); white-space: nowrap; }
.ui-bubble { position: relative; display: inline-block; background: var(--surface); color: var(--on-surface); font-family: var(--font-ui); font-weight: 700; font-size: 0.95rem; line-height: 1.3; text-shadow: none; padding: 0.32em 0.85em; border-radius: var(--r-md); box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(31, 42, 74, 0.18), var(--shadow-1); max-width: 15rem; white-space: normal; }
.ui-bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; background: var(--surface); transform: translateX(-50%) rotate(45deg); box-shadow: 2px 2px 0 #fff; }
.ui-wprompt { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.3em 1em 0.3em 0.4em; font-family: var(--font-ui); font-weight: 800; font-size: var(--fs-sm); color: var(--on-surface); text-shadow: none; background: var(--surface); border-radius: var(--r-pill); box-shadow: 0 0 0 2px #fff, var(--shadow-1); animation: ui-rise var(--t-med) var(--ease-pop) both; }

/* ===================================================================== animations */
@keyframes ui-shimmer { 0% { background-position: 130% 0; } 55%, 100% { background-position: -130% 0; } }
@keyframes ui-pulse { 50% { filter: brightness(1.35); } }
@keyframes ui-bob { 50% { transform: translateY(3px); } }
@keyframes ui-nudge { 50% { transform: translateX(3px); } }
@keyframes ui-pop { from { transform: scale(0.3); opacity: 0; } }
@keyframes ui-fade { from { opacity: 0; } }
@keyframes ui-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes ui-panel-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 16px)) scale(0.97); } }
@keyframes ui-panel-out { to { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(0.98); } }
@keyframes ui-side-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes ui-side-in-l { from { opacity: 0; transform: translateX(-24px); } }
@keyframes ui-glow { 0% { box-shadow: 0 0 0 0 var(--gold-glow); } 40% { box-shadow: 0 0 22px 2px var(--gold-glow); } 100% { box-shadow: 0 0 0 0 transparent; } }
.ui-anim-in { animation: ui-rise var(--t-slow) var(--ease-pop) both; }

@media (prefers-reduced-motion: reduce) {
  :root { --t-fast: 1ms; --t-med: 1ms; --t-slow: 1ms; --t-xslow: 1ms; }
  .ui-row::before, .ui-row::after, .ui-choice::after, .ui-card::after, .ui-bar--crit > i, .ui-dialog__more { animation: none !important; }
}
/* scrollbars inside panels */
.ui-panel ::-webkit-scrollbar, .ui-panel__body::-webkit-scrollbar { width: 10px; }
.ui-panel ::-webkit-scrollbar-thumb, .ui-panel__body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.35); border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; }
.ui-panel ::-webkit-scrollbar-track { background: transparent; }
.ui-panel, .ui-panel__body { scrollbar-color: rgba(255, 255, 255, 0.35) transparent; scrollbar-width: thin; }
/* "active / equipped / on team" state for rows: a mint spine, distinct from focus */
.ui-row.is-active { box-shadow: inset 4px 0 0 var(--verd); background: linear-gradient(90deg, rgba(79, 209, 181, 0.14), transparent 60%); }
.ui-row.is-active.is-sel, .ui-row.is-active:focus-visible { box-shadow: inset 4px 0 0 var(--verd), var(--sel-lines); }
.ui-row__sub .ui-chip, .ui-row__sub .ui-type { margin-right: 0.3em; }
