/* ==========================================================================
   Beyond the Rift — design system
   Tokens, base, layout and the shared components drawn by client/ui.mjs.
   Per-screen styles live in screens-*.css under .scr-<name>.
   Mobile-first: base rules are for phones; wider screens are layered on.
   ========================================================================== */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0c101a;
  --bg-deep: #070a12;
  --panel: #141e2e;
  --panel-2: #1a2639;
  --panel-3: #22314a;
  --surface: var(--panel);
  --surface-2: var(--panel-2);
  --border: #29364c;
  --border-strong: #3a4b68;
  --line: rgba(233, 237, 248, 0.08);

  /* Text */
  --text: #e9edf8;
  --muted: #91a4bd;
  --faint: #62738d;

  /* Accents */
  --accent: #7bd6c1;
  --accent-2: #89dfce;
  --accent-ink: #052521;
  --violet: #a599df;
  --violet-2: #ab92ee;
  --gold: #e6bd7f;
  --gold-2: #f3d6a4;

  /* Feedback */
  --good: #86dea3;
  --warn: #f2c46d;
  --bad: #f08ca4;
  --danger: #f08ca4;
  --info: #8fb8f2;

  /* Rarity frames (by stars) */
  --rarity-1: #8d99ae;
  --rarity-2: #7fd19b;
  --rarity-3: #6fb4f4;
  --rarity-4: #ab92ee;
  --rarity-5: #e6bd7f;

  /* Shape */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Depth */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
  --glow-accent: 0 0 0 1px rgba(123, 214, 193, 0.45), 0 8px 28px rgba(123, 214, 193, 0.32);
  --glow-gold: 0 0 0 1px rgba(230, 189, 127, 0.5), 0 8px 28px rgba(230, 189, 127, 0.3);

  /* Type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: clamp(22px, 5.4vw, 30px);
  --fs-hero: clamp(34px, 9vw, 64px);

  /* Layout */
  --tap: 44px;
  --gutter: 16px;
  --maxw: 1100px;
  --header-h: 60px;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.14s;
  --dur: 0.28s;
  --dur-slow: 0.5s;
}

@media (min-width: 720px) {
  :root {
    --gutter: 24px;
    --fs-md: 16px;
    --header-h: 68px;
  }
}

