@charset "UTF-8";

:root {
  --night: #0b1d17;
  --night-lo: #07130f;
  --felt: #1f6a4f;
  --felt-lo: #175640;
  --felt-deep: #0e3b2c;
  --wood: #5a3119;
  --wood-hi: #8a5530;
  --wood-lo: #2e170b;
  --lacquer: #b3261e;
  --lacquer-hi: #d8473a;
  --lacquer-lo: #6c140f;
  --gold: #e9b95b;
  --gold-hi: #ffe2a0;
  --gold-lo: #a2732f;
  --paper: #f8eed6;
  --paper-lo: #ecdbb4;
  --ink: #2a1f14;
  --ink-soft: #4a3a28;
  --cream: #f4ead3;
  --muted: #b8c6b5;
  --jade: #2fae8c;
  --glow-play: #ffd75e;
  --glow-target: #ff5b4a;
  --tribe-default: var(--lacquer);

  --font-body: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-display: "Noto Serif CJK TC", "Noto Serif TC", "Songti TC", "Source Han Serif TC", "PMingLiU", serif;
  --font-num: "Avenir Next", Avenir, "Futura", "Trebuchet MS", sans-serif;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  --shadow-card: 0 6px 14px rgb(0 0 0 / .45);
  --shadow-lift: 0 16px 30px rgb(0 0 0 / .55), 0 3px 6px rgb(0 0 0 / .4);
  --glow-ready: drop-shadow(0 0 2px var(--glow-play)) drop-shadow(0 0 9px rgb(255 205 70 / .85));
  --glow-hostile: drop-shadow(0 0 2px var(--glow-target)) drop-shadow(0 0 10px rgb(255 70 50 / .9));

  --z-board: 1;
  --z-hand: 10;
  --z-lift: 20;
  --z-top: 30;
  --z-banner: 40;
  --z-fx: 50;

  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 360ms;
  --dur-windup: 120ms;
  --dur-travel: 180ms;
  --dur-hitstop: 60ms;
  --dur-return: 220ms;
  --dur-hit: 420ms;
  --dur-shake: 260ms;
  --dur-float: 700ms;
  --dur-death: 450ms;
  --dur-summon: 380ms;
  --dur-fly: 350ms;
  --dur-glow: 520ms;
  --dur-shield: 300ms;
  --dur-trigger: 400ms;
  --dur-hero-hit: 600ms;
  --hold-banner: 800ms;
  --banner-lead: 450ms;
  --pace-enemy-step: 120ms;
  --dur-deal: 220ms;
  --pace-deal: 70ms;
  --pace-coin: 60ms;
  --hold-ko: 800ms;
  --dur-ko-stop: 150ms;
  --dur-seal-loss: 520ms;
  --dur-confetti: 900ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  color-scheme: dark;
  font-family: var(--font-body);
  color: var(--cream);
  background: var(--night);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(70vmax 46vmax at 4% -10%, rgb(255 110 50 / .26), transparent 62%),
    radial-gradient(70vmax 46vmax at 96% -10%, rgb(255 80 40 / .22), transparent 62%),
    radial-gradient(110vmax 70vmax at 50% 115%, rgb(31 106 79 / .38), transparent 62%),
    linear-gradient(var(--night), var(--night-lo));
  background-attachment: fixed;
}
h1, h2, p, ol, ul, blockquote { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.art { display: block; background-color: #e6d6b0; background-repeat: no-repeat; }

/* ---------- shared chrome ---------- */

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

.topbar {
  position: relative;
  z-index: var(--z-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: min(1120px, 100% - 24px);
  margin: 0 auto;
  padding: 10px 0;
}
.topbar-brand { font: 900 19px/1 var(--font-display); letter-spacing: .24em; color: var(--gold); text-shadow: 0 0 18px rgb(255 120 50 / .45); }
.topbar-actions { display: flex; gap: 8px; }

.chip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgb(233 185 91 / .38);
  border-radius: var(--r-pill);
  background: rgb(255 255 255 / .05);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.chip-button:hover { background: rgb(233 185 91 / .14); border-color: var(--gold); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  cursor: pointer;
  transition: translate var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.button--primary {
  color: #3a1a06;
  background: linear-gradient(#ffe7a8, var(--gold) 52%, #c98f33);
  box-shadow: 0 3px 0 #85561b, 0 8px 18px rgb(0 0 0 / .35), inset 0 1px 0 #fff6d8;
}
.button--primary:hover { translate: 0 -1px; box-shadow: 0 4px 0 #85561b, 0 12px 24px rgb(0 0 0 / .4), inset 0 1px 0 #fff6d8; }
.button--ghost { color: var(--cream); background: rgb(255 255 255 / .05); border: 1px solid rgb(233 185 91 / .45); }
.button--ghost:hover { background: rgb(233 185 91 / .14); }
.button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; translate: none; }
.count-chip { padding: 2px 8px; border-radius: var(--r-pill); background: rgb(0 0 0 / .35); color: var(--gold-hi); font: 700 13px/1.4 var(--font-num); }

.seal-stamp {
  display: inline-block;
  padding: 3px 8px;
  border: 2px solid #e0473b;
  border-radius: 6px;
  background: rgb(60 10 8 / .7);
  color: #ffb9ad;
  font: 900 15px/1.2 var(--font-display);
  letter-spacing: .12em;
  rotate: 7deg;
}

.lanterns { position: absolute; inset: 0 0 auto; display: flex; justify-content: space-around; pointer-events: none; }
.lanterns > span { width: clamp(22px, 3.4vw, 38px); filter: drop-shadow(0 0 12px rgb(255 90 40 / .8)) drop-shadow(0 0 36px rgb(255 120 50 / .35)); }
.lanterns > span:nth-child(3n + 1) { margin-top: 16px; }
.lanterns > span:nth-child(3n + 2) { margin-top: 4px; }
.lantern { display: block; width: 100%; height: auto; }

/* ---------- gems ---------- */

.gem {
  --gem: 30px;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--gem);
  height: var(--gem);
  vertical-align: middle;
  filter: drop-shadow(0 1px 1.5px rgb(0 0 0 / .7));
}
.gem::before, .gem::after { content: ""; position: absolute; inset: 0; clip-path: var(--shape); }
.gem::before { background: var(--rim); }
.gem::after { inset: 10%; background: var(--fill); }
.gem b {
  position: relative;
  z-index: 1;
  font: 800 calc(var(--gem) * .54)/1 var(--font-num);
  color: #fff;
  text-shadow: -1px -1px 0 #2a1205, 1px -1px 0 #2a1205, -1px 1px 0 #2a1205, 1px 1px 0 #2a1205, 0 2px 2px rgb(0 0 0 / .6);
}
.gem.is-hurt b { color: #ffc2b6; }
.gem.is-up b { color: #b4ffb0; }
.gem-attack {
  --shape: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0 71%, 0 29%);
  --rim: linear-gradient(160deg, #fff0bf, #a8651c);
  --fill: radial-gradient(circle at 35% 28%, #ffd98a, #ee9d27 50%, #8f4c0d);
}
.gem-cost {
  --shape: polygon(50% 0, 96% 25%, 96% 75%, 50% 100%, 4% 75%, 4% 25%);
  --rim: linear-gradient(160deg, #eafff8, #1f7d65);
  --fill: radial-gradient(circle at 38% 26%, #92f2d8, var(--jade) 50%, #0c5a47);
}
.gem-armor {
  --shape: polygon(0 0, 100% 0, 100% 58%, 50% 100%, 0 58%);
  --rim: linear-gradient(#f2f6f8, #6f7e86);
  --fill: linear-gradient(160deg, #c9d3d8, #5f6e76);
}
.gem-health::before { inset: 0 27%; clip-path: none; border-radius: 2px; background: linear-gradient(#f3c260 0 13%, transparent 13% 87%, #f3c260 87%); }
.gem-health::after {
  inset: 9% 1%;
  clip-path: none;
  border-radius: 48% / 50%;
  background:
    repeating-linear-gradient(90deg, transparent 0 21%, rgb(110 10 6 / .32) 21% 23%),
    radial-gradient(circle at 38% 30%, #ff8d6d, #d6352a 46%, #86120c);
  box-shadow: inset 0 0 0 1.5px #f3c260;
}

/* ---------- card (hand / collection) ---------- */

.card {
  position: relative;
  flex: none;
  width: var(--card-w, 150px);
  aspect-ratio: 5 / 7.2;
  container-type: inline-size;
}
.card-main {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 7cqi;
  background: none;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
}
span.card-main { cursor: default; }
.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 4cqi 5cqi 17cqi;
  border: 1.6cqi solid var(--gold-lo);
  border-radius: 7cqi;
  background: radial-gradient(120% 70% at 50% 0%, #fffaf0, transparent 70%), linear-gradient(var(--paper), var(--paper-lo));
  box-shadow: inset 0 0 0 1.4cqi var(--paper), inset 0 0 0 2cqi rgb(179 38 30 / .7), var(--shadow-card);
  transition: box-shadow var(--dur-base);
}
.card-name {
  padding: 0 0 1.5cqi 17cqi;
  font: 800 12cqi/1.25 var(--font-display);
  letter-spacing: .04em;
  text-align: left;
  white-space: nowrap;
}
.card .gem-cost { --gem: 26cqi; position: absolute; left: -5cqi; top: -5cqi; z-index: 2; }
.card-art {
  flex: 1 1 0;
  min-height: 18cqi;
  margin: 0 1cqi;
  border-radius: 40cqi 40cqi 3cqi 3cqi / 26cqi 26cqi 3cqi 3cqi;
  box-shadow: 0 0 0 1cqi var(--gold-lo), 0 0 0 1.8cqi var(--paper), 0 0 0 2.4cqi rgb(179 38 30 / .55);
}
.card-title {
  position: relative;
  z-index: 1;
  align-self: center;
  margin-top: -4.5cqi;
  padding: 1.2cqi 7cqi;
  font: 700 max(10px, 9.4cqi)/1.3 var(--font-display);
  color: var(--gold-hi);
  white-space: nowrap;
  background: linear-gradient(#d33d2f, #971d15);
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
  text-shadow: 0 1px 0 rgb(0 0 0 / .4);
}
.keywords { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.5cqi; margin-top: 1.8cqi; }
.keyword {
  display: inline-flex;
  align-items: center;
  gap: 1cqi;
  padding: .4cqi 3cqi .4cqi 2cqi;
  border-radius: var(--r-pill);
  font: 700 max(9px, 7.4cqi)/1.35 var(--font-body);
  color: #fff6e0;
  background: #2f5b4b;
}
.keyword .icon { width: 1.15em; height: 1.15em; }
.keyword-guard { background: #556169; }
.keyword-rush { background: #b45d17; }
.card-text {
  margin-top: 1.6cqi;
  padding-inline: 3cqi;
  font: 500 max(10px, 8.2cqi)/1.36 var(--font-body);
  color: var(--ink-soft);
}
.card .gem-attack, .card .gem-health { --gem: 26cqi; position: absolute; bottom: -5cqi; z-index: 2; }
.card .gem-attack { left: -5cqi; }
.card .gem-health { right: -5cqi; }
.card.is-playable .card-face { box-shadow: inset 0 0 0 1.4cqi var(--paper), inset 0 0 0 2cqi rgb(179 38 30 / .7), 0 0 0 2px var(--glow-play), 0 0 18px 5px rgb(255 200 60 / .7); }
.card.is-dim .card-face > :not(.card-reason) { filter: saturate(.35) brightness(.72); }
.card.is-dim .card-face { background: linear-gradient(#cbbf9f, #b5a682); }
/* Sits on the foot of the art and nets zero height (margins cancel its line), so it can't reach the name above or push the title below. */
.card-reason {
  position: relative;
  z-index: 3;
  align-self: center;
  margin: calc(-1lh - 12cqi) 0 12cqi;
  padding: 0 5cqi;
  rotate: -3deg;
  border-radius: 2cqi;
  background: rgb(42 31 20 / .9);
  color: var(--gold-hi);
  font: 700 max(10px, 8.6cqi)/1.4 var(--font-body);
  white-space: nowrap;
}
.card.is-selected .card-face { box-shadow: inset 0 0 0 1.4cqi var(--paper), inset 0 0 0 2cqi rgb(179 38 30 / .7), 0 0 0 3px var(--gold), 0 0 22px 4px rgb(255 200 60 / .55); }
.card-stamp {
  position: absolute;
  right: 6cqi;
  top: 26cqi;
  z-index: 3;
  padding: 1.5cqi 3cqi;
  border: 1.2cqi solid var(--lacquer);
  border-radius: 3cqi;
  background: rgb(255 248 230 / .88);
  color: var(--lacquer);
  font: 900 10cqi/1.1 var(--font-display);
  rotate: 12deg;
}
.peek {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--gold-lo);
  border-radius: 50%;
  background: rgb(42 31 20 / .78);
  color: #fff3d6;
  cursor: pointer;
}
.peek::after { content: ""; position: absolute; inset: calc(50% - 22px); }
.peek .icon { width: 16px; height: 16px; }
/* Phone hands shrink cards to fit five across. Below 80px the art takes the top, the name becomes the ribbon under it, and the title and effect text move to the ⓘ detail. */
@container (max-width: 80px) {
  .card-face { padding: 5cqi 5cqi 17px; }
  .card-name {
    order: 1;
    z-index: 1;
    align-self: center;
    margin-top: -4cqi;
    padding: 1px 7px;
    background: linear-gradient(#d33d2f, #971d15);
    clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
    color: var(--gold-hi);
    font-size: 12px;
    text-align: center;
  }
  .keywords { order: 2; }
  .card-title, .card-text { display: none; }
  .card .gem { --gem: 20px; }
}

/* ---------- unit token (board) ---------- */

.unit {
  --unit-glow: drop-shadow(0 0 0 transparent);
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: .8;
  padding: 0;
  border: 0;
  background: none;
  container-type: inline-size;
  filter: var(--unit-glow) drop-shadow(0 6px 5px rgb(0 0 0 / .45));
  transition: translate var(--dur-fast) var(--ease-out), filter var(--dur-base);
}
button.unit { cursor: pointer; }
.unit::before { content: ""; position: absolute; inset: -6cqi -2cqi 2cqi; border-radius: 50%; pointer-events: none; }
.unit-frame {
  position: absolute;
  inset: 0 3cqi 7cqi;
  z-index: 1;
  padding: 5cqi;
  border-radius: 50% 50% 14cqi 14cqi / 38% 38% 12cqi 12cqi;
  background: linear-gradient(160deg, #94603a, #4a2814 58%, #2c170a);
  box-shadow: inset 0 0 0 1.6cqi var(--gold), inset 0 0 0 2.6cqi #2c170a;
}
.unit-art {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 10cqi 10cqi / 36% 36% 9cqi 9cqi;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .35);
}
.unit-name {
  position: absolute;
  left: 50%;
  bottom: 3cqi;
  z-index: 2;
  translate: -50% 0;
  max-width: 50cqi;
  padding: .6cqi 3.5cqi;
  overflow: hidden;
  border: 1px solid var(--gold-lo);
  border-radius: 2cqi;
  background: var(--tribe, var(--tribe-default));
  color: var(--gold-hi);
  font: 700 max(10px, 11cqi)/1.25 var(--font-display);
  white-space: nowrap;
}
.unit .gem { --gem: 32cqi; position: absolute; bottom: 0; z-index: 3; }
.unit .gem-attack { left: -3cqi; }
.unit .gem-health { right: -3cqi; }
.unit-tier {
  position: absolute;
  top: -3cqi;
  left: 50%;
  z-index: 3;
  translate: -50% 0;
  display: flex;
  gap: 2cqi;
  padding: 1.6cqi 3cqi;
  border: 1px solid var(--gold);
  border-radius: var(--r-pill);
  background: var(--lacquer-lo);
}
.unit-tier i { width: 4.5cqi; height: 4.5cqi; rotate: 45deg; background: var(--gold-hi); }
.unit-mark {
  position: absolute;
  left: 50%;
  bottom: 17cqi;
  z-index: 3;
  translate: -50% 0;
  display: grid;
  place-items: center;
  width: 19cqi;
  height: 19cqi;
  border-radius: 50%;
  background: #2b1d3a;
  color: #cdb0ff;
  box-shadow: 0 0 0 1px var(--gold-lo);
}
.unit-mark .icon { width: 70%; height: 70%; }
.unit-aura { position: absolute; inset: -6cqi -2cqi 3cqi; z-index: 4; border-radius: 50%; pointer-events: none; }
.unit.is-guard .unit-frame,
.unit.is-guard .unit-art { border-radius: 0; clip-path: polygon(50% 0, 96% 9%, 100% 50%, 85% 80%, 50% 100%, 15% 80%, 0 50%, 4% 9%); }
.unit.is-guard .unit-frame { padding: 8cqi 9cqi 13cqi; background: linear-gradient(160deg, #e1e6e8, #7d8a90 48%, #3b454a); box-shadow: none; }
.unit.has-shield .unit-aura {
  background:
    radial-gradient(circle at 32% 24%, rgb(255 255 255 / .8) 0 5%, transparent 16%),
    radial-gradient(closest-side, transparent 70%, rgb(200 240 255 / .25) 84%, rgb(255 236 250 / .8) 100%);
  box-shadow: 0 0 14px 2px rgb(220 240 255 / .55);
}
.unit.has-reborn::before { inset: 0 3cqi 7cqi; border-radius: 50% 50% 14cqi 14cqi / 38% 38% 12cqi 12cqi; box-shadow: 0 0 0 1.5px rgb(170 235 255 / .9), 0 0 18px 7px rgb(110 200 255 / .7); }
.unit.has-reborn .unit-art { filter: saturate(.75) hue-rotate(-12deg); }
.unit.is-golden .unit-frame { background: linear-gradient(135deg, #fff1b8, #e3a92f 34%, #fff4c4 50%, #b8781a 70%, #ffe39a); box-shadow: inset 0 0 0 1.6cqi #fff6d0, inset 0 0 0 2.6cqi #7a4c0a; }
.unit.is-golden .unit-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(110deg, transparent 35%, rgb(255 255 240 / .55) 47%, transparent 58%) 0 0 / 260% 100%;
  animation: sheen 3.2s linear infinite;
  pointer-events: none;
}
.unit.is-ready { --unit-glow: var(--glow-ready); }
.unit.is-selected { --unit-glow: drop-shadow(0 0 3px #fff3c0) drop-shadow(0 0 14px rgb(255 215 94)); translate: 0 -7%; }
.unit.is-target { --unit-glow: var(--glow-hostile); cursor: crosshair; }
.unit.is-ready:hover, .unit.is-target:hover { translate: 0 -4%; }
@container (max-width: 64px) { .unit-name { display: none; } }

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

.hero { --hero-size: clamp(60px, 9.4vh, 96px); position: relative; display: grid; justify-items: center; }
.hero-portrait {
  position: relative;
  display: block;
  width: var(--hero-size);
  aspect-ratio: 1;
  padding: 6%;
  border: 0;
  border-radius: 50%;
  background: conic-gradient(from 20deg, var(--gold-hi), var(--gold-lo), var(--gold), var(--gold-lo), var(--gold-hi), var(--gold-lo), var(--gold-hi));
  box-shadow: 0 0 0 3px var(--lacquer-lo), 0 10px 20px rgb(0 0 0 / .55);
  container-type: inline-size;
  transition: box-shadow var(--dur-base);
}
button.hero-portrait { cursor: pointer; }
.hero-portrait::after { content: ""; position: absolute; inset: 3.5%; border: 1.5px dashed rgb(90 30 10 / .55); border-radius: 50%; pointer-events: none; }
.hero-emblem {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #e24b3d, var(--lacquer) 50%, var(--lacquer-lo));
  box-shadow: inset 0 0 0 2cqi rgb(255 226 160 / .35);
  font: 900 50cqi/1 var(--font-display);
  color: var(--gold-hi);
  text-shadow: 0 2px 0 var(--lacquer-lo), 0 0 14px rgb(255 200 100 / .4);
}
.hero-art { width: 100%; height: 100%; border-radius: 50%; }
.hero .gem-health { --gem: 48cqi; position: absolute; right: -26cqi; bottom: 2cqi; z-index: 3; }
.hero .gem-armor { --gem: 34cqi; position: absolute; left: -14cqi; bottom: 6cqi; z-index: 3; }
.hero-name {
  position: relative;
  z-index: 1;
  margin-top: -8px;
  padding: 2px 12px;
  border: 1px solid var(--gold-lo);
  border-radius: 5px;
  background: linear-gradient(var(--lacquer), var(--lacquer-lo));
  color: var(--gold-hi);
  font: 700 13px/1.4 var(--font-display);
  white-space: nowrap;
}
.hero.is-target .hero-portrait { box-shadow: 0 0 0 3px var(--glow-target), 0 0 24px 7px rgb(255 70 50 / .7); cursor: crosshair; }
.hero-power {
  position: absolute;
  left: calc(100% + 18px);
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  padding: 10px 4px 4px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #4b927a, #1d4d3c 60%, #0f2c22);
  box-shadow: 0 0 0 3px var(--wood-lo), 0 8px 14px rgb(0 0 0 / .5);
  font: 800 13px/1.15 var(--font-display);
  color: var(--gold-hi);
  cursor: pointer;
}
.hero-power .gem { --gem: 26px; position: absolute; top: -12px; left: 50%; translate: -50% 0; }
.hero-power.is-ready { border-color: var(--glow-play); box-shadow: 0 0 14px 3px rgb(255 205 70 / .65); }
.hero-power[aria-disabled="true"] { filter: saturate(.3) brightness(.7); cursor: not-allowed; }

/* ---------- banner ---------- */

.banner {
  position: fixed;
  left: 50%;
  top: 46%;
  z-index: var(--z-banner);
  translate: -50% -50%;
  opacity: 0;
  scale: .7 1;
  pointer-events: none;
  transition: opacity var(--dur-base), scale var(--dur-slow) var(--ease-out);
}
.banner.is-on { opacity: 1; scale: 1 1; }
.banner-text {
  display: block;
  padding: 14px 64px 16px;
  border-block: 3px solid var(--gold);
  background: linear-gradient(var(--lacquer-hi), var(--lacquer) 58%, var(--lacquer-lo));
  clip-path: polygon(0 0, 100% 0, 95% 50%, 100% 100%, 0 100%, 5% 50%);
  font: 900 clamp(28px, 6vw, 52px)/1.1 var(--font-display);
  letter-spacing: .22em;
  color: var(--gold-hi);
  white-space: nowrap;
  text-shadow: 0 3px 0 var(--lacquer-lo), 0 0 20px rgb(255 200 100 / .45);
  filter: drop-shadow(0 12px 18px rgb(0 0 0 / .6));
}

/* ---------- home ---------- */

.screen--home { overflow: hidden; }
.screen--home > .lanterns { height: 120px; }
.home { position: relative; z-index: 1; display: grid; justify-items: center; gap: 26px; width: min(1080px, 100% - 32px); margin: 0 auto; padding: 104px 0 48px; }
.home-title { display: grid; justify-items: center; gap: 18px; text-align: center; }
.plaque {
  position: relative;
  padding: 16px 40px 18px 50px;
  border: 3px solid var(--gold);
  border-radius: 10px;
  background: linear-gradient(#c3342a, #a3241c 55%, #7c1812);
  box-shadow: 0 0 0 6px #5a110c, 0 0 0 8px var(--gold-lo), 0 22px 44px rgb(0 0 0 / .6), inset 0 2px 0 rgb(255 220 170 / .35);
  outline: 1px solid rgb(255 226 160 / .45);
  outline-offset: -10px;
  font: 900 clamp(46px, 9vw, 92px)/1.05 var(--font-display);
  letter-spacing: .16em;
}
.plaque span { background: linear-gradient(#fff5cc, var(--gold) 55%, #b07a2a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #4a0d09); }
.home-tagline { font: 700 clamp(16px, 2.2vw, 20px)/1.5 var(--font-display); color: var(--gold-hi); letter-spacing: .08em; }
.cast { display: flex; padding: 0 0 0 12px; list-style: none; }
.medallion {
  width: clamp(52px, 8vw, 78px);
  aspect-ratio: 1;
  margin-left: -12px;
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(var(--gold-hi), var(--gold-lo), var(--gold), var(--gold-lo), var(--gold-hi));
  box-shadow: 0 0 0 2px var(--lacquer-lo), 0 8px 16px rgb(0 0 0 / .55);
}
.medallion:nth-child(even) { translate: 0 10px; }
.medallion-art { width: 100%; height: 100%; border-radius: 50%; }
.modes { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 18px; width: 100%; }
.mode {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 10px;
  border: 0;
  border-radius: var(--r-lg);
  background: repeating-linear-gradient(97deg, rgb(255 255 255 / .035) 0 2px, transparent 2px 10px), linear-gradient(160deg, var(--wood-hi), var(--wood) 42%, var(--wood-lo));
  box-shadow: 0 18px 36px rgb(0 0 0 / .5), inset 0 2px 0 rgb(255 220 170 / .22), inset 0 -3px 0 rgb(0 0 0 / .4);
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  transition: translate var(--dur-fast) var(--ease-out), box-shadow var(--dur-base);
}
.mode:hover { translate: 0 -4px; }
.mode--duel { box-shadow: 0 0 0 2px var(--gold), 0 0 34px 4px rgb(255 190 70 / .35), 0 18px 36px rgb(0 0 0 / .5), inset 0 2px 0 rgb(255 220 170 / .22); }
.mode-art {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 168px;
  overflow: hidden;
  border-radius: var(--r-md);
  background: radial-gradient(ellipse at 50% 40%, rgb(255 255 255 / .08), transparent 65%), linear-gradient(var(--felt), var(--felt-lo));
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / .3), inset 0 0 40px rgb(0 0 0 / .45);
}
.mode-art--fan { padding-bottom: 16px; }
.fan-card { width: 84px; aspect-ratio: 143 / 170; margin: 0 -10px; border: 3px solid var(--paper); border-radius: 9px; box-shadow: 0 0 0 1px var(--gold-lo), 0 10px 16px rgb(0 0 0 / .5); }
.fan-card:nth-child(1) { rotate: -11deg; translate: 0 8px; }
.fan-card:nth-child(2) { z-index: 1; translate: 0 -6px; }
.fan-card:nth-child(3) { rotate: 11deg; translate: 0 8px; }
.mode-art--stall { gap: 6px; padding-bottom: 16px; background: radial-gradient(ellipse at 50% 30%, rgb(255 140 60 / .25), transparent 70%), linear-gradient(#20364a, #12212f); }
.mode-art--stall .lanterns { top: 26px; }
.mode-art--stall .lanterns > span { width: 18px; }
.stall-awning { position: absolute; inset: 0 0 auto; height: 30px; background: radial-gradient(circle at 50% 0, transparent 0 9px, #12212f 10px) 0 100% / 20px 10px repeat-x, repeating-linear-gradient(90deg, #c8281e 0 20px, var(--paper) 20px 40px); background-clip: border-box; }
.mode-art--stall .medallion-art { width: 62px; height: 62px; border: 3px solid var(--gold); box-shadow: 0 8px 14px rgb(0 0 0 / .5); }
.map-art { position: absolute; inset: 0; background-color: #d9ecf2; }
.mode-copy { display: grid; align-content: start; gap: 6px; padding: 14px 8px 8px; }
.mode-copy strong { font: 900 24px/1.25 var(--font-display); color: var(--gold-hi); letter-spacing: .06em; }
.mode-copy span { font-size: 14px; line-height: 1.6; color: #eadfc5; }
.mode-cta {
  justify-self: start;
  margin: 4px 8px 6px;
  padding: 8px 26px;
  border: 2px solid var(--gold);
  border-radius: 10px;
  background: linear-gradient(var(--lacquer-hi), var(--lacquer) 55%, var(--lacquer-lo));
  font: 900 18px/1.3 var(--font-display);
  letter-spacing: .2em;
  color: var(--gold-hi);
}
.home-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ---------- deck builder ---------- */

.deck-page { width: min(1120px, 100% - 32px); margin: 0 auto; padding: 8px 0 24px; }
.deck-heading { display: grid; gap: 6px; margin-bottom: 22px; }
.deck-heading h1 { font: 900 clamp(28px, 4vw, 40px)/1.2 var(--font-display); color: var(--gold-hi); letter-spacing: .06em; }
.deck-heading p { color: #dcd2b9; font-size: 15px; line-height: 1.6; }
.collection { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 18px; justify-items: center; padding: 6px; }
.collection .card { width: min(100%, 186px); }
.collection .card:hover .card-face { translate: 0 -3px; }
.deck-bar { position: sticky; bottom: 0; z-index: var(--z-top); padding: 22px 0 12px; background: linear-gradient(transparent, rgb(7 19 15 / .94) 34%); }
.deck-bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  width: min(1120px, 100% - 24px);
  margin: 0 auto;
  padding: 10px 12px;
  border: 1px solid rgb(233 185 91 / .35);
  border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--wood), var(--wood-lo));
  box-shadow: 0 12px 30px rgb(0 0 0 / .5);
}
.deck-count { display: grid; gap: 4px; min-width: 92px; }
.deck-count strong { font: 800 22px/1 var(--font-num); color: var(--gold-hi); }
.deck-count small { font-size: 14px; color: var(--muted); }
.deck-meter { display: block; height: 6px; border-radius: var(--r-pill); background: rgb(0 0 0 / .4); overflow: hidden; }
.deck-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); }
.deck-notice { flex: 1; min-width: 120px; font-size: 14px; color: #eadfc5; }
.deck-notice:empty { visibility: hidden; }

/* ---------- duel ---------- */

.duel-view { --card-max: clamp(112px, 9.4vw, 136px); --duel-hero: clamp(56px, 8.2vh, 80px); padding-bottom: 8px; }
.tip, .dock, .table { width: min(1120px, 100% - 24px); margin-inline: auto; }
.tip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 2px 2px 2px 12px;
  border: 1px solid rgb(233 185 91 / .25);
  border-radius: 12px;
  background: rgb(0 0 0 / .3);
}
.tip p { display: flex; flex: 1; gap: 8px; align-items: center; font-size: 13px; line-height: 1.45; color: #e3d9c0; }
.tip-close { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.guide { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 12px; min-width: 0; font-size: 14px; line-height: 1.45; text-align: center; }
.guide strong { color: var(--gold-hi); }
.guide-message { color: #d4cbb4; }
.guide .chip-button { min-height: 36px; }

.table {
  --unit-w: min(104px, 10vh, 19.5vw);
  position: relative;
  padding: clamp(8px, 1.2vw, 14px);
  border-radius: clamp(22px, 3vw, 36px);
  background: repeating-linear-gradient(96deg, rgb(255 255 255 / .035) 0 2px, transparent 2px 11px), linear-gradient(160deg, var(--wood-hi), var(--wood) 40%, var(--wood-lo));
  box-shadow: 0 30px 60px rgb(0 0 0 / .55), inset 0 2px 0 rgb(255 220 170 / .25), inset 0 -3px 0 rgb(0 0 0 / .45);
}
.felt {
  position: relative;
  display: grid;
  gap: clamp(2px, .8vh, 8px);
  padding: clamp(8px, 1.2vh, 12px) clamp(8px, 2vw, 24px);
  border-radius: clamp(14px, 2vw, 24px);
  background:
    radial-gradient(ellipse at 50% 50%, rgb(255 255 255 / .07), transparent 62%),
    repeating-radial-gradient(circle at 30% 40%, rgb(0 0 0 / .03) 0 1px, transparent 1px 3px),
    linear-gradient(var(--felt), var(--felt-lo));
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / .3), inset 0 0 70px rgb(0 0 0 / .45);
}
.felt::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(44%, 400px);
  aspect-ratio: 1;
  translate: -50% -50%;
  border: 1px solid rgb(233 185 91 / .14);
  border-radius: 50%;
  box-shadow: 0 0 0 12px rgb(233 185 91 / .035), inset 0 0 0 12px rgb(233 185 91 / .035);
  pointer-events: none;
}
.side-row { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.side-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.side-info b { font: 700 16px/1 var(--font-num); color: var(--cream); }
.side-info--end { justify-content: flex-end; }
.side-row--player .side-info--end { justify-content: flex-start; }
.side-info .is-warn, .side-info .is-warn b { color: #ffad9d; }
.card-backs { display: flex; padding-left: 9px; }
.card-backs i { width: 17px; height: 24px; margin-left: -9px; border: 1.5px solid var(--gold); border-radius: 3px; background: repeating-linear-gradient(45deg, #9b1f17 0 3px, #b3261e 3px 6px); box-shadow: 0 2px 3px rgb(0 0 0 / .45); }
.board { display: flex; justify-content: center; align-items: center; gap: clamp(6px, 1.4vw, 16px); min-height: calc(var(--unit-w) * 1.25 + 4px); }
.slot { position: relative; flex: none; width: var(--unit-w); aspect-ratio: .8; }
.slot--empty { border: 1.5px dashed rgb(233 185 91 / .22); border-radius: 50% 50% 14px 14px / 38% 38% 12px 12px; background: rgb(0 0 0 / .1); }
.slot .peek { top: -2px; right: -2px; width: 24px; height: 24px; opacity: .85; }
/* A 40px round tap area around the button, so on a narrow unit the centre still belongs to the unit (select / attack). */
.slot .peek::after { inset: calc(50% - 20px); border-radius: 50%; }
.midline { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; min-height: 44px; }
.midline-rule { height: 2px; background: linear-gradient(90deg, transparent, rgb(233 185 91 / .55), transparent); }
.midline-info { display: none; }
.round-tile {
  display: grid;
  place-items: center;
  align-content: center;
  width: 36px;
  height: 44px;
  border-radius: 7px;
  background: linear-gradient(170deg, #fffdf6, #eadcbb);
  box-shadow: 0 5px 0 #1d7a5a, 0 6px 0 #0d3d2c, 0 10px 14px rgb(0 0 0 / .45);
  color: #17573f;
}
.round-tile b { font: 800 20px/1 var(--font-num); color: #18684b; }
.round-tile small { font: 700 9px/1.3 var(--font-body); letter-spacing: .1em; color: var(--lacquer); }

/* hero plate: temple medallion, health seal, name plaque */
.table .hero { --hero-size: var(--duel-hero); display: flex; align-items: center; }
.table .hero-portrait {
  z-index: 2;
  padding: calc(var(--hero-size) * .08);
  background:
    radial-gradient(circle at 34% 26%, rgb(255 246 214 / .6), transparent 52%),
    repeating-conic-gradient(from 22.5deg, #6e4512 0 2.5deg, var(--gold) 2.5deg 22.5deg, #c48a2c 22.5deg 45deg);
  box-shadow: 0 0 0 2px #3b1206, 0 0 0 4px var(--gold-lo), 0 8px 16px rgb(0 0 0 / .55);
}
.table .hero-portrait::after { inset: 7%; border-color: rgb(60 20 5 / .6); }
.table .hero-emblem {
  box-shadow: inset 0 0 0 2cqi var(--gold-hi), inset 0 0 0 3.6cqi var(--lacquer-lo), inset 0 0 0 4.6cqi rgb(255 226 160 / .45), inset 0 -7cqi 12cqi rgb(0 0 0 / .35);
  font-size: 46cqi;
}
.table .hero--enemy .hero-emblem {
  background: radial-gradient(circle at 38% 30%, #6a76bd, #343b7a 52%, #171a3d);
  color: #f6e7c1;
  text-shadow: 0 2px 0 #0b0d22, 0 0 14px rgb(160 180 255 / .45);
}
.table .hero .gem-health { --gem: 54cqi; right: -30cqi; bottom: -8cqi; }
.table .hero-name {
  margin: 0 0 0 calc(var(--hero-size) * -.22);
  padding: 7px 18px 7px calc(var(--hero-size) * .5 + 6px);
  border: 0;
  border-radius: 3px;
  background: linear-gradient(#64190f, #2e0906);
  box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 0 4px #2e0906, inset 0 0 0 5px rgb(233 185 91 / .5), 0 6px 12px rgb(0 0 0 / .45);
  font: 900 clamp(14px, 2.1vh, 18px)/1.2 var(--font-display);
  letter-spacing: .18em;
  color: var(--gold-hi);
  text-shadow: 0 1px 0 #000, 0 0 10px rgb(255 200 100 / .35);
}
.table .hero-name::before {
  content: "";
  position: absolute;
  inset: -4px 6px auto calc(var(--hero-size) * .3);
  height: 8px;
  background: linear-gradient(var(--lacquer-hi), var(--lacquer-hi)) 0 0 / 100% 2px no-repeat, radial-gradient(circle at 50% 0, var(--lacquer-hi) 0 4px, transparent 4.5px) 0 0 / 12px 8px repeat-x;
}
.table .hero--enemy .hero-name { background: linear-gradient(#2d3368, #121533); }
.table .hero.is-target .hero-name { box-shadow: inset 0 0 0 2px var(--glow-target), inset 0 0 0 4px #2e0906, 0 0 18px 3px rgb(255 70 50 / .55); }

/* hero power: a wooden command tablet (令牌) hanging from the plaque by two red cords, brass coin for the cost */
.table .hero { display: grid; grid-template-columns: auto auto auto; justify-content: start; align-items: center; }
.table .hero-portrait { grid-area: 1 / 1; }
.table .hero-name { grid-area: 1 / 2; min-width: calc(var(--hero-size) * 1.5); text-align: center; }
.table .hero-art { box-shadow: inset 0 0 0 2cqi rgb(60 20 5 / .55); }
.power-tablet {
  --tablet-w: clamp(204px, 15.5vw, 224px);
  position: relative;
  grid-area: 1 / 3;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "coin name stamp" "coin rule rule";
  align-items: center;
  column-gap: 7px;
  width: var(--tablet-w);
  margin-left: 14px;
  padding: 6px 9px 6px 6px;
  border: 0;
  border-radius: 3px 3px 10px 10px;
  background: repeating-linear-gradient(92deg, rgb(255 255 255 / .06) 0 2px, transparent 2px 8px), linear-gradient(#a06838, #62391b 58%, #3d2210);
  box-shadow: inset 0 0 0 1.5px var(--gold-lo), inset 0 0 0 3px #2b1408, 0 7px 12px rgb(0 0 0 / .5);
  color: var(--cream);
  font: inherit;
  text-align: left;
  transform-origin: 0 50%;
  rotate: 1.2deg;
  transition: box-shadow var(--dur-base), filter var(--dur-base), translate var(--dur-base);
}
button.power-tablet { cursor: pointer; }
.power-tablet::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 28%;
  width: 16px;
  height: 44%;
  background: linear-gradient(#d8473a, #d8473a) 0 0 / 100% 2px no-repeat, linear-gradient(#d8473a, #d8473a) 0 100% / 100% 2px no-repeat, radial-gradient(circle at 100% 50%, var(--gold) 0 3px, transparent 3.5px);
  pointer-events: none;
}
.power-coin {
  grid-area: coin;
  display: grid;
  place-items: center;
  width: 30px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff4c8, #e9b95b 38%, #b47c27 70%, #714514);
  box-shadow: inset 0 0 0 1.5px #6e4512, inset 0 0 0 3.5px rgb(255 236 180 / .4), 0 1px 3px rgb(0 0 0 / .6);
}
.power-coin b { font: 800 16px/1 var(--font-num); color: #3a1d06; text-shadow: 0 1px 0 rgb(255 240 190 / .6); }
.power-name { grid-area: name; font: 900 15px/1.2 var(--font-display); letter-spacing: .06em; color: var(--gold-hi); text-shadow: 0 1px 0 #000; }
.power-rule { grid-area: rule; font: 500 12px/1.3 var(--font-body); color: #f1e4c8; text-wrap: pretty; }
/* The 已用 seal is a grid item on the name row, so it can never sit on top of the name or the rule. */
.power-stamp {
  grid-area: stamp;
  rotate: -4deg;
  padding: 0 6px;
  border: 2px solid #e0473b;
  border-radius: 4px;
  background: rgb(255 248 230 / .95);
  color: #c8281e;
  font: 900 12px/1.3 var(--font-display);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgb(0 0 0 / .45);
}
.power-tablet.is-ready { box-shadow: inset 0 0 0 1.5px var(--glow-play), inset 0 0 0 3px #2b1408, 0 0 0 2px rgb(255 215 94 / .75), 0 0 18px 4px rgb(255 205 70 / .55); }
button.power-tablet.is-ready:hover, button.power-tablet.is-ready:focus-visible { translate: 0 -2px; box-shadow: inset 0 0 0 1.5px var(--glow-play), inset 0 0 0 3px #2b1408, 0 0 0 3px rgb(255 215 94 / .95), 0 0 24px 6px rgb(255 205 70 / .7); }
.power-tablet.is-dim { filter: saturate(.45) brightness(.72); cursor: not-allowed; }
.power-tablet.is-used { filter: saturate(.55) brightness(.88); cursor: not-allowed; }
.power-tablet.is-used .power-coin { filter: grayscale(.8) brightness(.85); }
.power-tablet--enemy { background: repeating-linear-gradient(92deg, rgb(255 255 255 / .05) 0 2px, transparent 2px 8px), linear-gradient(#5b6296, #2d3368 58%, #171a3d); }

/* hero pick */
.pick-page { display: grid; justify-items: center; gap: 20px; width: min(1040px, 100% - 24px); margin: 0 auto; padding: clamp(14px, 3vh, 34px) 0 28px; }
@media (min-width: 821px) {
  .pick-page { align-content: center; min-height: calc(100dvh - 76px); gap: clamp(20px, 4vh, 40px); padding-block: 0 24px; }
  .pick-list { align-items: stretch; }
  .pick-portrait { width: min(180px, 64%); }
}
.pick-head { display: grid; justify-items: center; gap: 6px; text-align: center; }
.pick-head h1 { font: 900 clamp(28px, 4.6vw, 42px)/1.2 var(--font-display); letter-spacing: .12em; color: var(--gold-hi); text-shadow: 0 3px 0 var(--lacquer-lo), 0 0 24px rgb(255 150 60 / .45); }
.pick-head p { max-width: 34em; font-size: 15px; line-height: 1.6; color: #eadfc5; }
.pick-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; width: 100%; margin: 0; padding: 0; list-style: none; }
.pick-head p { text-wrap: balance; }
.pick-clause { display: inline-block; }
.pick-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr auto;
  justify-items: center;
  align-content: stretch;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 16px 14px 14px;
  border: 0;
  border-radius: 8px 8px 22px 22px;
  background: repeating-linear-gradient(92deg, rgb(255 255 255 / .05) 0 2px, transparent 2px 9px), linear-gradient(#8a5530, #5a3119 45%, #2e170b);
  box-shadow: 0 0 0 2px var(--gold-lo), inset 0 0 0 5px #2b1408, inset 0 0 0 6.5px rgb(233 185 91 / .4), 0 18px 34px rgb(0 0 0 / .5);
  color: var(--cream);
  text-align: center;
  cursor: pointer;
  transition: translate var(--dur-base) var(--ease-out), box-shadow var(--dur-base);
}
.pick-card:hover, .pick-card:focus-visible { translate: 0 -6px; box-shadow: 0 0 0 3px var(--gold-hi), inset 0 0 0 5px #2b1408, inset 0 0 0 6.5px rgb(233 185 91 / .4), 0 0 34px 6px rgb(255 190 70 / .4), 0 24px 40px rgb(0 0 0 / .55); }
.pick-portrait { width: min(150px, 60%); padding: 4px; border-radius: 10px; background: linear-gradient(var(--gold-hi), var(--gold-lo)); box-shadow: 0 5px 12px rgb(0 0 0 / .5); }
.pick-art { display: block; width: 100%; aspect-ratio: 143 / 170; border-radius: 7px; }
.pick-who { display: grid; justify-items: center; gap: 1px; }
.pick-name { padding: 2px 18px; border: 2px solid var(--gold); border-radius: 6px; background: linear-gradient(var(--lacquer), var(--lacquer-lo)); color: var(--gold-hi); font: 900 22px/1.3 var(--font-display); letter-spacing: .14em; }
.pick-job { margin-top: 3px; font: 700 14px/1.4 var(--font-display); color: var(--gold-hi); }
.pick-power { display: grid; align-content: start; gap: 4px; width: 100%; padding: 9px 11px 10px; border-radius: 4px 4px 12px 12px; background: linear-gradient(var(--paper), var(--paper-lo)); box-shadow: inset 0 0 0 1.5px rgb(162 115 47 / .6); color: var(--ink); text-align: left; }
.pick-power-head { display: flex; align-items: center; gap: 8px; }
.pick-power-head .gem { --gem: 28px; flex: none; }
.pick-power-head strong { flex: 1; font: 900 16px/1.3 var(--font-display); color: var(--lacquer-lo); }
.pick-power-head small { padding: 1px 7px; border-radius: 6px; background: rgb(141 20 14 / .14); color: #8d140e; font: 800 11px/1.5 var(--font-body); white-space: nowrap; }
.pick-rule { font-size: 14px; line-height: 1.5; color: var(--ink); }
.pick-flavor { font: italic 500 13px/1.5 var(--font-body); color: var(--ink-soft); }
.pick-cta { padding: 8px 24px; border-radius: 10px; background: linear-gradient(#ffe7a8, var(--gold) 52%, #c98f33); color: #3a1a06; font: 800 15px/1 var(--font-display); letter-spacing: .1em; box-shadow: 0 3px 0 #85561b; }

/* 本錢 purse: cash coins on a red cord */
.purse { display: flex; align-items: center; gap: 8px; }
.purse-label {
  padding: 5px 3px;
  border: 1px solid var(--gold);
  border-radius: 3px;
  background: linear-gradient(var(--lacquer-hi), var(--lacquer-lo));
  color: var(--gold-hi);
  font: 800 12px/1 var(--font-display);
  letter-spacing: .12em;
  writing-mode: vertical-rl;
}
.purse-string { --coin: 26px; position: relative; display: flex; align-items: center; padding: 0 12px 0 4px; }
.purse-string::before { content: ""; position: absolute; left: 0; right: 4px; top: 50%; height: 2px; translate: 0 -50%; border-radius: 2px; background: linear-gradient(90deg, #8d140e, #d8473a 50%, #8d140e); }
.purse-string::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 9px;
  height: 19px;
  translate: 0 -4px;
  background:
    radial-gradient(circle at 50% 4px, var(--gold) 0 3px, transparent 3.5px),
    linear-gradient(90deg, transparent 1px, #e0392c 1px 2px, #9b1f17 2px 3px, #e0392c 3px 4px, #9b1f17 4px 5px, #e0392c 5px 6px, #9b1f17 6px 7px, #e0392c 7px 8px, transparent 8px) 0 7px / 100% 12px no-repeat;
}
.coin {
  position: relative;
  flex: none;
  width: var(--coin);
  aspect-ratio: 1;
  margin-left: calc(var(--coin) * -.14);
  border-radius: 50%;
  background:
    linear-gradient(#c8281e, #c8281e) center / 30% 10% no-repeat,
    linear-gradient(#3a1d06, #3a1d06) center / 30% 30% no-repeat,
    linear-gradient(#9a6a1f, #9a6a1f) center / 44% 44% no-repeat,
    radial-gradient(circle at 34% 28%, #fff4c8, #e9b95b 36%, #b47c27 68%, #714514);
  box-shadow: inset 0 0 0 1.5px #6e4512, inset 0 0 0 3px rgb(255 236 180 / .4), 0 1px 3px rgb(0 0 0 / .55), 0 0 7px rgb(255 205 70 / .5);
}
.coin:first-child { margin-left: 0; }
.coin { transition: filter var(--dur-fast); }
.coin.is-spent { filter: saturate(.15) brightness(.48); box-shadow: inset 0 0 0 1.5px #6e4512, 0 1px 3px rgb(0 0 0 / .55); }
.purse-count { font: 800 20px/1 var(--font-num); color: var(--gold-hi); white-space: nowrap; }
.purse-count small { margin-left: 1px; font-size: 13px; color: var(--muted); }

/* dock: battle log, hand, gong */
.dock {
  position: relative;
  z-index: var(--z-hand);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "log hand gong";
  align-items: end;
  margin-top: -16px;
}
.hand { grid-area: hand; }
/* Cards shrink (then overlap) only when the whole hand cannot fit between the log and the gong. */
.hand-cards {
  --room: calc(min(1120px, 100vw - 24px) - 256px);
  --card-w: clamp(96px, var(--room) / var(--count) - 6px, var(--card-max));
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: calc(var(--card-max) * 1.44 + 22px);
  padding: 8px 0 14px;
}
.hand .card {
  margin-inline: min(3px, (var(--room) - var(--count) * var(--card-w)) / (2 * var(--count)));
  transform-origin: 50% 130%;
  rotate: calc(var(--fan, 0) * 2deg);
  translate: 0 calc(var(--arc, 0) * 1.2px);
  transition: translate var(--dur-fast) var(--ease-out), rotate var(--dur-fast) var(--ease-out), scale var(--dur-fast) var(--ease-out);
}
.hand .card .gem-attack { left: -2cqi; }
.hand .card .gem-health { right: -2cqi; }
.hand .card:hover, .hand .card:focus-within { z-index: var(--z-lift); rotate: 0deg; translate: 0 -22px; scale: 1.1; }
.hand-empty { align-self: center; padding: 30px 0; color: var(--muted); font-size: 14px; }
/* A hand that scrolls fades at whichever edge hides cards; the scroll timeline is inactive when everything fits, so nothing fades then. */
@property --fade-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-end { syntax: "<length>"; inherits: false; initial-value: 0px; }
@keyframes hand-edges { from { --fade-start: 0px; --fade-end: 36px; } to { --fade-start: 36px; --fade-end: 0px; } }
@keyframes hand-hint { from { opacity: 1; } 40%, to { opacity: 0; } }

.gong {
  --gong: clamp(62px, 9vh, 82px);
  grid-area: gong;
  justify-self: start;
  align-self: center;
  position: relative;
  display: grid;
  justify-items: center;
  margin-left: clamp(10px, 2vw, 28px);
  padding: 14px 0 0;
  border: 0;
  background: none;
  color: var(--gold-hi);
  cursor: pointer;
}
.gong::before { content: ""; position: absolute; top: 0; left: 50%; width: calc(var(--gong) * .78); height: 6px; translate: -50% 0; border-radius: 3px; background: linear-gradient(var(--wood-hi), var(--wood-lo)); box-shadow: 0 2px 3px rgb(0 0 0 / .5); }
.gong::after { content: ""; position: absolute; top: 4px; left: 50%; width: 22px; height: 16px; translate: -50% 0; border: 2px solid var(--lacquer-hi); border-bottom: 0; border-radius: 11px 11px 0 0; }
.gong-face {
  position: relative;
  z-index: 1;
  width: var(--gong);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, #ffe9ad 0 8%, #b07a24 9% 12%, transparent 13%),
    repeating-radial-gradient(circle, transparent 0 6.5%, rgb(90 50 10 / .28) 7% 7.6%),
    radial-gradient(circle at 36% 30%, #fff1c2, var(--gold) 30%, #b17a26 62%, #6e4512 92%);
  box-shadow: inset 0 0 0 3px #7a4d12, inset 0 0 0 5px rgb(255 230 160 / .45), inset 0 -6px 12px rgb(60 30 5 / .5), 0 8px 16px rgb(0 0 0 / .55);
  transform-origin: 50% -18%;
  transition: rotate var(--dur-fast) var(--ease-out), scale var(--dur-fast) var(--ease-out), filter var(--dur-base);
}
.gong-label {
  position: relative;
  z-index: 2;
  margin-top: -14px;
  padding: 3px 10px 4px;
  border: 1.5px solid var(--gold);
  border-radius: 6px;
  background: linear-gradient(var(--lacquer-hi), var(--lacquer) 55%, var(--lacquer-lo));
  box-shadow: 0 3px 0 #4a0d09, 0 6px 12px rgb(0 0 0 / .45);
  font: 900 15px/1.2 var(--font-display);
  letter-spacing: .1em;
  white-space: nowrap;
}
.gong:not(:disabled):hover .gong-face { rotate: -5deg; scale: 1.04; }
.gong:not(:disabled):active .gong-face { scale: .95; }
.gong.is-suggested .gong-face { box-shadow: inset 0 0 0 3px #7a4d12, inset 0 0 0 5px rgb(255 230 160 / .45), 0 0 0 3px var(--glow-play), 0 0 26px 8px rgb(255 205 70 / .6); animation: gong-sway 1.8s ease-in-out infinite; }
.gong:disabled { cursor: default; }
.gong:disabled .gong-face { filter: saturate(.2) brightness(.55); }
.gong:disabled .gong-label { border-color: #6d7a72; background: linear-gradient(#4b5a53, #2f3b36); color: #b7c3bc; box-shadow: 0 3px 0 #1c2521, 0 6px 12px rgb(0 0 0 / .4); }
@keyframes gong-sway { 0%, 100% { rotate: -3deg; } 50% { rotate: 3deg; } }

.duel-log { grid-area: log; position: relative; z-index: calc(var(--z-lift) + 1); justify-self: start; max-width: 100%; margin-bottom: 14px; border: 1px solid rgb(233 185 91 / .2); border-radius: 12px; background: rgb(0 0 0 / .35); }
.duel-log summary { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; color: var(--gold-hi); font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.duel-log summary span { flex: 1; min-width: 0; max-width: 220px; overflow: hidden; color: #cfc6b0; font-weight: 400; text-overflow: ellipsis; }
.duel-log ol { position: absolute; left: 0; bottom: calc(100% + 6px); width: min(380px, 80vw); max-height: min(48vh, 360px); overflow: auto; padding: 12px 16px 12px 36px; border: 1px solid rgb(233 185 91 / .3); border-radius: 12px; background: rgb(10 22 17 / .96); box-shadow: 0 16px 30px rgb(0 0 0 / .55); font-size: 13px; line-height: 1.75; color: #ddd3bb; }

.card.is-invalid .card-main, .unit.is-invalid, .hero.is-invalid .hero-portrait, .power-tablet.is-invalid { animation: shake var(--dur-shake) ease-in-out; }
/* a tap that landed mid-animation glows until the board is idle and it runs */
.duel-view .is-held { animation: bg-held 520ms ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) {
  .duel-view .is-held { animation: none; filter: drop-shadow(0 0 4px #fff3c0) drop-shadow(0 0 16px rgb(255 205 70)); }
}

/* ---------- fx overlay ---------- */

.fx-top { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
#fx-layer { position: fixed; inset: 0; z-index: var(--z-fx); overflow: hidden; pointer-events: none; }
#fx-layer > *, .fx-top > * { position: absolute; translate: -50% -50%; pointer-events: none; transition: none; }
#fx-layer .fx-fly > * { width: 100%; margin: 0; rotate: none; translate: none; }
.fx-num {
  z-index: 2;
  font: 900 clamp(28px, 3.2vw, 42px)/1 var(--font-num);
  color: #ff5a43;
  white-space: nowrap;
  -webkit-text-stroke: 6px #3a0905;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 #3a0905, 0 0 16px rgb(255 80 40 / .7);
}
.fx-num--heal { color: #86ffbf; -webkit-text-stroke-color: #0b3d27; text-shadow: 0 3px 0 #0b3d27, 0 0 16px rgb(60 255 160 / .6); }
.fx-num--buff { font-size: clamp(18px, 2vw, 26px); color: var(--gold-hi); -webkit-text-stroke: 5px #5a3505; text-shadow: 0 2px 0 #5a3505, 0 0 14px rgb(255 205 70 / .7); }
.fx-burst { border-radius: 50%; mix-blend-mode: screen; background: radial-gradient(closest-side, #fffae1 0 16%, rgb(255 170 90 / .85) 34%, rgb(255 70 40 / .45) 60%, transparent); }
.fx-burst--hero { background: radial-gradient(closest-side, transparent 44%, rgb(255 60 35 / .75) 64%, transparent); }
.fx-glow { border-radius: 50%; mix-blend-mode: screen; background: radial-gradient(closest-side, rgb(255 230 150 / .95), rgb(255 190 60 / .55) 55%, transparent); }
.fx-glow--heal { background: radial-gradient(closest-side, rgb(180 255 215 / .9), rgb(47 174 140 / .5) 55%, transparent); }
.fx-ring { border-radius: 50%; opacity: 0; }
.fx-ring--dust { background: radial-gradient(closest-side, transparent 52%, rgb(255 226 160 / .8) 72%, transparent); }
.fx-ring--shield { border: 3px solid rgb(255 240 190 / .95); box-shadow: 0 0 16px 4px rgb(255 215 94 / .8), inset 0 0 16px rgb(255 215 94 / .7); }
.fx-shard { width: 12px; height: 16px; border-radius: 2px; background: var(--c); box-shadow: 0 1px 2px rgb(0 0 0 / .35); }
.fx-shard--lantern { width: 16px; height: 20px; border-block: 3px solid var(--gold); border-radius: 50%; background: var(--lacquer-hi); }
.fx-glyph {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--gold-hi);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--lacquer-hi), var(--lacquer-lo));
  color: var(--gold-hi);
  box-shadow: 0 0 16px 4px rgb(255 205 70 / .6);
}
.fx-glyph .icon { width: 22px; height: 22px; }
.fx-banner { scale: none; }
.fx-banner--enemy .banner-text {
  background: linear-gradient(#3d4479, #272c55 58%, #141733);
  color: #f6e7c1;
  text-shadow: 0 3px 0 #0b0d22, 0 0 20px rgb(150 170 255 / .45);
}

/* ---------- dialogs ---------- */

#game-dialog {
  width: min(640px, 100% - 24px);
  max-height: calc(100dvh - 32px);
  padding: 30px 26px 24px;
  border: 0;
  border-radius: 20px;
  background: radial-gradient(120% 60% at 50% 0%, #fffaf0, transparent 70%), linear-gradient(var(--paper), var(--paper-lo));
  box-shadow: 0 0 0 4px var(--gold-lo), 0 0 0 9px var(--lacquer), 0 30px 80px rgb(0 0 0 / .7);
  color: var(--ink);
  overflow: auto;
}
#game-dialog::backdrop { background: rgb(5 12 9 / .74); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: rgb(42 31 20 / .08); color: var(--ink); cursor: pointer; }
#game-dialog h2 { font: 900 clamp(24px, 4vw, 30px)/1.3 var(--font-display); color: var(--lacquer-lo); letter-spacing: .04em; }
#game-dialog .button--ghost { color: var(--ink); border-color: var(--gold-lo); }
.card-detail { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 24px; align-items: start; }
.detail-portrait { position: relative; padding: 6px; border-radius: 16px; background: linear-gradient(var(--gold-hi), var(--gold-lo)); box-shadow: 0 10px 20px rgb(0 0 0 / .25); }
.detail-art { width: 100%; aspect-ratio: 143 / 170; border-radius: 120px 120px 10px 10px / 90px 90px 10px 10px; }
.detail-region { position: absolute; left: 50%; bottom: -12px; translate: -50% 0; padding: 3px 16px; border: 2px solid var(--gold); border-radius: 6px; background: var(--lacquer); color: var(--gold-hi); font: 900 18px/1.3 var(--font-display); white-space: nowrap; }
.detail-copy { display: grid; gap: 10px; }
.detail-zone { font-size: 13px; font-weight: 700; color: var(--gold-lo); }
.detail-copy blockquote { padding-left: 12px; border-left: 3px solid var(--lacquer); font: 600 16px/1.6 var(--font-display); color: var(--ink-soft); }
.detail-stats { display: flex; flex-wrap: wrap; gap: 14px; }
.detail-stats span { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; }
.detail-stats .gem { --gem: 36px; }
.detail-keywords { font-weight: 800; color: var(--lacquer-lo); }
.detail-skill { font-size: 16px; line-height: 1.6; }
.detail-note { padding: 8px 12px; border-radius: 10px; background: rgb(162 115 47 / .14); font-size: 14px; line-height: 1.55; color: var(--ink-soft); }
.rules-dialog { display: grid; gap: 14px; }
.rules-intro { font-size: 16px; color: var(--ink-soft); }
.rules-list { display: grid; gap: 12px; padding-left: 22px; }
.rules-list li::marker { font: 800 16px var(--font-num); color: var(--lacquer); }
.rules-list strong { font: 800 16px/1.5 var(--font-display); }
.rules-list p { font-size: 14px; line-height: 1.65; color: var(--ink-soft); }
.rules-dialog .button { justify-self: start; }
.result-dialog { display: grid; justify-items: center; gap: 14px; padding-top: 6px; text-align: center; }
#game-dialog:has(.result-seal.is-stamping) { overflow: visible; }
.hero-portrait.is-fallen { opacity: .4; filter: grayscale(1) brightness(.7); }
.result-dialog p { font-size: 15px; color: var(--ink-soft); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 4px; }

@keyframes shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -6px 0; }
  50% { translate: 6px 0; }
  75% { translate: -3px 0; }
}
@keyframes sheen { from { background-position: 130% 0; } to { background-position: -130% 0; } }

/* ---------- responsive ---------- */

@media (min-width: 821px) {
  .duel-view { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; min-height: 100dvh; }
  /* The tip rides in the felt's empty top-right corner so the boards can use its row. */
  .duel-view > .tip { grid-area: 2 / 1; z-index: 2; align-self: start; justify-self: end; width: min(300px, 26vw); margin: clamp(22px, 3.2vh, 32px) max(34px, calc((100% - 1120px) / 2 + 34px)) 0 0; }
  .duel-view > .table { grid-area: 2 / 1; display: grid; }
  .felt { align-content: space-evenly; }
  /* Units get the height left after the topbar, felt padding, midline and dock (cards are 1.44x their width tall). The hero plates sit in the boards' rows. */
  .table { --unit-w: clamp(64px, (94.4vh - 160px - 1.44 * var(--card-max)) / 2.5, 136px); }
  .duel-view { --duel-hero: clamp(96px, 12vh, 112px); }

  /* Flank layout: each hero (portrait over name plaque) stands left of its board and its command tablet right of it, so the portrait can outsize the units without costing board height.
     The side rows and heroes dissolve into the felt grid; a hero spans the felt's columns on its board's row and takes the outer two through a subgrid. */
  .felt { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: auto auto auto; align-items: center; }
  .felt > .side-row { display: contents; }
  .side-row--enemy > *, .board--enemy { grid-row: 1; }
  .side-row--player > *, .board--player { grid-row: 3; }
  .board { grid-column: 2; }
  .midline { grid-row: 2; grid-column: 1 / -1; }
  .table .hero { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; grid-template-rows: auto auto; align-self: center; align-items: center; justify-items: center; pointer-events: none; }
  .table .hero > * { pointer-events: auto; }
  .table .hero-portrait { grid-area: 1 / 1; justify-self: center; }
  .table .hero-name { grid-area: 2 / 1; justify-self: center; margin: -12px 0 0; min-width: calc(var(--hero-size) * 1.3); padding: 4px 14px; font-size: clamp(15px, 2.1vh, 18px); letter-spacing: .14em; z-index: 3; }
  .table .hero-name::before { inset: -4px 6px auto 6px; }
  .table .hero .gem-health { right: -26cqi; bottom: 12cqi; }
  .table .hero .power-tablet { grid-area: 1 / 3 / 3; justify-self: start; align-self: end; margin: 0 0 0 18px; max-width: calc(100% - 18px); }
  .table .hero--player .power-tablet { align-self: start; }
  .side-row--enemy > .side-info:first-child { grid-column: 1; justify-self: start; align-self: start; flex-direction: column; align-items: flex-start; gap: 3px; }
  .side-row--enemy > .side-info--end { display: none; }
  .side-row--player > .side-info:first-child { grid-column: 1; justify-self: start; align-self: end; }
  .side-row--player > .side-info--end { grid-column: 3; justify-self: start; align-self: end; margin: 0 0 12px 18px; }
}

/* The opponent's command tablet needs the felt's top row, so the corner coach steps aside on narrow desktops (the guide line above says the same). */
@media (min-width: 821px) and (max-width: 959px) {
  .duel-view > .tip { display: none; }
}

@media (max-width: 900px) {
  .modes { grid-template-columns: 1fr 1fr; }
  .mode--duel { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .dock { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "hand gong" "log log"; align-items: center; margin-top: -12px; }
  .hand { position: relative; min-width: 0; timeline-scope: --hand; }
  .hand-cards { --card-w: 100px; justify-content: safe center; gap: 6px; min-height: 0; padding: 10px 8px 12px 12px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-timeline: --hand x; mask-image: linear-gradient(90deg, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); animation: hand-edges linear both; animation-timeline: --hand; }
  .hand::after {
    content: "滑動 ›";
    position: absolute;
    right: 4px;
    top: calc(50% - 11px);
    z-index: var(--z-lift);
    padding: 3px 8px 4px 10px;
    border: 1px solid rgb(233 185 91 / .55);
    border-radius: var(--r-pill);
    background: rgb(10 22 17 / .85);
    color: var(--gold-hi);
    font: 700 12px/1.2 var(--font-body);
    opacity: 0;
    pointer-events: none;
    animation: hand-hint linear both;
    animation-timeline: --hand;
  }
  .gong { --gong: 54px; margin: 0 2px 0 0; padding-top: 12px; }
  .gong-label { margin-top: -10px; padding: 2px 6px 3px; font-size: 12px; letter-spacing: .04em; }
  .duel-log { justify-self: stretch; margin: 6px 0 0; }
  .duel-log summary span { max-width: none; }
  .duel-log ol { width: 100%; max-height: 50vh; }
  .hand .card { margin: 0; rotate: none; translate: none; scroll-snap-align: center; }
  .hand .card:hover, .hand .card:focus-within { rotate: none; translate: 0 -4px; scale: 1; }
  .card { aspect-ratio: 5 / 7.6; }
}

@media (max-width: 640px) {
  .topbar-brand { display: none; }
  .chip-button { padding: 0 11px; }
  .home { gap: 20px; padding-top: 86px; }
  .plaque { padding: 12px 22px 14px 30px; }
  .modes { grid-template-columns: 1fr; }
  .mode-art { height: 130px; }
  .fan-card { width: 70px; }
  .mode-copy strong { font-size: 21px; }
  .hero { --hero-size: 60px; }
  .topbar { flex-wrap: wrap; }
  .topbar .guide { order: 3; flex-basis: 100%; font-size: 13px; }
  .tip p { font-size: 12.5px; }
  .hero-name { font-size: 12px; padding: 1px 8px; }
  .side-info { gap: 2px 8px; font-size: 12px; }
  .side-info b { font-size: 14px; }
  .midline { min-height: 40px; gap: 8px; }
  .round-tile { width: 32px; height: 40px; }
  .round-tile b { font-size: 18px; }
  .duel-view { --duel-hero: 64px; }
  .slot .peek { top: -6px; right: -6px; }
  .duel-view .chip-label { display: none; }
  /* Plates sit left on phones so the purse and deck count get the row's remaining width. */
  .side-row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "hero info"; column-gap: 12px; }
  .side-row > .hero { grid-area: hero; }
  .side-row--enemy > .side-info:first-child { grid-area: info; }
  .side-row--enemy > .side-info--end { display: none; }
  .side-row--player { grid-template-areas: "hero hero" "purse deck"; row-gap: 3px; }
  .side-row--player > .side-info:first-child { grid-area: deck; justify-self: end; }
  .side-row--player > .side-info--end { grid-area: purse; }
  /* The opponent's hand and deck counts move onto the midline so the enemy tablet gets the row's width. */
  .side-row--enemy > .side-info:first-child { display: none; }
  .midline-rule--info { display: flex; align-items: center; gap: 8px; height: auto; background: none; }
  .midline-rule--info::after { content: ""; flex: 1; height: 2px; background: linear-gradient(90deg, rgb(233 185 91 / .55), transparent); }
  .midline-info { display: block; font-size: 12px; line-height: 1.2; color: var(--muted); white-space: nowrap; }
  .midline-info b { font: 700 14px/1 var(--font-num); color: var(--cream); }
  /* The command tablet rides in the hero's row, right of the plaque, so the plates cost no extra height. */
  .table .hero { grid-template-columns: auto auto minmax(0, 1fr); }
  .table .hero-name { min-width: 0; }
  .power-tablet { width: auto; min-height: 40px; max-width: 216px; margin-left: 11px; padding: 4px 7px 4px 4px; column-gap: 5px; rotate: .8deg; }
  .power-tablet::before { left: -12px; width: 13px; }
  .power-coin { width: 26px; }
  .power-coin b { font-size: 14px; }
  .power-name { font-size: 13px; letter-spacing: .03em; }
  .power-rule { font-size: 11px; line-height: 1.25; }
  .power-stamp { padding: 0 4px; font-size: 10.5px; }
  .pick-page { gap: 10px; padding-top: 4px; }
  .pick-head p { font-size: 13.5px; line-height: 1.5; }
  .pick-list { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pick-card { grid-template-columns: 84px minmax(0, 1fr); grid-template-rows: auto auto; grid-template-areas: "portrait who" "portrait power"; justify-items: start; align-items: start; gap: 6px 12px; padding: 12px 12px 12px 14px; border-radius: 6px 6px 18px 18px; text-align: left; }
  .pick-portrait { grid-area: portrait; width: 100%; padding: 3px; }
  .pick-who { grid-area: who; display: flex; align-items: center; gap: 8px; justify-items: start; }
  .pick-name { padding: 1px 12px; font-size: 18px; }
  .pick-job { margin-top: 0; font-size: 13px; }
  .pick-power { grid-area: power; gap: 2px; padding: 6px 9px 7px; }
  .pick-power-head { gap: 6px; }
  .pick-power-head .gem { --gem: 24px; }
  .pick-power-head strong { font-size: 15px; }
  .pick-rule { font-size: 13px; line-height: 1.4; }
  .pick-flavor { font-size: 12px; line-height: 1.4; }
  /* No room for a button on a phone, so the pick prompt becomes a gold seal in the card's corner. */
  .pick-cta { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 0; box-shadow: 0 2px 0 #85561b, 0 0 0 2px #3a1a06; }
  .pick-cta::before { content: "選"; font: 900 17px/1 var(--font-display); letter-spacing: 0; }
  .table .hero-name { padding: 5px 10px 5px calc(var(--hero-size) * .5 + 4px); font-size: 13px; letter-spacing: .1em; }
  .purse { gap: 6px; }
  .purse-string { --coin: 16px; padding-right: 10px; }
  .purse-label { padding: 3px 2px; font-size: 11px; }
  .purse-count { font-size: 17px; }
  /* The hand gets the full row so five cards fit; the gong hangs beside the battle log. Cards stay at the compact (80px and under) layout however few are held. */
  .dock { grid-template-areas: "hand hand" "log gong"; }
  .hand-cards { --card-w: clamp(60px, (100vw - 36px) / var(--count) - 4px, 80px); gap: 4px; padding: 10px 6px 12px; }
  .gong { --gong: 40px; grid-auto-flow: column; align-items: center; margin: 6px 0 0 8px; padding: 0; }
  .gong::before, .gong::after { display: none; }
  .gong-label { margin: 0 0 0 -8px; padding: 4px 10px 5px 14px; font-size: 14px; }
  .card-detail { grid-template-columns: 1fr; justify-items: center; }
  .detail-portrait { width: min(200px, 70%); }
  .deck-notice { flex-basis: 100%; order: -1; }
  .deck-notice:empty { display: none; }
  .deck-bar-inner .button { flex: 1; padding: 0 10px; }
  .deck-count { flex-basis: 100%; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; }
  .collection { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; }
  .banner-text { padding: 12px 40px 14px; }
  .topbar-actions { gap: 6px; }
  .chip-speed .icon { display: none; }
  /* The duel fills the phone's height: spare room spreads through the felt instead of pooling under the dock. */
  .duel-view { display: flex; flex-direction: column; min-height: 100dvh; }
  .duel-view > .table { flex: 1; display: grid; }
  .felt { align-content: space-evenly; }
}

/* Short phones (375x667): trim the bars and the board so the whole duel fits without page scroll. */
@media (max-width: 640px) and (max-height: 700px) {
  .duel-view > .topbar { row-gap: 4px; padding: 6px 0 4px; }
  .duel-view .guide { line-height: 1.3; }
  .duel-view { --duel-hero: 64px; }
  .table { --unit-w: min(104px, 6.8vh, 19.5vw); }
  .midline { min-height: 30px; }
  .round-tile { height: 30px; }
  .hand-cards { padding-top: 6px; padding-bottom: 8px; }
}

/* Short laptop screens (1280x720): the home menu gives up spare air so 編輯牌組 and 玩法說明 stay above the fold. */
@media (min-width: 641px) and (max-height: 800px) {
  .home { gap: 16px; padding: 56px 0 20px; }
  .home-title { gap: 10px; }
  .plaque { font-size: clamp(46px, 11vh, 92px); }
  .mode-art { height: 128px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur-base: 0ms; --dur-slow: 0ms; --dur-hit: 0ms; --dur-shake: 0ms; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 0ms !important; scroll-behavior: auto !important; }
  .unit.is-golden .unit-frame::after { animation: none; }
}


/* 夜市群英會 */

:root {
  --tribe-food: #e8833a;
  --tribe-temple: #d23b2e;
  --tribe-wild: #3e8e4f;
  --tribe-sea: #2e7dbf;
  --tribe-street: #8b5cc4;
  --sky: #151b36;
  --sky-lo: #0d1424;
  --tarp: #2f6fc4;
  --neon: #ff5fa2;
  --dur-stagger: 30ms;
  --dur-merge: 900ms;
  --pace-combat: 60ms;
  --hold-plate: 600ms;
  --hold-result: 600ms;
  --hold-heavy: 120ms;
  --hold-knockout: 1000ms;
  --hold-clear: 900ms;
  --dur-count: 400ms;
}

.screen--bg {
  background:
    radial-gradient(90% 50% at 50% -8%, rgb(255 150 70 / .24), transparent 62%),
    radial-gradient(60% 40% at 8% 100%, rgb(255 110 60 / .1), transparent 70%),
    linear-gradient(var(--sky), var(--sky-lo) 48%, var(--night));
}
.bg-view { display: flex; flex-direction: column; min-height: 100dvh; }
.bg-view[aria-busy="true"] .bg-main { cursor: progress; }
.bg-guide { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 12px; min-width: 0; text-align: center; }
.bg-guide strong { font: 900 18px/1.4 var(--font-display); letter-spacing: .08em; color: var(--gold-hi); }
.bg-guide-msg { font-size: 14px; line-height: 1.45; color: #d9cfb8; }
.bg-stage {
  --room: calc(100dvh - 314px);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(1400px, 100% - 24px);
  margin: 0 auto;
  padding-bottom: 10px;
}
.bg-main { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bg-coin {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: radial-gradient(circle at 35% 30%, #fff0b8, var(--gold) 52%, #a2732f);
  box-shadow: inset 0 0 0 1.5px #fff2c2, 0 1px 2px rgb(0 0 0 / .45);
  color: #4a2a05;
  font: 800 13px/1 var(--font-num);
}

/* standings: lantern tags strung across the street */
.bg-tags { position: relative; z-index: 9; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; margin: 0; padding: 0 1%; list-style: none; }
.bg-tags::before { content: ""; position: absolute; left: -12px; right: -12px; top: 3px; height: 2px; background: linear-gradient(90deg, transparent, #c99a45 5%, #e9b95b 50%, #c99a45 95%, transparent); box-shadow: 0 1px 2px rgb(0 0 0 / .5); }
.bg-tag { position: relative; display: grid; justify-items: center; padding-top: 11px; transform-origin: 50% 4px; transition: translate var(--dur-slow) var(--ease-out), rotate var(--dur-slow) var(--ease-out), opacity var(--dur-slow), filter var(--dur-slow); }
.bg-tag:nth-child(even) { padding-top: 16px; }
.bg-tag::before { content: ""; position: absolute; left: 50%; top: 4px; width: 1.5px; height: 5px; background: #c99a45; }
.bg-tag:nth-child(even)::before { height: 10px; }
.bg-tag-body {
  position: relative;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 7px;
  max-width: 100%;
  padding: 3px 16px 3px 4px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent 0 11px, rgb(90 8 4 / .2) 11px 12px),
    radial-gradient(130% 120% at 50% 18%, #ff9a6a, #d8342a 45%, #8d140e);
  box-shadow: 0 0 0 1.5px #e9b95b, 0 6px 12px rgb(0 0 0 / .45), 0 0 16px rgb(255 110 50 / .3);
}
.bg-tag-body::before, .bg-tag-body::after { content: ""; position: absolute; left: 50%; translate: -50% 0; width: 26px; height: 5px; border-radius: 2px; background: linear-gradient(#ffe39a, #b8781a); }
.bg-tag-body::before { top: -4px; }
.bg-tag-body::after { bottom: -4px; }
.bg-tag-face { --face: clamp(32px, var(--room) * .07, 42px); grid-row: span 2; position: relative; width: var(--face); height: var(--face); padding: 2px; border-radius: 50%; background: conic-gradient(from 30deg, var(--gold-hi), var(--gold-lo), var(--gold), var(--gold-lo), var(--gold-hi)); }
.bg-tag-art { width: 100%; height: 100%; border-radius: 50%; }
.bg-tag-tier { position: absolute; left: -5px; bottom: -4px; display: grid; place-items: center; width: 17px; height: 17px; border: 1.5px solid #ffd3e6; border-radius: 50%; background: #1d0a17; color: #fff3fa; font: 800 10px/1 var(--font-num); box-shadow: 0 0 6px rgb(255 95 162 / .7); }
.bg-tag-hp { align-self: end; font: 800 20px/1 var(--font-num); color: #fff6e2; text-shadow: 0 1px 0 rgb(80 6 4 / .8); }
.bg-tag-name { align-self: start; font: 700 12px/1.3 var(--font-display); color: #ffe2b0; white-space: nowrap; }
.bg-tag.is-me .bg-tag-body {
  background:
    repeating-linear-gradient(90deg, transparent 0 11px, rgb(120 70 10 / .16) 11px 12px),
    radial-gradient(130% 120% at 50% 18%, #fff3c4, #f0c050 45%, #a2732f);
  box-shadow: 0 0 0 1.5px #fff3c4, 0 6px 12px rgb(0 0 0 / .45), 0 0 18px rgb(255 205 70 / .5);
}
.bg-tag.is-me .bg-tag-hp { color: #4a2a05; text-shadow: none; }
.bg-tag.is-me .bg-tag-name { color: #6b3f05; }
.bg-tag.is-next .bg-tag-body { box-shadow: 0 0 0 2px #fff0b8, 0 6px 12px rgb(0 0 0 / .45), 0 0 22px 6px rgb(255 190 80 / .75); animation: bg-tag-glow 1.6s ease-in-out infinite; }
.bg-tag.is-foe .bg-tag-body { box-shadow: 0 0 0 2px #ffb3a6, 0 6px 12px rgb(0 0 0 / .45), 0 0 26px 8px rgb(255 70 50 / .8); }
@keyframes bg-tag-glow { 50% { box-shadow: 0 0 0 2px #fff0b8, 0 6px 12px rgb(0 0 0 / .45), 0 0 34px 12px rgb(255 190 80 / .95); } }
.bg-tag-flag { position: absolute; left: 50%; top: 100%; z-index: 1; translate: -50% 7px; padding: 1px 9px 2px; border-radius: 2px 2px 8px 8px; background: linear-gradient(#fff3c4, #f0c050); color: #6b1209; font: 900 13px/1.4 var(--font-display); letter-spacing: .1em; white-space: nowrap; box-shadow: 0 3px 8px rgb(0 0 0 / .45); }
.bg-tag-flag::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 1.5px; height: 7px; background: #e9b95b; }
.bg-tag.is-foe .bg-tag-flag { background: linear-gradient(#ffb3a6, #e0473b); color: #fff8f0; }
.bg-tag.is-out { opacity: .5; filter: grayscale(1); rotate: 9deg; translate: 0 8px; }
.bg-tag.is-out.is-next, .bg-tag.is-out.is-foe { opacity: .85; }
.bg-tag.is-out .bg-tag-hp { font-size: 15px; }

/* stall */
.bg-stall { position: relative; border-radius: 18px 18px 14px 14px; background: linear-gradient(#4a2c18, #2c180c); box-shadow: 0 18px 34px rgb(0 0 0 / .5), inset 0 -10px 0 var(--wood), inset 0 -12px 0 var(--wood-lo); }
.bg-awning {
  position: relative;
  z-index: 2;
  height: 32px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(rgb(255 255 255 / .18), transparent 40%, rgb(0 0 0 / .2)), repeating-linear-gradient(90deg, #c8281e 0 24px, var(--paper) 24px 48px);
  box-shadow: 0 4px 8px rgb(0 0 0 / .35);
}
.bg-awning::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -11px;
  height: 12px;
  background:
    radial-gradient(circle at 50% 0, #c8281e 0 11.5px, transparent 12px) 0 0 / 48px 12px repeat-x,
    radial-gradient(circle at 50% 0, var(--paper) 0 11.5px, transparent 12px) 24px 0 / 48px 12px repeat-x;
  filter: drop-shadow(0 3px 2px rgb(0 0 0 / .35));
}
.bg-awning .lanterns { inset: 14px 18% auto; z-index: 3; justify-content: space-between; }
.bg-awning .lanterns > span { width: 19px; margin-top: 0; }
.bg-awning .lanterns > span:nth-child(odd) { margin-top: 6px; }
.bg-stall-body {
  position: relative;
  display: grid;
  grid-template-areas: "tools shop tier";
  grid-template-columns: 150px minmax(0, 1fr) 150px;
  align-items: center;
  gap: 10px;
  padding: 30px 14px 22px;
  background: radial-gradient(60% 90% at 50% 0, rgb(255 196 120 / .22), transparent 75%);
}
.bg-stall-ctl { display: grid; justify-items: center; gap: 8px; }
.bg-stall-ctl--tier { grid-area: tier; }
.bg-stall-ctl--tools { grid-area: tools; }
.bg-sign {
  display: grid;
  justify-items: center;
  min-width: 92px;
  padding: 5px 12px 6px;
  border: 2px solid #ffd3e6;
  border-radius: 10px;
  background: linear-gradient(#2a0f22, #140814);
  box-shadow: 0 0 6px 1px var(--neon), 0 0 22px rgb(255 95 162 / .45), inset 0 0 10px rgb(255 95 162 / .45);
}
.bg-sign b { font: 900 30px/1 var(--font-num); color: #fff3fa; text-shadow: 0 0 6px var(--neon), 0 0 16px var(--neon); }
.bg-sign span { font: 900 14px/1.3 var(--font-display); letter-spacing: .12em; color: #ffd9ec; text-shadow: 0 0 8px rgb(255 95 162 / .9); white-space: nowrap; }
/* 換一攤 and 留攤 are wooden signboards hung on cords; 升級 is a paper slip under the neon sign */
.bg-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 118px;
  min-height: 46px;
  padding: 0 14px;
  border: 2px solid #3b220f;
  border-radius: 6px;
  background:
    repeating-linear-gradient(178deg, rgb(255 230 190 / .07) 0 2px, transparent 2px 6px),
    linear-gradient(#a0703f, #74482a 55%, #5a361d);
  box-shadow: inset 0 1px 0 rgb(255 225 180 / .4), inset 0 -3px 0 rgb(0 0 0 / .28), 0 7px 10px rgb(0 0 0 / .45);
  color: #fbe7c0;
  font: 800 15px/1 var(--font-display);
  letter-spacing: .06em;
  text-shadow: 0 -1px 0 rgb(0 0 0 / .55);
  cursor: pointer;
  transition: translate var(--dur-fast), box-shadow var(--dur-base);
}
.bg-btn:hover { translate: 0 -1px; }
.bg-btn:active { translate: 0 2px; box-shadow: inset 0 1px 0 rgb(255 225 180 / .4), inset 0 -2px 0 rgb(0 0 0 / .28), 0 3px 6px rgb(0 0 0 / .45); }
.bg-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.bg-stall-ctl--tools { gap: 22px; }
.bg-stall-ctl--tools .bg-btn { rotate: -2deg; }
.bg-stall-ctl--tools .bg-btn + .bg-btn { rotate: 1.5deg; }
.bg-stall-ctl--tools .bg-btn::before { content: ""; position: absolute; left: 20%; right: 20%; bottom: calc(100% + 2px); height: 16px; border-inline: 2px solid #c99a45; pointer-events: none; }
.bg-btn--freeze.is-on {
  border-color: #1d3f73;
  background: repeating-linear-gradient(178deg, rgb(255 255 255 / .08) 0 2px, transparent 2px 6px), linear-gradient(#5fa8f0, #2f6fc4);
  color: #fff;
}
.bg-btn--tier { border: 1.5px solid var(--gold-lo); border-radius: 10px; background: linear-gradient(var(--paper), var(--paper-lo)); box-shadow: 0 3px 0 #6b4a1d, 0 6px 10px rgb(0 0 0 / .35); color: var(--ink); text-shadow: none; }
.bg-btn--tier:active { box-shadow: 0 1px 0 #6b4a1d, 0 3px 6px rgb(0 0 0 / .35); }
.bg-btn--tier.is-ready { border-color: var(--glow-play); animation: bg-pulse 1.6s ease-in-out infinite; }
.bg-shop { --unit-w: clamp(64px, min(var(--room) * .23, (100vw - 440px) / (var(--n) * 1.2)), 140px); position: relative; isolation: isolate; grid-area: shop; display: flex; justify-content: center; align-items: flex-end; gap: clamp(8px, 1.4vw, 18px); min-height: calc(var(--unit-w) * 1.25 + 14px); }
.bg-shop-empty { align-self: center; color: #e7d6b6; font-size: 14px; }
/* the vendor counter the wares stand on, with steam off the griddles at its ends */
.bg-shop::before { content: ""; position: absolute; left: -18px; right: -18px; bottom: -12px; z-index: -1; height: 28px; border-radius: 6px 6px 3px 3px; background: linear-gradient(#c08a52 0 3px, #8a5a33 3px 9px, #6d4423 9px, #4f2f17); box-shadow: 0 6px 10px rgb(0 0 0 / .45), inset 0 1px 0 rgb(255 225 180 / .35); pointer-events: none; }
.bg-shop::after {
  content: "";
  position: absolute;
  left: -10px;
  right: -10px;
  bottom: 12px;
  z-index: -1;
  height: 75%;
  background:
    radial-gradient(16px 40px at 3% 100%, rgb(255 244 228 / .22), transparent 70%),
    radial-gradient(12px 30px at 7% 72%, rgb(255 244 228 / .16), transparent 70%),
    radial-gradient(16px 40px at 97% 100%, rgb(255 244 228 / .22), transparent 70%),
    radial-gradient(12px 30px at 93% 72%, rgb(255 244 228 / .16), transparent 70%);
  pointer-events: none;
  animation: bg-steam 3.8s ease-in-out infinite;
}
@keyframes bg-steam {
  0% { opacity: 0; translate: 0 12px; }
  45% { opacity: 1; }
  100% { opacity: 0; translate: 0 -26px; }
}
.bg-slot { position: relative; flex: none; width: var(--unit-w); aspect-ratio: .8; touch-action: none; }
.bg-slot > .unit { cursor: grab; }
.bg-slot .peek { top: -4px; right: -6px; width: 24px; height: 24px; opacity: 0; transition: opacity var(--dur-fast); }
.bg-slot:hover .peek, .bg-slot:focus-within .peek { opacity: .9; }
@media (hover: none) { .bg-slot .peek { opacity: .85; } }
.bg-price { position: absolute; left: -10px; top: 6%; z-index: 5; display: flex; padding: 3px 4px 3px 11px; border-radius: 3px 5px 5px 3px; background: linear-gradient(#fff6e0, #ecd9b4); box-shadow: 0 2px 5px rgb(0 0 0 / .45); rotate: -12deg; pointer-events: none; }
.bg-price::before { content: ""; position: absolute; left: 3px; top: 50%; width: 5px; height: 5px; translate: 0 -50%; border-radius: 50%; background: #6b4a1d; box-shadow: inset 0 1px 1px rgb(0 0 0 / .5); }
.bg-shop .unit.is-idle { filter: saturate(.3) brightness(.62) drop-shadow(0 6px 5px rgb(0 0 0 / .45)); }
.bg-shop .slot:has(.unit.is-idle) .bg-price { filter: grayscale(.8) brightness(.8); }
.bg-tarp {
  position: absolute;
  inset: 8px -4px 4px;
  grid-area: shop;
  z-index: 6;
  display: none;
  border-radius: 8px 8px 14px 14px;
  background:
    radial-gradient(circle at 12% 18%, rgb(255 255 255 / .55) 0 2px, transparent 3px),
    radial-gradient(circle at 84% 30%, rgb(255 255 255 / .5) 0 2px, transparent 3px),
    radial-gradient(circle at 60% 80%, rgb(255 255 255 / .45) 0 1.5px, transparent 2.5px),
    repeating-linear-gradient(90deg, rgb(47 111 196 / .46) 0 30px, rgb(88 156 236 / .34) 30px 60px);
  box-shadow: inset 0 0 0 2px rgb(190 225 255 / .6), inset 0 -10px 18px rgb(160 210 255 / .35), 0 0 18px rgb(120 190 255 / .35);
  pointer-events: none;
}
.bg-tarp span { position: absolute; right: 10px; top: -10px; padding: 2px 10px; border-radius: 6px; background: var(--tarp); color: #fff; font: 800 13px/1.5 var(--font-display); box-shadow: 0 2px 6px rgb(0 0 0 / .4); }
.bg-stall.is-frozen .bg-tarp { display: block; }
.bg-stall.is-frozen .bg-shop .unit { filter: saturate(.7) hue-rotate(-14deg) brightness(.95) drop-shadow(0 0 6px rgb(150 210 255 / .7)); }
.bg-sell-hint {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  place-items: center;
  border-radius: inherit;
  background: rgb(60 30 8 / .78);
  box-shadow: inset 0 0 0 3px var(--glow-play), inset 0 0 40px rgb(255 200 60 / .45);
  color: var(--gold-hi);
  font: 900 26px/1 var(--font-display);
  letter-spacing: .1em;
}
.bg-view.is-dragging-board .bg-sell-hint { display: grid; opacity: .45; }
.bg-stall.is-drop-sell .bg-sell-hint { opacity: 1; }

/* board on the table */
.bg-board, .bg-arena {
  position: relative;
  border: clamp(8px, 1vw, 12px) solid transparent;
  border-radius: clamp(22px, 3vw, 34px);
  background:
    radial-gradient(ellipse at 50% 40%, rgb(255 255 255 / .08), transparent 64%) padding-box,
    repeating-radial-gradient(circle at 30% 40%, rgb(0 0 0 / .03) 0 1px, transparent 1px 3px) padding-box,
    linear-gradient(var(--felt), var(--felt-lo)) padding-box,
    linear-gradient(160deg, var(--wood-hi), var(--wood) 40%, var(--wood-lo)) border-box;
  box-shadow: 0 24px 50px rgb(0 0 0 / .5), inset 0 0 60px rgb(0 0 0 / .4);
}
.bg-board { --unit-w: clamp(64px, min(var(--room) * .275, (100vw - 180px) / 7.6), 164px); flex: 1; display: grid; place-items: center; min-height: calc(var(--unit-w) * 1.25 + 34px); padding: 15px 12px 11px; }
.bg-row { display: flex; justify-content: center; align-items: center; gap: clamp(6px, 1.2vw, 16px); }
.bg-row > .slot { width: var(--unit-w); }
.bg-board .slot--empty { width: var(--unit-w); aspect-ratio: .8; }
.bg-insert { position: absolute; top: 16%; bottom: 16%; width: 6px; translate: -50% 0; border-radius: 3px; background: var(--glow-play); box-shadow: 0 0 14px 4px rgb(255 205 70 / .75); pointer-events: none; }
.bg-insert[hidden] { display: none; }
.bg-view.is-dragging-hand .bg-board { box-shadow: 0 24px 50px rgb(0 0 0 / .5), inset 0 0 60px rgb(0 0 0 / .4), 0 0 0 3px rgb(255 215 94 / .55); }
.bg-tray {
  position: absolute;
  left: 50%;
  top: -12px;
  z-index: 12;
  translate: -50% -50%;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% + 16px);
  padding: 5px 6px;
  border: 1px solid var(--gold-lo);
  border-radius: var(--r-pill);
  background: rgb(26 16 10 / .94);
  box-shadow: 0 8px 18px rgb(0 0 0 / .5);
  white-space: nowrap;
}
.bg-tray .chip-button { min-height: 40px; padding: 0 12px; }
.bg-tray-text { padding: 0 8px; font: 700 14px/1.3 var(--font-display); color: var(--gold-hi); }
.bg-flip .icon { rotate: 180deg; }
.bg-board .unit.is-idle { filter: saturate(.35) brightness(.55) drop-shadow(0 6px 5px rgb(0 0 0 / .45)); }
.bg-stage[data-pick="aim"] .bg-board .unit.is-ready { animation: bg-aim 1.1s ease-in-out infinite; }
@keyframes bg-aim {
  0%, 100% { filter: drop-shadow(0 0 2px var(--glow-play)) drop-shadow(0 0 6px rgb(255 205 70 / .6)); }
  50% { filter: drop-shadow(0 0 4px #fff3c0) drop-shadow(0 0 16px rgb(255 205 70 / 1)); }
}
/* aiming: the board is the only live zone. A paper slip on its rim says what to do, the played card stands lifted in hand, the rest of the street steps back. */
.bg-tray--aim { --tray-y: -50%; translate: -50% var(--tray-y); gap: 12px; padding: 6px 6px 6px 16px; border: 0; border-radius: 14px; background: linear-gradient(var(--paper), var(--paper-lo)); box-shadow: 0 0 0 2px var(--gold-lo), 0 0 0 5px var(--lacquer), 0 14px 30px rgb(0 0 0 / .55); color: var(--ink); animation: bg-coach-pop var(--dur-slow) var(--ease-out); }
.bg-tray--aim.is-nudged { animation: bg-tray-shake var(--dur-shake) ease-in-out; }
@keyframes bg-tray-shake {
  25% { translate: calc(-50% - 6px) var(--tray-y); }
  50% { translate: calc(-50% + 6px) var(--tray-y); }
  75% { translate: calc(-50% - 3px) var(--tray-y); }
}
.bg-tray--aim .bg-tray-text { display: grid; padding: 0; color: var(--ink); font: 800 17px/1.3 var(--font-display); }
.bg-tray--aim .bg-tray-text b { font: 800 12px/1.3 var(--font-body); color: var(--lacquer); letter-spacing: .06em; }
.bg-aim-cancel { gap: 4px; border-color: var(--lacquer); background: var(--lacquer); color: var(--gold-hi); }
.bg-aim-cancel:hover { background: var(--lacquer-hi); }
.bg-stage[data-pick="aim"] :is(.bg-stall, .bg-purse), .bg-stage[data-aim="card"] .bg-hero-dock, .bg-stage[data-pick="aim"] .bg-hand .card:not(.is-selected) { filter: brightness(.5) saturate(.55); }
.bg-stage[data-pick="aim"] .bg-hand .card.is-selected { z-index: var(--z-lift); rotate: 0deg; translate: 0 -24px; scale: 1.08; }
.bg-sell { border-color: var(--gold); color: var(--gold-hi); }

/* dock: hero, hand, purse */
.bg-dock { position: relative; display: grid; grid-template-columns: 236px minmax(0, 1fr) auto; align-items: end; gap: 10px; border-radius: 18px; transition: box-shadow var(--dur-base); }
.bg-dock.is-drop-buy { box-shadow: 0 0 0 3px var(--glow-play), 0 0 30px rgb(255 205 70 / .4); }
/* the hero plate carries its power as a temple fortune stick (籤): a bamboo slip, red head with the cost, its name across the slip */
.bg-hero-dock { align-self: end; justify-self: start; margin-bottom: 4px; padding: 12px 14px 8px 12px; border-radius: 18px 18px 12px 12px; background: linear-gradient(160deg, #5a2a17, #2e150a); box-shadow: 0 0 0 2px var(--gold-lo), 0 12px 24px rgb(0 0 0 / .45), inset 0 1px 0 rgb(255 220 170 / .2); }
.bg-hero-dock .hero { --hero-size: clamp(66px, var(--room) * .18, 92px); --stick: 62px; justify-items: start; width: calc(var(--hero-size) + 30px + var(--stick)); }
.bg-hero-dock .hero-name { margin-left: calc(var(--hero-size) / 2); translate: -50% 0; }
.bg-hero-dock .hero-power {
  --head: 34px;
  left: calc(var(--hero-size) + 30px);
  top: auto;
  bottom: 0;
  translate: none;
  rotate: 4deg;
  transform-origin: 50% 100%;
  display: grid;
  grid-template-rows: var(--head) auto minmax(0, 1fr);
  justify-items: center;
  row-gap: 5px;
  width: var(--stick);
  height: calc(var(--hero-size) + 30px);
  padding: 0 4px 6px;
  border: 1.5px solid #7a5426;
  border-radius: 8px 8px 4px 4px;
  background:
    linear-gradient(#c8281e 0 var(--head), #8d140e var(--head) calc(var(--head) + 2px), transparent calc(var(--head) + 2px)),
    linear-gradient(90deg, #b88645, #f2d79d 40%, #e0bb74 64%, #a87a3e);
  box-shadow: inset 0 0 0 1px rgb(255 240 200 / .3), inset 0 -4px 0 rgb(110 70 25 / .45), 0 8px 14px rgb(0 0 0 / .5);
  color: #3a1a06;
  transition: translate var(--dur-fast) var(--ease-out), rotate var(--dur-base) var(--ease-out), box-shadow var(--dur-base);
}
.bg-hero-dock .hero-power::before { content: "英雄技能"; grid-row: 2; padding: 1px 3px; border-radius: 3px; background: rgb(141 20 14 / .14); color: #8d140e; font: 800 11px/1.3 var(--font-body); white-space: nowrap; }
.bg-hero-dock .hero-power .gem { --gem: 26px; position: relative; top: auto; left: auto; grid-row: 1; align-self: center; translate: none; }
.bg-hero-dock .hero-power-name { grid-row: 3; align-self: center; font: 900 15px/1.2 var(--font-display); text-align: center; text-wrap: balance; }
.bg-hero-dock .hero-power.is-ready { border-color: var(--glow-play); translate: 0 -8px; rotate: 2deg; box-shadow: inset 0 0 0 1px rgb(255 240 200 / .4), inset 0 -4px 0 rgb(110 70 25 / .45), 0 0 0 2px rgb(255 215 94 / .85), 0 0 20px 5px rgb(255 205 70 / .6); }
.bg-hero-dock .hero-power.is-ready:hover { translate: 0 -11px; }
.bg-hero-dock .hero-power.is-ready:active { translate: 0 -2px; box-shadow: inset 0 0 0 1px rgb(255 240 200 / .4), inset 0 -1px 0 rgb(110 70 25 / .45), 0 0 0 2px rgb(255 215 94 / .85), 0 0 10px 2px rgb(255 205 70 / .5); }
.bg-hero-dock[data-power="used"] .hero-power {
  filter: none;
  rotate: 0deg;
  background:
    linear-gradient(#6d4a44 0 var(--head), #4a2c28 var(--head) calc(var(--head) + 2px), transparent calc(var(--head) + 2px)),
    linear-gradient(90deg, #6d5a3e, #9a8866 40%, #8a7656 64%, #5e4a30);
  color: #3a2c1a;
}
.bg-hero-dock[data-power="used"] .hero-power::after { content: "已用"; position: absolute; left: 50%; top: 5px; translate: -50% 0; rotate: -12deg; padding: 2px 6px; border: 2px solid #e0473b; border-radius: 4px; background: rgb(255 248 230 / .94); color: #c8281e; font: 900 13px/1.1 var(--font-display); white-space: nowrap; }
.bg-hero-dock[data-power="passive"] .hero-power {
  filter: none;
  cursor: help;
  background:
    linear-gradient(#5a3a78 0 var(--head), #3a2450 var(--head) calc(var(--head) + 2px), transparent calc(var(--head) + 2px)),
    linear-gradient(90deg, #b88645, #f2d79d 40%, #e0bb74 64%, #a87a3e);
}
.bg-hero-dock[data-power="passive"] .hero-power .gem { display: none; }
.bg-hero-dock[data-power="passive"] .hero-power::before { content: "被動技能"; background: rgb(58 36 80 / .16); color: #3a2450; }
.bg-hand { min-width: 0; }
.bg-hand-cards {
  --card-w: clamp(84px, var(--room) * .22, 128px);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: calc(var(--card-w) * 1.44 + 18px);
  padding: 14px 8px 4px;
  container-type: inline-size;
}
.bg-hand .card {
  margin-inline: clamp(var(--card-w) * -.4, (100cqw - var(--count) * var(--card-w)) / (2 * var(--count)), 3px);
  transform-origin: 50% 130%;
  rotate: calc(var(--fan, 0) * 1.8deg);
  translate: 0 calc(var(--arc, 0) * 2px);
  touch-action: pan-x;
  transition: translate var(--dur-fast) var(--ease-out), rotate var(--dur-fast) var(--ease-out), scale var(--dur-fast) var(--ease-out);
}
.bg-hand .card:hover, .bg-hand .card:focus-within { z-index: var(--z-lift); rotate: 0deg; translate: 0 -20px; scale: 1.12; }
.bg-hand-empty { align-self: center; padding: 0 0 30px; color: var(--muted); font-size: 14px; }
/* 本錢: a bamboo coin tube with the coins stacked on its mouth */
.bg-purse { display: flex; align-items: flex-end; justify-content: flex-end; gap: 14px; padding: 0 6px 6px 0; }
.bg-gold { display: grid; justify-items: center; }
.bg-coins { position: relative; z-index: 1; display: flex; gap: 4px; height: 40px; margin-bottom: -9px; }
.bg-pile { position: relative; width: 32px; }
.bg-pile i { position: absolute; left: 0; bottom: calc(var(--k) * 6px); width: 100%; height: 12px; border-radius: 50%; background: radial-gradient(ellipse at 40% 35%, #fff4c6, var(--gold) 55%, #9a6a1f); box-shadow: inset 0 -2px 0 #8f5f1c, 0 1px 2px rgb(0 0 0 / .5); }
.bg-tube {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  width: 86px;
  padding: 15px 0 11px;
  border-radius: 12px 12px 10px 10px / 8px 8px 10px 10px;
  background:
    linear-gradient(transparent 0 60%, rgb(40 58 14 / .55) 60% 65%, transparent 65%),
    linear-gradient(90deg, #3f5821, #7c9a3e 22%, #b7cf72 42%, #8fae4e 62%, #4f6b2a);
  box-shadow: inset 0 0 0 1.5px rgb(30 45 10 / .6), 0 8px 14px rgb(0 0 0 / .45);
}
.bg-tube::before { content: ""; position: absolute; left: 7px; right: 7px; top: -5px; height: 12px; border-radius: 50%; background: radial-gradient(#1c1206 40%, #4a3a14); box-shadow: 0 0 0 2px #9fbb5a; }
.bg-tube b { font: 900 34px/1 var(--font-num); color: #fff8e0; text-shadow: 0 2px 0 #2c3d0f, 0 0 8px rgb(0 0 0 / .4); }
.bg-tube small { font: 800 15px/1 var(--font-num); color: #f0f5d8; text-shadow: 0 1px 0 #2c3d0f; }
.bg-gold-label { margin-top: 5px; font: 700 12px/1 var(--font-display); color: var(--muted); letter-spacing: .2em; }
.bg-go {
  min-width: 168px;
  min-height: 66px;
  padding: 0 22px;
  border: 3px solid var(--gold);
  border-radius: 16px;
  background: radial-gradient(120% 90% at 50% 0, var(--lacquer-hi), var(--lacquer) 55%, var(--lacquer-lo));
  box-shadow: 0 5px 0 #4a0d09, 0 12px 22px rgb(0 0 0 / .5), inset 0 0 0 2px rgb(255 220 160 / .35);
  color: var(--gold-hi);
  font: 900 27px/1 var(--font-display);
  letter-spacing: .14em;
  text-shadow: 0 2px 0 var(--lacquer-lo);
  cursor: pointer;
  transition: translate var(--dur-fast), box-shadow var(--dur-base);
}
.bg-go:hover { translate: 0 -2px; }
.bg-go:active { translate: 0 3px; box-shadow: 0 2px 0 #4a0d09, 0 6px 12px rgb(0 0 0 / .5); }
.bg-go.is-suggested { animation: bg-pulse 1.4s ease-in-out infinite; }
.bg-btn.is-invalid, .bg-go.is-invalid, .hero-power.is-invalid, .chip-button.is-invalid { animation: shake var(--dur-shake) ease-in-out; box-shadow: 0 0 0 3px var(--glow-target), 0 0 18px rgb(255 70 50 / .6); }
/* a tap that landed mid-animation glows until the street is idle and it runs */
.bg-view .is-held { animation: bg-held 520ms ease-in-out infinite alternate; }
.bg-go.is-held { translate: 0 3px; }
@keyframes bg-held {
  from { filter: drop-shadow(0 0 2px #fff3c0); }
  to { filter: drop-shadow(0 0 4px #fff3c0) drop-shadow(0 0 16px rgb(255 205 70)); }
}
@media (prefers-reduced-motion: reduce) {
  .bg-view .is-held { animation: none; filter: drop-shadow(0 0 4px #fff3c0) drop-shadow(0 0 16px rgb(255 205 70)); }
}
@keyframes bg-pulse {
  0%, 100% { box-shadow: 0 5px 0 #4a0d09, 0 12px 22px rgb(0 0 0 / .5), 0 0 0 0 rgb(255 215 94 / 0); }
  50% { box-shadow: 0 5px 0 #4a0d09, 0 12px 22px rgb(0 0 0 / .5), 0 0 0 4px rgb(255 215 94 / .9), 0 0 26px 8px rgb(255 205 70 / .55); }
}

/* cards and units of the night market */
.card-tier {
  position: absolute;
  left: -5cqi;
  top: -5cqi;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 24cqi;
  height: 24cqi;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--lacquer-hi), var(--lacquer-lo));
  box-shadow: 0 0 0 1.4cqi var(--gold), 0 2px 4px rgb(0 0 0 / .5);
}
.card-tier b { font: 800 14cqi/1 var(--font-num); color: var(--gold-hi); text-shadow: 0 1px 0 rgb(0 0 0 / .5); }
.card[data-tribe] .card-title { background: linear-gradient(color-mix(in srgb, var(--tribe) 88%, white), color-mix(in srgb, var(--tribe) 70%, black)); color: #fff8e6; }
.card[data-tribe] .card-name { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: max(10px, 11cqi); letter-spacing: 0; }
.card[data-tribe] .card-art { background-size: cover; }
.unit[data-tribe] .unit-name { background: color-mix(in srgb, var(--tribe) 72%, black); color: #fff8e6; }
.screen--bg .unit-name { left: 2cqi; right: 2cqi; bottom: 0; translate: none; max-width: none; padding: .6cqi 1cqi; overflow: visible; text-align: center; font-size: max(10px, min(12cqi, 92cqi / var(--chars, 4))); line-height: 1.3; letter-spacing: 0; }
.screen--bg .unit .gem { --gem: 30cqi; bottom: max(19cqi, 17px); }
.screen--bg .unit-art { box-shadow: inset 0 0 0 1px rgb(0 0 0 / .35), inset 0 -6cqi 16cqi rgb(150 60 10 / .3); }
@container (max-width: 64px) { .screen--bg .unit .gem { bottom: 0; } }
.keyword-shield { background: #9a7420; }
.keyword-reborn { background: #2d7fa3; }
.keyword-windfury { background: #5a46a8; }
.keyword-venom { background: #3d7d26; }
.unit-mark--seal { left: auto; right: 2cqi; top: 12cqi; bottom: auto; translate: none; width: 21cqi; height: 21cqi; border: 1px solid var(--gold); background: var(--lacquer); color: var(--gold-hi); font: 900 12cqi/1 var(--font-display); box-shadow: 0 1px 3px rgb(0 0 0 / .5); }
.unit.has-windfury .unit-frame { box-shadow: inset 0 0 0 1.6cqi var(--gold), inset 0 0 0 2.6cqi #2c170a, 0 0 0 1.6cqi #e6f6ff, 0 0 0 3.4cqi #4aa3ff, 0 0 12px 2px rgb(74 163 255 / .6); }
.unit.has-venom .unit-aura::after { content: "辣"; position: absolute; left: 3cqi; top: 16cqi; display: grid; place-items: center; width: 21cqi; height: 21cqi; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff6a45, #a1120a); color: #fff3d6; font: 900 12cqi/1 var(--font-display); box-shadow: 0 0 0 1px #ffd27a, 0 0 8px rgb(255 60 30 / .8); }
@container (max-width: 58px) { .unit-mark--seal, .unit.has-venom .unit-aura::after { display: none; } }
/* Narrow hands (phones, short laptops) use the compact card: art on top, the name as a tribe ribbon sized to its length so the longest still reads whole, keywords and gems; the effect text moves to ⓘ. */
.bg-hand .peek { display: none; }
@container (max-width: 110px) {
  .bg-hand .card-face { padding: 5cqi 5cqi 17px; }
  .bg-hand .card .card-name {
    order: 1;
    z-index: 1;
    margin-top: -4cqi;
    padding: 1px 7cqi;
    background: linear-gradient(color-mix(in srgb, var(--tribe) 88%, white), color-mix(in srgb, var(--tribe) 70%, black));
    clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
    color: #fff8e6;
    font-size: clamp(10px, 70cqi / var(--chars, 6), 13px);
    text-align: center;
    text-shadow: 0 1px 0 rgb(0 0 0 / .4);
  }
  .bg-hand .keywords { order: 2; }
  .bg-hand .card-title, .bg-hand .card-text { display: none; }
  .bg-hand .peek { display: grid; }
}

/* motion pieces */
.fx-anchor { position: fixed; z-index: var(--z-fx); visibility: hidden; pointer-events: none; }
.fx-anchor.bg-merge-ghost { z-index: 60; visibility: visible; }
.bg-merge-ghost > * { width: 100% !important; height: 100%; margin: 0 !important; rotate: none !important; translate: none !important; }
.bg-drag-ghost { position: fixed; z-index: 70; margin: 0 !important; rotate: none !important; translate: none !important; pointer-events: none; filter: drop-shadow(0 18px 16px rgb(0 0 0 / .55)); }
.bg-drag-ghost .peek { display: none; }
.is-lifted { opacity: .25; }
.bg-preview { position: fixed; z-index: 45; pointer-events: none; filter: drop-shadow(0 18px 24px rgb(0 0 0 / .6)); }
.bg-preview .card { --card-w: 170px; }
.fx-seal { font: 900 21px/1 var(--font-display); color: var(--gold-hi); text-shadow: 0 1px 0 var(--lacquer-lo); }
.fx-num--venom { font-size: clamp(20px, 2.2vw, 28px); color: #c6ff6a; -webkit-text-stroke-color: #1f3d06; text-shadow: 0 3px 0 #1f3d06, 0 0 16px rgb(140 255 60 / .6); }
.fx-num--power { font-size: 26px; color: #fff0b8; -webkit-text-stroke: 5px #6b3f05; text-shadow: 0 2px 0 #6b3f05, 0 0 16px rgb(255 205 70 / .8); }
.fx-num--gold { font-size: clamp(18px, 2vw, 26px); color: #fff0b8; -webkit-text-stroke: 5px #6b3f05; text-shadow: 0 2px 0 #6b3f05, 0 0 16px rgb(255 205 70 / .8); }
.bg-dmg-orb { display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1c6, #ff7a3d 45%, #b3261e); box-shadow: 0 0 18px 6px rgb(255 110 50 / .8); color: #fff; font: 900 18px/1 var(--font-num); -webkit-text-stroke: 3px #5a0d07; paint-order: stroke fill; }

/* discover */
.bg-modal { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 16px; background: rgb(6 10 22 / .74); backdrop-filter: blur(3px); }
.bg-modal-panel { display: grid; justify-items: center; gap: 10px; width: min(640px, 100%); padding: 22px 20px 26px; border-radius: 20px; background: radial-gradient(120% 60% at 50% 0%, #fffaf0, transparent 70%), linear-gradient(var(--paper), var(--paper-lo)); box-shadow: 0 0 0 4px var(--gold-lo), 0 0 0 9px var(--lacquer), 0 30px 80px rgb(0 0 0 / .7); color: var(--ink); text-align: center; }
.bg-modal-panel h2 { font: 900 30px/1.2 var(--font-display); color: var(--lacquer-lo); letter-spacing: .2em; }
.bg-modal-panel p { color: var(--ink-soft); font-size: 15px; }
.bg-discover-options { display: flex; justify-content: center; gap: clamp(10px, 2vw, 22px); padding-top: 12px; }
.bg-discover-options .card { --card-w: clamp(92px, (100vw - 76px) / 3, 168px); }

/* first-run coach: the street dims around the zone to act on and a paper slip points at it; only 略過 takes taps */
.bg-coach { position: absolute; inset: 0; z-index: 28; overflow: hidden; pointer-events: none; animation: bg-coach-in var(--dur-slow) var(--ease-out) 900ms both; }
.bg-coach-spot {
  position: absolute;
  border-radius: 18px;
  box-shadow: 0 0 0 200vmax rgb(6 10 22 / .52);
  transition: left var(--dur-slow) var(--ease-out), top var(--dur-slow) var(--ease-out), width var(--dur-slow) var(--ease-out), height var(--dur-slow) var(--ease-out);
}
.bg-coach-spot::after { content: ""; position: absolute; inset: 0; border: 3px solid var(--glow-play); border-radius: inherit; box-shadow: 0 0 18px 4px rgb(255 205 70 / .6), inset 0 0 14px rgb(255 205 70 / .35); animation: bg-coach-ring 1.6s ease-in-out infinite; }
.bg-coach-tip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(360px, 100% - 24px);
  padding: 5px 5px 5px 7px;
  border-radius: 14px;
  background: linear-gradient(var(--paper), var(--paper-lo));
  box-shadow: 0 0 0 2px var(--gold-lo), 0 0 0 5px var(--lacquer), 0 14px 30px rgb(0 0 0 / .55);
  color: var(--ink);
  transition: left var(--dur-slow) var(--ease-out), top var(--dur-slow) var(--ease-out);
}
.bg-coach-tip::after { content: ""; position: absolute; left: var(--arrow, 50%); translate: -50% 0; border: 0 solid transparent; }
.bg-coach-tip[data-side="below"]::after { bottom: calc(100% + 4px); border-width: 0 10px 12px; border-bottom-color: var(--lacquer); }
.bg-coach-tip[data-side="above"]::after { top: calc(100% + 4px); border-width: 12px 10px 0; border-top-color: var(--lacquer); }
.bg-coach-tip.is-new { animation: bg-coach-pop var(--dur-slow) var(--ease-out); }
.bg-coach-n { flex: none; display: grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 8px; background: var(--lacquer); color: var(--gold-hi); font: 800 13px/1 var(--font-num); }
.bg-coach-text { font: 800 16px/1.35 var(--font-display); letter-spacing: .02em; }
.bg-coach-skip { flex: none; padding: 0 12px; border-color: rgb(107 74 29 / .45); background: rgb(107 74 29 / .1); color: var(--ink-soft); pointer-events: auto; }
.bg-coach-skip:hover { background: rgb(107 74 29 / .2); border-color: var(--gold-lo); }
@keyframes bg-coach-in { from { opacity: 0; } }
@keyframes bg-coach-ring { 50% { opacity: .5; } }
@keyframes bg-coach-pop { from { opacity: .3; scale: .9; } 60% { scale: 1.04; } }
@media (prefers-reduced-motion: reduce) {
  .bg-coach, .bg-coach-tip.is-new, .bg-coach-spot::after { animation: none; }
  .bg-coach-spot, .bg-coach-tip { transition: none; }
}

/* combat */
.bg-main--fight { justify-content: center; }
.bg-arena { --unit-w: clamp(60px, min((100dvh - 480px) / 2.5, (100vw - 200px) / 7.6), 140px); flex: 1; display: grid; grid-template-rows: auto auto auto auto auto; align-content: center; gap: clamp(6px, 1.6vh, 16px); padding: 14px; }
.bg-arena-hero { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 40px; }
.bg-arena-hero .bg-arena-tier { justify-self: end; grid-column: 1; grid-row: 1; }
.bg-arena-hero .hero { grid-column: 2; grid-row: 1; }
.bg-arena-hero .bg-vs { justify-self: start; grid-column: 3; grid-row: 1; }
.bg-fight > .slot { flex: 0 1 var(--unit-w); width: auto; min-width: 0; }
.bg-arena-hero .hero { --hero-size: clamp(64px, 9.6vh, 88px); }
.bg-arena-tier { display: inline-grid; justify-items: center; padding: 3px 10px; border: 1.5px solid #ffd3e6; border-radius: 8px; background: #1d0a17; color: #ffd9ec; font: 800 12px/1.3 var(--font-display); box-shadow: 0 0 10px rgb(255 95 162 / .45); }
.bg-arena-tier b { font: 900 18px/1 var(--font-num); color: #fff3fa; text-shadow: 0 0 8px var(--neon); }
.bg-vs { padding: 5px 14px; border: 1.5px solid var(--gold); border-radius: 8px; background: linear-gradient(#3d4479, #1d2148); color: #f6e7c1; font: 800 15px/1.3 var(--font-display); box-shadow: 0 8px 16px rgb(0 0 0 / .45); }
.bg-fight { min-height: calc(var(--unit-w) * 1.25); }
.bg-arena-mid { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 48px; }
.bg-arena-mid::before { content: ""; position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: linear-gradient(90deg, transparent, rgb(233 185 91 / .55), transparent); }
.bg-result { position: relative; z-index: 1; grid-column: 2; padding: 0 16px; font: 900 clamp(20px, 3.2vh, 30px)/1.2 var(--font-display); letter-spacing: .08em; color: var(--gold-hi); text-shadow: 0 2px 0 rgb(0 0 0 / .6), 0 0 18px rgb(255 200 80 / .5); background: radial-gradient(closest-side, rgb(14 59 44 / .95), transparent); }
.bg-result:empty { display: none; }
.bg-result[data-outcome="loss"] { color: #ffb3a6; text-shadow: 0 2px 0 rgb(0 0 0 / .6), 0 0 18px rgb(255 80 60 / .5); }
.bg-result[data-outcome="draw"] { color: var(--cream); }
.bg-seal { position: absolute; z-index: 5; left: 50%; top: 50%; translate: -50% -50%; pointer-events: none; }
.bg-seal-mark, .result-seal { display: grid; place-items: center; width: 84px; aspect-ratio: 1; border-radius: 50%; rotate: -8deg; color: #fff3e0; font: 900 48px/1 var(--font-display); text-shadow: 0 3px 0 rgb(0 0 0 / .45); background: radial-gradient(circle at 35% 30%, #e0473b, #b3261e 55%, #6e130d); box-shadow: inset 0 0 0 5px rgb(255 235 200 / .5), 0 0 0 3px #5a0d07, 0 10px 22px rgb(0 0 0 / .55); }
.bg-seal[data-outcome="win"] .bg-seal-mark, .result--win .result-seal { color: var(--gold-hi); }
.bg-seal[data-outcome="loss"] .bg-seal-mark, .result--loss .result-seal { background: radial-gradient(circle at 35% 30%, #5b6482, #343b57 55%, #1b2036); box-shadow: inset 0 0 0 5px rgb(200 210 240 / .35), 0 0 0 3px #0d1020, 0 10px 22px rgb(0 0 0 / .55); }
.bg-seal[data-outcome="draw"] .bg-seal-mark, .result--draw .result-seal { background: radial-gradient(circle at 35% 30%, #4aa383, #1f6b52 55%, #0e3b2c); box-shadow: inset 0 0 0 5px rgb(220 255 235 / .4), 0 0 0 3px #06241a, 0 10px 22px rgb(0 0 0 / .55); }
.bg-seal-n { position: absolute; left: calc(100% + 12px); top: 50%; translate: 0 -62%; min-width: 3.4ch; font: 900 44px/1 var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; color: #ff5a43; -webkit-text-stroke: 7px #3a0905; paint-order: stroke fill; text-shadow: 0 3px 0 #3a0905, 0 0 16px rgb(255 80 40 / .7); }
.bg-seal[data-outcome="win"] .bg-seal-n { color: #fff0b8; -webkit-text-stroke-color: #6b3f05; text-shadow: 0 3px 0 #6b3f05, 0 0 16px rgb(255 205 70 / .8); }
.bg-seal-who { position: absolute; left: calc(100% + 14px); top: 50%; translate: 0 150%; white-space: nowrap; font: 800 14px/1 var(--font-display); color: var(--cream); text-shadow: 0 1px 0 rgb(0 0 0 / .8), 0 0 8px rgb(0 0 0 / .7); }
.bg-dmg-orb.is-heavy { scale: 1.6; }
.bg-skip { grid-column: 3; justify-self: end; z-index: 2; margin-right: 6px; background: rgb(20 12 8 / .7); }
.bg-skip .icon { rotate: 180deg; }
.bg-arena-mid.has-seal .bg-skip { visibility: hidden; }
/* 開市對決 lands on the midline; at this size it fits the gap between the two lines, so it never covers a name plate. */
@media (min-width: 821px) {
  body:has(.bg-arena) #fx-layer > .fx-banner .banner-text { padding: 8px 52px 9px; font-size: 32px; }
}
/* Wide tables seat each hero beside its own line, so both lines get the felt's full height and grow to fit the count they start with (--n, at least 4). */
@media (min-width: 1200px) {
  .bg-arena {
    --unit-w: clamp(96px, min((100dvh - 340px) / 2.5, (min(1400px, 100vw - 24px) - 300px) / (var(--n, 7) + .6)), 200px);
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "hb b" "mid mid" "ha a";
    column-gap: 16px;
  }
  .bg-arena-hero--b { grid-area: hb; }
  .bg-arena-hero--a { grid-area: ha; }
  .bg-fight[data-side="b"] { grid-area: b; }
  .bg-fight[data-side="a"] { grid-area: a; }
  .bg-arena-mid { grid-area: mid; min-height: 64px; }
  .bg-arena-hero { grid-template-columns: auto; justify-items: center; align-content: center; gap: 8px; }
  .bg-arena-hero :is(.bg-arena-tier, .hero, .bg-vs) { grid-column: 1; justify-self: center; }
  .bg-arena-hero .hero { grid-row: 1; }
  .bg-arena-hero .bg-arena-tier { grid-row: 2; }
  .bg-arena-hero .bg-vs { grid-row: 3; text-align: center; }
}

/* hero select */
.bg-pick { position: relative; display: grid; justify-items: center; gap: 22px; width: min(1080px, 100% - 32px); margin: 0 auto; padding: 70px 0 40px; }
.bg-pick > .lanterns { height: 90px; }
.bg-pick-head { position: relative; display: grid; justify-items: center; gap: 8px; text-align: center; }
.bg-pick-head h1 { font: 900 clamp(30px, 5vw, 46px)/1.2 var(--font-display); letter-spacing: .1em; color: var(--gold-hi); text-shadow: 0 3px 0 var(--lacquer-lo), 0 0 24px rgb(255 150 60 / .45); }
.bg-pick-head p { max-width: 34em; font-size: 15px; line-height: 1.7; color: #eadfc5; }
.bg-pick-list { display: grid; grid-template-columns: repeat(3, minmax(0, 270px)); justify-content: center; gap: 24px; width: 100%; margin: 0; padding: 0; list-style: none; }
.bg-hero-pick {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 14px 14px 16px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(170deg, #5a2a17, #2e150a);
  box-shadow: 0 0 0 2px var(--gold-lo), 0 18px 36px rgb(0 0 0 / .5), inset 0 2px 0 rgb(255 220 170 / .2);
  color: var(--cream);
  text-align: center;
  cursor: pointer;
  transition: translate var(--dur-base) var(--ease-out), box-shadow var(--dur-base);
}
.bg-hero-pick:hover, .bg-hero-pick:focus-visible { translate: 0 -6px; box-shadow: 0 0 0 3px var(--gold-hi), 0 0 34px 6px rgb(255 190 70 / .45), 0 24px 40px rgb(0 0 0 / .55); }
.bg-poster { position: relative; width: 100%; padding: 5px; border-radius: 120px 120px 14px 14px / 90px 90px 14px 14px; background: linear-gradient(var(--gold-hi), var(--gold-lo)); }
.bg-poster-art { width: 100%; aspect-ratio: 143 / 170; border-radius: 116px 116px 10px 10px / 86px 86px 10px 10px; }
.bg-poster-hp { position: absolute; right: -6px; bottom: -10px; }
.bg-poster-hp .gem { --gem: 50px; }
.bg-pick-name { margin-top: -16px; padding: 3px 18px; border: 2px solid var(--gold); border-radius: 7px; background: var(--lacquer); color: var(--gold-hi); font: 900 22px/1.3 var(--font-display); letter-spacing: .08em; z-index: 1; }
.bg-pick-title { font: 700 15px/1.4 var(--font-display); color: var(--gold-hi); }
.bg-pick-power { display: grid; gap: 4px; width: 100%; padding: 10px 12px; border-radius: 12px; background: linear-gradient(var(--paper), var(--paper-lo)); color: var(--ink); text-align: left; }
.bg-pick-power-head { display: flex; align-items: center; gap: 8px; }
.bg-pick-power-head strong { font: 900 16px/1.3 var(--font-display); color: var(--lacquer-lo); }
.bg-pick-text { font-size: 14px; line-height: 1.55; color: var(--ink-soft); }
.bg-passive { padding: 1px 8px; border-radius: 6px; background: #3a2450; color: #f0e3ff; font: 700 12px/1.5 var(--font-body); }
.bg-pick-cta { margin-top: 4px; padding: 8px 22px; border-radius: 10px; background: linear-gradient(#ffe7a8, var(--gold) 52%, #c98f33); color: #3a1a06; font: 800 15px/1 var(--font-display); letter-spacing: .1em; box-shadow: 0 3px 0 #85561b; }

/* placement */
.bg-over { position: relative; flex: 1; display: grid; place-items: center; padding: 80px 16px 32px; }
.bg-over > .lanterns { height: 100px; }
.bg-over-panel { position: relative; display: grid; justify-items: center; gap: 8px; width: min(620px, 100%); padding: 30px 24px 26px; border-radius: 24px; background: radial-gradient(120% 60% at 50% 0%, #fffaf0, transparent 70%), linear-gradient(var(--paper), var(--paper-lo)); box-shadow: 0 0 0 4px var(--gold-lo), 0 0 0 10px var(--lacquer), 0 30px 80px rgb(0 0 0 / .7); color: var(--ink); text-align: center; }
.bg-over-hero { position: relative; width: 132px; height: 132px; margin-top: -84px; padding: 6px; border-radius: 50%; background: conic-gradient(from 20deg, var(--gold-hi), var(--gold-lo), var(--gold), var(--gold-lo), var(--gold-hi)); box-shadow: 0 0 0 4px var(--lacquer-lo), 0 16px 30px rgb(0 0 0 / .5); }
.bg-over-art { width: 100%; height: 100%; border-radius: 50%; }
.bg-over-seal { position: absolute; right: -22px; bottom: -6px; display: grid; place-items: center; width: 56px; height: 56px; border: 3px solid #e0473b; border-radius: 12px; background: rgb(255 248 230 / .92); color: #c8281e; font: 900 30px/1 var(--font-display); rotate: 10deg; box-shadow: 0 4px 10px rgb(0 0 0 / .3); }
.bg-over:not(.is-win) .bg-over-seal { border-color: #6d7f78; color: #4a5a54; }
.bg-rank { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; color: var(--lacquer-lo); }
.bg-rank b { font: 900 clamp(72px, 14vw, 104px)/1 var(--font-num); background: linear-gradient(#e9473a, var(--lacquer) 55%, var(--lacquer-lo)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgb(162 115 47 / .6)); }
.bg-rank small { font: 900 26px/1 var(--font-display); }
.bg-over.is-win .bg-rank b { background-image: linear-gradient(#ffd56a, #d0901f 55%, #8a5410); }
.bg-over-verdict { font: 900 20px/1.4 var(--font-display); color: var(--lacquer); }
.bg-over:not(.is-win) .bg-over-verdict { color: var(--ink-soft); }
.bg-over-line { max-width: 28em; font-size: 15px; line-height: 1.6; color: var(--ink-soft); }
.bg-over-board { --unit-w: clamp(42px, 11vw, 66px); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 2px; padding: 12px 10px 10px; border-radius: 16px; background: linear-gradient(var(--felt), var(--felt-deep)); box-shadow: inset 0 0 24px rgb(0 0 0 / .4); }
.bg-over-board .slot { width: var(--unit-w); aspect-ratio: .8; }
.bg-over-board p { color: var(--muted); font-size: 14px; padding: 10px; }
.bg-over-meta { font-size: 13px; color: var(--ink-soft); }
.bg-over-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
.bg-over-actions .button--ghost { color: var(--ink); border-color: var(--gold-lo); }

/* phones and narrow tablets */
@media (max-width: 820px) {
  .bg-stage { gap: 8px; }
  .bg-main { gap: 8px; }
  .bg-tags { gap: 3px; padding: 0; }
  .bg-tags::before { left: -8px; right: -8px; }
  .bg-tag { padding-top: 9px; }
  .bg-tag:nth-child(even) { padding-top: 13px; }
  .bg-tag::before { height: 4px; }
  .bg-tag:nth-child(even)::before { height: 8px; }
  .bg-tag-body { grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: 1px; width: 100%; max-width: 44px; padding: 4px 2px; border-radius: 40% / 24%; }
  .bg-tag-body::before, .bg-tag-body::after { width: 18px; height: 4px; }
  .bg-tag-body::before { top: -3px; }
  .bg-tag-body::after { bottom: -3px; }
  .bg-tag-face { grid-row: auto; width: min(30px, 7.4vw); height: min(30px, 7.4vw); padding: 1.5px; }
  .bg-tag-tier { left: -4px; bottom: -3px; width: 14px; height: 14px; font-size: 9px; }
  .bg-tag-hp { font-size: 13px; }
  .bg-tag-name { display: none; }
  .bg-tag-flag { padding: 0 3px 1px; font-size: 10px; letter-spacing: 0; translate: -50% 5px; }
  .bg-tag-flag::before { height: 5px; }
  .bg-awning { height: 22px; }
  .bg-awning .lanterns > span { width: 12px; }
  .bg-stall-body { grid-template-areas: "tools tier" "shop shop"; grid-template-columns: auto auto; justify-content: space-between; gap: 8px; padding: 24px 8px 22px; }
  .bg-stall-ctl { grid-auto-flow: column; justify-content: start; align-items: center; }
  .bg-stall-ctl--tools { gap: 6px; }
  .bg-stall-ctl--tier { justify-content: end; }
  .bg-stall-ctl--tools .bg-btn::before { height: 12px; }
  .bg-sign { min-width: 0; padding: 2px 8px 3px; }
  .bg-sign b { font-size: 20px; }
  .bg-sign span { font-size: 11px; letter-spacing: .04em; }
  .bg-btn { min-width: 0; min-height: 42px; padding: 0 9px; font-size: 14px; }
  .bg-shop { --unit-w: min(104px, (100vw - 52px) / var(--n, 6) - 10px); grid-column: 1 / -1; min-height: calc(var(--unit-w) * 1.25 + 10px); gap: 10px; }
  .bg-shop::before { left: -4px; right: -4px; height: 22px; }
  .bg-tarp { inset: 0 -2px 4px; }
  .bg-board { --unit-w: min(76px, (100vw - 68px) / 7); min-height: 0; padding: 14px 3px 8px; border-width: 5px; border-radius: 18px; }
  .bg-row { gap: 4px; }
  .bg-board .peek { display: none; }
  .bg-row .unit .gem { --gem: 42cqi; }
  .bg-board .bg-row .unit .gem, .bg-fight .unit .gem { --gem: max(26px, 42cqi); }
  .bg-tray { top: -6px; gap: 4px; padding: 3px 4px; }
  .bg-tray .chip-button { min-height: 40px; padding: 0 10px; font-size: 13px; }
  /* phone boards are one or two short rows: the slip sits wholly above the rim, over the dimmed stall, so no target hides under it */
  .bg-tray--aim { --tray-y: -100%; top: 4px; gap: 8px; padding: 4px 4px 4px 12px; }
  .bg-tray--aim .bg-tray-text { font-size: 15px; }
  .bg-stage[data-pick="aim"] .bg-hand .card.is-selected { translate: 0 -4px; scale: 1; }
  .bg-dock { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "hero purse" "hand hand"; align-items: center; gap: 4px; }
  .bg-hero-dock { grid-area: hero; align-self: center; margin: 10px 0 0; padding: 8px 10px 6px 8px; border-radius: 14px 14px 10px 10px; }
  .bg-hero-dock .hero { --hero-size: 58px; --stick: 56px; width: calc(var(--hero-size) + 24px + var(--stick)); }
  .bg-hero-dock .hero-power { --head: 28px; left: calc(var(--hero-size) + 24px); height: calc(var(--hero-size) + 28px); padding: 0 3px 4px; row-gap: 3px; }
  .screen--bg .chip-speed { min-width: 44px; justify-content: center; }
  .bg-hero-dock .hero-power .gem { --gem: 22px; }
  .bg-hero-dock .hero-power::before { padding: 0 2px; font-size: 10px; }
  .bg-hero-dock .hero-power-name { font-size: 13px; }
  .bg-hero-dock[data-power="used"] .hero-power::after { top: 3px; padding: 1px 5px; font-size: 12px; }
  .bg-purse { grid-area: purse; align-items: center; gap: 10px; padding: 0; }
  .bg-coins { height: 28px; margin-bottom: -7px; }
  .bg-pile { width: 24px; }
  .bg-pile i { bottom: calc(var(--k) * 4px); height: 9px; }
  .bg-tube { width: 62px; padding: 11px 0 7px; }
  .bg-tube b { font-size: 24px; }
  .bg-tube small { font-size: 12px; }
  .bg-gold-label { margin-top: 3px; font-size: 11px; }
  .bg-go { min-width: 112px; min-height: 52px; padding: 0 14px; font-size: 21px; letter-spacing: .08em; }
  .bg-hand { grid-area: hand; }
  .bg-hand-cards { --card-w: 94px; justify-content: safe center; gap: 6px; min-height: calc(var(--card-w) * 1.52 + 22px); padding: 12px 8px 10px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
  .bg-hand .card { margin: 0; rotate: none; translate: none; scroll-snap-align: center; }
  .bg-hand .card:hover, .bg-hand .card:focus-within { rotate: none; translate: 0 -4px; scale: 1; }
  .bg-hand-empty { padding: 26px 0; }
  .bg-arena { --unit-w: 84px; padding: 8px 4px; border-width: 6px; border-radius: 18px; }
  body:has(.screen--bg) #fx-layer > .fx-banner .banner-text { padding: 7px 36px 8px; border-block-width: 2px; font-size: 22px; letter-spacing: .14em; }
  .bg-arena-hero { gap: 16px; }
  .bg-fight { gap: 4px; }
  .bg-arena-hero .hero { --hero-size: 56px; }
  .bg-vs { font-size: 13px; padding: 4px 8px; }
  .bg-skip { margin-right: 2px; padding: 0 10px; }
  .bg-result { padding: 0 6px; font-size: 17px; letter-spacing: .02em; }
  .bg-pick { padding-top: 64px; gap: 16px; }
  .bg-pick-list { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .bg-hero-pick { grid-template-columns: 104px minmax(0, 1fr); grid-template-areas: "poster name" "poster title" "power power" "cta cta"; justify-items: start; align-items: center; column-gap: 14px; row-gap: 4px; padding: 12px; }
  .bg-poster { grid-area: poster; }
  .bg-poster-hp .gem { --gem: 36px; }
  .bg-pick-name { grid-area: name; margin: 0; align-self: end; font-size: 20px; }
  .bg-pick-title { grid-area: title; align-self: start; }
  .bg-pick-power { grid-area: power; }
  .bg-pick-cta { grid-area: cta; justify-self: stretch; text-align: center; }
  .bg-over-hero { width: 108px; height: 108px; margin-top: -70px; }
  .bg-modal { padding: 12px; }
  .bg-modal-panel { padding: 18px 12px 22px; }
  .bg-discover-options { gap: 8px; }
}

@media (max-width: 640px) {
  .bg-guide { order: 3; flex-basis: 100%; }
  .bg-guide strong { font-size: 16px; }
  .bg-guide-msg { font-size: 13px; }
  .bg-chip-label { display: none; }
  .bg-arena-mid { min-height: 64px; }
  .bg-seal-mark { width: 56px; font-size: 32px; }
  .bg-seal-n { left: calc(100% + 8px); font-size: 38px; -webkit-text-stroke-width: 6px; }
  .bg-seal-who { display: none; }
}

@media (max-width: 820px) and (max-height: 700px) {
  .bg-hand-cards { --card-w: 84px; }
}

/* Short laptops give up air above the heroes so a four-line power (頂讓 heroes) still keeps the picks above the fold. */
@media (min-width: 821px) and (max-height: 820px) {
  .bg-pick { gap: 10px; padding: 44px 0 8px; }
  .bg-pick-list { grid-template-columns: repeat(3, minmax(0, 236px)); }
  .bg-pick-power { padding: 8px 12px; }
  .bg-pick-cta { margin-top: 0; }
}

/* phones: the board and both combat lines wrap into rows of 4 + 3 so units and their numbers stay readable; short phones keep one full-bleed row.
   The stall, tags and hand give up the height the board takes; a combat line keeps two rows of room so deaths never shift the arena. */
@media (max-width: 480px) {
  .bg-stage, .bg-main { gap: 6px; }
  .bg-stage { padding-bottom: 6px; }
  .bg-tag { padding-top: 6px; }
  .bg-tag:nth-child(even) { padding-top: 10px; }
  .bg-tag::before { height: 2px; }
  .bg-tag:nth-child(even)::before { height: 6px; }
  .bg-stall-body { padding: 18px 8px 14px; }
  .bg-shop { --unit-w: clamp(44px, (100vw - 52px) / var(--n, 6) - 10px, 76px); }
  .bg-board { --unit-w: clamp(52px, min((100vw - 72px) / 4, (100dvh - 660px) / 2.5), 72px); }
  .bg-board .bg-row { flex-wrap: wrap; row-gap: 6px; max-width: calc(4 * var(--unit-w) + 12px); }
  .bg-hero-dock { margin-top: 2px; padding: 5px 10px 4px 8px; }
  .bg-hand-cards { --card-w: 84px; min-height: calc(var(--card-w) * 1.52 + 10px); padding: 6px 8px 4px; }
  .bg-over { padding: 72px 12px 12px; }
  .bg-arena { --unit-w: clamp(52px, min((100vw - 64px) / 4, (100dvh - 480px) / 5), 76px); grid-template-columns: minmax(0, 1fr); }
  .bg-fight { justify-self: center; flex-wrap: wrap; row-gap: 6px; width: 100%; max-width: calc(4 * var(--unit-w) + 12px); min-height: calc(var(--unit-w) * 2.5 + 6px); }
  .bg-fight[data-side="b"] { align-content: flex-end; }
  .bg-fight[data-side="a"] { align-content: flex-start; }
  .bg-fight > .slot { flex: none; width: var(--unit-w); }
}

/* short phones also hold the guide to one line, so a long hint cannot push the hand below the fold */
@media (max-width: 480px) and (max-height: 799px) {
  .bg-shop { --unit-w: clamp(44px, (100vw - 52px) / var(--n, 6) - 10px, 64px); }
  .bg-board { --unit-w: calc((100vw - 10px) / 7); margin-inline: -12px; padding: 4px 0 3px; border-width: 3px 2px; border-radius: 0; }
  .bg-board .bg-row { flex-wrap: nowrap; max-width: none; gap: 1px; }
  .bg-arena { --unit-w: 72px; margin-inline: -12px; padding: 6px 0; border-width: 3px 2px; border-radius: 0; }
  .bg-fight { flex-wrap: nowrap; max-width: none; gap: 1px; min-height: calc(var(--unit-w) * 1.25); }
  .bg-fight > .slot { flex: 0 1 var(--unit-w); }
  .bg-view > .topbar { row-gap: 4px; padding: 6px 0 4px; }
  .bg-guide { flex-wrap: nowrap; align-items: center; }
  .bg-guide strong { flex: none; }
  .bg-guide-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
