/* ===== Mainspring - game-specific styles =====
   Chrome (bar, glass, modals, toast) comes from shared/css/glass.css.
   This file re-tints the shell to oxidized brass and lays out the duel:
   the automaton, the escapement rail, the clockmaker, the hand and the route.
   All state lives in mainspring.js. */

:root {
  --accent-1: #e0a95c;
  --accent-2: #5fd3c0;
  --on-accent: #10201c;
  --bg-1: #12232c;
  --bg-2: #05090c;
  --bg-glow-a: rgba(224, 169, 92, .20);
  --bg-glow-b: rgba(95, 211, 192, .13);
  --gold: #ffd88a;
  --brass: #e0a95c;
  --brass-hi: #ffd88a;
  --brass-lo: #a9742f;
  --patina: #5fd3c0;
  --ivory: #f4ece0;
  --ink: #0a1216;
  /* Card scale. Five cards plus the hand's gaps and padding have to fit inside
     the arena at every width, so the width is derived from the viewport rather
     than clamped to a guess: 92px is the frame, gaps and paddings around the row.
     The 15vh cap keeps a short laptop window from pushing the hand off-screen. */
  --cw: clamp(78px, min(calc((96vw - 92px) / 5), 15vh), 166px);
  --card-h: calc(var(--cw) * 1.4);
}

/* Class-level display rules would beat the UA [hidden] rule otherwise. */
[hidden] { display: none !important; }

/* ---------- Clocktower sky ----------
   The shared shell is translucent, so the page itself carries the backdrop:
   a brass glow under the rail, a vast escapement face and drifting gear teeth. */
.ms-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(52% 38% at 50% 108%, rgba(224, 169, 92, .26), transparent 74%),
    radial-gradient(38% 30% at 88% 4%, rgba(95, 211, 192, .12), transparent 76%),
    linear-gradient(180deg, #101f28 0%, #080f14 54%, #04080a 100%);
}
.ms-page::after {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 216, 138, .8) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(95, 211, 192, .5) 0 1.1px, transparent 1.9px);
  background-size: 280px 280px, 190px 190px;
  background-position: 0 0, 80px 40px;
  opacity: .18;
  animation: msSparks 34s linear infinite;
}
@keyframes msSparks {
  from { background-position: 0 0, 80px 40px; }
  to { background-position: 16px -280px, 62px -150px; }
}
.c-app { position: relative; z-index: 1; }
.ms-page .c-app { background: transparent; }
.gc-back { z-index: 2; }

/* A faint escape-wheel face behind everything, plus a haze at the base. */
.ms-sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.ms-sky__face {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(96vw, 940px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg,
      rgba(255, 216, 138, .16) 0deg .35deg, transparent .35deg 6deg),
    repeating-conic-gradient(from 0deg,
      rgba(255, 216, 138, .08) 0deg .18deg, transparent .18deg 2deg);
  -webkit-mask-image: radial-gradient(circle, transparent 46%, #000 62%, #000 66%, transparent 74%);
  mask-image: radial-gradient(circle, transparent 46%, #000 62%, #000 66%, transparent 74%);
  opacity: .5;
  animation: msTurn 240s linear infinite;
}
.ms-sky__gears {
  position: absolute;
  left: 50%;
  bottom: -18%;
  width: min(110vw, 1200px);
  height: 62%;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 18% 60%, rgba(224, 169, 92, .16) 0 12%, transparent 12.4%),
    radial-gradient(circle at 78% 42%, rgba(95, 211, 192, .10) 0 9%, transparent 9.4%);
  opacity: .8;
}
.ms-sky__haze {
  position: absolute;
  left: 50%;
  bottom: -26%;
  width: 94vw;
  height: 62vh;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(224, 169, 92, .18), transparent 76%);
}
@keyframes msTurn {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.c-app { --fpad: clamp(10px, 3vw, 28px); }
/* align-items: stretch lets the wrap fill the table so the arena can breathe;
   the bottom padding reserves room for the fixed back chip. */
.c-table {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding-bottom: 52px;
}

.gc-back {
  border-color: rgba(255, 216, 138, .22);
  background: rgba(8, 16, 20, .66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f4e8d2;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .45);
  opacity: .85;
}
.gc-back:hover { color: #fff; opacity: 1; }

/* ---------- Frame ---------- */
.ms-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(96vw, 780px);
  /* Pin the board to the top: a tall screen must not open with a dead band. */
  margin: 0 auto auto;
}
@media (min-width: 1000px) {
  .ms-wrap { width: min(94vw, 1120px); }
}

.ms-arena {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px clamp(12px, 2vw, 20px) 10px;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 84% -10%, rgba(224, 169, 92, .16), transparent 60%),
    radial-gradient(90% 70% at 8% 112%, rgba(95, 211, 192, .08), transparent 70%),
    linear-gradient(168deg, rgba(30, 44, 50, .88), rgba(6, 11, 14, .92));
  border: 1px solid rgba(224, 169, 92, .22);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, .55),
    inset 0 1px 0 rgba(255, 255, 255, .08),
    inset 0 0 0 1px rgba(0, 0, 0, .2);
}
/* Brass filigree in the corners: the arena reads as a machine plate. */
.ms-arena::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(30% 44% at 90% 68%, rgba(224, 169, 92, .16), transparent 72%),
    radial-gradient(24% 30% at 6% 12%, rgba(95, 211, 192, .10), transparent 72%);
}
.ms-arena::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 216, 138, .5), transparent);
  pointer-events: none;
}

