/* ============================================================================
 * battle.css — the game's own components.
 *
 * components.css holds the shell vocabulary shared with every other app in the
 * family (.topbar, .view, .tabbar, .sheet, .btn, .chip, .card, .toast). This
 * file holds the parts that only exist because this is Animas.
 *
 * ---------------------------------------------------------------------------
 * WHAT THIS FILE IS TRYING TO STOP BEING
 *
 * The first version of this screen was a stack of bordered rectangles, each
 * with a heading and a paragraph. The second version lit those rectangles in
 * type colour and mirrored them, which helped, and it was still two slabs —
 * one brick for your character and one brick for theirs, with a grid of
 * smaller bricks underneath. Legible, complete, and a spreadsheet.
 *
 * This version is built the way Pokémon, Final Fantasy and Pokémon Showdown
 * build a battle screen, because they solved this problem thirty years ago
 * and the answer has not changed:
 *
 *   THE BATTLE HAPPENS ON A STAGE. A scene with a sky, a horizon and two
 *   platforms, the opponent's further away at the top right and yours nearer
 *   at the bottom left. The creatures STAND on it, large, with nothing boxed
 *   around them. The stage is the thing that turns two rows of a table into
 *   two things facing each other.
 *
 *   THE NUMBERS FLOAT OVER THE SCENE ON PLATES. A name, a health bar, an aura
 *   bar and a handful of small marks, on a piece of dark glass at the corner
 *   of the stage — Pokémon's datastrip, Showdown's status bar. The plate is
 *   small because the creature is the subject and the plate is the caption.
 *
 *   THE COMMANDS LIVE IN A WINDOW UNDER THE STAGE. "What will Kelpie do?" and
 *   four move tiles, then Switch. Final Fantasy's command window.
 *
 *   THE STORY IS TOLD IN A MESSAGE BOX. What just happened, as text, in a box
 *   at the bottom with the little ▼ that says there is more. The full log is
 *   one tap down.
 *
 * Two rules from the earlier rebuild still hold and are still load-bearing:
 *
 *   DEPTH COMES FROM LIGHT, NOT FROM BORDERS. On a dark ground a 1px line
 *   around everything reads as a grid. Platforms glow in the creature's type
 *   colour, plates are lit along their top edge, tiles are washed in the
 *   move's colour. DO NOT ADD BORDERS BACK to the stage, the plates or the
 *   move grid to "define" them — that is the change that would undo this and
 *   it will look like an improvement in isolation on a desktop monitor.
 *
 *   TYPE COLOUR IS THE PRIMARY SIGNAL. The nine --type-* tokens are DATA. A
 *   platform, a portrait, a move tile and a move row all carry the colour of
 *   the thing they belong to, so the board can be read before it is read.
 *
 * ---------------------------------------------------------------------------
 * NAMING follows the house convention — flat kebab-case, component prefix,
 * prefix-noun-modifier. `plate-hp-text`, not `.plate .hp .text`.
 *
 * EVERY :hover RULE IN THIS FILE IS AT THE BOTTOM, inside one
 * `@media (hover: hover)` block, and it has to stay that way. On iOS Safari
 * :hover sticks to the last-tapped element, so the next element rendered into
 * that slot inherits a highlight it never earned — and this interface
 * re-renders the same four move tiles with different moves in them every
 * single turn, which is exactly the shape of that bug.
 * ========================================================================= */

/* ---------- portraits ----------------------------------------------------
 * A disc, a halo in the character's type colours, and its glyph. This is the
 * component that answers "what am I looking at" before any text is read. It
 * appears everywhere a character is listed; on the stage the creature is a
 * SPRITE instead — the glyph alone, with no disc, standing on a platform. */

.portrait {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  /* Two stops so a dual type shows both colours: the primary fills the disc,
   * the secondary rims it. A Fire/Air Phoenix and a Fire/Psychic Bakeneko are
   * different objects at a glance because of this one line. */
  background:
    radial-gradient(circle at 50% 30%,
      color-mix(in srgb, var(--halo-a) 55%, transparent) 0%,
      color-mix(in srgb, var(--halo-b) 30%, transparent) 60%,
      var(--bg-sunken) 100%);
  box-shadow:
    inset 0 0 0 1.5px color-mix(in srgb, var(--halo-a) 55%, transparent),
    inset 0 -6px 12px -6px rgb(0 0 0 / 0.6),
    0 0 20px -6px color-mix(in srgb, var(--halo-a) 75%, transparent);
}

.portrait-glyph {
  line-height: 1;
  filter: saturate(1.1) drop-shadow(0 2px 3px rgb(0 0 0 / 0.5));
}

.portrait-xl { width: 84px; height: 84px; }
.portrait-xl .portrait-glyph { font-size: 42px; }
.portrait-lg { width: 62px; height: 62px; }
.portrait-lg .portrait-glyph { font-size: 31px; }
.portrait-md { width: 46px; height: 46px; }
.portrait-md .portrait-glyph { font-size: 23px; }
.portrait-sm { width: 32px; height: 32px; }
.portrait-sm .portrait-glyph { font-size: 16px; }

/* A defeated character keeps its shape and loses its colour, so a bench of
 * five still reads as five bodies with three of them gone. */
.portrait-faded { filter: grayscale(1) brightness(0.45); box-shadow: inset 0 0 0 1px var(--line); }
.portrait-ring { box-shadow: inset 0 0 0 2px var(--accent), 0 0 12px -2px var(--accent); }

/* ---------- type pips ----------------------------------------------------
 * The nine --type-* tokens are DATA colours; see the long note in tokens.css
 * about why they exist and why nothing else may borrow them. */

.pip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--pip-color) 18%, transparent);
  color: var(--pip-color);
  white-space: nowrap;
}
/* Compact pips carry the glyph only, in a small disc. */
.pip-compact { padding: 0; width: 22px; height: 22px; justify-content: center; font-size: 11px; }

