/* ---------- fonts (bundled, so the game works offline; SIL Open Font License, see fonts/) ---------- */
@font-face { font-family: 'Teko'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/teko-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Teko'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/teko-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Teko'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/teko-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Teko'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/teko-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/barlow-semi-condensed-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/barlow-semi-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/barlow-semi-condensed-latin-700-normal.woff2') format('woff2'); }

/* ============ Banner — night-ops theme ============ */
/* Layout: full-bleed dark stage; board in the middle, HUD strip on top, command panel below. */
:root {
  --bg: #07090f;
  --ink-bg: #0c0e12;
  --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;
  --cut: none;
  --cut-s: none;
  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.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-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-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: "Type Only" ----------
   Minimal look for menus and HUD alike: no pictures, no boxes, no glow. Big type on a flat dark ground, links underlined, and the player's
   colour as a soft wash at the top of the hand-off and victory screens. */
.screen, .overlay { position: fixed; inset: 0; z-index: 50; overflow: auto; }
.stage { position: fixed; inset: 0; z-index: -1; background: var(--ink-bg); }
.handoff, .victory .stage { background: linear-gradient(180deg, color-mix(in srgb, var(--fc) 26%, var(--ink-bg)), var(--ink-bg) 55%); }

/* buttons are words: the main one underlined, the others muted */
.btn, .btn-ghost, .btn-icon, .btn-train {
  --b: currentColor;
  background: none; box-shadow: none; border-radius: 0; filter: none; text-shadow: none;
  font-weight: 500; font-size: 30px; letter-spacing: .12em; color: #fff;
  padding: 6px 0 2px; border-bottom: 2px solid currentColor;
}
.btn::after { display: none; }
.btn:hover:not(:disabled) { filter: none; opacity: .8; }
.btn:disabled { filter: none; opacity: .35; }
.btn-ghost { border-bottom: 0; font-size: 20px; color: var(--muted); }
:is(.handoff, .victory) .btn-big { color: var(--fc); }
.caption-plain { margin: 0; font-family: var(--display); font-weight: 500; font-size: 18px; line-height: 1; letter-spacing: .26em; text-transform: uppercase; color: var(--muted); }

/* title */
.title-screen { display: grid; }
.title-inner { margin: auto; width: min(420px, 100%); padding: 32px max(24px, env(safe-area-inset-right, 0px)) 40px max(24px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.logo { margin: 0; font-family: var(--display); font-weight: 500; font-size: clamp(80px, 24vw, 132px); line-height: .8; letter-spacing: .04em; text-transform: uppercase; color: #fff; animation: fadeUp .5s both; }
.logo-mark { width: clamp(64px, 18vw, 96px); height: auto; margin-bottom: -14px; animation: fadeUp .5s both; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 8px; }

/* saved games: a coloured rule and plain text */
.saved-games { width: 100%; display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 10px; }
.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.saved-game { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; padding: 2px 0 2px 14px; border-left: 3px solid var(--line); }
.sg-players { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.sg-player { font-size: 17px; font-weight: 600; color: var(--fc); overflow-wrap: anywhere; }
.sg-player.out { opacity: .45; text-decoration: line-through; }
.sg-vs { font-size: 14px; color: var(--muted); }
.sg-meta { grid-column: 1; font-size: 14px; font-weight: 500; color: var(--muted); }
.sg-meta b { color: var(--text); font-weight: 600; }
.sg-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
:is(.screen) .sg-actions .btn { font-size: 20px; }
:is(.screen) .sg-actions .sg-del { font-size: 14px; }
.saved-game.confirm .sg-del { color: var(--hot); }

/* setup */
.setup-screen { display: grid; padding: 24px max(24px, env(safe-area-inset-right, 0px)) 24px max(24px, env(safe-area-inset-left, 0px)); }
.setup-inner { margin: auto; width: min(520px, 100%); display: flex; flex-direction: column; gap: 22px; }
.count-picker { display: flex; gap: 22px; }
.chip { font-family: var(--display); font-weight: 500; font-size: 22px; line-height: 1; letter-spacing: .14em; text-transform: uppercase; padding: 0 0 4px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.chip.on { color: #fff; border-bottom: 2px solid #fff; }
.player-cards { display: flex; flex-direction: column; gap: 22px; }
.player-card { padding: 2px 0 2px 14px; border-left: 4px solid var(--fc); }
.pc-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pc-label { font-family: var(--display); font-weight: 500; font-size: 18px; line-height: 1; letter-spacing: .18em; text-transform: uppercase; color: var(--fc); }
.pc-random { margin-left: 10px; font-family: var(--body); font-size: 12px; letter-spacing: .06em; text-transform: none; color: var(--muted); }
.pc-name {
  font: inherit; font-size: 19px; font-weight: 600; color: var(--text);
  padding: 6px 0; border: 0; border-bottom: 1px solid var(--line); background: none; border-radius: 0;
  width: 100%; user-select: text; -webkit-user-select: text;
}
.pc-name::placeholder { color: #4e5563; }
.pc-name:focus { outline: none; border-bottom-color: var(--fc); }
.setup-actions { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }

/* hand-off and victory: the name is the picture */
.handoff { display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 24px; }
.ho-right { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; max-width: 92vw; }
.ho-name, .vic-name {
  margin: 0; font-family: var(--display); font-weight: 500; text-transform: uppercase; color: #fff;
  font-size: clamp(64px, 18vw, 120px); line-height: .85; letter-spacing: .03em; word-break: break-word;
}
.ho-faction, .vic-faction { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: .08em; color: var(--muted); }
.ho-go { margin-top: 10px; }
.handoff.enter .ho-right { animation: fadeUp .4s both; }
.victory { display: grid; text-align: center; }
.vic-inner { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; }
.vic-name { animation: fadeUp .5s both; }

/* ---------- 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;
}

/* ---------- HUD: "Type Only" ----------
   Flat strips with a hairline in the player's colour; numbers with small word labels; actions as words. */
#topbar { background: var(--ink-bg); border-bottom: 1px solid var(--fc); box-shadow: none; }
.hud-player span { text-shadow: none; color: var(--fc); font-weight: 500; }
.pill, .pill.turn { background: none; box-shadow: none; border-radius: 0; padding: 0; flex-direction: column; align-items: flex-start; gap: 0; }
.pill .lbl { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pill b { font-weight: 500; }
.pill small { color: var(--muted); margin-left: 4px; }
.pill > span:not(.lbl) { display: flex; align-items: baseline; }
.pill.turn { font-size: 18px; justify-content: flex-end; color: var(--muted); }
#topbar .btn { font-size: 22px; padding: 4px 0 1px; }
#topbar .btn-end { color: var(--fc); }
.btn-end.pulse { animation: none; }
#topbar .btn-icon, #zoom-ctrls .btn { width: 40px; height: 40px; padding: 0; border: 0; font-size: 24px; color: var(--text); }
#zoom-ctrls .btn { background: rgba(12, 14, 18, .72); border-radius: 50%; }

#panel { background: var(--ink-bg); border-top: 1px solid var(--line); box-shadow: none; gap: 10px 18px; }
.p-hint { font-weight: 500; color: var(--muted); }
.p-hint b { font-weight: 500; color: var(--text); }
.p-title { font-weight: 500; }
.p-title small { font-weight: 500; }
.hpbar { height: 4px; margin-top: 8px; transform: none; background: var(--line); box-shadow: none; border-radius: 2px; }
.hpbar i { background: var(--good); box-shadow: none; border-radius: 2px; }
.hpbar span { display: none; }
.hp-text { font-size: 13px; color: var(--muted); margin-top: 3px; }
.stats { gap: 12px; flex-wrap: wrap; font-weight: 500; }
.stats small { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.traits { gap: 0; }
.trait { background: none; box-shadow: none; border-radius: 0; padding: 0; color: var(--muted); font-family: var(--body); font-size: 13px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.trait + .trait::before { content: '·'; margin: 0 6px; }
.p-actions { gap: 8px 20px; }
#panel .btn { font-size: 22px; padding: 6px 0 2px; border-bottom: 2px solid currentColor; color: var(--text); }
#panel .btn-ghost { border-bottom: 0; color: var(--muted); font-size: 18px; }
.train-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 12px 8px; align-items: start; }
.train-row .reason, .train-row .btn-grow { grid-column: 1 / -1; justify-self: start; }
#panel .btn-train { flex-direction: column; align-items: center; gap: 3px; padding: 0; border: 0; white-space: normal; text-align: center; }
.bt-icon { color: #fff; display: grid; place-items: center; width: 46px; height: 46px; }
.bt-icon .unit-icon { width: 40px; height: 40px; display: block; }
.btn-train .bt-name { font-size: 17px; line-height: 1; letter-spacing: .08em; }
#panel .btn .cost { background: none; padding: 0; font-family: var(--body); font-size: 13px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); }
.reason { color: var(--muted); }
.toast { background: rgba(12, 14, 18, .92); box-shadow: none; border-left: 2px solid var(--fc); border-radius: 0; font-weight: 500; }
.toast.big { box-shadow: none; border-left-color: var(--hot); font-weight: 500; }
.toast.error { box-shadow: none; border-left-color: var(--hot); }
.panel-frame { background: var(--ink-bg); box-shadow: none; }

/* ---------- 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); }

/* ---------- install ---------- */
.btn-install { font-size: 20px; }
.install-steps { margin: 0; padding-left: 22px; font-size: 18px; line-height: 1.5; color: #c4ccdd; display: flex; flex-direction: column; gap: 8px; }
.install-steps b { color: #fff; }

/* ---------- capture the flag ---------- */
.bt-icon svg { width: 40px; height: 40px; display: block; }
.pill b.full { color: var(--warn, #ffad1f); }
.btn .cost .res + .res::before { content: '· '; }
.p-flag { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--fc, var(--cyan)); }
.btn-place { box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--cyan) 60%, transparent); }
@media (max-width: 520px) { .pill .lbl { font-size: 10px; } .pills { gap: 4px; } }
.fx-float.energy { color: var(--cyan); }
.btn-pick.spent { opacity: .45; }
.btn-pick { position: relative; }
.btn-pick.working::after { content: ''; position: absolute; top: 2px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 6px var(--good); opacity: .85; }
#panel { touch-action: pan-y; }
.p-stack { margin-top: 4px; font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--muted); user-select: none; }
.p-stack small { font-weight: 400; margin-left: 4px; }
.p-cycle { font: inherit; font-size: 18px; line-height: 1; color: var(--text); background: none; border: 0; padding: 2px 8px; cursor: pointer; }
.b3-hp[data-count]:not([data-count=""])::after { content: attr(data-count); position: absolute; left: 100%; top: -2px; margin-left: 4px; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }
