/* ============ Conquest — night-ops theme ============ */
/* Layout: full-bleed dark stage; board in the middle, HUD strip on top, command panel below. */
:root {
  --bg: #07090f;
  --bg-2: #0d111b;
  --panel: rgba(13, 17, 27, .94);
  --panel-2: #151a28;
  --line: #262e44;
  --text: #e9edf6;
  --muted: #8a94ad;
  --ink: #07080d;
  --hot: #ff2e4d;
  --cyan: #3fd8ff;
  --amber: #ffad1f;
  --good: #34e07a;
  --fc: #3fd8ff;
  --display: 'Teko', 'Oswald', 'Arial Narrow', 'Impact', sans-serif;
  --body: 'Barlow Semi Condensed', 'Barlow', 'Arial Narrow', system-ui, sans-serif;
  --dots: radial-gradient(circle, rgba(255, 255, 255, .055) 1px, transparent 1.4px) 0 0 / 6px 6px;
  /* Forged Steel: brushed gunmetal plates with a light top bevel; colour comes from glowing edges. */
  --cut: none;
  --cut-s: none;
  --brushed: repeating-linear-gradient(90deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px);
  --plate: linear-gradient(180deg, #3a404b, #262a32 12%, #1c2027 88%, #12151a);
  --plate-hi: linear-gradient(180deg, #4a515d, #2a2f38 50%, #1e2229);
  --bevel: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -1px 0 rgba(0, 0, 0, .6), 0 0 0 1px #0a0b0e;
  --well: #0b0d11;
  --well-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .08);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  --b: var(--hot);
  position: relative;
  font-family: var(--display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--b) 85%, #fff), var(--b) 55%, color-mix(in srgb, var(--b) 70%, #000));
  border: 0;
  clip-path: var(--cut-s);
  padding: 10px 18px 7px;
  cursor: pointer;
  transition: transform .12s ease, filter .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .45);
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%) -150% 0 / 200% 100% no-repeat;
  transition: background-position .5s ease;
  pointer-events: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.12) drop-shadow(0 0 10px color-mix(in srgb, var(--b) 60%, transparent)); }
.btn:hover:not(:disabled)::after { background-position: 150% 0; }
.btn:active:not(:disabled) { transform: translateY(2px) scale(.98); }
.btn:disabled { filter: grayscale(.85) brightness(.6); cursor: not-allowed; }
.btn-big { font-size: 32px; padding: 12px 34px 8px; }
.btn-alt { --b: #1597c9; }
.btn-hot { --b: #d97c0a; }
.btn-ghost {
  --b: #2a3247;
  background: linear-gradient(180deg, #1d2335, #131827);
  box-shadow: inset 0 0 0 1px #34405e;
  color: #cfd7ea;
}
.btn-icon {
  width: 42px; height: 42px; padding: 0; font-family: var(--body); font-weight: 700; font-size: 22px; letter-spacing: 0;
  --b: #2a3247; background: linear-gradient(180deg, #1d2335, #131827); box-shadow: inset 0 0 0 1px #34405e; color: #cfd7ea;
}
.btn .cost {
  font-family: var(--display); font-size: 17px; letter-spacing: .04em;
  background: rgba(0, 0, 0, .35); padding: 2px 6px 0; clip-path: var(--cut-s);
}

.caption {
  display: inline-block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--fc);
  margin: 0;
  padding: 6px 14px 3px 12px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fc) 22%, transparent), transparent);
  border-left: 3px solid var(--fc);
}
.panel-frame {
  background: var(--panel);
  background-image: var(--dots);
  box-shadow: inset 0 0 0 1px var(--line);
  clip-path: var(--cut);
}

/* ---------- game layout ---------- */
#app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "top" "board" "panel";
}
#topbar { grid-area: top; }
#zoom-ctrls, #toasts { grid-area: board; }
/* The board runs under the panel, so a taller or shorter panel never resizes (and redraws) the board. */
#viewport { grid-row: 2 / 4; grid-column: 1; }
#panel { grid-area: panel; }
#app.hidden-board #viewport, #app.hidden-board #panel { visibility: hidden; }