.pip-fire     { --pip-color: var(--type-fire); }
.pip-water    { --pip-color: var(--type-water); }
.pip-grass    { --pip-color: var(--type-grass); }
.pip-electric { --pip-color: var(--type-electric); }
.pip-air      { --pip-color: var(--type-air); }
.pip-fighting { --pip-color: var(--type-fighting); }
.pip-psychic  { --pip-color: var(--type-psychic); }
.pip-dark     { --pip-color: var(--type-dark); }
.pip-light    { --pip-color: var(--type-light); }
.pip-neutral  { --pip-color: var(--ink-faint); }

.pip-row { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* A type medallion: the type's glyph in a small lit disc. Used on move tiles
 * and move rows so a move's type is a shape in the corner rather than a word
 * in the middle. */
.medal {
  flex: none;
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 13px; line-height: 1;
  background: radial-gradient(circle at 50% 30%,
    color-mix(in srgb, var(--medal-color, var(--ink-faint)) 55%, transparent),
    color-mix(in srgb, var(--medal-color, var(--ink-faint)) 18%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--medal-color, var(--ink-faint)) 40%, transparent);
}
.medal-lg { width: 44px; height: 44px; font-size: 22px; }

/* ---------- bars ---------------------------------------------------------- */

.bar {
  height: 10px;
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.45);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.5);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 520ms cubic-bezier(0.22, 0.9, 0.3, 1), background-color 300ms ease;
}

/* A highlight along the top of the fill turns a flat rectangle into something
 * with a surface. It is the cheapest possible way to stop a health bar reading
 * as a table cell. */
.bar-hp   .bar-fill { background: linear-gradient(180deg, color-mix(in srgb, var(--hp-good) 60%, white) 0%, var(--hp-good) 45%, color-mix(in srgb, var(--hp-good) 80%, black) 100%); }
.bar-hp.warn .bar-fill { background: linear-gradient(180deg, color-mix(in srgb, var(--hp-warn) 60%, white) 0%, var(--hp-warn) 45%, color-mix(in srgb, var(--hp-warn) 80%, black) 100%); }
.bar-hp.bad  .bar-fill { background: linear-gradient(180deg, color-mix(in srgb, var(--hp-bad) 60%, white) 0%, var(--hp-bad) 45%, color-mix(in srgb, var(--hp-bad) 80%, black) 100%); }
.bar-aura { height: 5px; }
.bar-aura .bar-fill { background: linear-gradient(180deg, color-mix(in srgb, var(--aura) 55%, white), var(--aura)); }

/* ---------- the cost pill ------------------------------------------------
 * One shape for "what does this cost", everywhere a move is listed: a small
 * pill with the aura diamond and the number. Free is a word in green rather
 * than a zero, and a price the character cannot pay right now is red. The
 * tile, the codex row and the builder row all use this one class, so the
 * three can never disagree about what a cost looks like. */

.cost {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.68rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--aura) 16%, transparent);
  color: var(--aura);
  white-space: nowrap;
}
.cost-glyph { font-size: 0.6em; }
.cost.free  { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); font-family: var(--font-body); font-size: 0.6rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.cost.short { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }

/* ---------- the stage ----------------------------------------------------
 * A scene, not a list. See the header. The stage is one relatively-positioned
 * box with a sky and a ground, and everything on it — two platforms, two
 * sprites, two plates, the corner badge — is absolutely placed inside it, the
 * way a battle screen has always been composed. */

.stage {
  position: relative;
  height: clamp(232px, 66vw, 330px);
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  background:
    /* the horizon glow, in the field's colour when there is a field */
    radial-gradient(90% 46% at 50% 57%, color-mix(in srgb, var(--stage-tint) 30%, transparent) 0%, transparent 70%),
    /* three star layers at different scales so the pattern does not repeat visibly */
    radial-gradient(1px 1px at 12% 22%, rgb(255 255 255 / 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 12%, rgb(255 255 255 / 0.45) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 35%, rgb(255 255 255 / 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 86% 40%, rgb(255 255 255 / 0.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 25% 48%, rgb(255 255 255 / 0.3) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 20%, rgb(255 255 255 / 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 28%, rgb(255 255 255 / 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 8%, rgb(255 255 255 / 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 95% 6%, rgb(255 255 255 / 0.4) 50%, transparent 51%),
    /* sky, horizon, ground */
    linear-gradient(180deg,
      var(--stage-sky) 0%,
      color-mix(in srgb, var(--stage-horizon) 70%, var(--stage-tint) 30%) 56%,
      var(--stage-ground) 57%,
      color-mix(in srgb, var(--stage-ground) 85%, black) 100%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.07),
    inset 0 -40px 60px -40px rgb(0 0 0 / 0.6),
    var(--shadow-md);
}

/* The horizon haze: a soft band where sky meets ground, so the join is a
 * glow rather than a line. */
.stage::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 48%; height: 18%;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--stage-tint) 22%, transparent) 50%, transparent);
  pointer-events: none;
}

/* A short phone: the stage gives up a little height, the tiles a little
 * padding, and the plates a little air — in that order, and only a little,
 * because a stage under 215px stops reading as a scene. The page scrolls by
 * a few dozen pixels on a 667px phone rather than the screen being cramped. */
@media (max-height: 700px) {
  .stage { height: clamp(215px, 58vw, 260px); }
  .move-btn { min-height: 68px; }
  .plate { gap: 4px; padding: 7px 10px 8px; }
}

/* --- the spots: a platform and the creature standing on it --------------- */

.spot { position: absolute; }
.spot-foe { right: 4%; top: 15%; width: 40%; height: 44%; }
.spot-own { left: 2%; bottom: 7%; width: 46%; height: 56%; }

/* The platform is an ellipse lit from above in the creature's type colours,
 * with a soft pool of the same light beneath it. Perspective is faked by
 * size alone: the far platform is smaller and higher. */
.platform {
  position: absolute; left: 0; right: 0; bottom: 0;
  aspect-ratio: 3.4 / 1;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 20%,
      color-mix(in srgb, var(--halo-a) 38%, var(--stage-ground)) 0%,
      color-mix(in srgb, var(--halo-b) 22%, var(--stage-ground)) 60%,
      color-mix(in srgb, var(--stage-ground) 80%, black) 100%);
  box-shadow:
    inset 0 2px 0 color-mix(in srgb, var(--halo-a) 35%, transparent),
    inset 0 -3px 8px rgb(0 0 0 / 0.5),
    0 10px 30px -6px color-mix(in srgb, var(--halo-a) 55%, transparent);
}

/* The sprite: the glyph alone, big, standing at the middle of the platform,
 * with a shadow the colour of its type. It bobs very slightly, on a cycle
 * long enough to be felt rather than seen; the two sides run on different
 * lengths so they never move in step. The blanket reduced-motion rule in
 * base.css stops it. */
.sprite {
  position: absolute;
  left: 50%; bottom: 13%;
  transform: translateX(-50%);
  line-height: 1;
  z-index: 1;
  filter: drop-shadow(0 8px 10px color-mix(in srgb, var(--halo-a) 70%, transparent));
  animation: sprite-idle 3.4s ease-in-out infinite;
  will-change: transform;
}
.spot-own .sprite { font-size: clamp(60px, 18vw, 88px); }
.spot-foe .sprite { font-size: clamp(46px, 14vw, 68px); animation-duration: 4.1s; }

@keyframes sprite-idle {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-3px); }
}

/* A creature that has just come out slides up onto its platform. Applied only
 * when the active character changed since the last render, so a turn with
 * no switch does not replay it. */
.sprite.enter { animation: sprite-enter 420ms cubic-bezier(0.2, 0.8, 0.3, 1.1), sprite-idle 3.4s ease-in-out 420ms infinite; }
@keyframes sprite-enter {
  from { transform: translateX(-50%) translateY(26px) scale(0.6); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

/* The hit. A recoil and a white flash, 380ms — long enough to be seen, short
 * enough that six in a row are not tiring. */
.sprite.hit { animation: sprite-hit 380ms ease-out, sprite-idle 3.4s ease-in-out 380ms infinite; }
.spot-foe .sprite.hit { animation-name: sprite-hit-foe, sprite-idle; }
@keyframes sprite-hit {
  0%   { transform: translateX(-50%); filter: drop-shadow(0 8px 10px color-mix(in srgb, var(--halo-a) 70%, transparent)); }
  20%  { transform: translateX(calc(-50% - 9px)); filter: brightness(2.4) saturate(0.2) drop-shadow(0 0 14px white); }
  45%  { transform: translateX(calc(-50% + 6px)); }
  70%  { transform: translateX(calc(-50% - 3px)); filter: brightness(1.2); }
  100% { transform: translateX(-50%); }
}
@keyframes sprite-hit-foe {
  0%   { transform: translateX(-50%); }
  20%  { transform: translateX(calc(-50% + 9px)); filter: brightness(2.4) saturate(0.2) drop-shadow(0 0 14px white); }
  45%  { transform: translateX(calc(-50% - 6px)); }
  70%  { transform: translateX(calc(-50% + 3px)); filter: brightness(1.2); }
  100% { transform: translateX(-50%); }
}

/* Out of reach: the creature has vanished into the sky or under the water for
 * a charge move. It lifts and fades rather than disappearing, so the player
 * can still see WHO is out of reach. */
.sprite.vanished { opacity: 0.32; filter: blur(0.5px); animation: sprite-vanish 3s ease-in-out infinite; }
@keyframes sprite-vanish {
  0%, 100% { transform: translateX(-50%) translateY(-14px); }
  50%      { transform: translateX(-50%) translateY(-20px); }
}

/* Down. Grey, small, sunk into the platform. Only visible in the moment
 * between a faint and the replacement being chosen. */
.sprite.down { filter: grayscale(1) brightness(0.4); transform: translateX(-50%) translateY(12px) scale(0.7); animation: none; opacity: 0.6; }

/* The floating number. Damage in white on a red shadow, healing in green,
 * rising from the sprite and fading, the way every game since the SNES has
 * done it. Injected after the render (see flashTheHit in views/battle.js) so
 * it survives the rebuild of the markup that carries it. */
.pop {
  position: absolute;
  left: 50%; top: 12%;
  transform: translateX(-50%);
  z-index: 3;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 6vw, 1.8rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: white;
  text-shadow: 0 0 2px rgb(0 0 0 / 0.9), 0 2px 0 var(--bad), 0 0 12px color-mix(in srgb, var(--bad) 80%, transparent);
  pointer-events: none;
  animation: pop-rise 950ms ease-out forwards;
}
.pop.heal { text-shadow: 0 0 2px rgb(0 0 0 / 0.9), 0 2px 0 var(--good), 0 0 12px color-mix(in srgb, var(--good) 80%, transparent); }
.pop.big { font-size: clamp(1.6rem, 8vw, 2.3rem); color: var(--accent-soft); }
@keyframes pop-rise {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.6); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.15); }
  30%  { transform: translateX(-50%) translateY(-2px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-34px) scale(1); }
}

/* --- the plates: the caption under each creature ------------------------- */

.plate {
  position: absolute;
  z-index: 2;
  width: 55%;
  max-width: 250px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 11px 9px;
  border-radius: var(--radius-sm);
  /* The whole plate is a <button> — tapping it asks "what is this thing" —
   * so the UA's default border and font have to be cleared explicitly, or
   * every plate wears a 2px white ButtonBorder, which is exactly the ruled-box
   * look this file exists to get away from. */
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  background: var(--glass);
  backdrop-filter: blur(8px) saturate(1.2);
  box-shadow:
    inset 0 1px 0 var(--glass-edge),
    inset 0 0 0 1px rgb(255 255 255 / 0.03),
    0 10px 30px -14px rgb(0 0 0 / 0.9);
}
.plate-foe { left: 10px; top: 10px; }
.plate-own { right: 10px; bottom: 10px; }

.plate-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.plate-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  min-width: 0; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plate-top .pip-row { flex: none; gap: 2px; }
.plate-top .pip-compact { width: 18px; height: 18px; font-size: 9px; }

/* The two bars are two rows of ONE grid — bar, then number — so the aura bar
 * starts flush with the left edge of the health bar and both numbers sit in
 * the same right-hand column. The number column is a fixed width for the same
 * reason: "375/375" over "◆ 120" must not make the aura bar longer than the
 * health bar above it. */
.plate-bars {
  display: grid;
  grid-template-columns: 1fr 60px;
  column-gap: 8px;
  row-gap: 4px;
  align-items: center;
}
.plate-bars .bar-hp { height: 8px; }
.plate-bars .bar-aura { height: 5px; }
.plate-hp-text, .plate-aura {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.plate-hp-text i { font-style: normal; color: var(--ink-faint); }
.plate-aura { font-size: 0.66rem; font-weight: 700; color: var(--aura); }
.plate-aura .cost-glyph { font-size: 0.55em; }

/* Beneath the bars: who is still standing. */
.plate-foot { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* A row of marks: the Ability, then anything currently true about the
 * character that is not a number. Most turns it is the Ability alone. */
.plate-marks { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; }

/* ---------- the team rail ------------------------------------------------
 * Five portraits, tiny, so "how much of that team is left" is a glance rather
 * than a count. Dots would be cheaper and would tell you the number without
 * telling you WHO — which is half the information a switch decision needs. */

.rail { display: flex; gap: 3px; flex: none; }
.rail .portrait-sm { width: 18px; height: 18px; }
.rail .portrait-sm .portrait-glyph { font-size: 9px; }
.rail .portrait-ring { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 8px -1px var(--accent); }

/* A bench slot for a character the opponent has not shown yet. The opposing
 * bench is hidden, but the SHAPE of it is not — five slots, filling in as the
 * match reveals them, is exactly the information a person across a table
 * would have. */
.rail-unknown {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgb(255 255 255 / 0.06);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
  color: var(--ink-faint);
  font-size: 9px; font-weight: 800;
}

/* ---------- status flags -------------------------------------------------- */

.flag {
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgb(255 255 255 / 0.07);
  color: var(--ink-soft);
  white-space: nowrap;
}
.flag-bad  { color: var(--bad);  background: color-mix(in srgb, var(--bad) 18%, transparent); }
.flag-good { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); }
.flag-ability { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); text-transform: none; letter-spacing: 0.01em; font-size: 0.6rem; }

/* ---------- the field badge ------------------------------------------------
 * The active field, when there is one: a small pill in the top right of the
 * stage, above the far platform, in the field's own colour. Name and turns
 * left only — the full sentence is on the Codex's Types tab and in the log
 * line that announced it. The turn number is NOT here; it lives in the
 * command prompt, because the badge shares its row with the opponent's plate
 * and there is room for one of them. The width cap is what stops "Storm
 * Front" running under the plate on a 390px phone. */

.stage-badge {
  position: absolute; z-index: 2;
  top: 10px; right: 10px;
  max-width: calc(45% - 16px);
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  box-shadow: inset 0 1px 0 var(--glass-edge), 0 0 14px -4px var(--field-color, var(--accent));
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--field-color, var(--accent));
  white-space: nowrap;
}
.stage-badge .field-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.stage-badge .field-turns { font-family: var(--font-mono); opacity: 0.8; flex: none; }

/* The turn counter, at the end of the prompt line. */
.command-turn {
  float: right;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.06);
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* The field banner outside the stage — the Codex's type sheet uses it. */
.field-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--field-color, var(--accent)) 20%, transparent), transparent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--field-color, var(--accent));
}
.field-turns { font-family: var(--font-mono); opacity: 0.7; }

/* ---------- the setup and result stages ---------------------------------
 * The same scene, used as a title card. Five silhouettes on the far platform
 * for the opponent — the shape of the bench is not a secret, its contents
 * are — and your five on the near one. */

.stage-title { height: clamp(250px, 70vw, 340px); }
.stage-title .spot-foe { right: 4%; top: 14%; width: 50%; height: 40%; }
.stage-title .spot-own { left: 2%; bottom: 8%; width: 78%; height: 52%; }
.stage-title .platform { aspect-ratio: 3.8 / 1; }
.stage-title .party {
  position: absolute; left: 50%; bottom: 8%;
  transform: translateX(-50%);
  display: flex; gap: 2px; align-items: flex-end;
  z-index: 1;
}
.stage-title .party .portrait-lg { width: 50px; height: 50px; }
.stage-title .party .portrait-lg .portrait-glyph { font-size: 25px; }
.stage-title .party .portrait-md { width: 34px; height: 34px; }
.stage-title .party .portrait-md .portrait-glyph { font-size: 17px; }
.stage-title .party > * { animation: party-bob 3.6s ease-in-out infinite; }
.stage-title .party > :nth-child(2) { animation-delay: -0.6s; }
.stage-title .party > :nth-child(3) { animation-delay: -1.2s; }
.stage-title .party > :nth-child(4) { animation-delay: -1.8s; }
.stage-title .party > :nth-child(5) { animation-delay: -2.4s; }
@keyframes party-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.stage-title .spot-foe .platform { --halo-a: var(--ink-faint); --halo-b: var(--ink-faint); }
.silhouette {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  background: rgb(0 0 0 / 0.35);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
  color: var(--ink-faint);
  font-size: 13px; font-weight: 800;
}
.vs {
  position: absolute; z-index: 2;
  left: 22%; top: 48%;
  transform: translate(-50%, -50%) rotate(-8deg);
  font-family: var(--font-display);
  font-size: 2.2rem; font-weight: 900; font-style: italic;
  letter-spacing: -0.04em;
  color: var(--accent);
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 60%, transparent), 0 2px 0 rgb(0 0 0 / 0.6);
  pointer-events: none;
}
.stage-name {
  position: absolute; z-index: 2;
  left: 12px; top: 12px;
  max-width: 62%;
  display: flex; flex-direction: column; gap: 2px;
}
.stage-name-title {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgb(0 0 0 / 0.7);
}
.stage-name-sub { font-size: 0.7rem; color: var(--ink-soft); text-shadow: 0 1px 4px rgb(0 0 0 / 0.7); }