/* -------------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  background:
    radial-gradient(ellipse 80% 55% at 15% -10%, rgba(123, 214, 193, 0.1), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(171, 146, 238, 0.12), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 110%, rgba(38, 56, 92, 0.5), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 var(--fs-md) / 1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body.has-modal {
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.4em;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: clamp(18px, 4.2vw, 22px); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p {
  margin: 0 0 0.75em;
  text-wrap: pretty;
}

a {
  color: var(--accent-2);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: #b5f0e2;
}

img,
svg,
canvas,
video {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

input,
select,
textarea {
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(123, 214, 193, 0.22);
}

::selection {
  background: rgba(123, 214, 193, 0.35);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

/* Headings focused by the router shouldn't draw a ring after a tap. */
[tabindex="-1"]:focus:not(:focus-visible) {
  outline: none;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------- utilities */

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.center { text-align: center; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.grid-heroes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

@media (min-width: 720px) {
  .grid-heroes {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 14px;
  }
}

/* ------------------------------------------------------------------ layout */

.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

/* The router's per-route container. Layout-neutral: screens own their width. */
.screen {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Standard page frame for screens that want it (and for placeholders). */
.page {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px var(--gutter) calc(28px + env(safe-area-inset-bottom, 0px));
}

.panel,
.card {
  position: relative;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--panel-2), var(--panel) 60%);
  box-shadow: var(--shadow-sm);
}

.panel + .panel {
  margin-top: 14px;
}

@media (min-width: 720px) {
  .panel,
  .card {
    padding: 20px;
    border-radius: var(--radius-lg);
  }
}

.placeholder-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* -------------------------------------------------------- screen transitions */

.screen-enter {
  animation-duration: 0.34s;
  animation-timing-function: var(--ease-out);
  animation-fill-mode: both;
}

.screen-enter-forward { animation-name: screen-in-forward; }
.screen-enter-back { animation-name: screen-in-back; }
.screen-enter-fade { animation-name: screen-in-fade; }

@keyframes screen-in-forward {
  from { opacity: 0; transform: translate3d(28px, 0, 0); }
  to { opacity: 1; transform: none; }
}

@keyframes screen-in-back {
  from { opacity: 0; transform: translate3d(-28px, 0, 0); }
  to { opacity: 1; transform: none; }
}

@keyframes screen-in-fade {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ icons */

.icon {
  --icon-size: 1.15em;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--icon-size);
  height: var(--icon-size);
  line-height: 1;
  vertical-align: -0.2em;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.icon-glyph {
  font-size: var(--icon-size);
  width: auto;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  touch-action: manipulation;
  transition:
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    box-shadow var(--dur) ease,
    transform var(--dur-fast) ease,
    filter var(--dur-fast) ease,
    opacity var(--dur-fast) ease;
}

/* Variant rules use two classes so screen-level `button { font/color: inherit }`
   resets never flatten kit buttons. */
.btn.btn-primary,
.btn.btn-secondary,
.btn.btn-ghost,
.btn.btn-danger {
  font: 700 var(--fs-md) / 1.2 var(--font);
  letter-spacing: 0.01em;
}

.btn.btn-primary {
  border-color: rgba(190, 255, 238, 0.35);
  background: linear-gradient(180deg, #9ae8d5, var(--accent) 55%, #5fc3ac);
  color: var(--accent-ink);
  box-shadow: var(--glow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn.btn-primary:hover:not(:disabled) {
  filter: brightness(1.07);
  box-shadow: 0 0 0 1px rgba(137, 223, 206, 0.6), 0 10px 34px rgba(123, 214, 193, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn.btn-secondary {
  border-color: var(--border-strong);
  background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  background: linear-gradient(180deg, #2a3c58, var(--panel-3));
}

.btn.btn-ghost {
  background: transparent;
  color: var(--text);
}

.btn.btn-ghost:hover:not(:disabled) {
  background: rgba(233, 237, 248, 0.07);
}

.btn.btn-danger {
  border-color: rgba(240, 140, 164, 0.5);
  background: rgba(240, 140, 164, 0.14);
  color: #ffd3de;
}

.btn.btn-danger:hover:not(:disabled) {
  background: rgba(240, 140, 164, 0.24);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.97);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  filter: saturate(0.6);
}

.btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

.btn.btn-sm {
  min-height: 40px;
  padding: 6px 12px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-xs);
}

.btn.btn-lg {
  min-height: 56px;
  padding: 14px 28px;
  font-size: var(--fs-lg);
  border-radius: var(--radius);
}

.btn.btn-block {
  display: flex;
  width: 100%;
}

.btn.btn-icon-only {
  padding: 0;
  width: var(--tap);
}

.btn.btn-icon-only.btn-sm {
  width: 40px;
  min-width: 40px;
}

.btn-icon {
  display: inline-flex;
  font-size: 1.15em;
}

.btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border: 2px solid var(--bg);
  border-radius: var(--radius-pill);
  background: var(--bad);
  color: #2a0710;
  font: 800 11px/16px var(--font-num);
  text-align: center;
  text-shadow: none;
}

.btn.is-busy {
  color: transparent !important;
  text-shadow: none;
  cursor: progress;
  opacity: 0.85;
}

.btn[aria-disabled="true"]:not(.is-busy) {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.is-busy > * {
  visibility: hidden;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2.5px solid rgba(233, 237, 248, 0.35);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn.btn-primary.is-busy::after {
  border-color: rgba(5, 37, 33, 0.25);
  border-top-color: var(--accent-ink);
}

/* ------------------------------------------------------------ screen header */

.screen-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--header-h);
  margin: 0 0 12px;
}

.screen-header-back {
  margin-left: -8px;
}

.screen-header-title {
  flex: 1;
  min-width: 0;
}

.screen-header-title h1 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: var(--fs-xl);
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.screen-header-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.screen-header-end {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

/* ------------------------------------------------------------- currency */

.currency-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.currency {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 12px 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(7, 10, 18, 0.65);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font: 800 var(--fs-sm) / 1 var(--font-num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.currency .icon {
  --icon-size: 22px;
}

.currency-gold .currency-value { color: var(--gold-2); }
.currency-scrolls .currency-value { color: #d9ccff; }

/* --------------------------------------------------------------- progress */

.progress {
  --bar: var(--accent);
  position: relative;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: rgba(7, 10, 18, 0.8);
  box-shadow: inset 0 0 0 1px var(--line);
}

.progress:has(.progress-label) {
  height: 22px;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--bar) 70%, #000), var(--bar));
  box-shadow: 0 0 12px color-mix(in srgb, var(--bar) 55%, transparent);
  transition: width var(--dur-slow) var(--ease-out);
}

.progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font: 800 var(--fs-xs) / 1 var(--font-num);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.progress-gold { --bar: var(--gold); }

/* A full gold bar is bright: dark text reads on it, white does not. */
.progress-gold.is-full .progress-label {
  color: #1a1206;
  text-shadow: none;
}
.progress-violet { --bar: var(--violet-2); }
.progress-hp { --bar: var(--good); }
.progress-danger { --bar: var(--bad); }

/* ------------------------------------------------------------------ stars */

.stars {
  display: inline-flex;
  gap: 1px;
  line-height: 1;
  white-space: nowrap;
}

.star {
  font-size: 0.95em;
}

.star.is-on {
  color: var(--gold);
  text-shadow: 0 0 6px rgba(230, 189, 127, 0.55);
}

.star.is-off {
  color: rgba(145, 164, 189, 0.3);
}

/* ------------------------------------------------------------ class badge */

.class-badge {
  --class-color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px 3px 4px;
  border: 1px solid rgba(123, 214, 193, 0.45);
  border: 1px solid color-mix(in srgb, var(--class-color) 50%, transparent);
  border-radius: var(--radius-pill);
  background: rgba(123, 214, 193, 0.12);
  background: color-mix(in srgb, var(--class-color) 16%, rgba(7, 10, 18, 0.7));
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.class-badge-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--class-color);
  color: #0b1018;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 10px color-mix(in srgb, var(--class-color) 50%, transparent);
}

.class-badge-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-badge-role {
  color: var(--muted);
  font-weight: 600;
}

.class-badge-role::before {
  content: "·";
  margin-right: 6px;
}

.class-badge--sm {
  padding: 0;
  border: 0;
  background: none;
}

.class-badge--sm .class-badge-icon {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(7, 10, 18, 0.85);
}

.class-badge--lg {
  padding: 5px 14px 5px 5px;
  font-size: var(--fs-sm);
}

.class-badge--lg .class-badge-icon {
  width: 28px;
  height: 28px;
  font-size: 15px;
}

.class-badge--unknown {
  display: none;
}

/* ------------------------------------------------------------- rarity */

.rarity-1 { --rarity: var(--rarity-1); }
.rarity-2 { --rarity: var(--rarity-2); }
.rarity-3 { --rarity: var(--rarity-3); }
.rarity-4 { --rarity: var(--rarity-4); }
.rarity-5 { --rarity: var(--rarity-5); }

/* ---------------------------------------------------------------- portrait */

.portrait {
  --rarity: var(--rarity-1);
  --size: 72px;
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--size);
  height: var(--size);
  overflow: hidden;
  border: 2px solid var(--rarity);
  border-radius: 22%;
  background:
    radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--rarity) 35%, #1b2740), #0b111c 75%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 4px 14px color-mix(in srgb, var(--rarity) 25%, transparent);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 32%;
}

.portrait--xs { --size: 32px; border-width: 1.5px; }
.portrait--sm { --size: 48px; }
.portrait--md { --size: 72px; }
.portrait--lg { --size: 128px; border-width: 3px; }
.portrait--xl { --size: 184px; border-width: 3px; }

.portrait.rarity-5 {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 18px rgba(230, 189, 127, 0.45);
}

/* --------------------------------------------------------------- hero card */

.hero-card {
  --rarity: var(--rarity-1);
  --card-w: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--card-w);
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--rarity);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--rarity) 28%, var(--panel)) 0%, var(--panel) 70%);
  color: var(--text);
  text-align: left;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform var(--dur-fast) ease, box-shadow var(--dur) ease, border-color var(--dur) ease, opacity var(--dur) ease, filter var(--dur) ease;
}

button.hero-card {
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
}

button.hero-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45), 0 0 18px color-mix(in srgb, var(--rarity) 40%, transparent);
}

button.hero-card:active {
  transform: scale(0.97);
}

.hero-card-art {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--rarity) 42%, #1f2c44), #0a0f18 78%);
}

.hero-card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}

.hero-card-art::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  background: linear-gradient(0deg, rgba(10, 14, 22, 0.85), transparent);
  pointer-events: none;
}

.hero-card-class {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
}

.hero-card-flight {
  position: absolute;
  top: 36px;
  left: 8px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(7, 10, 18, 0.75);
  color: #cfe8ff;
  font-size: 12px;
}

.hero-card-level {
  position: absolute;
  bottom: 6px;
  left: 7px;
  z-index: 1;
  font: 800 var(--fs-xs) / 1 var(--font-num);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.hero-card-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  max-width: calc(100% - 44px);
  padding: 3px 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--gold);
  color: #2a1a05;
  font: 800 11px / 1.2 var(--font-num);
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.hero-card-check {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 12px rgba(123, 214, 193, 0.7);
}

.hero-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 9px 9px;
}

.hero-card-name {
  overflow: hidden;
  font-size: var(--fs-sm);
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-card .stars {
  font-size: 11px;
}

.hero-card.is-selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent), 0 0 24px rgba(123, 214, 193, 0.45);
}

.hero-card.is-dim {
  filter: grayscale(0.75) brightness(0.65);
  opacity: 0.7;
}

/* Sizes */
.hero-card--sm .hero-card-art { aspect-ratio: 1; }
.hero-card--sm .hero-card-info { padding: 5px 7px 6px; }
.hero-card--sm .hero-card-name { font-size: var(--fs-xs); }
.hero-card--sm .hero-card-flight { display: none; }

.hero-card--lg {
  border-width: 3px;
  border-radius: var(--radius-lg);
}

.hero-card--lg .hero-card-info { padding: 10px 14px 14px; gap: 5px; }
.hero-card--lg .hero-card-name { font-size: var(--fs-lg); }
.hero-card--lg .stars { font-size: 16px; }
.hero-card--lg .hero-card-level { font-size: var(--fs-sm); bottom: 8px; left: 10px; }

/* Legendary shimmer */
.hero-card.rarity-5 {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 16px rgba(230, 189, 127, 0.3);
}

.hero-card.rarity-5 .hero-card-art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 236, 200, 0.28) 50%, transparent 65%);
  background-size: 250% 100%;
  animation: shimmer 3.2s ease-in-out infinite;
  pointer-events: none;
}

.hero-card.rarity-4 .hero-card-art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(circle at 50% 110%, rgba(171, 146, 238, 0.28), transparent 60%);
  pointer-events: none;
}

@keyframes shimmer {
  0% { background-position: 120% 0; }
  60%,
  100% { background-position: -120% 0; }
}

/* ------------------------------------------------------------------ chip */

.chip {
  --chip: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--chip) 45%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--chip) 14%, transparent);
  color: color-mix(in srgb, var(--chip) 70%, #fff);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.3;
  white-space: nowrap;
}

.chip-accent { --chip: var(--accent); }
.chip-gold { --chip: var(--gold); }
.chip-violet { --chip: var(--violet-2); }
.chip-danger { --chip: var(--bad); }

/* ----------------------------------------------------------- empty state */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 24px auto;
  padding: 32px 20px;
  max-width: 460px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(20, 30, 46, 0.5);
  text-align: center;
}

.empty-state-glyph {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(171, 146, 238, 0.3), transparent 70%);
  color: var(--violet-2);
  font-size: 26px;
}

.empty-state-text {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-md);
}

.empty-state-action {
  margin-top: 4px;
}

/* ----------------------------------------------------------------- spinner */