#topbar {
  z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, #0c0f19, #090b12);
  border-bottom: 2px solid var(--fc);
  box-shadow: 0 0 24px -4px var(--fc);
  transition: border-color .4s, box-shadow .4s;
}
.hud-player { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1; letter-spacing: .06em; text-transform: uppercase; min-width: 0; }
.hud-player span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; padding-top: 4px; text-shadow: 0 0 14px var(--fc); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: flex; align-items: center; gap: 5px;
  background: #121725;
  box-shadow: inset 0 0 0 1px var(--line);
  clip-path: var(--cut-s);
  padding: 3px 12px 2px 8px;
  font-size: 14px;
}
.pill b { font-family: var(--display); font-weight: 500; font-size: 24px; line-height: 1; padding-top: 3px; font-variant-numeric: tabular-nums; }
.pill small { font-size: 13px; color: var(--good); }
.pill.turn { font-family: var(--display); font-size: 20px; letter-spacing: .12em; text-transform: uppercase; padding: 5px 12px 2px; color: var(--muted); }
.pill.bump { animation: bump .45s cubic-bezier(.3, 1.6, .5, 1); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.btn-end { --b: var(--fc); font-size: 24px; }
.btn-end.pulse { animation: endPulse 1.4s ease-in-out infinite; }

@media (max-width: 640px) {
  #topbar { gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .hud-player { font-size: 24px; }
  .pills { order: 3; width: 100%; justify-content: space-between; }
  .pill { padding: 2px 9px 1px 6px; }
  .pill b { font-size: 21px; }
  .btn-end { font-size: 21px; padding: 8px 12px 5px; }
  .btn-icon { width: 38px; height: 38px; }
}

/* ---------- board ---------- */
#viewport {
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(63, 216, 255, .07), transparent 60%),
    var(--dots),
    radial-gradient(ellipse at 50% 40%, #141a2c 0%, #0a0d17 55%, #05060b 100%);
}
#viewport::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background:
    radial-gradient(ellipse 75% 70% at 50% 48%, transparent 50%, rgba(2, 3, 8, .5) 80%, rgba(2, 3, 8, .88) 100%),
    linear-gradient(180deg, rgba(2, 3, 8, .35), transparent 14%, transparent 86%, rgba(2, 3, 8, .4));
}
/* drifting motes of light over the board (screen space, under the vignette) */

/* Moving tile parts are separate SVGs that animate only opacity and transform, so they run on the GPU. */

.terr-fill { opacity: .2; }
.terr-edge { filter: drop-shadow(0 0 4px rgba(255, 255, 255, .35)); }

.spark { animation: twinkle 1.6s ease-in-out infinite; }
.flag { animation: flagWave 1.8s ease-in-out infinite; }
.beacon { animation: blink 1.4s steps(2, end) infinite; }
.glow-eye { animation: flicker 2.6s ease-in-out infinite; }
.capital-star { animation: spinStar 6s linear infinite; transform-origin: 98px 26px; transform-box: view-box; }

.c-name {
  position: absolute; pointer-events: none;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px;
  font-family: var(--display); font-weight: 500; font-size: 16px; line-height: 1; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  color: #dfe5f2;
  background: rgba(8, 10, 17, .88);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fc) 55%, transparent);
  clip-path: var(--cut-s);
  padding: 2px 8px 0 2px;
}
.c-name .lvl {
  display: inline-grid; place-items: center;
  width: 17px; height: 17px; margin-bottom: 2px;
  background: var(--fc); color: #05060b;
  font-size: 15px; padding-top: 2px;
}
.c-name.neutral { color: #a7afc0; }

/* units */

/* Only a hero's painted shapes take taps, so big sprites don't block the heroes and tiles around them. */

/* marks & labels */

.tag {
  position: absolute; transform: translate(-50%, -100%);
  font-family: var(--display); font-weight: 600; font-size: 24px; line-height: 1; letter-spacing: .04em;
  color: #fff; background: rgba(8, 10, 17, .92);
  box-shadow: inset 0 0 0 1.5px var(--hot);
  clip-path: var(--cut-s);
  padding: 4px 9px 1px;
  animation: tagBounce 1s ease-in-out infinite;
}
.tag small { font-size: 16px; margin-left: 5px; color: #ffb3bf; }
.tag.kills { background: var(--hot); color: #fff; letter-spacing: .1em; }

/* ---------- effects ---------- */
.fx-burst {
  position: absolute; width: 120px; height: 120px;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  animation: burstIn 1s cubic-bezier(.3, 1.6, .5, 1) forwards;
}
.fx-burst.big { width: 170px; height: 170px; }
.fx-burst svg { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 0 10px var(--c)); }
.fx-burst .flash { animation: flash .35s ease-out forwards; transform-box: fill-box; transform-origin: center; }
.fx-burst span {
  position: relative;
  font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1; letter-spacing: .04em; color: #fff;
  text-shadow: 0 0 10px var(--c), 0 0 2px var(--c), 2px 2px 0 #000;
  transform: rotate(-8deg) skewX(-10deg);
  white-space: nowrap;
}
.fx-burst.big span { font-size: 42px; }
.fx-float {
  position: absolute; transform: translate(-50%, 0);
  font-family: var(--display); font-weight: 700; font-size: 38px; line-height: 1; color: #fff;
  text-shadow: 0 0 8px currentColor, 2px 2px 0 #000;
  animation: floatUp 1.3s cubic-bezier(.2, .8, .3, 1) forwards; white-space: nowrap;
}
.fx-float.dmg { color: #ff4d64; }
.fx-float.energy { color: var(--cyan); }
.fx-float.lvl { color: var(--amber); font-size: 40px; letter-spacing: .08em; }

/* ---------- command panel ---------- */
#panel {
  z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  min-height: 96px;
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left, 0px));
  background: var(--dots), linear-gradient(180deg, #10141f, #0a0d15);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--fc) 40%, transparent), 0 -18px 30px rgba(0, 0, 0, .45);
}
/* A new selection slides in; it never starts invisible, so the panel doesn't blank between taps. */
#panel.swap > * { animation: panelSwap .18s ease-out both; }
.p-hint { font-size: 16px; line-height: 1.4; color: #c4ccdd; max-width: 70ch; }
.p-hint b { font-family: var(--display); font-weight: 600; font-size: 24px; letter-spacing: .1em; text-transform: uppercase; color: var(--fc); margin-right: 6px; }
.p-portrait {
  flex: none; width: 78px; height: 78px;
  clip-path: var(--cut-s);
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--fc, #3fd8ff) 45%, transparent), transparent 70%),
    var(--dots),
    #0d111c;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fc, #3fd8ff) 60%, transparent);
  padding: 5px; display: grid; place-items: center; overflow: hidden;
}
.p-portrait .sprite { width: 100%; height: 100%; }
.sprite.portrait { object-fit: contain; display: block; }
.tile-portrait { --fc: #4c6a8a; position: relative; }
.tile-portrait > svg { width: 90%; height: auto; }
.tp-res { position: absolute; width: 36px; height: 36px; left: 50%; top: 40%; transform: translate(-50%, -50%); }
.p-info { flex: 1 1 180px; min-width: 0; }
.p-title { font-family: var(--display); font-weight: 600; font-size: 30px; line-height: .95; letter-spacing: .06em; text-transform: uppercase; padding-top: 3px; }
.p-title small { font-family: var(--body); font-weight: 600; font-size: 13px; letter-spacing: .12em; color: var(--muted); margin-left: 6px; }
.p-sub { font-size: 14px; margin-top: 4px; color: #aab3c8; }
.hpbar { position: relative; height: 14px; margin-top: 6px; background: #05060b; box-shadow: inset 0 0 0 1px #2c3550; max-width: 240px; transform: skewX(-12deg); }
.hpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #1fb862, #4dffa0); box-shadow: 0 0 10px rgba(52, 224, 122, .6); }
.hpbar span { position: relative; display: block; text-align: center; font-size: 12px; font-weight: 700; color: #fff; line-height: 14px; transform: skewX(12deg); text-shadow: 0 1px 2px #000; }
.stats { display: flex; gap: 14px; font-size: 14px; margin-top: 5px; color: #c9d1e3; font-variant-numeric: tabular-nums; }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.train-row { flex: 1 1 100%; }
.btn-train {
  --b: #1a2032;
  flex-direction: column; gap: 2px; padding: 6px 12px 6px; font-size: 18px;
  background: linear-gradient(180deg, #1c2335, #121726);
  box-shadow: inset 0 0 0 1px #33405f;
}
.btn-train .bt-art { width: 42px; height: 42px; display: block; }
.btn-train .bt-art .sprite { width: 100%; height: 100%; }
.btn-grow { --b: #1597c9; align-self: stretch; }
.reason { font-size: 13px; color: #ff8396; flex-basis: 100%; }

@media (min-width: 900px) {
  .train-row { flex: 0 1 auto; }
}

/* ---------- zoom + toasts ---------- */
#zoom-ctrls { z-index: 7; align-self: start; justify-self: end; display: flex; flex-direction: column; gap: 8px; margin: 10px max(10px, env(safe-area-inset-right, 0px)) 10px 10px; }
#zoom-ctrls .btn { --b: #1a2032; background: rgba(16, 20, 32, .85); box-shadow: inset 0 0 0 1px #33405f; color: #cfd7ea; }
#toasts { z-index: 8; align-self: start; justify-self: center; display: flex; flex-direction: column; gap: 6px; margin-top: 12px; pointer-events: none; max-width: 90vw; }
.toast {
  font-size: 15px; color: var(--text);
  background: rgba(10, 13, 21, .92);
  box-shadow: inset 3px 0 0 var(--fc), inset 0 0 0 1px var(--line);
  clip-path: var(--cut-s);
  padding: 8px 16px 8px 18px; text-align: center;
  animation: toastIn .4s cubic-bezier(.3, 1.4, .5, 1) both;
}
.toast b { color: #fff; }
.toast.big { font-family: var(--display); font-size: 26px; line-height: 1; letter-spacing: .08em; text-transform: uppercase; padding: 10px 18px 6px 20px; box-shadow: inset 3px 0 0 var(--hot), inset 0 0 0 1px var(--line); }
.toast.error { box-shadow: inset 3px 0 0 var(--hot), inset 0 0 0 1px #4a2030; color: #ffc2cc; }
.toast.income { color: #cfd7ea; }
.toast.out { animation: toastOut .5s ease-in forwards; }

/* ---------- screens & overlays ---------- */
.screen, .overlay { position: fixed; inset: 0; z-index: 50; overflow: auto; }
/* The steel stage behind menus and overlays: brushed gunmetal, a glow in the screen's colour and a beam of light
   from above onto the hero. Static gradients only, so it costs nothing per frame on low-end phones. */
.stage, .handoff {
  --beam: color-mix(in srgb, var(--fc) 30%, transparent);
  background:
    radial-gradient(ellipse 80% 45% at 50% 36%, color-mix(in srgb, var(--fc) 22%, transparent), transparent 70%),
    var(--brushed),
    linear-gradient(180deg, #1b1f27, #0b0d12 60%, #07080b);
}
.stage { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.stage::before, .handoff::before {
  content: ''; position: absolute; left: 50%; top: 0; width: min(560px, 120vw); height: 70%; transform: translateX(-50%);
  background: linear-gradient(180deg, var(--beam), transparent 85%);
  clip-path: polygon(40% 0, 60% 0, 100% 100%, 0 100%);
  pointer-events: none;
}
.title-screen .stage, .setup-screen .stage { --fc: var(--cyan); }
.setup-screen .stage::before { display: none; }

.title-screen { display: grid; text-align: center; isolation: isolate; }
.title-inner { margin: auto; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.logo { margin: 0; display: flex; flex-direction: column; align-items: center; line-height: .8; font-family: var(--display); font-weight: 700; text-transform: uppercase; }
.logo .logo-main {
  font-size: clamp(76px, 20vw, 168px); letter-spacing: .02em; font-style: italic; padding: 0 .08em;
  background: linear-gradient(180deg, #ffffff 0%, #dfe6f3 45%, #8d9ab5 52%, #e9eef8 60%, #ffffff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 46, 77, .45)) drop-shadow(0 4px 0 #000);
  transform: skewX(-8deg);
  animation: slamIn .7s .2s cubic-bezier(.3, 1.6, .5, 1) both;
}
.logo::after {
  content: ''; display: block; width: 70%; height: 4px; margin-top: 4px;
  background: linear-gradient(90deg, transparent, var(--hot), var(--cyan), transparent);
  box-shadow: 0 0 16px var(--hot);
  transform: skewX(-30deg);
  animation: fadeUp .6s .5s both;
}
.tagline { margin: 0; font-size: 15px; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); animation: fadeUp .5s .5s both; }
.title-heroes { display: flex; gap: 10px; align-items: flex-end; justify-content: center; height: 160px; }
.title-hero { width: 116px; height: 126px; animation: heroIn .7s cubic-bezier(.3, 1.5, .5, 1) both, float 3.4s ease-in-out infinite; animation-delay: calc(.6s + var(--i) * .15s), calc(var(--i) * -1s); }
.title-hero.f-stormmane { width: 170px; height: 144px; }
.title-hero.f-titan { width: 130px; height: 136px; }
.title-hero .sprite { width: 100%; height: 100%; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .45)); }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; animation: fadeUp .5s .9s both; }

.setup-screen { display: grid; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); isolation: isolate; }
.setup-inner { margin: auto; width: min(760px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 16px; animation: panelIn .45s cubic-bezier(.3, 1.4, .5, 1) both; }
.count-picker { display: flex; gap: 8px; }
.chip {
  font-family: var(--display); font-weight: 500; font-size: 22px; line-height: 1; letter-spacing: .1em; text-transform: uppercase;
  padding: 8px 18px 5px; cursor: pointer; border: 0; color: var(--muted);
  background: #121725; box-shadow: inset 0 0 0 1px var(--line); clip-path: var(--cut-s);
  transition: color .15s, background .15s;
}
.chip.on { color: #fff; background: linear-gradient(180deg, #ff4d66, #c3132f); box-shadow: none; }
.player-cards { display: flex; flex-direction: column; gap: 12px; }
.player-card {
  display: flex; gap: 14px; align-items: stretch;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fc) 14%, #0f131e), #0f131e 55%);
  box-shadow: inset 3px 0 0 var(--fc), inset 0 0 0 1px var(--line);
  clip-path: var(--cut-s);
  padding: 12px; animation: cardIn .45s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(var(--i) * .08s);
}
.pc-art { flex: none; width: 108px; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--fc) 45%, transparent), transparent 70%), #080a12; clip-path: var(--cut-s); display: grid; place-items: center; padding: 4px; }
.pc-art .sprite { width: 100%; height: 88px; animation: float 3s ease-in-out infinite; }
.pc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.pc-label { font-family: var(--display); font-weight: 600; font-size: 20px; line-height: 1; letter-spacing: .16em; text-transform: uppercase; color: var(--fc); }
.pc-random { margin-left: 10px; font-size: 12px; letter-spacing: .1em; color: #fff; padding: 2px 8px 2px 22px; border-radius: 10px; background: #1a1f2e; position: relative; vertical-align: middle; }
.pc-random::before { content: ''; position: absolute; left: 6px; top: 50%; width: 11px; height: 11px; margin-top: -5.5px; border-radius: 50%; background: conic-gradient(#a35bff, #ff4fd8, #19e3c8, #c8f03c, #a35bff); }
.pc-name {
  font: inherit; font-size: 18px; font-weight: 600; color: var(--text);
  padding: 8px 12px; border: 0; background: #070910; box-shadow: inset 0 0 0 1px #2c3550;
  width: 100%; user-select: text; -webkit-user-select: text;
}
.pc-name::placeholder { color: #59627a; }
.pc-name:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--fc), 0 0 12px color-mix(in srgb, var(--fc) 40%, transparent); }
.pc-factions { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 4px; font-size: 14px; font-weight: 600; color: var(--muted);
  background: #0a0d16; border: 0; box-shadow: inset 0 0 0 1px var(--line); clip-path: var(--cut-s); cursor: pointer;
  transition: color .15s, background .15s;
}
.fchip.on { color: #fff; background: color-mix(in srgb, var(--fc) 30%, #0a0d16); box-shadow: inset 0 0 0 1.5px var(--fc); }
.setup-actions { display: flex; justify-content: space-between; align-items: center; }
@media (max-width: 520px) {
  .pc-art { width: 78px; }
  .pc-art .sprite { height: 64px; }
  .fchip span { font-size: 12px; }
}

/* hand-off */
.handoff {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; padding: 16px;
}
.ho-panel { position: relative; }
.ho-left { width: min(320px, 42vw); height: min(340px, 52vh); display: grid; place-items: center; z-index: 1; }
.ho-left #ho-art { width: 100%; height: 100%; display: grid; place-items: center; }
.ho-hero { width: 100%; height: 100%; animation: float 2.8s ease-in-out infinite; }
.ho-hero .sprite { width: 100%; height: 100%; filter: drop-shadow(0 0 24px color-mix(in srgb, var(--fc) 50%, transparent)); }
.ho-right {
  padding: 28px 34px 26px 30px;
  background: rgba(8, 10, 17, .82);
  box-shadow: inset 3px 0 0 var(--fc), inset 0 0 0 1px var(--line);
  clip-path: var(--cut);
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 60vw;
}
.ho-name {
  font-family: var(--display); font-weight: 700; font-size: clamp(54px, 11vw, 104px); line-height: .82; letter-spacing: .02em; text-transform: uppercase; font-style: italic;
  color: #fff; text-shadow: 0 0 24px var(--fc), 0 3px 0 #000;
  word-break: break-word; padding-top: 8px;
}
.ho-faction { display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: #cfd7ea; }
.ho-pass { margin: 0; font-size: 14px; color: var(--muted); }
.ho-go { --b: var(--fc); animation: endPulse 1.4s ease-in-out infinite; }
.ho-menu { font-size: 18px; padding: 7px 14px 4px; }
.handoff.enter .ho-left { animation: slideL .55s cubic-bezier(.3, 1.2, .5, 1) both; }
.handoff.enter .ho-right { animation: slideR .55s .08s cubic-bezier(.3, 1.2, .5, 1) both; }
.handoff.enter .ho-name { animation: slamIn .6s .3s cubic-bezier(.3, 1.6, .5, 1) both; }
@media (max-width: 640px) {
  .handoff { flex-direction: column; }
  .ho-left { width: 72vw; height: 32vh; }
  .ho-right { max-width: 92vw; padding: 24px 20px 20px; align-items: center; text-align: center; }
}

/* victory */
.victory { display: grid; isolation: isolate; text-align: center; }
.vic-inner { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 20px; }
#vic-art { width: 240px; height: 240px; display: grid; place-items: center; animation: heroIn .8s cubic-bezier(.3, 1.5, .5, 1) both; }
#vic-art > * { grid-area: 1 / 1; }
.vic-hero { width: 100%; height: 100%; animation: float 2.4s ease-in-out infinite; }
.vic-hero .sprite { width: 100%; height: 100%; filter: drop-shadow(0 0 26px color-mix(in srgb, var(--fc) 50%, transparent)); }
.vic-name {
  margin: 0; font-family: var(--display); font-weight: 700; font-style: italic; text-transform: uppercase;
  font-size: clamp(56px, 13vw, 120px); line-height: .85; letter-spacing: .02em;
  color: #fff; text-shadow: 0 0 30px var(--fc), 0 4px 0 #000;
  animation: slamIn .7s .2s cubic-bezier(.3, 1.6, .5, 1) both;
}

/* help */
.help { display: grid; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); background: rgba(3, 4, 8, .78); backdrop-filter: blur(4px); z-index: 60; }
.help-inner { margin: auto; max-width: 640px; padding: 24px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; animation: panelIn .35s cubic-bezier(.3, 1.4, .5, 1) both; }
.help-inner ul { margin: 0; padding-left: 20px; font-size: 16px; line-height: 1.5; color: #c4ccdd; display: flex; flex-direction: column; gap: 6px; }
.help-inner b { color: #fff; }
.help-inner .btn { align-self: center; }

/* saved games (title screen) */
.saved-games { width: min(580px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 10px; animation: fadeUp .5s 1s both; text-align: left; }
.saved-games .caption { align-self: flex-start; }
.saved-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.saved-game {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center;
  padding: 12px 14px;
  background: rgba(12, 15, 25, .9);
  box-shadow: inset 0 0 0 1px var(--line);
  clip-path: var(--cut-s);
  transition: box-shadow .15s;
}
.saved-game:hover { box-shadow: inset 0 0 0 1px #3d4a6e, inset 3px 0 0 var(--cyan); }
.sg-players { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.sg-player { display: inline-flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 700; }
.sg-player span { color: #fff; overflow-wrap: anywhere; }
.sg-player.out { opacity: .45; }
.sg-player.out span { text-decoration: line-through; }
.sg-vs { font-family: var(--display); font-size: 17px; color: var(--hot); letter-spacing: .1em; padding-top: 2px; }
.sg-meta { grid-column: 1; font-size: 14px; color: var(--muted); }
.sg-meta b { color: #dfe5f2; }
.sg-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 6px; }
.sg-actions .btn { font-size: 21px; padding: 8px 16px 5px; }
.sg-actions .sg-del { font-size: 15px; padding: 5px 10px 3px; }
.saved-game.confirm .sg-del { background: linear-gradient(180deg, #ff4d66, #c3132f); color: #fff; box-shadow: none; }
@media (max-width: 480px) {
  .saved-game { grid-template-columns: 1fr; }
  .sg-actions { grid-column: 1; grid-row: auto; flex-direction: row; }
}
@media (max-width: 420px) {
  .title-heroes { height: 110px; gap: 2px; }
  .title-hero { width: 70px; height: 84px; }
  .title-hero.f-stormmane { width: 112px; height: 96px; }
  .title-hero.f-titan { width: 82px; height: 92px; }
}

/* ---------- keyframes ---------- */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hoof {
  0%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-3px) rotate(-1.5deg); }
  28% { transform: translateY(0) rotate(0); }
  55% { transform: translateY(-2px) rotate(1deg); }
  62% { transform: translateY(0) rotate(0); }
}
@keyframes flap { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-14deg); } }
@keyframes sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-10deg); } }
@keyframes orb { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.25); opacity: 1; } }
@keyframes dash { to { stroke-dashoffset: -32; } }

@keyframes shimmer { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes tagBounce { 0%, 100% { transform: translate(-50%, -100%); } 50% { transform: translate(-50%, -110%); } }

@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes flagWave { 0%, 100% { transform: skewY(0) scaleX(1); } 50% { transform: skewY(-6deg) scaleX(.92); } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: .75; } 50% { opacity: 1; } 52% { opacity: .5; } 55% { opacity: 1; } }
@keyframes spinStar { to { transform: rotate(360deg); } }

@keyframes burstIn {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-25deg); opacity: 1; }
  22% { transform: translate(-50%, -50%) scale(1.15) rotate(4deg); }
  38% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1.08); opacity: 0; }
}
@keyframes flash { from { opacity: 1; transform: scale(.6); } to { opacity: 0; transform: scale(2.4); } }
@keyframes floatUp { 0% { transform: translate(-50%, 10px) scale(.4); opacity: 0; } 20% { transform: translate(-50%, -6px) scale(1.2); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -60px) scale(1); opacity: 0; } }

@keyframes endPulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.25) drop-shadow(0 0 12px var(--b)); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); filter: brightness(1.5); } 100% { transform: scale(1); } }
@keyframes panelSwap { from { opacity: .55; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scaleX(.6); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }
@keyframes slamIn { 0% { opacity: 0; transform: scale(2.2) skewX(-8deg); filter: blur(6px); } 60% { opacity: 1; transform: scale(.96) skewX(-8deg); filter: none; } 100% { transform: scale(1) skewX(-8deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; } }
@keyframes heroIn { from { opacity: 0; transform: translateY(50px) scale(.7); filter: brightness(3); } to { opacity: 1; transform: none; filter: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
@keyframes slideL { from { transform: translateX(-120vw); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideR { from { transform: translateX(120vw); opacity: 0; } to { transform: none; opacity: 1; } }

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

/* ability chips on the unit panel (passives and attack type, from the rules catalog) */
.traits { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-right: 6px; vertical-align: middle; }
.trait {
  font-family: var(--display); font-weight: 500; font-size: 15px; line-height: 1; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fc, var(--cyan)); padding: 3px 7px 1px;
  background: color-mix(in srgb, var(--fc, var(--cyan)) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fc, var(--cyan)) 45%, transparent);
  clip-path: var(--cut-s);
}
.p-title small { text-transform: uppercase; }

/* ---------- 3D board (one WebGL canvas, HTML labels on top) ---------- */
.b3-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.b3-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.b3-anchor { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.b3-anchor > .c-name, .b3-anchor > .fx-float { left: 0; top: 0; }
.b3-anchor > .tag { left: 0; top: 0; }
.b3-anchor > .fx-burst { left: 0; top: 0; }
.b3-hp {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%) skewX(-12deg);
  width: 46px; height: 9px; background: rgba(5, 6, 11, .85); box-shadow: 0 0 0 1px rgba(255, 255, 255, .18);
}
.b3-hp i { position: absolute; inset: 0 auto 0 0; }
.b3-hp b {
  position: absolute; left: 100%; top: -4px; margin-left: 4px; transform: skewX(12deg);
  font: 700 13px/1 var(--display); color: #fff; text-shadow: 0 1px 2px #000;
}

/* ============ Forged Steel finish ============
   Buttons, panels and fields as brushed-metal plates. A button's colour (--b) is a glowing strip along its
   bottom edge; heroes stand on a glowing ring like the one under units on the board. */
.btn {
  background: var(--plate-hi);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 0 1px #0a0b0e, inset 0 -3px 0 var(--b), 0 0 18px -4px var(--b);
}
.btn::after { border-radius: inherit; }
.btn-ghost, .btn-icon, #zoom-ctrls .btn {
  background: var(--plate);
  box-shadow: var(--bevel);
  color: #c9d0dc;
}
.btn-train { background: var(--plate); box-shadow: var(--bevel); }
.btn .cost { border-radius: 3px; }

.caption {
  color: #e6eaf1;
  border-left-color: var(--fc);
  background: linear-gradient(90deg, color-mix(in srgb, var(--fc) 18%, transparent), transparent);
}
.panel-frame, .ho-right, .saved-game, .player-card {
  background: var(--brushed), var(--plate);
  box-shadow: var(--bevel), 0 10px 26px rgba(0, 0, 0, .5);
  border-radius: 10px;
}
.player-card, .saved-game { border-radius: 8px; }
.player-card { border-left: 3px solid var(--fc); }
.ho-right { border-left: 3px solid var(--fc); }
.saved-game:hover { box-shadow: var(--bevel), inset 3px 0 0 var(--cyan); }

/* fields and insets are wells sunk into the plate */
.pc-name { background: var(--well); box-shadow: var(--well-shadow); border-radius: 4px; }
.pc-art, .p-portrait {
  background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--fc, var(--cyan)) 38%, transparent), transparent 65%), var(--well);
  box-shadow: var(--well-shadow);
  border-radius: 6px;
}
.pill { background: var(--well); box-shadow: var(--well-shadow); border-radius: 5px; }
.hpbar, .b3-hp { border-radius: 2px; }

.chip { background: var(--plate); box-shadow: var(--bevel); border-radius: 6px; color: #9aa3b4; }
.chip.on { background: var(--plate-hi); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 0 1px #0a0b0e, inset 0 -3px 0 var(--hot), 0 0 16px -4px var(--hot); }
.fchip { background: var(--plate); box-shadow: var(--bevel); border-radius: 5px; color: #b8c0cd; }
.fchip.on { background: var(--plate-hi); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 0 1px var(--fc), 0 0 10px color-mix(in srgb, var(--fc) 70%, transparent); }
.trait, .c-name, .tag, .toast { border-radius: 4px; }
.toast { background: var(--brushed), var(--plate); }

/* HUD strip and command panel: dark steel with the player's colour as an edge light */
#topbar { background: var(--brushed), linear-gradient(180deg, #2a2f38, #15181e); }
#panel { background: var(--brushed), linear-gradient(180deg, #23272f, #121419); border-top-color: #3a404b; }

/* the logo: polished chrome */
.logo .logo-main {
  background: linear-gradient(180deg, #fff 0%, #d9dee6 38%, #6f7784 52%, #c9cfd8 64%, #f4f6f9 100%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 2px 0 #2a2f38) drop-shadow(0 0 18px rgba(63, 216, 255, .3));
}
.logo::after { background: linear-gradient(90deg, transparent, #8b93a1, var(--cyan), #8b93a1, transparent); box-shadow: 0 0 14px var(--cyan); }

/* the glowing ring heroes stand on */
.pedestal { position: relative; }
.pedestal::after {
  content: ''; position: absolute; left: 50%; bottom: 3%; width: 70%; height: 11%; transform: translateX(-50%); z-index: -1;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, .65), transparent 70%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--fc) 80%, #fff), 0 0 18px 3px var(--fc);
}
.title-hero, .ho-hero, .vic-hero { isolation: isolate; }
.title-hero .sprite, .ho-hero .sprite, .vic-hero .sprite { filter: drop-shadow(0 12px 12px rgba(0, 0, 0, .55)); }

/* hero sizes on the menus: pictures keep their own shape, so only the height is set */
.sprite.portrait { width: auto; max-width: 100%; height: 100%; margin: 0 auto; object-position: 50% 100%; }
.title-heroes { height: 170px; gap: 6px; }
.title-hero, .title-hero.f-stormmane, .title-hero.f-titan { width: auto; height: 160px; display: flex; justify-content: center; }
.title-hero.f-stormmane { height: 150px; }
.pc-art { width: 104px; place-items: end center; padding-bottom: 10px; }
.pc-art .sprite.portrait { height: 120px; width: auto; animation: none; }
.handoff { flex-direction: column; gap: 0; }
.ho-left { width: min(420px, 90vw); height: min(380px, 44vh); }
.ho-hero { display: flex; justify-content: center; align-items: flex-end; }
.ho-right { max-width: min(520px, 92vw); width: 100%; align-items: center; text-align: center; margin-top: -6px; }
#vic-art { width: min(440px, 94vw); height: min(300px, 40vh); display: flex; align-items: flex-end; justify-content: center; }
#vic-art > * { grid-area: auto; }
.vic-hero { height: 68%; flex: 0 1 auto; display: flex; justify-content: center; }
.vic-hero.warrior { height: 100%; z-index: 1; margin: 0 -9%; }
.vic-hero:not(.warrior) .sprite { filter: drop-shadow(0 12px 12px rgba(0, 0, 0, .55)) brightness(.8); }
@media (max-width: 420px) {
  .title-heroes { height: 128px; gap: 0; }
  .title-hero, .title-hero.f-stormmane, .title-hero.f-titan { width: auto; height: 120px; }
  .title-hero.f-stormmane { height: 112px; }
  .pc-art { width: 92px; }
  .pc-art .sprite.portrait { height: 132px; }
}
#btn-victory-new { --b: var(--fc); }
/* ---------- beta: version line, gate, feedback, invite ---------- */
.app-version { margin: 8px 0 0; font-size: 13px; letter-spacing: .04em; color: var(--muted); text-align: center; animation: fadeUp .5s 1.1s both; }
.app-version b { color: var(--text); font-weight: 600; }
.beta-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.beta-buttons .btn { font-size: 20px; }
.beta-overlay { display: grid; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); background: rgba(3, 4, 8, .82); backdrop-filter: blur(4px); z-index: 70; }
.beta-gate { background: var(--bg); background-image: var(--dots); z-index: 80; }
.beta-inner { margin: auto; width: min(460px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; animation: panelIn .35s cubic-bezier(.3, 1.4, .5, 1) both; }
.beta-inner .logo { margin: 0 auto 4px; }
.beta-inner .logo .logo-main { font-size: clamp(54px, 15vw, 96px); }
.beta-inner .caption { align-self: flex-start; }
.beta-inner > .btn { align-self: center; }
.beta-text { margin: 0; font-size: 17px; line-height: 1.45; color: #c4ccdd; }
.beta-label { font-family: var(--display); font-size: 20px; letter-spacing: .06em; text-transform: uppercase; color: var(--text); margin-bottom: -6px; }
.beta-input {
  width: 100%; font: 600 20px/1.3 var(--body); color: var(--text); background: rgba(0, 0, 0, .45);
  border: 0; box-shadow: inset 0 0 0 1px var(--line); clip-path: var(--cut-s); padding: 10px 12px; resize: vertical;
}
.beta-input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--cyan); }
.beta-link { font-size: 15px; font-family: ui-monospace, monospace; }
.beta-error { margin: 0; min-height: 1.2em; font-size: 15px; color: var(--hot); }
.beta-error.good { color: var(--good); }
.beta-note { margin: 0; font-size: 14px; color: var(--muted); }
.beta-actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.btn-link { align-self: center; background: none; border: 0; color: var(--cyan); font: 600 16px var(--body); text-decoration: underline; cursor: pointer; padding: 4px; }
.btn-link:empty { display: none; }
.fb-kinds { display: flex; gap: 10px; }
.fb-kind {
  flex: 1; font: 500 22px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); cursor: pointer;
  background: rgba(0, 0, 0, .35); border: 0; box-shadow: inset 0 0 0 1px var(--line); clip-path: var(--cut-s); padding: 12px 8px 9px;
}
.fb-kind[aria-checked="true"] { color: var(--ink); background: var(--cyan); box-shadow: 0 0 16px -2px var(--cyan); }
.fb-kind[data-kind="bug"][aria-checked="true"] { background: var(--amber); box-shadow: 0 0 16px -2px var(--amber); }