/* The result: the title floats over the survivors. */
.stage-result .party { bottom: 14%; }
.result-title {
  position: absolute; z-index: 2;
  left: 0; right: 0; top: 14%;
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 2.4rem; font-weight: 900; letter-spacing: -0.03em;
  text-shadow: 0 4px 16px rgb(0 0 0 / 0.7);
  animation: title-in 600ms cubic-bezier(0.2, 0.8, 0.3, 1.1);
}
.result-title.win  { color: var(--accent); text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 60%, transparent), 0 4px 16px rgb(0 0 0 / 0.7); }
.result-title.lose { color: var(--bad); }
@keyframes title-in {
  from { opacity: 0; transform: translateY(10px) scale(0.85); }
  to   { opacity: 1; transform: none; }
}
.result-sub {
  position: absolute; z-index: 2;
  left: 0; right: 0; top: calc(14% + 3rem);
  margin: 0;
  text-align: center;
  color: var(--ink-soft); font-size: 0.78rem;
  text-shadow: 0 1px 4px rgb(0 0 0 / 0.7);
}

/* ---------- the command window --------------------------------------------
 * "What will Kelpie do?" and the four move tiles. This is the biggest target
 * on the screen because four moves is the whole decision most turns. */

.command {
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-raised) 0%, color-mix(in srgb, var(--bg-raised) 70%, var(--bg)) 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), var(--shadow-sm);
}
.command-prompt {
  margin: 2px 4px 9px;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.command-prompt b { color: var(--ink); }

.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.move-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 78px;
  padding: 10px 11px 9px;
  border-radius: var(--radius-sm);
  border: 0;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  /* Washed in its own type colour, lit from the top-left, so the grid reads
   * as four objects rather than four cells. */
  background:
    linear-gradient(150deg,
      color-mix(in srgb, var(--move-color) 36%, var(--bg-lift)) 0%,
      color-mix(in srgb, var(--move-color) 12%, var(--bg-raised)) 65%,
      var(--bg-raised) 100%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.12),
    inset 0 0 0 1px color-mix(in srgb, var(--move-color) 22%, transparent),
    0 2px 6px -2px rgb(0 0 0 / 0.5);
  transition: transform 90ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.move-btn:active { transform: scale(0.97); }
.move-btn:disabled { filter: grayscale(0.85) brightness(0.55); cursor: not-allowed; }

.move-head { display: flex; align-items: flex-start; gap: 6px; }
.move-name {
  flex: 1; min-width: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.move-head .medal { width: 22px; height: 22px; font-size: 11px; margin-top: -1px; }

.move-foot { display: flex; align-items: flex-end; gap: 6px; min-height: 22px; }

/* The damage preview is the founding rule made visible: every number is
 * knowable before you commit. Big, because it is the number the decision turns
 * on, and it comes from the same function that resolves the move. */
.move-dmg {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgb(0 0 0 / 0.4);
}
.move-dmg.super { color: var(--hp-warn); }
.move-dmg.weak  { color: var(--ink-faint); }
/* A lethal preview is GOOD NEWS — it is the move that wins the exchange — so
 * it is green, not red. Red is the colour this interface uses for damage taken
 * and for a character dying, and this is the opposite of a warning. */
.move-dmg.kill  { color: var(--good); text-shadow: 0 0 12px color-mix(in srgb, var(--good) 60%, transparent); }

.move-mult {
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--hp-warn) 20%, transparent);
  color: var(--hp-warn);
  margin-bottom: 2px;
}
.move-mult.down { background: rgb(255 255 255 / 0.06); color: var(--ink-faint); }
.move-mult.kill { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }

.move-foot .cost { margin-left: auto; margin-bottom: 1px; }

.move-flag {
  position: absolute;
  bottom: 9px; left: 11px;
  font-size: 0.55rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--move-color) 80%, white);
  opacity: 0.9;
}
/* A tile with no damage number gives its foot to the flag, so "Field" or
 * "First" is not floating under an empty space. */
.move-btn.no-dmg .move-flag { position: static; }

/* The Info toggle. On, every tile carries the move's sentence and tags under
 * its name; off, the tiles are name, number and price. It replaced Forfeit
 * in the action row — a way out of a match is needed once a session, a way
 * to read what a move does is needed every turn of the first ten matches —
 * and Forfeit now lives at the foot of the switch sheet. */
.btn-info { flex: 0 0 auto !important; min-width: 96px; }
.btn-info.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-lift));
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 50%, transparent);
}
.btn-info-glyph {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-family: var(--font-display); font-size: 0.7rem; font-weight: 900; font-style: italic;
  background: rgb(255 255 255 / 0.1);
}
.btn-info.active .btn-info-glyph { background: var(--accent); color: var(--accent-contrast); }

.move-text {
  margin: -2px 0 0;
  font-size: 0.68rem; line-height: 1.4;
  color: var(--ink-soft);
}
.move-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: -2px; }
.moves.info .move-btn { min-height: 0; gap: 6px; justify-content: flex-start; }
.moves.info .move-foot { margin-top: auto; }

/* ---------- the action row ----------------------------------------------- */

.action-row { display: flex; gap: 8px; margin-top: 10px; }
.action-row .btn { flex: 1; }
.command .action-row { margin-top: 8px; }
.command .action-row .btn { min-height: 42px; font-size: 0.85rem; }

.forced-note {
  padding: 16px 14px 4px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.forced-note b { color: var(--ink); display: block; margin-bottom: 3px; font-family: var(--font-display); font-size: 1.05rem; }

/* ---------- the message box ---------------------------------------------
 * What just happened, as text, in a box at the bottom. The full log used to
 * live here and on a small phone it pushed the move buttons — the one thing
 * the player has to reach — off the bottom of the screen. */

/* The live screen is a column that fills the viewport, so the box can take the
 * space left over instead of leaving a third of a phone empty beneath it. The
 * subtraction is the app's own chrome: the fixed top bar, the fixed tab bar,
 * both safe areas, and the container's own top and bottom padding. */
.battle-live {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh
    - var(--topbar-h) - var(--safe-t) - 12px
    - var(--tabbar-h) - var(--safe-b) - 24px);
}