.spinner {
  --spinner: 28px;
  display: inline-block;
  flex: none;
  width: var(--spinner);
  height: var(--spinner);
  border: 3px solid rgba(123, 214, 193, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--sm { --spinner: 18px; border-width: 2.5px; }
.spinner--lg { --spinner: 44px; border-width: 4px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------- modal */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in var(--dur) ease both;
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(88vh, 88dvh);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(170deg, #1d2a40, var(--panel) 45%);
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.32s var(--ease-out) both;
}

.modal:focus {
  outline: none;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 10px 4px 20px;
}

.modal-title {
  flex: 1;
  margin: 0;
  font-size: var(--fs-lg);
}

.modal-close {
  margin-left: auto;
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: 8px 20px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: #cdd6e6;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: rgba(7, 10, 18, 0.35);
}

.modal-actions .btn {
  flex: 1 1 140px;
}

.modal-layer.is-closing .modal {
  animation: sheet-down 0.18s ease-in both;
}

.modal-layer.is-closing .modal-backdrop {
  animation: fade-out 0.18s ease-in both;
}

@media (min-width: 600px) {
  .modal-layer {
    align-items: center;
    padding: 24px;
  }

  .modal {
    max-width: 520px;
    border-bottom: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    animation-name: pop-in;
  }

  .modal-actions {
    padding-bottom: 16px;
  }

  .modal-actions .btn {
    flex: 0 0 auto;
  }

  .modal-layer.is-closing .modal {
    animation-name: pop-out;
  }
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes pop-out { to { opacity: 0; transform: scale(0.97); } }

/* ------------------------------------------------------------------- toast */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(calc(100% - 32px), 440px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  --toast: var(--info);
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 6px 6px 6px 14px;
  border: 1px solid color-mix(in srgb, var(--toast) 45%, var(--border));
  border-radius: var(--radius);
  background: rgba(16, 23, 36, 0.96);
  box-shadow: var(--shadow), 0 0 20px color-mix(in srgb, var(--toast) 18%, transparent);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  pointer-events: auto;
  animation: toast-in 0.3s var(--ease-spring) both;
}

.toast.is-leaving {
  animation: toast-out 0.2s ease-in both;
}

.toast-icon {
  display: inline-flex;
  flex: none;
  color: var(--toast);
  font-size: 18px;
}

.toast-text {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
}

.toast-action {
  flex: none;
  color: var(--accent-2) !important;
}

.toast-close {
  flex: none;
  color: var(--muted) !important;
}

.toast-success { --toast: var(--good); }
.toast-error { --toast: var(--bad); }
.toast-reward { --toast: var(--gold); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

/* ------------------------------------------------------------- boot splash */

.boot {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 45% at 50% 42%, rgba(123, 214, 193, 0.14), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(171, 146, 238, 0.14), transparent 70%),
    var(--bg);
  text-align: center;
  transition: opacity 0.45s ease, visibility 0.45s;
}

.boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 380px);
}

.boot-sigil {
  position: relative;
  width: 92px;
  height: 92px;
  margin-bottom: 22px;
}

.boot-sigil-ring {
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--violet-2);
  border-radius: 50%;
  animation: spin 1.6s linear infinite;
}

.boot-sigil-core {
  position: absolute;
  inset: 24px;
  border: 3px solid var(--accent);
  box-shadow: 0 0 26px rgba(123, 214, 193, 0.55), inset 0 0 14px rgba(171, 146, 238, 0.6);
  transform: rotate(45deg);
  animation: breathe 2.2s ease-in-out infinite;
}

.boot-eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.boot-title {
  margin: 6px 0 22px;
  background: linear-gradient(180deg, #ffffff, #c9d6ee 60%, #9fb2d3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: clamp(32px, 9vw, 48px);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.boot-bar {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: rgba(233, 237, 248, 0.08);
}

.boot-bar span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--violet-2));
  box-shadow: 0 0 12px rgba(123, 214, 193, 0.6);
  transition: width 0.5s var(--ease-out);
}

.boot-status {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.boot-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.boot-hint {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.boot.is-error .boot-sigil-ring {
  border-top-color: var(--bad);
  border-right-color: var(--bad);
  animation-duration: 4s;
}

.boot.is-error .boot-sigil-core {
  border-color: var(--bad);
  box-shadow: 0 0 22px rgba(240, 140, 164, 0.5);
  animation: none;
}

.boot.is-error .boot-bar span {
  background: var(--bad);
  box-shadow: none;
}

.boot.is-error .boot-status {
  color: var(--text);
  font-weight: 700;
}

@keyframes breathe {
  0%,
  100% { transform: rotate(45deg) scale(1); opacity: 0.9; }
  50% { transform: rotate(45deg) scale(1.12); opacity: 1; }
}

.noscript {
  max-width: 460px;
  margin: 20vh auto 0;
  padding: 24px var(--gutter);
  text-align: center;
}

/* ---------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .spinner,
  .btn.is-busy::after,
  .boot-sigil-ring {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }

  .hero-card.rarity-5 .hero-card-art::before {
    animation: none !important;
  }
}