/* ---------- Automaton ---------- */
.ms-foe {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px 10px 10px;
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(224, 169, 92, .10), rgba(8, 14, 17, .22) 58%),
    radial-gradient(70% 120% at 12% 50%, rgba(255, 180, 90, .12), transparent 70%);
  border: 1px solid rgba(224, 169, 92, .20);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.ms-foe.is-boss {
  border-color: rgba(255, 160, 90, .38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 0 30px rgba(255, 150, 70, .10);
}
.ms-foe__art {
  position: relative;
  flex: none;
  width: 118px;
  height: 104px;
  display: grid;
  place-items: center;
}
.ms-foe__art::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 112px;
  height: 112px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224, 169, 92, .30), transparent 68%);
  animation: msAura 4s ease-in-out infinite;
}
.ms-foe.is-boss .ms-foe__art::before {
  background: radial-gradient(circle, rgba(255, 170, 80, .44), transparent 68%);
}
/* Dark disc under the sprite, so a pale automaton still separates from the aura. */
.ms-foe__art::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(4, 12, 16, .66), rgba(4, 12, 16, .26) 62%, transparent);
  pointer-events: none;
}
.ms-foe__art svg {
  position: relative;
  z-index: 1;
  width: 92px;
  height: 92px;
  display: block;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .5)) drop-shadow(0 0 10px rgba(255, 170, 90, .30));
  animation: msBob 4.2s ease-in-out infinite;
}
@keyframes msBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes msAura {
  0%, 100% { opacity: .66; transform: translate(-50%, -50%) scale(.94); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}
.ms-foe.is-lunge { animation: msLunge .42s ease; }
@keyframes msLunge {
  0%, 100% { transform: none; }
  30% { transform: translateY(6px) scale(.99); }
  58% { transform: translateY(-9px) scale(1.012); }
}
.ms-foe.is-hit { animation: msShake .4s ease; }

.ms-foe__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ms-foe__top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ms-foe__name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: #fdf3e2;
}
.ms-foe__next {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px 4px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  color: #ffd9a8;
  background: rgba(224, 169, 92, .12);
  border: 1px solid rgba(224, 169, 92, .38);
}
.ms-foe__next b { color: #fff; font-variant-numeric: tabular-nums; }
.ms-foe__ico { display: inline-flex; opacity: .85; }
.ms-foe__ico svg { width: 13px; height: 13px; display: block; }

/* ---------- Bars ---------- */
.ms-bar {
  position: relative;
  height: 19px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .48);
  border: 1px solid rgba(255, 255, 255, .09);
  overflow: hidden;
}
.ms-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: repeating-linear-gradient(90deg,
    transparent 0 calc(10% - 1px),
    rgba(4, 8, 10, .42) calc(10% - 1px) 10%);
}
.ms-bar i {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  border-radius: 999px;
  transition: width .28s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3);
}
.ms-bar--foe i { background: linear-gradient(90deg, #ff6a5e, #ffb765); }
.ms-bar--hero i { background: linear-gradient(90deg, #3fb8a6, #9ee89a); }
.ms-bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  font-variant-numeric: tabular-nums;
}

/* ---------- Status tags ---------- */
.ms-tags { display: flex; flex-wrap: wrap; gap: 5px; min-height: 0; }
.ms-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  color: #f2e6d6;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .10);
  white-space: nowrap;
}
.ms-tag b { color: #fff; }
.ms-tag__ico { display: inline-flex; opacity: .8; }
.ms-tag__ico svg { width: 10px; height: 10px; display: block; }
.ms-tag--guard { color: #b8ecff; border-color: rgba(110, 200, 255, .38); background: rgba(90, 180, 255, .12); }
.ms-tag--tension { color: #ffd2a8; border-color: rgba(255, 170, 90, .40); background: rgba(255, 150, 70, .12); }
.ms-tag--loose { color: #ffb8c8; border-color: rgba(255, 110, 150, .40); background: rgba(255, 90, 130, .12); }
.ms-tag--rage { color: #ffb066; border-color: rgba(255, 140, 60, .50); background: rgba(255, 120, 50, .14); }
.ms-tag--grip { color: #d6c7ff; border-color: rgba(170, 140, 255, .40); background: rgba(150, 120, 255, .12); }

/* ---------- Escapement rail ---------- */
.ms-clock {
  position: relative;
  padding: 7px 12px 9px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 216, 138, .07), rgba(4, 9, 12, .34)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .03) 0 1px, transparent 1px 12px);
  border: 1px solid rgba(224, 169, 92, .24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), inset 0 -8px 20px rgba(0, 0, 0, .22);
}
.ms-clock__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.ms-clock__mark {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: rgba(255, 216, 138, .82);
}
.ms-clock__mark b {
  color: #fff;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.ms-risk {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}
.ms-risk.is-danger { color: #ff9a8a; }
.ms-risk.is-safe { color: #8ff0d4; }

.ms-rail {
  position: relative;
  height: 62px;
  margin: 0 2px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .30), rgba(0, 0, 0, .10)),
    linear-gradient(90deg, rgba(224, 169, 92, .10), rgba(224, 169, 92, .02));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
  overflow: hidden;
}
/* The baseline every scheduled action is pinned to. */
.ms-rail::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 17px;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 216, 138, .55), rgba(255, 216, 138, .22));
}
/* One hairline per tick, standing on the baseline; every fifth is labelled. */
.ms-rail__tick {
  position: absolute;
  bottom: 19px;
  width: 1px;
  height: 7px;
  background: rgba(255, 216, 138, .22);
  transform: translateX(-.5px);
}
.ms-rail__tick.is-odd { height: 4px; background: rgba(255, 216, 138, .12); }
.ms-rail__tick.is-major { height: 10px; background: rgba(255, 216, 138, .42); }
.ms-rail__tick b {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-top: 3px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .02em;
  color: rgba(255, 216, 138, .52);
  font-variant-numeric: tabular-nums;
}
/* Guard window: the stretch of rail your armour actually covers. */
.ms-rail__guard {
  position: absolute;
  left: 22px;
  bottom: 4px;
  height: 9px;
  border-radius: 0 5px 5px 0;
  background: linear-gradient(90deg, rgba(95, 211, 192, .6), rgba(95, 211, 192, .16));
  border-top: 1px solid rgba(160, 255, 235, .6);
  transition: width .3s ease;
}
.ms-rail__guard b {
  position: absolute;
  right: 6px;
  top: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(4, 24, 21, .9);
  line-height: 9px;
}
/* A scheduled action. One row: a stem drops from the chip to its exact tick, so
   the chip only has to carry what the hit is worth. */
.ms-ev {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  padding: 0 8px 0 6px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: #ffd9c0;
  background: rgba(120, 30, 20, .72);
  border: 1px solid rgba(255, 120, 90, .55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.ms-ev::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 11px;
  transform: translateX(-.5px);
  background: linear-gradient(180deg, currentColor, transparent);
  opacity: .7;
}
.ms-ev__ico { display: inline-flex; opacity: .95; }
.ms-ev__ico svg { width: 13px; height: 13px; display: block; }
.ms-ev b { font-size: 12px; font-variant-numeric: tabular-nums; }
/* A move that hits and hardens at once carries its guard alongside the damage. */
.ms-ev__sub {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-style: normal;
  font-size: 10px;
  color: #a9e6ff;
  opacity: .95;
}
.ms-ev__sub svg { width: 10px; height: 10px; display: block; }
.ms-ev__sub--jam { color: #dcc4ff; }
.ms-ev.is-def {
  color: #cbe8ff;
  background: rgba(24, 62, 100, .72);
  border-color: rgba(120, 190, 255, .55);
}
.ms-ev.is-jam {
  color: #e6ccff;
  background: rgba(62, 38, 96, .72);
  border-color: rgba(190, 150, 255, .55);
}
/* Inside the window of the card under the cursor. */
.ms-ev.is-hit {
  border-color: #ff8a72;
  background: rgba(150, 34, 22, .88);
  box-shadow: 0 0 0 1px rgba(255, 120, 90, .55), 0 0 18px rgba(255, 90, 70, .6);
  transform: translateX(-50%) scale(1.1);
}
/* "now" and the card landing mark. */
.ms-rail__now {
  position: absolute;
  left: 22px;
  top: 2px;
  bottom: 17px;
  width: 2px;
  transform: translateX(-1px);
  background: linear-gradient(180deg, rgba(255, 216, 138, .9), rgba(255, 216, 138, .2));
}
.ms-rail__now i {
  position: absolute;
  left: -3px;
  bottom: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffd88a;
  box-shadow: 0 0 10px rgba(255, 200, 100, .8);
}
.ms-rail__land {
  position: absolute;
  top: 2px;
  bottom: 17px;
  width: 2px;
  transform: translateX(-1px);
  background: repeating-linear-gradient(180deg, rgba(95, 211, 192, .9) 0 4px, transparent 4px 8px);
}
/* The label sits in the gap between the chips and the baseline, where nothing
   else can be. */
.ms-rail__land b {
  position: absolute;
  top: auto;
  bottom: 20px;
  left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 8.5px;
  font-weight: 800;
  color: #04201c;
  background: var(--patina);
  white-space: nowrap;
}

/* ---------- Clockmaker ---------- */
.ms-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  border-radius: 16px;
  background:
    linear-gradient(150deg, rgba(255, 216, 138, .07), rgba(6, 12, 15, .30)),
    radial-gradient(60% 120% at 6% 50%, rgba(95, 211, 192, .10), transparent 70%);
  border: 1px solid rgba(255, 216, 138, .16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.ms-hero.is-hit { animation: msShake .4s ease; }
.ms-hero.is-heal { animation: msHeal .5s ease; }

/* Crank dial: three brass pips that light as tempo is banked. */
.ms-cog {
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background:
    radial-gradient(circle at 36% 28%, rgba(255, 228, 170, .22), transparent 60%),
    linear-gradient(160deg, rgba(224, 169, 92, .24), rgba(10, 18, 20, .85));
  border: 1px solid rgba(224, 169, 92, .45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 4px 14px rgba(0, 0, 0, .4);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.ms-cog.is-live {
  border-color: rgba(95, 211, 192, .6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 0 18px rgba(95, 211, 192, .35);
}
.ms-cog small {
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 232, 200, .6);
}
.ms-cog__pips { display: flex; gap: 4px; }
.ms-cog__pips i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 216, 138, .10);
  box-shadow: inset 0 0 0 1px rgba(255, 216, 138, .38);
  transition: background .18s ease, box-shadow .18s ease;
}
.ms-cog__pips i.is-on {
  background: radial-gradient(circle at 36% 30%, #fff3c8, #ffc860 60%, #b97a1e);
  box-shadow: 0 0 9px rgba(255, 200, 96, .8);
}

.ms-hero__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.ms-hero__top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ms-hero__name { font-size: 14px; font-weight: 800; color: #f6ecdc; }
.ms-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.ms-pill b { font-variant-numeric: tabular-nums; }
.ms-pill i { font-style: normal; opacity: .7; font-weight: 700; }
.ms-pill--guard {
  color: #cfeaff;
  background: rgba(90, 170, 255, .16);
  border: 1px solid rgba(120, 190, 255, .42);
}
.ms-pill--jam {
  color: #e6ccff;
  background: rgba(180, 130, 255, .16);
  border: 1px solid rgba(190, 150, 255, .45);
}

.ms-acts { display: flex; flex-direction: column; gap: 5px; flex: none; }
.ms-rush,
.ms-hold {
  appearance: none;
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .02em;
  padding: 6px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: filter .15s ease, background .15s ease, transform .05s ease;
  white-space: nowrap;
}
.ms-hold {
  color: #22160a;
  border: 1px solid rgba(255, 236, 200, .7);
  background: linear-gradient(180deg, #ffdc9a, #e0a95c 62%, #c4853a);
  box-shadow: 0 4px 14px rgba(224, 169, 92, .28), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.ms-hold:hover { filter: brightness(1.06); }
.ms-rush {
  color: #cfe9ff;
  border: 1px solid rgba(120, 190, 255, .35);
  background: rgba(80, 150, 220, .14);
}
.ms-rush:hover { background: rgba(80, 150, 220, .24); }
.ms-rush.is-on {
  color: #06231f;
  border-color: rgba(160, 255, 235, .8);
  background: linear-gradient(180deg, #9ff3e0, #5fd3c0);
  box-shadow: 0 0 16px rgba(95, 211, 192, .5);
}
.ms-rush:active,
.ms-hold:active { transform: translateY(1px); }
.ms-rush:disabled,
.ms-hold:disabled {
  opacity: .38;
  filter: saturate(.4);
  cursor: default;
  box-shadow: none;
}

/* ---------- Hand ---------- */
.ms-hand {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 9px;
  min-height: calc(var(--card-h) + 22px);
  /* The row scrolls sideways, so the browser clips it vertically too. The top
     padding is the headroom a hovered card grows into. */
  padding: 20px 6px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(224, 169, 92, .3) transparent;
}
/* Zero-basis spacers centre a short hand while a big hand overflows left. */
.ms-hand::before,
.ms-hand::after {
  content: "";
  flex: 1 1 0;
  min-width: 0;
  align-self: stretch;
}
.ms-hand::-webkit-scrollbar { height: 5px; }
.ms-hand::-webkit-scrollbar-thumb { background: rgba(224, 169, 92, .28); border-radius: 99px; }
.ms-hand:empty::before { display: none; }
.ms-hand:empty::after {
  content: "No cards in hand";
  flex: 0 0 auto;
  align-self: center;
  color: var(--c-muted);
  font-size: 12.5px;
}

.ms-card {
  --ct: #ff8a72;
  --ch: 30;
  position: relative;
  flex: 0 0 auto;
  width: var(--cw);
  height: var(--card-h);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: calc(var(--cw) * .075) calc(var(--cw) * .075) calc(var(--cw) * .066);
  border-radius: calc(var(--cw) * .12);
  text-align: left;
  font: inherit;
  color: #f6ecdf;
  cursor: pointer;
  appearance: none;
  overflow: hidden;
  transform: rotate(var(--rot, 0deg)) translateY(var(--dy, 0px));
  transform-origin: 50% 118%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .08), transparent 30%),
    linear-gradient(168deg, color-mix(in srgb, var(--ct) 15%, #1d2a30), #080f13 76%);
  border: 1px solid color-mix(in srgb, var(--ct) 45%, rgba(255, 255, 255, .10));
  box-shadow:
    0 10px 18px rgba(0, 0, 0, .42),
    inset 0 1px 0 rgba(255, 255, 255, .13);
  transition: transform .16s cubic-bezier(.2, .8, .3, 1.2), box-shadow .16s ease, opacity .14s ease, border-color .16s ease;
}
/* Light sweeps across the card on hover. */
.ms-card::after {
  content: "";
  position: absolute;
  top: -60%;
  left: -80%;
  width: 55%;
  height: 220%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .18), transparent);
  transform: rotate(16deg);
  transition: left .5s ease;
  pointer-events: none;
}
.ms-card:hover::after { left: 135%; }
.ms-card:hover,
.ms-card:focus-visible {
  /* Grow, never move: straightening and lifting pulled the card out from under
     the cursor, so hovering an edge made :hover flip on and off. The offset
     turns the 1.07 scale into one anchored on the card's bottom edge. */
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--dy, 0px) + var(--cw) * .017)) scale(1.07);
  z-index: 5;
  border-color: color-mix(in srgb, var(--ct) 75%, #fff 10%);
  box-shadow:
    0 18px 30px rgba(0, 0, 0, .5),
    0 0 0 1px color-mix(in srgb, var(--ct) 60%, transparent),
    0 0 26px color-mix(in srgb, var(--ct) 28%, transparent);
  outline: none;
}
.ms-card:active {
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--dy, 0px) + var(--cw) * .007)) scale(1.03);
}
.ms-card.is-rushing {
  border-color: rgba(160, 255, 235, .75);
  box-shadow: 0 0 0 1px rgba(95, 211, 192, .5), 0 10px 22px rgba(0, 0, 0, .45);
}
.ms-card.is-static { cursor: default; }
.ms-card.is-static:hover {
  transform: none;
  box-shadow: 0 10px 18px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .13);
}
.ms-card--attack { --ct: #ff8a72; }
.ms-card--skill { --ct: #6fb6ff; }
.ms-card--gear { --ct: #d7a8ff; }

/* Wind badge: this is the card's only cost. */
.ms-card__wind {
  position: absolute;
  top: calc(var(--cw) * .055);
  left: calc(var(--cw) * .055);
  z-index: 2;
  width: calc(var(--cw) * .225);
  height: calc(var(--cw) * .225);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: calc(var(--cw) * .105);
  font-weight: 900;
  color: #1d1204;
  background: radial-gradient(circle at 36% 28%, #fff0c8, #e8b96a 58%, #b07a2e);
  border: 1px solid rgba(255, 244, 210, .85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .48);
  font-variant-numeric: tabular-nums;
}
.ms-card__plus {
  position: absolute;
  top: calc(var(--cw) * .03);
  right: calc(var(--cw) * .05);
  z-index: 2;
  font-size: calc(var(--cw) * .09);
  font-weight: 900;
  color: var(--gold);
}
.ms-card__art {
  position: relative;
  display: grid;
  place-items: center;
  height: calc(var(--cw) * .47);
  margin: calc(var(--cw) * -.075) calc(var(--cw) * -.075) 1px;
  border-bottom: 1px solid color-mix(in srgb, var(--ct) 24%, transparent);
  background:
    radial-gradient(80% 90% at 50% 108%, hsla(var(--ch), 80%, 58%, .22), transparent 70%),
    linear-gradient(180deg, hsla(var(--ch), 55%, 28%, .18), transparent 80%);
  overflow: hidden;
}
.ms-card__art::before {
  content: "";
  position: absolute;
  width: calc(var(--cw) * .4);
  height: calc(var(--cw) * .4);
  border-radius: 50%;
  border: 1px solid hsla(var(--ch), 90%, 72%, .20);
  background: radial-gradient(circle, hsla(var(--ch), 90%, 60%, .12), transparent 70%);
}
.ms-card__halo {
  position: absolute;
  left: 50%;
  bottom: calc(var(--cw) * -.2);
  width: calc(var(--cw) * .72);
  height: calc(var(--cw) * .72);
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, hsla(var(--ch), 88%, 62%, .36), transparent 68%);
}
.ms-card__glyph {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsla(var(--ch), 88%, 76%, 1);
  filter: drop-shadow(0 0 8px hsla(var(--ch), 88%, 58%, .45));
}
.ms-card__glyph svg { width: calc(var(--cw) * .28); height: calc(var(--cw) * .28); display: block; }
.ms-card__name {
  font-size: calc(var(--cw) * .099);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.15;
  color: #fff4e6;
}
.ms-card__text {
  font-size: calc(var(--cw) * .09);
  line-height: 1.36;
  color: #ded4c6;
}
.ms-card__text b { color: #fff; font-weight: 900; }
.ms-card__mark {
  position: absolute;
  right: calc(var(--cw) * -.08);
  bottom: calc(var(--cw) * .08);
  width: calc(var(--cw) * .68);
  height: calc(var(--cw) * .68);
  color: hsla(var(--ch), 90%, 70%, .06);
  pointer-events: none;
  z-index: 0;
}
.ms-card__mark svg { width: 100%; height: 100%; }
.ms-card__name,
.ms-card__text,
.ms-card__foot { position: relative; z-index: 1; }
.ms-card__foot {
  margin-top: auto;
  padding-top: calc(var(--cw) * .032);
  border-top: 1px solid color-mix(in srgb, var(--ct) 18%, transparent);
  font-size: calc(var(--cw) * .072);
  font-weight: 800;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ct) 80%, #fff);
  opacity: .85;
}

/* Deal-in stagger. Only set when a fresh hand hits the table. */
.ms-hand.is-dealt .ms-card {
  animation: msDeal .42s cubic-bezier(.2, .8, .3, 1.1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes msDeal {
  from { opacity: 0; transform: translateY(18px) rotate(calc(var(--rot, 0deg) - 5deg)) scale(.94); }
}

/* ---------- Foot ---------- */
.ms-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 2px;
  font-size: 11.5px;
  color: var(--c-muted);
}
.ms-pile b { color: #ffe9c6; font-variant-numeric: tabular-nums; }
.ms-foot__hint {
  flex: 1;
  text-align: center;
  font-size: 11px;
  letter-spacing: .01em;
  color: rgba(210, 226, 232, .6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Route strip ---------- */
.ms-route {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 216, 138, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.ms-route::before {
  content: "";
  position: absolute;
  left: 3%;
  right: 3%;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 216, 138, .55), transparent);
}
.ms-node {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: rgba(255, 232, 200, .78);
  background: rgba(8, 14, 18, .92);
  border: 1px solid rgba(255, 216, 138, .26);
}
.ms-node svg { width: 14px; height: 14px; display: block; }
.ms-node.is-done { color: #7ce4cb; border-color: rgba(95, 211, 192, .5); background: rgba(6, 26, 23, .92); }
.ms-node.is-bench { color: #ffcf85; border-color: rgba(255, 180, 90, .55); }
.ms-node.is-boss { color: #ffb094; border-color: rgba(255, 130, 90, .62); }
.ms-node.is-now {
  color: #10161a;
  background: linear-gradient(180deg, #ffe3a8, #e0a95c);
  border-color: rgba(255, 244, 210, .9);
  box-shadow: 0 0 14px rgba(224, 169, 92, .55);
  animation: msNow 2s ease-in-out infinite;
}
.ms-node.is-now.is-boss {
  background: linear-gradient(180deg, #ffc9a0, #ff7a5c);
  box-shadow: 0 0 16px rgba(255, 120, 90, .55);
}
@keyframes msNow {
  0%, 100% { box-shadow: 0 0 10px rgba(224, 169, 92, .35); }
  50% { box-shadow: 0 0 20px rgba(224, 169, 92, .7); }
}

/* ---------- Floating numbers ---------- */
.ms-float {
  position: absolute;
  top: 16px;
  z-index: 6;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -.01em;
  color: #ffb4a4;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .8);
  pointer-events: none;
  animation: msFloat .9s ease-out forwards;
}
.ms-float--guard { color: #8fd0ff; }
.ms-float--heal { color: #7ff0a8; }
.ms-float--tension { color: #ffc27a; }
.ms-float--jam { color: #d9b8ff; }
.ms-float--buff { color: #e0b6ff; }
@keyframes msFloat {
  from { opacity: 0; transform: translateY(8px) scale(.9); }
  30% { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-26px); }
}
@keyframes msShake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-6px) rotate(-.6deg); }
  55% { transform: translateX(5px) rotate(.5deg); }
  80% { transform: translateX(-2px); }
}
@keyframes msHeal {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05); }
  40% { box-shadow: inset 0 0 26px rgba(110, 240, 170, .35); }
}

/* ---------- Flow card extras ---------- */
.ms-flow { width: min(94vw, 660px); --cw: 118px; }
.ms-flow .c-modal__body { padding-bottom: 10px; }
.ms-flow .c-modal__foot:empty { display: none; }
.ms-rewards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 4px 0 10px;
}
.ms-rewards .ms-card { width: 100%; max-width: 148px; height: auto; min-height: 196px; }
.ms-opts { display: grid; gap: 9px; margin: 8px 0 2px; }
.ms-opt {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  text-align: left;
  font: inherit;
  color: var(--c-text);
  cursor: pointer;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 216, 138, .20);
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.ms-opt:hover {
  background: rgba(224, 169, 92, .12);
  border-color: rgba(255, 216, 138, .45);
}
.ms-opt:active { transform: translateY(1px); }
.ms-opt__glyph { flex: none; display: inline-flex; color: var(--brass-hi); margin-top: 1px; }
.ms-opt__glyph svg { width: 20px; height: 20px; display: block; }
.ms-opt__name { display: block; font-size: 14px; font-weight: 800; }
.ms-opt__desc { display: block; font-size: 12px; line-height: 1.45; color: var(--c-muted); margin-top: 2px; }
.ms-opt.is-off { opacity: .45; cursor: default; }
.ms-opt.is-off:hover { transform: none; background: rgba(255, 255, 255, .05); border-color: rgba(255, 216, 138, .20); }

.ms-end-screen { text-align: center; padding: 4px 0 2px; }
.ms-end-screen__mark { color: var(--gold); }
.ms-end-screen__mark svg { width: 60px; height: 60px; display: block; margin: 0 auto 4px; }
.ms-end-screen h3 {
  margin: 2px 0 4px;
  font-size: 22px;
  color: #fff4e6;
  letter-spacing: -.01em;
  text-transform: none;
}
.ms-end-screen__sub { margin: 0 0 14px; font-size: 13px; color: var(--c-muted); }
.ms-end-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.ms-end-stats div {
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 216, 138, .16);
}
.ms-end-stats b { display: block; font-size: 18px; color: #fff; font-variant-numeric: tabular-nums; }
.ms-end-stats span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.ms-map-panel { width: min(94vw, 520px); }
.ms-map { display: grid; gap: 6px; margin: 4px 0 12px; }
.ms-map__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--c-muted);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
}
.ms-map__row.is-now {
  border-color: rgba(224, 169, 92, .5);
  background: rgba(224, 169, 92, .12);
  color: #fff3e2;
}
.ms-map__row.is-done { opacity: .55; }
.ms-map__n {
  flex: none;
  width: 20px;
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ms-map__ic { flex: none; display: grid; place-items: center; color: var(--gold); }
.ms-map__ic svg { width: 16px; height: 16px; }
.ms-map__name { flex: 1; min-width: 0; font-weight: 700; }
.ms-map__state {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.ms-deck-panel { width: min(94vw, 560px); }
.ms-deck { display: grid; gap: 5px; margin: 4px 0 10px; }
.ms-deck__row {
  display: grid;
  grid-template-columns: 34px minmax(92px, auto) 34px 1fr;
  align-items: baseline;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
}
.ms-deck__n { color: var(--brass-hi); font-weight: 800; font-variant-numeric: tabular-nums; }
.ms-deck__name { color: #fff; font-weight: 700; }
.ms-deck__wind {
  color: #1d1204;
  font-weight: 900;
  text-align: center;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffe6b0, #d9a054);
}
.ms-deck__text { color: var(--c-muted); font-size: 11.5px; }
.ms-deck__text b { color: #fff; }
.ms-deck__empty { color: var(--c-muted); font-size: 12px; }
.ms-relic-row { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.ms-relic {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--brass-hi);
  background: rgba(224, 169, 92, .12);
  border: 1px solid rgba(255, 216, 138, .32);
}
.ms-relic svg { width: 15px; height: 15px; display: block; }

.ms-rules-panel { width: min(94vw, 600px); }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .ms-arena { padding: 11px 10px 8px; gap: 8px; border-radius: 18px; }
  .ms-foe { gap: 10px; padding: 8px 10px 8px 6px; }
  .ms-foe__art { width: 92px; height: 88px; }
  .ms-foe__art svg { width: 78px; height: 78px; }
  .ms-foe__art::before { width: 92px; height: 92px; }
  .ms-foe__name { font-size: 15px; }
  .ms-foe__next { font-size: 10.5px; padding: 3px 8px 3px 6px; }
  .ms-cog { width: 48px; height: 48px; }
  .ms-cog__pips i { width: 7px; height: 7px; }
  .ms-acts { flex-direction: row; }
  .ms-rush, .ms-hold { padding: 6px 10px; font-size: 11px; }
  .ms-hero { gap: 8px; padding: 7px 9px 7px 7px; flex-wrap: wrap; }
  .ms-hero__meta { flex: 1 1 120px; }
  .ms-hand { gap: 6px; padding: 18px 4px 6px; }
  .ms-rail { height: 54px; }
  .ms-ev { min-width: 22px; padding: 1px 4px; font-size: 9px; }
  .ms-ev.is-low { top: 29px; }
  .ms-ev b { font-size: 10px; }
  .ms-foot__hint { display: none; }
  .ms-route { gap: 3px; }
  .ms-node { width: 22px; height: 22px; }
  .ms-node svg { width: 12px; height: 12px; }
  .ms-rewards .ms-card { min-height: 172px; }
  .ms-end-stats { grid-template-columns: repeat(2, 1fr); }
  .ms-deck__row { grid-template-columns: 28px 1fr 30px; }
  .ms-deck__text { grid-column: 2 / -1; }
}

/* Below this width even 78px cards will not fit five across, so they fan into
   each other instead of scrolling: the hand stays whole on a phone. */
@media (max-width: 560px) {
  .ms-hand { gap: 0; padding-left: 2px; padding-right: 2px; }
  .ms-card + .ms-card { margin-left: -17px; }
  .ms-card:hover, .ms-card:focus-visible { z-index: 5; }
}

@media (max-width: 420px) {
  .ms-foe__art { width: 72px; height: 70px; }
  .ms-foe__art svg { width: 62px; height: 62px; }
  .ms-foe__art::before { width: 72px; height: 72px; }
  .ms-cog { width: 42px; height: 42px; }
  .ms-cog small { font-size: 6.5px; }
  .ms-cog__pips { gap: 3px; }
  .ms-cog__pips i { width: 6px; height: 6px; }
  .ms-pill { font-size: 9px; padding: 1px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .ms-sky__face,
  .ms-foe__art svg,
  .ms-foe__art::before,
  .ms-node.is-now,
  .ms-page::after { animation: none; }
  .ms-hand.is-dealt .ms-card,
  .ms-float { animation: none; }
}