.ticker {
  position: relative;
  margin-top: 10px;
  padding: 10px 30px 10px 14px;
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: inset 0 1px 0 var(--glass-edge), inset 0 0 0 1px rgb(255 255 255 / 0.03);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-faint);
  cursor: pointer;
  width: 100%;
  text-align: left;
  border: 0;
  overflow-wrap: anywhere;

  /* Takes everything the column has left and NOTHING more. The basis is
   * zero, not auto: with `auto` the box sizes to its forty lines of content
   * and runs off the bottom of the screen under the tab bar, which is exactly
   * the failure the ticker exists to prevent. The floor is two lines. */
  flex: 1 1 0;
  min-height: 62px;
  display: flex;
  flex-direction: column;
}

/* The little ▼. It is what every message box since 1996 has used to say
 * "there is more", and here there is: the whole log, one tap down. */
.ticker::after {
  content: "▼";
  position: absolute; right: 12px; bottom: 9px;
  font-size: 0.6rem;
  color: var(--accent);
  animation: more-blink 1.2s steps(2, start) infinite;
}
@keyframes more-blink { to { visibility: hidden; } }

/* column-reverse with the lines rendered newest-first: the newest sits at the
 * bottom and the overflow falls off the top, so the device decides how many
 * lines fit and nothing has to measure or scroll. See tickerHtml(). */
.ticker-lines {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  /* The oldest lines fade out at the top rather than being cut. */
  mask-image: linear-gradient(180deg, transparent 0%, black 28px);
}
/* Block, not inline. As spans the last two log lines ran together into one
 * sentence — "The battle begins.Undertow. Fafnir cannot leave the water." */
.ticker .log-line { display: block; margin: 0; }
.ticker .log-line:first-child { color: var(--ink); }
.ticker .log-line.move:first-child { color: var(--ink); }

/* The full log, in the sheet. */
.log {
  max-height: 60dvh;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.log-line { margin: 0 0 2px; }
.log-line.damage { color: var(--ink); }
.log-line.heal   { color: var(--good); }
.log-line.faint  { color: var(--bad); font-weight: 700; }
.log-line.big    { color: var(--accent); font-weight: 700; }
.log-line.enter  { color: var(--ink-faint); }
.log-line.move   { color: var(--ink); font-weight: 800; margin-top: 8px; }
.log-turn {
  margin: 14px 0 4px;
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.06);
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-faint);
}
.log-turn:first-child { margin-top: 0; }

/* ---------- bench / switch list ------------------------------------------
 * The party screen. Each row is a portrait, a name, and two small bars —
 * health and aura — rather than a line of numbers. The numbers are still
 * there, small, at the end of the bar. */

.bench { display: flex; flex-direction: column; gap: 6px; }

.bench-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  min-height: 62px;
  border-radius: var(--radius-sm);
  border: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--card-type, var(--line)) 14%, var(--bg-lift)) 0%, var(--bg-lift) 55%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.bench-item:disabled { opacity: 0.4; cursor: not-allowed; }
.bench-item.out { box-shadow: inset 0 0 0 1.5px var(--accent); }
.bench-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bench-top { display: flex; align-items: center; gap: 6px; }
.bench-name { font-family: var(--font-display); font-weight: 800; font-size: 0.92rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bench-sub  { font-size: 0.62rem; color: var(--ink-faint); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.bench-bars { display: flex; flex-direction: column; gap: 3px; }
.bench-bar { display: flex; align-items: center; gap: 6px; }
.bench-bar .bar { flex: 1; height: 6px; }
.bench-bar .bar-aura { height: 4px; }
.bench-bar-val { flex: none; width: 58px; text-align: right; font-family: var(--font-mono); font-size: 0.62rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.bench-bar-val.aura { color: var(--aura); }

/* ---------- the lineup ---------------------------------------------------
 * Five portraits in a row. This is the team, and it is one line instead of the
 * five-row table of stats it replaced. */

.lineup { display: flex; gap: 8px; justify-content: center; margin: 4px 0 14px; }
.lineup-slot { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.lineup-name {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.02em;
  color: var(--ink-faint); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}

/* A podium: the lineup standing on a lit ellipse, so a team card shows a
 * party on a stage rather than five icons in a row. */
.podium { position: relative; padding: 6px 0 2px; }
.podium::before {
  content: "";
  position: absolute; left: 8%; right: 8%; bottom: 8px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--accent) 16%, var(--bg-sunken)) 0%, color-mix(in srgb, var(--bg-sunken) 60%, transparent) 70%, transparent 100%);
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 30%, transparent);
}
.podium .lineup { position: relative; margin: 0; }

/* ---------- the hero ------------------------------------------------------ */

/* The setup screen is a title stage, one button and the record. Centred in
 * what is left of the viewport after the two bars, so on a tall phone it does
 * not sit at the top looking like a page that failed to finish loading. */
.setup {
  min-height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - var(--safe-t) - var(--safe-b) - 40px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.hero { text-align: center; padding: 8px 0 4px; }
.hero-title {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.hero-sub { margin: 0 0 14px; color: var(--ink-faint); font-size: 0.78rem; }

.record { display: flex; justify-content: center; gap: 8px; }
.record-item {
  flex: 1; max-width: 110px;
  padding: 9px 4px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-raised) 70%, transparent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
  text-align: center;
}
.record-val { display: block; font-family: var(--font-display); font-size: 1.3rem; font-weight: 900; line-height: 1; }
.record-key {
  display: block; margin-top: 4px;
  font-size: 0.55rem; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-faint);
}

/* ---------- fact tiles ---------------------------------------------------
 * The Rules screen used to open with four paragraphs. A number and a word do
 * the same job in a fifth of the space and are actually read. */

/* Five, on one row, at any phone width. auto-fit wrapped them 4 + 1 on a
 * 390px screen, which reads as a mistake rather than as a set. */
.facts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px; }
.fact {
  padding: 11px 2px 9px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--bg-lift), var(--bg-raised));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
  text-align: center;
}
.fact-val { font-family: var(--font-display); font-size: 1.2rem; font-weight: 900; color: var(--accent); line-height: 1; letter-spacing: -0.02em; }
.fact-key {
  margin-top: 5px;
  font-size: 0.5rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint);
}

/* The damage formula, as a thing rather than a sentence. */
.formula {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
  padding: 16px 12px; margin-bottom: 8px;
  border-radius: var(--radius);
  background: rgb(0 0 0 / 0.3);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.5);
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 900; letter-spacing: 0.08em;
}
.formula b { color: var(--accent); font-weight: 900; text-shadow: 0 0 12px color-mix(in srgb, var(--accent) 40%, transparent); }
.formula span { color: var(--ink-faint); }

/* A rule: one short line, with its own glyph in a medallion. */
.rules { display: flex; flex-direction: column; gap: 6px; }
.rule {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
  font-size: 0.8rem; line-height: 1.45; color: var(--ink-soft);
}
.rule-glyph {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent) 6%, transparent));
  font-size: 1.05rem; line-height: 1;
}
.rule b { color: var(--ink); }

/* ---------- move rows ----------------------------------------------------
 * The single biggest reduction in words on screen. See moveTags() in
 * views/render.js — the Moves codex was 88 full sentences and is now 88
 * scannable rows with each sentence one tap away. */

.mlist { display: flex; flex-direction: column; gap: 5px; }

.mrow {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px 9px 10px;
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--move-color, var(--line)) 18%, var(--bg-raised)) 0%, var(--bg-raised) 50%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.mrow.picked { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 14px -6px var(--accent); }
.mrow:disabled { opacity: 0.4; cursor: not-allowed; }
.mrow .medal { --medal-color: var(--move-color, var(--ink-faint)); }

.mrow-summary { display: flex; align-items: center; gap: 10px; width: 100%; list-style: none; cursor: pointer; }
.mrow-summary::-webkit-details-marker { display: none; }
.mrow-details { display: block; padding: 0; }
.mrow-details > .mrow-summary { padding: 9px 12px 9px 10px; min-height: 52px; }
.mrow-text { margin: 0; padding: 0 12px 11px 46px; font-size: 0.76rem; line-height: 1.5; color: var(--ink-soft); }

.mrow-head { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mrow-name { font-family: var(--font-display); font-weight: 800; font-size: 0.88rem; }
.mrow-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* Damage and cost, stacked on the right as one cluster rather than two
 * columns of digits. */
.mrow-stat { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.mrow-dmg {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 900; line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.mrow-dmg.none { color: var(--ink-faint); font-size: 0.8rem; font-weight: 700; }

/* ---------- tags ---------------------------------------------------------- */

.tag {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.55rem; font-weight: 800; letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgb(255 255 255 / 0.07);
  color: var(--ink-faint);
  white-space: nowrap;
}
.tag-sig   { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.tag-fast  { background: color-mix(in srgb, var(--type-air) 18%, transparent); color: var(--type-air); }
.tag-slow  { color: var(--ink-faint); }
.tag-field { background: color-mix(in srgb, var(--type-psychic) 20%, transparent); color: var(--type-psychic); }
.tag-good  { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.tag-bad   { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }

/* ---------- roster grid --------------------------------------------------- */

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 7px; }

.roster-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px 11px;
  border-radius: var(--radius-sm);
  border: 0;
  background:
    radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, var(--card-type, var(--line)) 18%, transparent), transparent 70%),
    var(--bg-raised);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
  color: var(--ink);
  cursor: pointer;
}
.roster-card.picked { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 14px -6px var(--accent); }
.roster-name {
  font-family: var(--font-display);
  font-weight: 800; font-size: 0.74rem; text-align: center; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
/* The hundred-aura breakpoint, as a dot rather than a sentence: gold means
 * this character can cast its type's signature, and nothing means it never
 * can. The design's whole claim is that the Aura stat answers a yes-or-no
 * question; this is that question answered without a number being read. */
.roster-wall {
  position: absolute; top: 8px; right: 8px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.roster-wall.locked { background: var(--line-strong); box-shadow: none; }

/* ---------- the character sheet ------------------------------------------
 * A header with the portrait and the types, the Ability on a card, then four
 * bars measured against the roster maximum rather than four numbers in boxes.
 * "Power 150" means nothing without knowing 150 is the joint highest in the
 * game; a nearly full bar says it without a sentence. */

.sheet-hero {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 14px;
  margin: 0 0 10px;
  border-radius: var(--radius);
  background:
    radial-gradient(90% 100% at 0% 50%, color-mix(in srgb, var(--card-type, var(--line)) 22%, transparent), transparent 70%),
    rgb(0 0 0 / 0.2);
}
.sheet-hero-body { flex: 1; min-width: 0; }
.sheet-hero-body .prose { margin-top: 8px; }

.statbars {
  display: flex; flex-direction: column; gap: 8px;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgb(0 0 0 / 0.22);
}
.statrow { display: flex; align-items: center; gap: 10px; font-size: 0.72rem; }
.statrow-key {
  flex: none; width: 36px;
  font-size: 0.56rem; font-weight: 800; letter-spacing: 0.08em;
  color: var(--ink-faint);
}
.statrow-bar { flex: 1; height: 8px; border-radius: var(--radius-pill); background: rgb(0 0 0 / 0.4); box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.5); overflow: hidden; }
.statrow-bar i { display: block; height: 100%; border-radius: inherit; box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.3); }
.statrow-val {
  flex: none; width: 32px; text-align: right;
  font-family: var(--font-display); font-size: 0.9rem; font-weight: 900; font-variant-numeric: tabular-nums;
}
.statrow-note { flex: none; width: 96px; font-size: 0.6rem; color: var(--ink-faint); }

.ability-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 0.64rem; font-weight: 800; letter-spacing: 0.02em;
  white-space: nowrap;
}
.ability-full {
  margin: 10px 0; padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 14%, var(--bg-sunken)), color-mix(in srgb, var(--accent) 5%, var(--bg-sunken)));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
  font-size: 0.8rem; line-height: 1.5; color: var(--ink-soft);
}
.ability-full b { color: var(--accent); }

/* ---------- matchups ------------------------------------------------------ */

.matchups { display: flex; flex-direction: column; gap: 7px; }
.matchup-row { display: flex; align-items: center; gap: 8px; }
.matchup-key {
  flex: none; width: 62px;
  font-size: 0.55rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint);
}
.matchup-mult { font-family: var(--font-mono); font-size: 0.6rem; color: var(--ink-faint); margin-left: -2px; }

/* ---------- type cards ---------------------------------------------------- */

.typecard {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 0;
  background:
    radial-gradient(70% 120% at 0% 50%, color-mix(in srgb, var(--card-type) 22%, transparent), transparent 70%),
    var(--bg-raised);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
  color: var(--ink); text-align: left; cursor: pointer; font: inherit;
}
.typecard-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.typecard-head { display: flex; align-items: baseline; gap: 8px; }
.typecard-name { font-family: var(--font-display); font-size: 1rem; font-weight: 800; color: var(--card-type); }
.typecard-count { font-size: 0.62rem; color: var(--ink-faint); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- team list ----------------------------------------------------- */

.teamcard {
  padding: 13px 14px 12px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), var(--shadow-sm);
}
.teamcard.chosen { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 20px -8px var(--accent); }
.teamcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.teamcard-name { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.teamcard-idea { margin: 10px 0 0; font-size: 0.76rem; line-height: 1.5; color: var(--ink-soft); }

/* The longer rationale, one tap down. Six teams' worth of it on the card was
 * three paragraphs of prose to answer one question — "which of these do I want
 * to play" — and the answer is really in the five portraits above it. */
.teamcard-why { margin-top: 8px; }
.teamcard-why > summary {
  list-style: none; cursor: pointer;
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-faint);
}
.teamcard-why > summary::-webkit-details-marker { display: none; }
.teamcard-why > summary::after { content: " ▾"; }
.teamcard-why[open] > summary::after { content: " ▴"; }
.teamcard-why p { margin: 8px 0 0; font-size: 0.74rem; line-height: 1.5; color: var(--ink-faint); }

/* ---------- team builder -------------------------------------------------- */

.slot-list { display: flex; flex-direction: column; gap: 6px; }

.slot {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px 8px 10px;
  min-height: 60px;
  border-radius: var(--radius-sm);
  border: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--card-type, var(--line)) 14%, var(--bg-raised)) 0%, var(--bg-raised) 55%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
  width: 100%; text-align: left; color: var(--ink); cursor: pointer;
}
/* An empty slot is a dashed outline, not a box: it is the absence of a
 * character, and it should look like a place to put one. */
.slot-empty { background: rgb(255 255 255 / 0.025); box-shadow: none; outline: 1.5px dashed var(--line-strong); outline-offset: -1.5px; color: var(--ink-faint); }
.slot-index {
  flex: none; width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 50%; background: rgb(0 0 0 / 0.25);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
  font-size: 1.2rem; color: var(--ink-faint);
}
.slot-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.slot-moves {
  font-size: 0.64rem; color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.input {
  width: 100%; min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 0;
  background: rgb(0 0 0 / 0.3);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.5), inset 0 0 0 1px rgb(255 255 255 / 0.06);
  color: var(--ink); font-weight: 800; font-size: 0.95rem;
  font-family: var(--font-display);
}

/* ---------- result -------------------------------------------------------- */

.result { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }

/* ---------- misc ---------------------------------------------------------- */

.section-head {
  margin: 20px 0 8px 4px;
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint);
}
.section-head:first-child { margin-top: 0; }

.prose { font-size: 0.8rem; line-height: 1.55; color: var(--ink-soft); }
.prose b, .prose strong { color: var(--ink); }
.prose p { margin: 0 0 8px; }
.prose p:last-child { margin-bottom: 0; }

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

/* A collapsed group. Used for the codex move lists and the builder's move
 * pools, which is how nine types' worth of moves became nine rows. */
.group { border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 6px; }
.group > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px; min-height: 48px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--card-type, var(--line)) 16%, var(--bg-raised)), var(--bg-raised) 60%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
  font-size: 0.76rem; font-weight: 800; letter-spacing: 0.03em;
  cursor: pointer; list-style: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: "▾"; margin-left: auto; color: var(--ink-faint); font-size: 0.7rem; }
.group[open] > summary::after { content: "▴"; }
.group-body { padding: 6px 0 2px; }
.group-count { color: var(--ink-faint); font-weight: 700; }

/* Wide content must scroll inside its own box; the page body must never scroll
 * sideways. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- pointer-only affordances -------------------------------------
 * EVERY :hover rule for this file lives here. See the header for why. */
@media (hover: hover) {
  .move-btn:hover:not(:disabled)   { box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15), inset 0 0 0 1.5px color-mix(in srgb, var(--move-color) 70%, transparent), 0 4px 14px -4px color-mix(in srgb, var(--move-color) 50%, transparent); filter: brightness(1.1); }
  .bench-item:hover:not(:disabled) { filter: brightness(1.12); }
  .roster-card:hover               { filter: brightness(1.12); }
  .slot:hover                      { filter: brightness(1.1); }
  .mrow:hover:not(:disabled)       { filter: brightness(1.15); }
  .typecard:hover                  { filter: brightness(1.1); }
  .plate:hover                     { box-shadow: inset 0 1px 0 var(--glass-edge), inset 0 0 0 1px rgb(255 255 255 / 0.12), 0 10px 30px -14px rgb(0 0 0 / 0.9); }
  .group > summary:hover           { filter: brightness(1.12); }
  .ticker:hover                    { filter: brightness(1.15); }
}
