:root {
  color-scheme: dark;
  --ink: #171425;
  --ink-2: #211c31;
  --panel: rgba(37, 31, 52, 0.92);
  --panel-soft: rgba(48, 41, 64, 0.72);
  --line: rgba(255, 255, 255, 0.1);
  --muted: #a9a3b8;
  --cream: #fff2d6;
  --gold: #ffc95c;
  --gold-deep: #c47a2a;
  --mint: #73e0a4;
  --coral: #ff766f;
  --violet: #a997ff;
  --water: #5da9d6;
  --teal: #38d6c5;
  --pack-accent: var(--gold);
  --cell-size: 56px;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Liberation Mono", monospace;
  font-synthesis: none;
  text-rendering: geometricPrecision;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% -20%, rgba(103, 76, 140, 0.26), transparent 48%),
    linear-gradient(180deg, #1b1729 0%, #151321 100%);
}

body[data-pack="mint"] { --pack-accent: var(--mint); }
body[data-pack="violet"] { --pack-accent: var(--violet); }
body[data-pack="coral"] { --pack-accent: var(--coral); }
body[data-pack="water"] { --pack-accent: var(--water); }
body[data-pack="teal"] { --pack-accent: var(--teal); }

body[data-pack="mint"] .sky-glow--one { opacity: 0.14; }
body[data-pack="violet"] .sky-glow--two { opacity: 0.15; }
body[data-pack="coral"] .sky-glow--one { background: var(--coral); opacity: 0.13; }
body[data-pack="water"] .sky-glow--two { background: var(--water); opacity: 0.16; }
body[data-pack="teal"] .sky-glow--one { background: var(--teal); opacity: 0.16; }
body[data-pack="teal"] .sky-glow--two { background: #3d8ca9; opacity: 0.12; }

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.13;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sky-glow {
  position: fixed;
  z-index: -1;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  opacity: 0.08;
  filter: blur(90px);
  pointer-events: none;
}

.sky-glow--one {
  top: 9%;
  left: -140px;
  background: #68e8a4;
}

.sky-glow--two {
  right: -120px;
  bottom: 4%;
  background: #bf73ff;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 82px;
  padding: 12px clamp(18px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(23, 20, 37, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 12px;
  color: var(--cream);
  text-decoration: none;
  letter-spacing: 0.12em;
}

.brand__crest {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--ink);
  border: 2px solid #ffdc86;
  border-radius: 9px 9px 14px 14px;
  background: linear-gradient(145deg, #ffdf83, #dd9140);
  box-shadow: 0 5px 0 #74452a, 0 8px 18px rgba(0, 0, 0, 0.28);
  text-shadow: 0 1px rgba(255, 255, 255, 0.6);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 3px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.33em;
}

.chapter-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.chapter-mark span:first-child {
  color: var(--gold);
}

.chapter-mark i {
  width: 34px;
  height: 1px;
  background: var(--line);
}

.top-actions {
  display: flex;
  justify-self: end;
  gap: 8px;
}

.icon-button,
.tool-button,
.secondary-button,
.primary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.icon-button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--muted);
}

.icon-button:hover,
.tool-button:hover:not(:disabled),
.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 201, 92, 0.5);
}

.icon-button__glyph {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  color: var(--gold);
  border-radius: 5px;
  background: rgba(255, 201, 92, 0.1);
  font-weight: 900;
}

.icon-button__label {
  font-size: 9px;
  letter-spacing: 0.13em;
}

.icon-button.is-muted .icon-button__glyph {
  color: var(--coral);
  text-decoration: line-through;
}

.game-shell {
  display: grid;
  grid-template-columns: 226px minmax(480px, 1fr) 250px;
  gap: clamp(16px, 2vw, 30px);
  width: min(1580px, 100%);
  min-height: calc(100vh - 130px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px) clamp(16px, 2.4vw, 38px) 28px;
}

.panel {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(44, 38, 59, 0.85), rgba(31, 27, 44, 0.9));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.17);
}

.campaign-panel,
.company-panel {
  position: sticky;
  top: 102px;
  padding: 18px;
}

.campaign-panel {
  display: flex;
  max-height: calc(100vh - 122px);
  flex-direction: column;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.eyebrow,
.progress-copy,
.live-dot {
  font-size: 9px;
  letter-spacing: 0.14em;
}

.eyebrow {
  color: var(--gold);
  font-weight: 800;
}

.progress-copy {
  color: var(--muted);
}

.campaign-progress {
  width: 100%;
  height: 3px;
  overflow: hidden;
  margin-bottom: 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
}

.campaign-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--pack-accent), #b85d3b 40%), var(--pack-accent));
  transition: width 350ms ease;
}

.pack-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 16px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.pack-tab {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 62px;
  place-items: center;
  padding: 6px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #888195;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: 160ms ease;
}

.pack-tab:hover { color: var(--cream); transform: translateY(-2px); }

.pack-tab > span {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 5px;
  color: var(--ink);
  background: #898292;
  font-size: 8px;
  font-weight: 900;
}

.pack-tab strong {
  width: 100%;
  overflow: hidden;
  font-size: 6px;
  letter-spacing: 0.02em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-tab small { font-size: 6px; }
.pack-tab:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  min-height: 48px;
  padding-inline: 10px;
  text-align: left;
}
.pack-tab:last-child:nth-child(odd) strong { text-align: left; }
.pack-tab--gold.is-current { border-color: rgba(255, 201, 92, 0.55); background: rgba(255, 201, 92, 0.11); }
.pack-tab--mint.is-current { border-color: rgba(115, 224, 164, 0.55); background: rgba(115, 224, 164, 0.11); }
.pack-tab--violet.is-current { border-color: rgba(169, 151, 255, 0.58); background: rgba(169, 151, 255, 0.12); }
.pack-tab--coral.is-current { border-color: rgba(255, 118, 111, 0.58); background: rgba(255, 118, 111, 0.12); }
.pack-tab--water.is-current { border-color: rgba(93, 169, 214, 0.6); background: rgba(93, 169, 214, 0.12); }
.pack-tab--teal.is-current { border-color: rgba(56, 214, 197, 0.62); background: rgba(56, 214, 197, 0.12); }
.pack-tab--gold.is-current > span { background: var(--gold); }
.pack-tab--mint.is-current > span { background: var(--mint); }
.pack-tab--violet.is-current > span { background: var(--violet); }
.pack-tab--coral.is-current > span { background: var(--coral); }
.pack-tab--water.is-current > span { background: var(--water); }
.pack-tab--teal.is-current > span { background: var(--teal); }
.pack-tab.is-complete::after {
  position: absolute;
  top: 3px;
  right: 4px;
  content: "✓";
  color: var(--mint);
  font-size: 7px;
}

.level-list {
  display: grid;
  min-height: 0;
  gap: 5px;
  padding-right: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--pack-accent), transparent 38%) transparent;
  scrollbar-width: thin;
}

.level-button {
  position: relative;
  display: grid;
  grid-template-columns: 27px 1fr auto;
  align-items: center;
  min-height: 45px;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #bcb6c8;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: 150ms ease;
}

.level-button::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  background: transparent;
}

.level-button:hover {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.045);
}

.level-button.is-current {
  color: var(--cream);
  border-color: rgba(255, 201, 92, 0.23);
  background: linear-gradient(90deg, rgba(255, 201, 92, 0.13), rgba(255, 255, 255, 0.025));
}

.level-button.is-current::before {
  background: var(--gold);
}

.level-button.is-complete .level-button__number {
  color: #15241d;
  border-color: var(--mint);
  background: var(--mint);
}

.level-button__number {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--muted);
  font-size: 9px;
}

.level-button__copy strong,
.level-button__copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-button__copy strong {
  font-size: 10px;
  letter-spacing: 0.04em;
}

.level-button__copy small {
  margin-top: 3px;
  color: #817a92;
  font-size: 8px;
}

.level-button__check {
  color: var(--mint);
  font-size: 12px;
}

.campaign-note {
  display: flex;
  gap: 10px;
  margin-top: 17px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: #8f899d;
  font-size: 9px;
  line-height: 1.6;
}

.campaign-note > span {
  color: var(--gold);
}

.campaign-note p {
  margin: 0;
}

.mission-panel {
  min-width: 0;
}

.mission-head {
  display: flex;
  min-height: 90px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.mission-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.mission-kicker i {
  width: 22px;
  height: 1px;
  background: rgba(255, 201, 92, 0.5);
}

.mission-head h1 {
  margin: 7px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(31px, 3.2vw, 50px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.98;
}

.mission-head p {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.mission-tools {
  display: flex;
  gap: 7px;
  flex: 0 0 auto;
}

.tool-button {
  min-height: 40px;
  padding: 8px 11px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.09em;
}

.tool-button span {
  color: var(--gold);
  font-size: 13px;
}

.tool-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.tool-button--workshop {
  color: #fff0bd;
  border-color: rgba(255, 201, 92, 0.42);
  background: rgba(255, 201, 92, 0.1);
}

.objective-ribbon {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  min-height: 49px;
  margin: 0 auto 14px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 201, 92, 0.18);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 201, 92, 0.1), rgba(63, 46, 67, 0.3));
}

.objective-ribbon__icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  color: var(--ink);
  background: var(--gold);
  box-shadow: 0 3px 0 var(--gold-deep);
}

.objective-ribbon strong,
.objective-ribbon span:not(.objective-ribbon__icon) {
  display: block;
}

.objective-ribbon strong {
  color: #ffe2a0;
  font-size: 9px;
  letter-spacing: 0.11em;
}

.objective-ribbon span:not(.objective-ribbon__icon) {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.board-stage {
  position: relative;
  display: flex;
  min-height: 360px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(22px, 4vw, 54px) clamp(10px, 2vw, 28px) 32px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 17px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 211, 114, 0.07), transparent 45%),
    repeating-linear-gradient(135deg, transparent 0 12px, rgba(255, 255, 255, 0.012) 12px 13px),
    rgba(26, 23, 37, 0.68);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.28), 0 24px 55px rgba(0, 0, 0, 0.21);
}

.board-stage::before,
.board-stage::after {
  position: absolute;
  width: 110px;
  height: 20px;
  content: "";
  border-top: 1px solid rgba(255, 201, 92, 0.16);
}

.board-stage::before {
  top: 20px;
  left: 20px;
  border-left: 1px solid rgba(255, 201, 92, 0.16);
}

.board-stage::after {
  right: 20px;
  bottom: 20px;
  border-right: 1px solid rgba(255, 201, 92, 0.16);
  border-bottom: 1px solid rgba(255, 201, 92, 0.16);
  border-top: 0;
}

.board-frame {
  position: relative;
  width: min(100%, calc(var(--cols) * var(--cell-size)));
  aspect-ratio: var(--cols) / var(--rows);
  isolation: isolate;
  border: 3px solid #493843;
  border-radius: 7px;
  background: #315647;
  box-shadow:
    0 0 0 2px #17121e,
    0 0 0 5px #765342,
    0 10px 0 #1a1320,
    0 18px 35px rgba(0, 0, 0, 0.35);
  touch-action: none;
  user-select: none;
}

.game-board {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  overflow: hidden;
  border-radius: 3px;
}

.cell {
  position: relative;
  container-name: board-cell;
  container-type: inline-size;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-right: 1px solid rgba(25, 48, 38, 0.19);
  border-bottom: 1px solid rgba(25, 48, 38, 0.19);
  background-color: #6aab61;
  background-image: url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0000.png");
  background-position: center;
  background-size: cover;
  cursor: crosshair;
  image-rendering: pixelated;
}

.cell:where([data-variation="1"]) {
  background-image: url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0001.png");
}

.cell::after {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  content: "";
  box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
  transition: box-shadow 120ms ease;
}

.cell--wilds {
  cursor: not-allowed;
  background-color: #243b36;
  background-image:
    linear-gradient(rgba(15, 26, 31, 0.42), rgba(15, 26, 31, 0.62)),
    url("./assets/vendor/kenney-tiny-town/Tiles/tile_0000.png");
  filter: saturate(0.64) brightness(0.65);
}

.cell--wilds .wild-sprite {
  position: absolute;
  left: 50%;
  bottom: -8%;
  width: 83%;
  transform: translateX(-50%);
  opacity: 0.72;
  image-rendering: pixelated;
}

.cell--river {
  isolation: isolate;
  background-color: #559ed0;
  background-image:
    linear-gradient(90deg, rgba(37, 89, 117, 0.7) 0 8%, transparent 8% 92%, rgba(37, 89, 117, 0.7) 92%),
    url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0037.png");
  background-size: 100% 100%, 32px 32px;
  animation: waterShimmer 1.4s steps(3, end) infinite;
}

.cell--river::before {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
  border-right: 4px solid rgba(230, 216, 142, 0.52);
  border-left: 4px solid rgba(230, 216, 142, 0.52);
  box-shadow: inset 7px 0 rgba(54, 118, 118, 0.34), inset -7px 0 rgba(54, 118, 118, 0.34);
  pointer-events: none;
}

.river-water {
  position: absolute;
  z-index: 3;
  inset: 5% 14%;
  overflow: hidden;
  pointer-events: none;
}

.river-water i {
  position: absolute;
  left: -35%;
  width: 42%;
  height: 2px;
  border-radius: 2px;
  background: rgba(220, 250, 255, 0.72);
  box-shadow: 9px 0 rgba(125, 205, 235, 0.7), 25px 0 rgba(220, 250, 255, 0.54), 42px 0 rgba(125, 205, 235, 0.68);
  animation: riverCurrent 1.15s steps(5, end) infinite;
}

.river-water i:nth-child(1) { top: 18%; }
.river-water i:nth-child(2) { top: 48%; animation-delay: -0.4s; }
.river-water i:nth-child(3) { top: 78%; animation-delay: -0.75s; }

.cell--hungry {
  cursor: not-allowed;
  background-color: #46744d;
  background-image:
    radial-gradient(circle at 50% 55%, rgba(255, 226, 147, 0.22), transparent 55%),
    url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0001.png");
  box-shadow: inset 0 0 0 2px rgba(36, 65, 48, 0.34);
}

.entity--hungry { width: 72%; bottom: 14%; animation: hungryBounce 1.1s steps(2, end) infinite; }
.entity--hungry-2 { width: 68%; filter: drop-shadow(0 0 8px rgba(255, 143, 83, 0.7)); }
.cell--hungry.is-fed .entity--hungry { animation: fedDance 480ms steps(4, end) 2, idleBob 1.5s steps(2, end) 960ms infinite; }
.cell--hungry.is-fed .tile-badge--hunger { color: #173a2e; border-color: #c2ffd9; background: var(--mint); box-shadow: 0 2px 0 #34775a; }

.tile-badge--hunger { min-width: clamp(11px, 42cqi, 24px); }

.hunger-pips {
  position: absolute;
  z-index: 6;
  bottom: 22%;
  left: 50%;
  display: flex;
  gap: 3px;
  transform: translateX(-50%);
}

.hunger-pips i {
  width: 7px;
  height: 7px;
  border: 1px solid #4c2f39;
  border-radius: 2px;
  background: #211c31;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.hunger-pips i.is-filled { border-color: #f7da83; background: var(--gold); }

.cell--mud {
  background-color: #7c6044;
  background-image:
    radial-gradient(ellipse at 30% 35%, rgba(48, 38, 39, 0.34) 0 14%, transparent 15%),
    radial-gradient(ellipse at 72% 70%, rgba(48, 38, 39, 0.32) 0 16%, transparent 17%),
    linear-gradient(145deg, #94714d, #604d41);
}

.mud-ripples { position: absolute; z-index: 3; inset: 15%; }
.mud-ripples i {
  position: absolute;
  width: 12px;
  height: 5px;
  border: 2px solid rgba(54, 42, 42, 0.55);
  border-radius: 50%;
  animation: mudBubble 1.6s steps(2, end) infinite;
}
.mud-ripples i:nth-child(1) { top: 5%; left: 8%; }
.mud-ripples i:nth-child(2) { top: 44%; right: 4%; animation-delay: -0.5s; }
.mud-ripples i:nth-child(3) { bottom: 0; left: 34%; animation-delay: -1s; }

.tile-badge--terrain { color: #fff2d6; border-color: #d8b47c; background: #6a4d42; }

.cell--supply { background-image: radial-gradient(circle, rgba(255, 201, 92, 0.2), transparent 60%), url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0000.png"); }
.entity--supply { width: 69%; animation: supplyPulse 1.2s steps(2, end) infinite; }

.cell--formation {
  background-color: #4c7995;
  background-image:
    linear-gradient(90deg, rgba(27, 47, 68, 0.5) 0 12%, transparent 12% 88%, rgba(27, 47, 68, 0.5) 88%),
    url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0001.png");
  box-shadow: inset 0 0 0 2px rgba(202, 239, 255, 0.2);
}

.cell--stride,
.cell--pivot {
  background-color: #397e78;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(220, 255, 250, 0.2), transparent 67%),
    url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0001.png");
  box-shadow: inset 0 0 0 2px rgba(215, 255, 250, 0.2);
}

.cell--pivot {
  background-color: #5d5586;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(237, 232, 255, 0.2), transparent 67%),
    url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0001.png");
}

.maneuver-marker,
.aegis-symbol {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.maneuver-marker {
  inset: 11% 13% 22%;
  border: clamp(2px, 7cqi, 4px) double #e5fffb;
  border-radius: clamp(4px, 12cqi, 8px);
  color: #f4fffd;
  background: rgba(22, 91, 85, 0.72);
  box-shadow: inset 0 -5px rgba(12, 59, 57, 0.36), 0 3px 0 rgba(25, 37, 46, 0.45);
  font-size: clamp(10px, 36cqi, 22px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px rgba(18, 33, 41, 0.7);
  transition: opacity 180ms ease, filter 180ms ease, transform 180ms ease;
}

.maneuver-marker--pivot {
  border-style: dashed;
  border-color: #eeeaff;
  color: #f8f5ff;
  background: rgba(73, 62, 119, 0.76);
}

.cell--aegis {
  background-color: #917441;
  background-image:
    radial-gradient(circle at 50% 48%, rgba(255, 240, 176, 0.48), transparent 61%),
    url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0001.png");
  box-shadow: inset 0 0 0 2px rgba(255, 238, 174, 0.24);
}

.aegis-symbol {
  inset: 12% 18% 23%;
  color: #fff5c9;
  border: clamp(2px, 7cqi, 4px) double #fff0a8;
  border-radius: 44% 44% 56% 56%;
  background: linear-gradient(145deg, #429d98, #1d625f);
  box-shadow: inset 0 -7px rgba(15, 63, 62, 0.48), 0 3px 0 rgba(48, 39, 35, 0.52), 0 0 9px rgba(255, 229, 143, 0.4);
  font-size: clamp(11px, 34cqi, 22px);
  text-shadow: 0 2px rgba(31, 54, 52, 0.72);
  transition: opacity 180ms ease, filter 180ms ease, transform 180ms ease;
}

.beacon-symbol,
.current-arrow,
.standard-gem {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.beacon-symbol {
  inset: 14%;
  color: #696173;
  border: 3px solid #665d70;
  border-radius: 50% 50% 8px 8px;
  background: #282333;
  box-shadow: inset 0 -7px rgba(0, 0, 0, 0.26), 0 4px 0 rgba(38, 27, 40, 0.5);
  font-size: 17px;
  transition: 220ms steps(3, end);
}

.cell--beacon.is-lit .beacon-symbol {
  color: #fff7d6;
  border-color: #ffe39b;
  background: #f0a94b;
  box-shadow: 0 0 15px rgba(255, 201, 92, 0.78), inset 0 -7px rgba(159, 83, 43, 0.25);
  animation: beaconFlare 720ms steps(3, end) infinite;
}

.current-arrow {
  inset: 13%;
  color: #fff3d2;
  border: 3px solid #d8cae9;
  border-radius: 8px;
  background: #62558e;
  box-shadow: inset 0 -5px #3f365e, 0 4px 0 rgba(40, 27, 52, 0.5);
  font-size: clamp(15px, 2vw, 24px);
  animation: arrowNudge 800ms steps(2, end) infinite;
}

.entity--commander-standby { width: 64%; opacity: 0.82; }
.cell--commanderStart.is-active-commander .entity--commander-standby { opacity: 0.16; }
.cell--commanderStart.is-locked-commander .entity--commander-standby { opacity: 0.25; filter: grayscale(0.5); }
.cell--commanderGoal .entity--goal-captain { filter: sepia(1) saturate(2.4) hue-rotate(318deg) drop-shadow(0 4px 0 rgba(39, 25, 41, 0.42)); }
.cell--commanderGoal .entity--goal-warden { filter: sepia(1) saturate(2) hue-rotate(145deg) drop-shadow(0 4px 0 rgba(39, 25, 41, 0.42)); }
.cell--commanderGoal .entity--goal-sage { filter: sepia(1) saturate(2.3) hue-rotate(205deg) drop-shadow(0 4px 0 rgba(39, 25, 41, 0.42)); }
.standard-gem {
  top: clamp(1px, 5cqi, 4px);
  left: clamp(1px, 5cqi, 4px);
  width: clamp(8px, 24cqi, 17px);
  height: clamp(8px, 24cqi, 17px);
  border-radius: clamp(2px, 6cqi, 4px);
  color: var(--cream);
  background: var(--coral);
  font-size: clamp(4px, 11cqi, 8px);
}
.standard-gem--warden { background: var(--water); }
.standard-gem--sage { background: var(--violet); }

.cell--planned:not(.cell--wilds)::after {
  background: repeating-linear-gradient(135deg, rgba(255, 242, 214, 0.075) 0 3px, transparent 3px 8px);
  box-shadow: inset 0 0 0 2px rgba(255, 220, 127, 0.2);
}

.cell--planned .tile-label {
  border: 1px dashed rgba(255, 235, 178, 0.3);
}

.cell--planned-event .tile-label {
  color: #f1ecff;
  border-color: rgba(216, 207, 255, 0.52);
  background: rgba(72, 61, 104, 0.78);
  box-shadow: 0 0 6px rgba(169, 151, 255, 0.34);
}

.cell--planned-event .tile-badge {
  border-style: dashed;
  filter: saturate(0.72) brightness(1.08);
}

.cell.is-planned-marker-pending::after {
  background: repeating-linear-gradient(135deg, rgba(255, 242, 214, 0.12) 0 4px, transparent 4px 9px);
  box-shadow: inset 0 0 0 3px rgba(255, 226, 143, 0.78), inset 0 0 14px rgba(255, 201, 92, 0.28);
  animation: markerPending 850ms steps(2, end) infinite;
}

.cell.is-planned-marker-pending .maneuver-marker {
  filter: brightness(1.32) drop-shadow(0 0 5px rgba(255, 236, 176, 0.8));
}

.cell.is-planned-marker-resolved .maneuver-marker,
.cell--stride.cell--resolved .maneuver-marker,
.cell--pivot.cell--resolved .maneuver-marker {
  opacity: 0.58;
  filter: saturate(0.72) brightness(1.2);
}

.cell.is-planned-marker-resolved::after {
  box-shadow: inset 0 0 0 2px rgba(56, 214, 197, 0.52);
}

.cell.is-planned-protected .entity--goblin {
  filter: drop-shadow(0 0 5px #fff0a8) drop-shadow(0 0 9px rgba(56, 214, 197, 0.66));
}

.cell.is-planned-protected .tile-label::before {
  content: "◆ ";
  color: #fff0a8;
}

.cell--resolved:not(.cell--wilds)::after {
  box-shadow: inset 0 0 0 2px rgba(115, 224, 164, 0.25);
}

.cell--hint::after {
  animation: hintPulse 650ms steps(2, end) 3;
  box-shadow: inset 0 0 0 4px var(--gold);
}

.cell--blocked {
  z-index: 7;
  animation: blockedShake 260ms steps(3, end);
}

.cell--blocked::after {
  box-shadow: inset 0 0 0 4px var(--coral);
}

.cell--fresh {
  animation: cellPop 220ms ease-out;
}

.entity {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 12%;
  width: 66%;
  max-height: 78%;
  transform: translateX(-50%);
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 0 rgba(39, 25, 41, 0.42));
  image-rendering: pixelated;
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
  animation: idleBob 1.55s steps(2, end) infinite;
}

.entity--goblin {
  width: 70%;
  animation: enemySway 1.25s steps(2, end) infinite;
}

.entity--dragon {
  width: 77%;
  animation: dragonBreathe 1.45s steps(3, end) infinite;
}

.cell--healer {
  background-image:
    radial-gradient(circle at 50% 52%, rgba(255, 179, 172, 0.5), transparent 58%),
    url("./assets/vendor/kenney-tiny-battle/Tiles/tile_0001.png");
  box-shadow: inset 0 0 0 2px rgba(255, 181, 175, 0.2);
}

.entity--healer {
  width: 70%;
  animation: healerFloat 1.1s steps(3, end) infinite;
  filter: drop-shadow(0 0 7px rgba(255, 180, 173, 0.78));
}

.healer-aura {
  position: absolute;
  z-index: 2;
  inset: 9%;
  display: grid;
  place-items: center;
  color: rgba(255, 226, 220, 0.34);
  border: 2px dashed rgba(255, 190, 183, 0.6);
  border-radius: 50%;
  font-size: 18px;
  animation: healerAura 1.4s steps(5, end) infinite;
}

.cell--healer.cell--resolved .healer-aura {
  opacity: 0.14;
  animation: none;
}

.entity--goal {
  width: 64%;
  animation: bannerWave 1s steps(2, end) infinite;
}

.cell--resolved .entity:not(.entity--goal) {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px) scale(0.55);
  filter: brightness(1.8) drop-shadow(0 0 8px var(--gold));
}

.cell--river.cell--resolved .entity {
  opacity: 1;
  transform: translateX(-50%);
}

.cell--aegis.cell--resolved .aegis-symbol {
  opacity: 0;
  transform: translateY(-10px) scale(0.48);
  filter: brightness(1.8) drop-shadow(0 0 8px #fff0a8);
}

/* Planning previews communicate outcomes without resolving the real board. */
.cell--preview-fed .entity--hungry,
.cell.is-planned-fed .entity--hungry {
  opacity: 0.72;
  filter: grayscale(0.2) sepia(0.25) drop-shadow(0 0 7px rgba(115, 224, 164, 0.55));
}

.cell--preview-fed .tile-badge--hunger,
.cell.is-planned-fed .tile-badge--hunger {
  color: #d8ffe7;
  border-color: rgba(115, 224, 164, 0.72);
  border-style: dashed;
  background: rgba(34, 88, 65, 0.88);
  box-shadow: 0 2px 0 #244d3d;
}

.cell--preview-fed .hunger-pips i,
.cell.is-planned-fed .hunger-pips i.is-planned-filled {
  border-color: rgba(115, 224, 164, 0.75);
  background: rgba(115, 224, 164, 0.38);
}

.cell .hunger-pips i.is-planned-filled {
  border-color: rgba(115, 224, 164, 0.75);
  background: rgba(115, 224, 164, 0.38);
  box-shadow: 0 0 4px rgba(115, 224, 164, 0.42);
}

.cell--beacon.cell--preview-lit .beacon-symbol,
.cell--beacon.is-planned-lit .beacon-symbol {
  color: #fff0bd;
  border-color: rgba(255, 227, 155, 0.65);
  border-style: dashed;
  background: rgba(140, 94, 49, 0.88);
  box-shadow: 0 0 10px rgba(255, 201, 92, 0.36), inset 0 -7px rgba(85, 50, 39, 0.24);
}

.cell--preview-open .gate-symbol,
.cell.is-planned-open .gate-symbol {
  opacity: 0.68;
  border-style: dashed;
  filter: brightness(1.15);
}

.cell.is-planned-formation-open .formation-gate {
  color: #eaffff;
  border-color: rgba(218, 248, 255, 0.78);
  border-style: dashed;
  background: repeating-linear-gradient(90deg, rgba(105, 197, 228, 0.78) 0 6px, rgba(38, 92, 126, 0.82) 6px 9px);
  box-shadow: 0 0 11px rgba(93, 169, 214, 0.55), inset 0 -7px rgba(25, 60, 84, 0.34);
}

.cell--preview-bridge .bridge-planks,
.cell.is-planned-bridge .bridge-planks {
  opacity: 0.32;
  transform: scaleY(1);
  transition: none;
  filter: grayscale(0.25) brightness(1.25);
}

.tile-badge {
  position: absolute;
  z-index: 5;
  top: clamp(1px, 4cqi, 4px);
  right: clamp(1px, 4cqi, 4px);
  display: grid;
  min-width: clamp(8px, 28cqi, 20px);
  height: clamp(8px, 28cqi, 20px);
  max-width: calc(100% - 2px);
  padding: 0 clamp(1px, 4cqi, 4px);
  overflow: hidden;
  place-items: center;
  border: clamp(1px, 2.5cqi, 2px) solid #fff1cf;
  border-radius: clamp(2px, 7cqi, 6px);
  color: #fff7e6;
  background: #a33f4d;
  box-shadow: 0 clamp(1px, 3cqi, 2px) 0 #532633;
  font-size: clamp(4px, 12cqi, 9px);
  font-weight: 900;
  line-height: 1;
  text-overflow: clip;
  white-space: nowrap;
}

@container board-cell (max-width: 44px) {
  .tile-label { display: none; }

  .entity {
    bottom: 5%;
    width: 78%;
    max-height: 86%;
    filter: drop-shadow(0 1px 0 rgba(39, 25, 41, 0.5));
  }

  .tile-badge {
    box-shadow: 0 1px 0 rgba(51, 31, 40, 0.8);
  }
}

@container board-cell (max-width: 20px) {
  .tile-badge {
    top: 1px;
    right: 1px;
    width: 5px;
    min-width: 5px;
    height: 5px;
    padding: 0;
    border-width: 1px;
    border-radius: 1px;
    font-size: 3px;
  }

  .tile-badge--hunger {
    width: 8px;
    min-width: 8px;
  }

  .standard-gem {
    top: 1px;
    left: 1px;
    width: 5px;
    height: 5px;
    border-radius: 1px;
    font-size: 3px;
  }
}

.tile-badge--pickup {
  color: #173a2e;
  border-color: #c2ffd9;
  background: var(--mint);
  box-shadow: 0 2px 0 #34775a;
}

.tile-badge--healer {
  color: #4c202c;
  border-color: #ffe2dc;
  background: var(--coral);
  box-shadow: 0 2px 0 #853f49;
}

.tile-badge--aegis {
  color: #153f3c;
  border-color: #fff3b5;
  background: #ffe08a;
  box-shadow: 0 2px 0 #8d6b34;
}

.tile-badge--formation {
  color: #173147;
  border-color: #dcf6ff;
  background: #8ed8ee;
  box-shadow: 0 2px 0 #326b8c;
}

.tile-label {
  position: absolute;
  z-index: 5;
  right: 4%;
  bottom: 4%;
  left: 4%;
  overflow: hidden;
  padding: 2px 3px;
  border-radius: 3px;
  color: rgba(255, 248, 225, 0.9);
  background: rgba(23, 20, 37, 0.7);
  font-size: clamp(5px, 0.55vw, 7px);
  letter-spacing: 0.04em;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.switch-symbol,
.gate-symbol,
.formation-gate,
.start-ring {
  position: absolute;
  z-index: 3;
  inset: 17%;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 900;
  line-height: 1;
}

.formation-gate {
  inset: 8% 13%;
  color: #e9faff;
  border: 3px double #c6edff;
  background: repeating-linear-gradient(90deg, #5da9d6 0 6px, #315c7c 6px 9px);
  box-shadow: inset 0 -7px rgba(24, 58, 82, 0.42), 0 4px 0 rgba(29, 38, 53, 0.52);
  font-size: clamp(12px, 1.35vw, 18px);
  letter-spacing: -0.08em;
  text-shadow: 0 2px #29445d;
}

.switch-symbol {
  color: #462f23;
  border: 3px solid #ffe6a2;
  background: #ffc95c;
  box-shadow: inset 0 -5px rgba(164, 92, 38, 0.25), 0 4px 0 rgba(60, 38, 38, 0.4);
  animation: switchGlow 1.3s steps(2, end) infinite;
}

.switch-symbol--moon {
  color: #e8e3ff;
  border-color: #d8d1ff;
  background: #7569be;
}

.gate-symbol {
  inset: 8% 13%;
  color: #493022;
  border: 3px solid #6c4736;
  background:
    repeating-linear-gradient(90deg, #c98049 0 6px, #6d4536 6px 9px);
  box-shadow: inset 0 -7px rgba(67, 43, 40, 0.38), 0 4px 0 rgba(40, 27, 37, 0.5);
  font-size: 15px;
}

.gate-symbol--moon {
  color: #e7e1ff;
  border-color: #4d4779;
  background: repeating-linear-gradient(90deg, #8f84d0 0 6px, #4d4779 6px 9px);
}

.cell--resolved .gate-symbol {
  transform-origin: bottom;
  animation: gateOpen 320ms steps(4, end) forwards;
}

.cell--formation.cell--resolved .formation-gate {
  transform-origin: bottom;
  animation: formationOpen 360ms steps(5, end) forwards;
}

.start-ring {
  inset: 20%;
  border: 3px dashed rgba(255, 235, 171, 0.82);
  border-radius: 50%;
  animation: ringRotate 6s linear infinite;
}

.bridge-planks {
  position: absolute;
  z-index: 4;
  inset: 10% 16%;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 220ms steps(4, end);
}

.bridge-planks i {
  border: 1px solid #6e4735;
  background: #d49150;
  box-shadow: inset 0 -2px #995d3c;
}

.cell--resolved .bridge-planks {
  transform: scaleY(1);
}

.route-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.route-shadow,
.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.route-shadow {
  stroke: rgba(73, 48, 40, 0.82);
  stroke-width: 13px;
}

.route-line {
  stroke: var(--gold);
  stroke-width: 7px;
  filter: drop-shadow(0 0 5px rgba(255, 208, 104, 0.58));
}

.route-line.is-locked { opacity: 0.88; }
.route-line.is-planned {
  opacity: 0.82;
  stroke-dasharray: 3 2;
}
.route-line.is-executed {
  opacity: 1;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 7px rgba(255, 242, 214, 0.72));
}
.route-line.is-draft {
  opacity: 0.48;
  stroke-dasharray: 7 7;
  filter: saturate(0.72) drop-shadow(0 0 3px rgba(238, 229, 255, 0.38));
  animation: draftRouteMarch 1.1s linear infinite;
}
.route-line--mint { stroke: var(--mint); filter: drop-shadow(0 0 5px rgba(115, 224, 164, 0.55)); }
.route-line--violet,
.route-line--sage { stroke: var(--violet); filter: drop-shadow(0 0 5px rgba(169, 151, 255, 0.55)); }
.route-line--captain { stroke: var(--coral); filter: drop-shadow(0 0 5px rgba(255, 118, 111, 0.55)); }
.route-line--water,
.route-line--warden { stroke: var(--water); filter: drop-shadow(0 0 5px rgba(93, 169, 214, 0.55)); }
.route-line--teal { stroke: var(--teal); filter: drop-shadow(0 0 6px rgba(56, 214, 197, 0.62)); }

.route-head {
  fill: #fff3bf;
  stroke: var(--gold-deep);
  stroke-width: 0.07;
  transform-box: fill-box;
  transform-origin: center;
  animation: headPulse 800ms steps(2, end) infinite;
}

.route-head--mint { fill: #d5ffe7; stroke: #2e8a5c; }
.route-head--violet,
.route-head--sage { fill: #eeeaff; stroke: #6657ba; }
.route-head--captain { fill: #ffe3df; stroke: #b94b4b; }
.route-head--water,
.route-head--warden { fill: #def5ff; stroke: #39789d; }
.route-head--teal { fill: #d9fffa; stroke: #16877d; }

.route-head[hidden] {
  display: none;
}

.cell--draft-route:not(.cell--wilds)::after {
  background: repeating-linear-gradient(135deg, rgba(225, 216, 255, 0.08) 0 3px, transparent 3px 7px);
  box-shadow: inset 0 0 0 2px rgba(211, 198, 255, 0.28);
}

.party-token {
  position: absolute;
  z-index: 8;
  left: 0;
  top: 0;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: left 150ms ease-out, top 150ms ease-out;
}

.party-token.is-stepping {
  animation: partyStep 190ms ease-out;
}

.party-token.is-winning {
  animation: partyWin 700ms steps(4, end) 2;
}

.party-token.is-starting {
  animation: partyStart 420ms steps(4, end);
}

.party-token.is-attacking {
  animation: partyAttack 280ms steps(4, end);
}

.party-token.is-casting {
  animation: partyCast 420ms steps(5, end);
}

.party-token.is-healing {
  animation: partyHeal 520ms steps(6, end);
}

.party-token.is-guarding {
  animation: partyGuard 430ms steps(5, end);
}

.party-token.is-stationary {
  transition: none;
}

.party-member {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 67%;
  transform: translateX(-50%);
  filter: drop-shadow(0 4px 0 rgba(43, 28, 43, 0.5));
  image-rendering: pixelated;
  animation: idleBob 850ms steps(2, end) infinite;
}

.party-follower {
  position: absolute;
  z-index: -1;
  width: 41%;
  filter: drop-shadow(0 3px 0 rgba(43, 28, 43, 0.46));
  image-rendering: pixelated;
  animation: followerBounce 700ms steps(2, end) infinite;
}

.party-follower:nth-child(2) { left: -2%; bottom: 6%; animation-delay: -120ms; }
.party-follower:nth-child(3) { right: -2%; bottom: 7%; animation-delay: -260ms; }
.party-follower:nth-child(4) { left: 7%; top: -1%; animation-delay: -380ms; }
.party-follower:nth-child(5) { right: 7%; top: -2%; animation-delay: -500ms; }

.planning-ghost {
  position: absolute;
  z-index: 7;
  left: 0;
  top: 0;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  border-radius: 50%;
  opacity: 0.7;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: left 115ms ease-out, top 115ms ease-out, opacity 160ms ease;
  filter: saturate(0.25) hue-rotate(160deg) drop-shadow(0 0 7px rgba(216, 207, 255, 0.82));
}

.planning-ghost::before {
  position: absolute;
  inset: 8%;
  content: "";
  border: 2px dashed rgba(231, 226, 255, 0.72);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(169, 151, 255, 0.2), transparent 68%);
  animation: ghostRing 1.15s steps(4, end) infinite;
}

.planning-ghost .party-member,
.planning-ghost .party-follower {
  opacity: 0.68;
  filter: grayscale(0.72) brightness(1.45) drop-shadow(0 0 5px rgba(216, 207, 255, 0.86));
}

.planning-ghost.is-stepping {
  animation: ghostStep 170ms ease-out;
}

.planning-ghost[hidden],
.solve-puzzle-button[hidden],
.execution-fx-layer[hidden] {
  display: none !important;
}

.execution-fx-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: visible;
  pointer-events: none;
}

.execution-fx {
  --fx-x: 50%;
  --fx-y: 50%;
  position: absolute;
  left: var(--fx-x);
  top: var(--fx-y);
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  pointer-events: none;
  transform: translate(-50%, -50%);
  transform-origin: center;
}

.execution-fx::before,
.execution-fx::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.execution-fx--recruit::before,
.execution-fx--mage::before,
.execution-fx--builder::before,
.execution-fx--healer::before,
.execution-fx--aegis::before {
  inset: 14%;
  border: 4px solid var(--fx-color, var(--mint));
  border-radius: 50%;
  box-shadow: 0 0 12px var(--fx-color, var(--mint));
  animation: pickupBurst 300ms steps(5, end) forwards;
}

.execution-fx--recruit { --fx-color: var(--mint); }
.execution-fx--mage { --fx-color: var(--violet); }
.execution-fx--builder { --fx-color: var(--gold); }
.execution-fx--healer { --fx-color: var(--coral); }
.execution-fx--aegis { --fx-color: #ffe08a; }

.execution-fx--recruit::after,
.execution-fx--mage::after,
.execution-fx--builder::after,
.execution-fx--healer::after,
.execution-fx--aegis::after {
  inset: 22%;
  background:
    linear-gradient(90deg, transparent 44%, var(--fx-color) 44% 56%, transparent 56%),
    linear-gradient(transparent 44%, var(--fx-color) 44% 56%, transparent 56%);
  filter: drop-shadow(0 0 4px var(--fx-color));
  animation: pickupSpark 300ms steps(4, end) forwards;
}

.execution-fx--stride::before,
.execution-fx--pivot::before {
  inset: 10%;
  display: grid;
  place-items: center;
  border: 4px double #e8fffb;
  border-radius: 7px;
  color: #f5fffd;
  background: rgba(24, 117, 108, 0.48);
  box-shadow: 0 0 14px rgba(56, 214, 197, 0.82);
  font-size: clamp(14px, 48%, 28px);
  font-weight: 900;
  animation: maneuverResolve 320ms steps(5, end) forwards;
}

.execution-fx--stride::before { content: "↕↔"; }

.execution-fx--pivot::before {
  content: "↱↰";
  border-style: dashed;
  border-color: #eeeaff;
  background: rgba(79, 66, 132, 0.5);
  box-shadow: 0 0 14px rgba(169, 151, 255, 0.86);
}

.execution-fx--aegis-guard::before,
.execution-fx--aegis-guard::after {
  inset: 2% 12%;
  border: 4px double #fff0a8;
  border-radius: 46% 46% 58% 58%;
  background: rgba(31, 122, 115, 0.28);
  box-shadow: inset 0 0 12px rgba(56, 214, 197, 0.65), 0 0 15px rgba(255, 224, 138, 0.85);
  animation: aegisGuard 430ms steps(6, end) forwards;
}

.execution-fx--aegis-guard::after {
  inset: 28%;
  content: "◆";
  display: grid;
  place-items: center;
  border: 0;
  color: #fff5c9;
  background: transparent;
  box-shadow: none;
  font-size: clamp(12px, 42%, 25px);
  animation-direction: reverse;
}

.execution-fx--impact-goblin::before,
.execution-fx--impact-orc::before,
.execution-fx--impact-ogre::before,
.execution-fx--dragon-death::before {
  inset: 16%;
  border: 4px solid var(--fx-color, #c4f084);
  border-radius: 45% 55% 48% 52%;
  box-shadow: 0 0 14px var(--fx-color, #c4f084);
  animation: enemyImpact 320ms steps(6, end) forwards;
}

.execution-fx--impact-orc { --fx-color: #f0a45d; }
.execution-fx--impact-ogre { --fx-color: var(--coral); }
.execution-fx--dragon-death { --fx-color: #d7a2ff; }

.execution-fx--fireball {
  --fx-dx: 0px;
  --fx-dy: 0px;
  width: clamp(10px, 34%, 24px);
  height: clamp(10px, 34%, 24px);
  border-radius: 50%;
  background: #fff2ae;
  box-shadow: 0 0 5px #fff2ae, 0 0 12px #ff8a4d, -8px 0 0 -3px #ff604f;
  animation: fireballFlight 280ms linear forwards;
}

.execution-fx--bridge::before {
  inset: 13% 18%;
  border: 3px dashed #f4bd65;
  border-radius: 4px;
  background: repeating-linear-gradient(0deg, #d49150 0 5px, #6e4735 5px 7px);
  box-shadow: 0 0 9px rgba(255, 201, 92, 0.72);
  animation: bridgeBuildFx 340ms steps(5, end) forwards;
}

.execution-fx--formation::before {
  inset: 5% 8%;
  border: 4px double #c9f3ff;
  border-radius: 7px;
  background: repeating-linear-gradient(90deg, rgba(93, 169, 214, 0.72) 0 7px, rgba(49, 92, 124, 0.5) 7px 10px);
  box-shadow: 0 0 14px rgba(93, 169, 214, 0.85);
  animation: formationInspection 380ms steps(6, end) forwards;
}

.execution-fx--formation::after {
  inset: 20%;
  border: 3px solid #effcff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(201, 243, 255, 0.88);
  animation: formationStamp 380ms steps(5, end) forwards;
}

.execution-fx--healing::before,
.execution-fx--healing::after {
  inset: 4%;
  border: 3px solid rgba(255, 164, 173, 0.82);
  border-radius: 50%;
  animation: healingWave 420ms ease-out forwards;
}

.execution-fx--healing::after {
  animation-delay: 120ms;
}

.execution-fx--completion::before {
  inset: -30%;
  background: conic-gradient(from 0deg, transparent 0 8%, var(--gold) 8% 10%, transparent 10% 23%, var(--mint) 23% 25%, transparent 25% 40%, var(--cream) 40% 42%, transparent 42% 100%);
  animation: completionFlash 440ms steps(8, end) forwards;
}

.cell.is-event-recruit .entity--recruit { animation: pickupSoldier 280ms steps(5, end) forwards; }
.cell.is-event-mage .entity--mage { animation: pickupMage 320ms steps(6, end) forwards; }
.cell.is-event-builder .entity--builder { animation: pickupBuilder 320ms steps(5, end) forwards; }
.cell.is-event-healer .entity--healer { animation: pickupHealer 360ms steps(6, end) forwards; }
.cell.is-event-aegis .aegis-symbol { animation: pickupAegis 360ms steps(6, end) forwards; }
.cell.is-event-stride .maneuver-marker,
.cell.is-event-pivot .maneuver-marker { animation: markerResolve 320ms steps(5, end); }
.cell.is-event-goblin-death .entity--goblin { animation: goblinDeath 280ms steps(5, end) forwards; }
.cell.is-event-orc-death .entity--goblin { animation: orcDeath 340ms steps(6, end) forwards; }
.cell.is-event-ogre-death .entity--goblin { animation: ogreDeath 400ms steps(7, end) forwards; }
.cell.is-event-dragon-death .entity--dragon { animation: dragonDeath 460ms steps(8, end) forwards; }
.cell.is-event-bridge-build .bridge-planks { animation: bridgePlanksBuild 340ms steps(5, end) forwards; }
.cell.is-event-formation-open .formation-gate { animation: formationOpen 360ms steps(5, end) forwards; transform-origin: bottom; }
.cell.is-event-healing { animation: healingCell 420ms steps(6, end); }
.cell.is-event-complete { animation: completionCell 440ms steps(8, end); }

.confetti-layer {
  position: absolute;
  inset: 0;
  z-index: 11;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: 45%;
  left: 50%;
  width: 7px;
  height: 7px;
  background: var(--confetti-color, var(--gold));
  image-rendering: pixelated;
  animation: confettiBurst 850ms steps(8, end) forwards;
}

.draw-callout {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(23, 20, 37, 0.74);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.draw-callout b {
  color: var(--cream);
}

.draw-callout.is-error {
  color: #ffd9d6;
  border-color: rgba(255, 118, 111, 0.55);
  background: rgba(102, 42, 54, 0.82);
  animation: calloutPop 180ms ease-out;
}

.draw-callout.is-success {
  color: #d8ffe7;
  border-color: rgba(115, 224, 164, 0.5);
  background: rgba(34, 88, 65, 0.82);
}

.draw-callout__mouse {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  color: var(--ink);
  border-radius: 6px;
  background: var(--gold);
  font-size: 14px;
  font-weight: 900;
}

.solve-puzzle-button {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 11px;
  width: min(360px, calc(100% - 18px));
  min-height: 58px;
  margin-top: 12px;
  padding: 8px 12px;
  overflow: hidden;
  border: 2px solid #ffe197;
  border-radius: 11px;
  color: #2d201d;
  background: linear-gradient(135deg, #ffe38b, #efa94b 72%);
  box-shadow: 0 5px 0 #8a5630, 0 12px 30px rgba(255, 182, 72, 0.25);
  cursor: pointer;
  text-align: left;
  transition: transform 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}

.solve-puzzle-button::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.48) 45%, transparent 65%);
  transform: translateX(-120%);
  animation: solveShine 1.8s ease-in-out infinite;
  pointer-events: none;
}

.solve-puzzle-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 7px 0 #8a5630, 0 16px 34px rgba(255, 182, 72, 0.32);
}

.solve-puzzle-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8a5630, 0 7px 18px rgba(255, 182, 72, 0.24);
}

.solve-puzzle-button:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 4px;
}

.solve-puzzle-button__crest {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid rgba(68, 39, 32, 0.48);
  border-radius: 8px 8px 12px 12px;
  background: rgba(255, 246, 198, 0.58);
  box-shadow: inset 0 -4px rgba(171, 99, 43, 0.22);
  font-size: 19px;
}

.solve-puzzle-button__copy,
.solve-puzzle-button__copy strong,
.solve-puzzle-button__copy small {
  display: block;
}

.solve-puzzle-button__copy strong {
  font-size: 11px;
  letter-spacing: 0.12em;
}

.solve-puzzle-button__copy small {
  margin-top: 3px;
  color: rgba(70, 43, 35, 0.72);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.solve-puzzle-button__arrow {
  position: relative;
  font-size: 22px;
  font-weight: 900;
}

body.game-phase--ready .solve-puzzle-button,
.board-frame.board-phase--ready + .draw-callout + .solve-puzzle-button,
.board-frame[data-phase="ready"] + .draw-callout + .solve-puzzle-button {
  animation: solveReady 900ms steps(4, end) infinite;
}

.solve-puzzle-button:not([hidden]) {
  animation: solveReady 900ms steps(4, end) infinite;
}

body.game-phase--planning #companyPhase,
body[data-game-phase="planning"] #companyPhase,
body:has(.board-frame[data-phase="planning"]) #companyPhase {
  color: var(--violet);
}

body.game-phase--ready #companyPhase,
body[data-game-phase="ready"] #companyPhase,
body:has(.board-frame[data-phase="ready"]) #companyPhase {
  color: var(--gold);
}

body.game-phase--executing #companyPhase,
body[data-game-phase="executing"] #companyPhase,
body:has(.board-frame[data-phase="executing"]) #companyPhase {
  color: var(--mint);
}

body.game-phase--won #companyPhase,
body[data-game-phase="won"] #companyPhase,
body:has(.board-frame[data-phase="won"]) #companyPhase {
  color: var(--cream);
}

body.game-phase--planning #companyPhase i,
body[data-game-phase="planning"] #companyPhase i,
body:has(.board-frame[data-phase="planning"]) #companyPhase i { background: var(--violet); box-shadow: 0 0 8px var(--violet); }
body.game-phase--ready #companyPhase i,
body[data-game-phase="ready"] #companyPhase i,
body:has(.board-frame[data-phase="ready"]) #companyPhase i { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
body.game-phase--executing #companyPhase i,
body[data-game-phase="executing"] #companyPhase i,
body:has(.board-frame[data-phase="executing"]) #companyPhase i { background: var(--mint); box-shadow: 0 0 8px var(--mint); animation: phaseBlink 520ms steps(2, end) infinite; }
body.game-phase--won #companyPhase i,
body[data-game-phase="won"] #companyPhase i,
body:has(.board-frame[data-phase="won"]) #companyPhase i { background: var(--cream); box-shadow: 0 0 8px var(--cream); }

body.game-phase--executing .planning-ghost,
body[data-game-phase="executing"] .planning-ghost,
.board-frame.board-phase--executing .planning-ghost,
.board-frame[data-phase="executing"] .planning-ghost {
  visibility: hidden;
  opacity: 0;
}

.board-frame.board-phase--planning,
.board-frame[data-phase="planning"] {
  border-color: #62526e;
}

.board-frame.board-phase--ready,
.board-frame[data-phase="ready"] {
  border-color: #9c7442;
  box-shadow:
    0 0 0 2px #17121e,
    0 0 0 5px #9c7442,
    0 10px 0 #1a1320,
    0 0 25px rgba(255, 201, 92, 0.18),
    0 18px 35px rgba(0, 0, 0, 0.35);
}

.board-frame.board-phase--executing,
.board-frame[data-phase="executing"] {
  border-color: #4b8f70;
}

.board-frame.board-phase--won,
.board-frame[data-phase="won"] {
  border-color: #d9b55e;
}

body.is-execution-locked .board-frame,
.board-frame.is-execution-locked,
.board-frame.is-input-locked,
.board-frame[data-phase="executing"] {
  cursor: progress;
}

body.is-execution-locked .game-board,
.board-frame.is-execution-locked .game-board,
.board-frame.is-input-locked .game-board,
.board-frame[data-phase="executing"] .game-board {
  pointer-events: none;
}

.board-frame[data-phase="executing"] {
  pointer-events: none;
}

body.is-execution-locked .mission-tools button,
body.is-execution-locked .campaign-panel button,
body.is-execution-locked .commander-chip {
  opacity: 0.42;
  pointer-events: none;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--mint);
}

.live-dot i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint);
}

.roster {
  display: grid;
  gap: 7px;
}

.roster-card {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  min-height: 58px;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.roster-card[hidden] { display: none; }

.roster-card.is-active {
  border-color: rgba(115, 224, 164, 0.35);
  background: rgba(115, 224, 164, 0.07);
}

.roster-card--healer.is-active {
  border-color: rgba(255, 118, 111, 0.48);
  background: rgba(255, 118, 111, 0.09);
}

.roster-card--aegis.is-active {
  border-color: rgba(56, 214, 197, 0.54);
  background: rgba(56, 214, 197, 0.09);
}

.roster-card.is-bumping {
  animation: rosterBump 260ms ease-out;
}

.roster-card img {
  width: 38px;
  image-rendering: pixelated;
}

.roster-card__glyph {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 3px double #fff0a8;
  border-radius: 44% 44% 56% 56%;
  color: #fff5c9;
  background: linear-gradient(145deg, #429d98, #1d625f);
  box-shadow: inset 0 -5px rgba(15, 63, 62, 0.44), 0 2px 0 rgba(27, 24, 37, 0.5);
  font-style: normal;
  font-size: 17px;
  line-height: 1;
}

.roster-card span,
.roster-card strong {
  display: block;
}

.roster-card span {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.roster-card strong {
  margin-top: 3px;
  color: var(--cream);
  font-family: Georgia, serif;
  font-size: 22px;
  line-height: 0.9;
}

.roster-card small {
  align-self: end;
  padding-bottom: 3px;
  color: #7f788d;
  font-size: 7px;
  white-space: nowrap;
}

.route-meters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.route-meter {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.route-meter span,
.route-meter strong { display: block; }
.route-meter span {
  overflow: hidden;
  color: var(--muted);
  font-size: 6px;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-meter strong { margin-top: 6px; color: var(--pack-accent); font-family: Georgia, serif; font-size: 17px; }

.commander-order {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}

.commander-order[hidden] { display: none; }

.commander-chip {
  display: grid;
  grid-template-columns: 29px 1fr auto;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 41px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  opacity: 0.58;
  color: #c8c1d0;
  background: rgba(255, 255, 255, 0.02);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: 180ms ease;
}

.commander-chip img { width: 29px; image-rendering: pixelated; }
.commander-chip span,
.commander-chip b,
.commander-chip small { display: block; min-width: 0; }
.commander-chip b { font-size: 8px; letter-spacing: 0.05em; }
.commander-chip small { margin-top: 2px; color: var(--muted); font-size: 6px; }
.commander-chip > i { color: var(--mint); font-style: normal; font-size: 10px; }
.commander-chip:hover:not(:disabled) {
  opacity: 1;
  transform: translateX(2px);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.055);
}
.commander-chip:focus-visible {
  z-index: 1;
  opacity: 1;
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.commander-chip:disabled {
  cursor: default;
}
.commander-chip.is-active { opacity: 1; transform: translateX(3px); background: rgba(255, 255, 255, 0.06); }
.commander-chip.is-complete { opacity: 0.76; }
.commander-chip.has-draft:not(.is-active) {
  opacity: 0.86;
  border-style: dashed;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 5px, transparent 5px 10px),
    rgba(255, 255, 255, 0.025);
}
.commander-chip.has-draft:not(.is-active) small,
.commander-chip.has-draft:not(.is-active) > i {
  color: #d8cfff;
}
.commander-chip--captain.is-active { border-color: rgba(255, 118, 111, 0.52); box-shadow: inset 3px 0 var(--coral); }
.commander-chip--warden.is-active { border-color: rgba(93, 169, 214, 0.52); box-shadow: inset 3px 0 var(--water); }
.commander-chip--sage.is-active { border-color: rgba(169, 151, 255, 0.52); box-shadow: inset 3px 0 var(--violet); }

.seal-meter {
  margin-top: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
}

.seal-meter > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.seal-chips {
  display: flex;
  gap: 6px;
}

.seal-chip {
  flex: 1;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #746d80;
  font-size: 8px;
  text-align: center;
  transition: 180ms ease;
}

.seal-chip.is-open {
  color: #2a2118;
  border-color: #ffdc7c;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(255, 201, 92, 0.24);
}

.seal-chip--moon.is-open {
  color: #1d173c;
  border-color: #cfc8ff;
  background: var(--violet);
}

.rules-card {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.rules-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
}

.rules-title h2 {
  margin: 0;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.rules-card ol {
  display: grid;
  gap: 11px;
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: rules;
}

.rules-card li {
  position: relative;
  padding-left: 27px;
  counter-increment: rules;
}

.rules-card li::before {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  content: counter(rules);
  border: 1px solid rgba(255, 201, 92, 0.25);
  border-radius: 5px;
  color: var(--gold);
  font-size: 7px;
}

.rules-card b,
.rules-card span {
  display: block;
}

.rules-card b {
  color: #e7dfcf;
  font-size: 9px;
  font-weight: 600;
}

.rules-card span {
  margin-top: 3px;
  color: #8a8396;
  font-size: 8px;
  line-height: 1.45;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 17px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: #817a8e;
  font-size: 7px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 7px;
  height: 7px;
  border-radius: 2px;
}

.legend-swatch--recruit { background: var(--mint); }
.legend-swatch--danger { background: var(--coral); }
.legend-swatch--route { background: var(--gold); }
.legend-swatch--hungry { background: var(--coral); }
.legend-swatch--served { background: var(--mint); }
.legend-swatch--relief { background: var(--water); }
.legend-swatch--commander { background: var(--violet); }
.legend-swatch--beacon { background: var(--gold); box-shadow: 0 0 5px var(--gold); }
.legend-swatch--locked { background: #5f7fa7; }
.legend-swatch--healer { background: var(--coral); box-shadow: 0 0 5px rgba(255, 118, 111, 0.7); }
.legend-swatch--formation { border: 1px double #e7f9ff; background: var(--water); box-shadow: 0 0 5px rgba(93, 169, 214, 0.72); }
.legend-swatch--stride {
  border: 1px double #e5fffb;
  background: var(--teal);
  box-shadow: 0 0 5px rgba(56, 214, 197, 0.72);
}
.legend-swatch--pivot {
  border: 1px dashed #eeeaff;
  background: var(--violet);
  box-shadow: 0 0 5px rgba(169, 151, 255, 0.72);
}
.legend-swatch--aegis {
  border: 1px double #fff0a8;
  border-radius: 45% 45% 58% 58%;
  background: #278a82;
  box-shadow: 0 0 5px rgba(255, 224, 138, 0.72);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 15px clamp(18px, 3vw, 48px) 24px;
  color: #655f72;
  font-size: 8px;
  letter-spacing: 0.12em;
}

dialog {
  color: var(--cream);
  border: 1px solid rgba(255, 201, 92, 0.34);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(57, 44, 67, 0.98), rgba(28, 24, 39, 0.99));
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.58);
}

dialog::backdrop {
  background: rgba(13, 11, 21, 0.74);
  backdrop-filter: blur(7px);
}

.victory-dialog {
  width: min(430px, calc(100% - 30px));
  padding: 30px;
  text-align: center;
}

.victory-dialog[open] {
  animation: dialogIn 260ms ease-out;
}

.victory-stars {
  margin-bottom: 14px;
  color: var(--gold);
  font-size: 22px;
  letter-spacing: 0.2em;
}

.victory-dialog h2,
.credits-dialog h2 {
  margin: 8px 0;
  font-family: Georgia, serif;
  font-size: 30px;
  font-weight: 500;
}

.victory-dialog p,
.credits-dialog p {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.victory-stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin: 22px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.victory-stats b {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 24px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 9px;
}

.secondary-button,
.primary-button {
  min-height: 46px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.primary-button {
  color: #251a19;
  border-color: #ffdf8c;
  background: linear-gradient(#ffda7d, #e9a944);
  box-shadow: 0 4px 0 #8a5630;
}

.secondary-button {
  color: var(--muted);
}

.credits-dialog {
  position: relative;
  width: min(520px, calc(100% - 30px));
  padding: 30px;
}

.credits-dialog ul {
  display: grid;
  gap: 10px;
  margin: 20px 0;
  padding: 0;
  list-style: none;
  color: #bcb5c8;
  font-size: 9px;
}

.credits-dialog li {
  padding-left: 16px;
  text-indent: -16px;
}

.credits-dialog li::before {
  margin-right: 8px;
  color: var(--gold);
  content: "✦";
}

.credits-dialog a {
  color: #ffe0a0;
}

.credits-note {
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.designer-dialog {
  width: min(1180px, calc(100vw - 24px));
  max-width: none;
  height: min(820px, calc(100dvh - 24px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  border-color: rgba(255, 201, 92, 0.42);
  background:
    radial-gradient(circle at 75% 0%, rgba(169, 151, 255, 0.13), transparent 40%),
    linear-gradient(180deg, #30283d, #1c1928);
}

.designer-dialog[open] {
  animation: dialogIn 240ms ease-out;
}

.designer-shell {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.designer-head {
  position: relative;
  display: flex;
  min-height: 104px;
  align-items: center;
  gap: 24px;
  padding: 20px 72px 18px 24px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(255, 201, 92, 0.08), transparent 45%),
    rgba(20, 18, 30, 0.38);
}

.designer-head h2,
.designer-workspace h3,
.designer-section h3 {
  margin: 0;
}

.designer-head h2 {
  margin-top: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.designer-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.designer-head__save {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 7px 10px;
  border: 1px solid rgba(115, 224, 164, 0.2);
  border-radius: 7px;
  color: #a4cfb5;
  background: rgba(115, 224, 164, 0.05);
  font-size: 8px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.designer-save-light {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--mint);
  box-shadow: 0 0 8px rgba(115, 224, 164, 0.75);
}

.designer-head__save.is-saving .designer-save-light {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(255, 201, 92, 0.7);
  animation: saveBlink 600ms steps(2, end) infinite;
}

.designer-layout {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: 310px minmax(0, 1fr);
}

.designer-sidebar,
.designer-workspace {
  min-height: 0;
  overflow: auto;
  scrollbar-color: #685d74 #211c2c;
  scrollbar-width: thin;
}

.designer-sidebar {
  padding: 19px;
  border-right: 1px solid var(--line);
  background: rgba(17, 15, 25, 0.27);
}

.designer-section + .designer-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.designer-section__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.designer-section__heading > span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(255, 201, 92, 0.28);
  border-radius: 5px;
  color: var(--gold);
  background: rgba(255, 201, 92, 0.06);
  font-size: 7px;
}

.designer-section h3 {
  color: #d9d1e1;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.designer-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.designer-field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.designer-field--wide {
  grid-column: 1 / -1;
}

.designer-field > span:not(.sr-only) {
  color: #91899f;
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.designer-field input,
.designer-field select,
.designer-field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 6px;
  outline: 0;
  color: var(--cream);
  background: rgba(13, 12, 20, 0.55);
  font: inherit;
  font-size: 9px;
  line-height: 1.45;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.designer-field input,
.designer-field select {
  min-height: 37px;
  padding: 7px 9px;
}

.designer-field textarea {
  min-height: 60px;
  padding: 8px 9px;
  resize: vertical;
}

.designer-field input::placeholder,
.designer-field textarea::placeholder {
  color: #625c6e;
}

.designer-field input:focus,
.designer-field select:focus,
.designer-field textarea:focus {
  border-color: rgba(255, 201, 92, 0.65);
  background: rgba(16, 14, 23, 0.78);
  box-shadow: 0 0 0 2px rgba(255, 201, 92, 0.1);
}

.designer-mini-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
  margin-top: 7px;
}

.designer-mini-actions button {
  min-width: 0;
  min-height: 33px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #aaa3b5;
  background: rgba(255, 255, 255, 0.035);
  font-size: 7px;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.designer-mini-actions button:hover {
  color: var(--cream);
  border-color: rgba(255, 201, 92, 0.4);
}

.designer-mini-actions button.is-danger:hover {
  color: #ffd8d5;
  border-color: rgba(255, 118, 111, 0.58);
  background: rgba(255, 118, 111, 0.08);
}

.designer-size-fields {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 10px;
}

.designer-size-fields > span {
  padding-bottom: 10px;
  color: var(--gold);
  font-size: 12px;
}

.designer-workspace {
  display: grid;
  align-content: start;
  gap: 13px;
  grid-auto-rows: max-content;
  padding: 19px;
  overscroll-behavior: contain;
}

.designer-paint-panel,
.designer-check-panel,
.designer-export {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

.designer-paint-panel {
  min-width: 0;
  min-height: 420px;
  padding: 16px;
  overflow: hidden;
}

.designer-workspace-heading,
.designer-export__heading,
.designer-check-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.designer-workspace h3 {
  margin-top: 4px;
  color: #eee7d8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 500;
}

.designer-workspace-heading > p {
  margin: 0;
  color: #746e80;
  font-size: 7px;
  line-height: 1.5;
  text-align: right;
}

.designer-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 48px;
  margin-top: 14px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(13, 12, 20, 0.38);
}

.designer-palette > button,
.designer-palette__button {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  padding: 2px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--cream);
  background: #334d43;
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  cursor: pointer;
  image-rendering: pixelated;
}

.designer-palette > button:hover,
.designer-palette__button:hover {
  z-index: 1;
  transform: translateY(-2px);
  border-color: rgba(255, 201, 92, 0.65);
}

.designer-palette > button[aria-pressed="true"],
.designer-palette__button.is-selected {
  border-color: #fff1bd;
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.18), 0 0 12px rgba(255, 201, 92, 0.32);
}

.designer-palette img,
.designer-cell img,
.designer-grid > button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  image-rendering: pixelated;
}

.designer-grid-scroll {
  position: relative;
  z-index: 0;
  display: block;
  max-width: 100%;
  width: 100%;
  height: clamp(250px, 37dvh, 390px);
  min-height: 0;
  max-height: none;
  margin-top: 11px;
  padding: 20px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  outline: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    rgba(13, 12, 20, 0.5);
  background-size: 16px 16px;
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.24);
  scrollbar-color: #6c6079 #211c2c;
  scrollbar-width: thin;
  contain: layout paint;
  isolation: isolate;
  overscroll-behavior: contain;
}

.designer-grid-scroll:focus-visible {
  border-color: rgba(255, 201, 92, 0.55);
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.24), 0 0 0 2px rgba(255, 201, 92, 0.12);
}

.designer-grid {
  display: grid;
  width: max-content;
  min-width: 100%;
  min-height: 230px;
  grid-template-columns: repeat(var(--design-cols, 8), var(--designer-cell-size, 46px));
  grid-auto-rows: var(--designer-cell-size, 46px);
  align-content: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

/* Workshop cells are real board cells; only sizing and paint affordances differ. */
.designer-grid > .designer-cell {
  width: var(--designer-cell-size, 46px);
  height: var(--designer-cell-size, 46px);
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(25, 48, 38, 0.19);
  border-bottom: 1px solid rgba(25, 48, 38, 0.19);
  border-radius: 0;
  font: inherit;
  cursor: crosshair;
}

.designer-grid > .designer-cell:focus-visible {
  z-index: 3;
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.designer-paint-help {
  margin: 9px 0 0;
  color: #777082;
  font-size: 7px;
  line-height: 1.5;
  text-align: center;
}

.designer-check-panel {
  position: relative;
  z-index: 2;
  padding: 14px 16px;
}

.designer-check-panel > div:first-child {
  min-width: 0;
}

.designer-status {
  margin: 6px 0 0;
  color: #928b9e;
  font-size: 8px;
  line-height: 1.45;
}

/* A standing verdict on whether the game can start this map at all, distinct from
   the status line below it, which reports what just happened. */
.designer-readiness {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  padding: 6px 8px;
  border: 1px solid rgba(126, 226, 178, 0.28);
  border-radius: 6px;
  color: var(--mint);
  background: rgba(126, 226, 178, 0.08);
  font-size: 8px;
  line-height: 1.45;
}

.designer-readiness::before {
  flex: 0 0 auto;
  content: "✓";
}

.designer-readiness.is-blocked {
  border-color: rgba(255, 170, 165, 0.34);
  color: #ffaaa5;
  background: rgba(255, 118, 111, 0.09);
}

.designer-readiness.is-blocked::before {
  content: "!";
}

.designer-status.is-success { color: var(--mint); }
.designer-status.is-error { color: #ffaaa5; }
.designer-status.is-working { color: var(--gold); }

.designer-primary-actions {
  position: relative;
  z-index: 3;
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1.2fr;
  gap: 7px;
}

.designer-primary-actions .secondary-button,
.designer-primary-actions .primary-button {
  min-width: 118px;
  padding: 8px 13px;
}

.designer-export {
  position: relative;
  z-index: 1;
  padding: 14px 16px 16px;
}

.designer-export__heading {
  margin-bottom: 10px;
}

.designer-export__heading .secondary-button {
  min-height: 38px;
  padding: 7px 12px;
}

.designer-export textarea {
  min-height: 102px;
  max-height: 220px;
  color: #b9e6c9;
  background: #121019;
  font-size: 8px;
  resize: vertical;
}

@keyframes saveBlink {
  50% { opacity: 0.3; }
}

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

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

@keyframes enemySway {
  0%, 100% { transform: translateX(-50%) rotate(-2deg); }
  50% { transform: translateX(-50%) rotate(2deg) translateY(-2px); }
}

@keyframes dragonBreathe {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06) translateY(-2px); }
}

@keyframes bannerWave {
  0%, 100% { transform: translateX(-50%) skewY(-2deg); }
  50% { transform: translateX(-50%) skewY(3deg) translateY(-2px); }
}

@keyframes ringRotate { to { transform: rotate(360deg); } }
@keyframes waterShimmer { 50% { filter: brightness(1.08) hue-rotate(3deg); } }
@keyframes riverCurrent { to { transform: translateX(31px); } }
@keyframes hungryBounce { 50% { transform: translateX(-50%) translateY(-3px) scaleY(1.06); } }
@keyframes healerFloat { 50% { transform: translateX(-50%) translateY(-4px); filter: brightness(1.2) drop-shadow(0 0 9px rgba(255, 180, 173, 0.9)); } }
@keyframes healerAura { to { transform: rotate(360deg); opacity: 0.72; } }
@keyframes fedDance { 25% { transform: translateX(-50%) rotate(-7deg) translateY(-4px); } 75% { transform: translateX(-50%) rotate(7deg) translateY(-4px); } }
@keyframes mudBubble { 50% { transform: scale(1.25); opacity: 0.5; } }
@keyframes supplyPulse { 50% { transform: translateX(-50%) translateY(-2px); filter: brightness(1.25) drop-shadow(0 0 6px var(--gold)); } }
@keyframes beaconFlare { 50% { transform: translateY(-2px) scale(1.05); } }
@keyframes arrowNudge { 50% { transform: translateX(3px); filter: brightness(1.22); } }
@keyframes switchGlow { 50% { filter: brightness(1.2); transform: translateY(-2px); } }
@keyframes gateOpen { to { transform: scaleY(0.12); opacity: 0.45; } }
@keyframes formationOpen { to { transform: scaleY(0.1); opacity: 0.3; filter: brightness(1.5); } }
@keyframes headPulse { 50% { transform: scale(1.35); opacity: 0.72; } }
@keyframes draftRouteMarch { to { stroke-dashoffset: -28; } }
@keyframes cellPop { 50% { filter: brightness(1.25); } }
@keyframes rosterBump { 50% { transform: scale(1.035); } }
@keyframes calloutPop { 50% { transform: scale(1.02); } }

@keyframes blockedShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes hintPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.5); }
}

@keyframes partyStep {
  0% { transform: translate(-50%, -50%) scale(0.9, 1.1); }
  55% { transform: translate(-50%, -58%) scale(1.07, 0.94); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes partyWin {
  0%, 100% { transform: translate(-50%, -50%) rotate(0); }
  25% { transform: translate(-50%, -65%) rotate(-5deg); }
  75% { transform: translate(-50%, -65%) rotate(5deg); }
}

@keyframes partyStart {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  25% { transform: translate(-50%, -62%) scale(0.94, 1.08) rotate(-4deg); }
  55% { transform: translate(-50%, -66%) scale(1.08, 0.92) rotate(4deg); }
}

@keyframes partyAttack {
  0%, 100% { transform: translate(-50%, -50%); }
  35% { transform: translate(-68%, -48%) rotate(-7deg) scale(0.94, 1.05); }
  68% { transform: translate(-34%, -53%) rotate(7deg) scale(1.08, 0.94); }
}

@keyframes partyCast {
  0%, 100% { transform: translate(-50%, -50%); filter: none; }
  35% { transform: translate(-50%, -62%) scale(0.94); filter: brightness(1.35) drop-shadow(0 0 6px var(--violet)); }
  65% { transform: translate(-50%, -57%) scale(1.08); filter: brightness(1.7) drop-shadow(0 0 11px var(--violet)); }
}

@keyframes partyHeal {
  0%, 100% { transform: translate(-50%, -50%); filter: none; }
  45% { transform: translate(-50%, -60%) scale(1.08); filter: brightness(1.55) drop-shadow(0 0 12px var(--coral)); }
}

@keyframes partyGuard {
  0%, 100% { transform: translate(-50%, -50%) scale(1); filter: none; }
  35% { transform: translate(-50%, -54%) scale(0.92); filter: brightness(1.35) drop-shadow(0 0 7px #fff0a8); }
  65% { transform: translate(-50%, -54%) scale(1.08); filter: brightness(1.65) drop-shadow(0 0 13px var(--teal)); }
}

@keyframes ghostRing {
  0%, 100% { transform: scale(0.9) rotate(0); opacity: 0.42; }
  50% { transform: scale(1.05) rotate(12deg); opacity: 0.9; }
}

@keyframes ghostStep {
  0% { transform: translate(-50%, -50%) scale(0.88); opacity: 0.35; }
  58% { transform: translate(-50%, -58%) scale(1.05); opacity: 0.82; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
}

@keyframes pickupBurst {
  0% { transform: scale(0.3); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: scale(1.45); opacity: 0; }
}

@keyframes pickupSpark {
  0% { transform: rotate(0) scale(0.4); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: rotate(90deg) scale(1.35); opacity: 0; }
}

@keyframes enemyImpact {
  0% { transform: scale(0.28) rotate(-8deg); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: scale(1.55) rotate(18deg); opacity: 0; }
}

@keyframes maneuverResolve {
  0% { transform: scale(0.55); opacity: 0; }
  38% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1.28); opacity: 0; }
}

@keyframes aegisGuard {
  0% { transform: scale(0.45); opacity: 0; }
  30% { transform: scale(0.9); opacity: 1; }
  68% { transform: scale(1.05); opacity: 0.95; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes fireballFlight {
  0% { transform: translate(-50%, -50%) translate(0, 0) scale(0.65); opacity: 0; }
  18% { opacity: 1; }
  78% { opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--fx-dx), var(--fx-dy)) scale(1.35); opacity: 0; }
}

@keyframes bridgeBuildFx {
  0% { transform: scaleY(0.08) rotate(-2deg); opacity: 0; }
  35% { opacity: 1; }
  75% { transform: scaleY(1.08) rotate(1deg); opacity: 0.9; }
  100% { transform: scaleY(1); opacity: 0; }
}

@keyframes formationInspection {
  0% { transform: scaleY(1); opacity: 0.2; }
  45% { transform: scaleY(1.08); opacity: 1; }
  100% { transform: scaleY(0.1); opacity: 0; }
}

@keyframes formationStamp {
  0% { transform: scale(1.8); opacity: 0; }
  38% { transform: scale(0.78); opacity: 1; }
  70% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.25); opacity: 0; }
}

@keyframes healingWave {
  0% { transform: scale(0.25); opacity: 0.9; }
  100% { transform: scale(1.65); opacity: 0; }
}

@keyframes completionFlash {
  0% { transform: rotate(0) scale(0.2); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: rotate(90deg) scale(1.15); opacity: 0; }
}

@keyframes pickupSoldier {
  0% { transform: translateX(-50%); opacity: 1; }
  45% { transform: translateX(-50%) translateY(-35%) scale(1.16); filter: brightness(1.6) drop-shadow(0 0 8px var(--mint)); }
  100% { transform: translateX(-50%) translateY(-65%) scale(0.48); opacity: 0; }
}

@keyframes pickupMage {
  0% { transform: translateX(-50%) rotate(0); opacity: 1; }
  55% { transform: translateX(-50%) translateY(-28%) rotate(12deg) scale(1.12); filter: brightness(1.65) drop-shadow(0 0 10px var(--violet)); }
  100% { transform: translateX(-50%) translateY(-62%) rotate(24deg) scale(0.42); opacity: 0; }
}

@keyframes pickupBuilder {
  0% { transform: translateX(-50%) rotate(0); opacity: 1; }
  35% { transform: translateX(-50%) rotate(-8deg) translateY(-10%); }
  65% { transform: translateX(-50%) rotate(8deg) translateY(-25%) scale(1.12); filter: brightness(1.45) drop-shadow(0 0 8px var(--gold)); }
  100% { transform: translateX(-50%) translateY(-58%) scale(0.48); opacity: 0; }
}

@keyframes pickupHealer {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  45% { transform: translateX(-50%) translateY(-32%) scale(1.14); filter: brightness(1.55) drop-shadow(0 0 12px var(--coral)); }
  100% { transform: translateX(-50%) translateY(-65%) scale(0.45); opacity: 0; }
}

@keyframes pickupAegis {
  0% { transform: scale(1); opacity: 1; }
  45% { transform: translateY(-20%) scale(1.14); filter: brightness(1.55) drop-shadow(0 0 12px #fff0a8); }
  100% { transform: translateY(-55%) scale(0.45); opacity: 0; }
}

@keyframes markerResolve {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.08); filter: brightness(1.55) drop-shadow(0 0 10px var(--teal)); }
}

@keyframes markerPending {
  0%, 100% { opacity: 0.62; }
  50% { opacity: 1; }
}

@keyframes goblinDeath {
  0% { transform: translateX(-50%) rotate(0) scale(1); opacity: 1; }
  42% { transform: translateX(-58%) rotate(-18deg) scale(1.08, 0.88); filter: brightness(1.7); }
  100% { transform: translateX(-68%) translateY(35%) rotate(-45deg) scale(0.48); opacity: 0; }
}

@keyframes orcDeath {
  0%, 24% { transform: translateX(-50%) rotate(0) scale(1); opacity: 1; }
  45% { transform: translateX(-43%) rotate(8deg) scale(1.12, 0.9); filter: brightness(1.55) drop-shadow(0 0 7px #f0a45d); }
  100% { transform: translateX(-35%) translateY(38%) rotate(38deg) scale(0.55); opacity: 0; }
}

@keyframes ogreDeath {
  0%, 20% { transform: translateX(-50%) scale(1); opacity: 1; }
  38% { transform: translateX(-56%) scale(1.14, 0.86); filter: brightness(1.7) drop-shadow(0 0 10px var(--coral)); }
  55% { transform: translateX(-44%) scale(0.92, 1.1); }
  100% { transform: translateX(-50%) translateY(42%) rotate(14deg) scale(0.58, 0.34); opacity: 0; }
}

@keyframes dragonDeath {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  35% { transform: translateX(-50%) translateY(-12%) scale(1.12); filter: brightness(2) hue-rotate(28deg) drop-shadow(0 0 13px var(--violet)); }
  62% { transform: translateX(-50%) translateY(-20%) rotate(-6deg) scale(0.92); opacity: 0.85; }
  100% { transform: translateX(-50%) translateY(-52%) rotate(12deg) scale(0.34); opacity: 0; }
}

@keyframes bridgePlanksBuild {
  0% { transform: scaleY(0); opacity: 0; }
  35% { opacity: 1; }
  78% { transform: scaleY(1.08); }
  100% { transform: scaleY(1); opacity: 1; }
}

@keyframes healingCell {
  0%, 100% { filter: brightness(1); }
  45% { filter: brightness(1.5) saturate(1.2) drop-shadow(0 0 8px rgba(255, 118, 111, 0.75)); }
}

@keyframes completionCell {
  0%, 100% { filter: brightness(1); }
  35% { filter: brightness(1.8) drop-shadow(0 0 10px var(--gold)); }
  65% { filter: brightness(1.35) drop-shadow(0 0 14px var(--mint)); }
}

@keyframes solveShine {
  0%, 38% { transform: translateX(-120%); }
  72%, 100% { transform: translateX(120%); }
}

@keyframes solveReady {
  0%, 100% { box-shadow: 0 5px 0 #8a5630, 0 12px 30px rgba(255, 182, 72, 0.22); }
  50% { box-shadow: 0 5px 0 #8a5630, 0 12px 38px rgba(255, 214, 126, 0.48); }
}

@keyframes phaseBlink {
  50% { opacity: 0.35; }
}

@keyframes confettiBurst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) rotate(var(--spin)); opacity: 0; }
}

@keyframes dialogIn {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
}

@media (max-width: 1380px) {
  .game-shell {
    grid-template-columns: 190px minmax(440px, 1fr);
  }

  .company-panel {
    position: static;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 20px;
  }

  .company-panel .panel-heading,
  .company-panel .route-meters,
  .company-panel .commander-order,
  .company-panel .seal-meter,
  .company-panel .legend {
    grid-column: 1;
  }

  .company-panel .rules-card {
    grid-column: 2;
    grid-row: 1 / span 4;
    margin-top: 0;
    padding-top: 0;
    padding-left: 18px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .commander-order { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .commander-chip { grid-template-columns: 26px 1fr; }
  .commander-chip > i { display: none; }
}

@media (max-width: 940px) {
  .designer-dialog {
    width: calc(100vw - 14px);
    height: calc(100dvh - 14px);
  }

  .designer-layout {
    display: block;
    overflow: auto;
  }

  .designer-sidebar,
  .designer-workspace {
    overflow: visible;
  }

  .designer-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .designer-section--size {
    max-width: 290px;
  }

  .designer-paint-panel {
    min-height: 0;
  }
}

@media (max-width: 820px) {
  :root { --cell-size: 52px; }

  .topbar {
    grid-template-columns: 1fr auto;
    min-height: 70px;
    padding: 10px 16px;
  }

  .chapter-mark { display: none; }
  .icon-button__label { display: none; }
  .icon-button { min-width: 43px; justify-content: center; padding: 7px; }

  .game-shell {
    display: flex;
    min-height: auto;
    flex-direction: column;
    padding: 16px 12px 24px;
  }

  .campaign-panel {
    display: block;
    max-height: none;
    position: static;
    order: 2;
    overflow: visible;
  }

  .mission-panel { order: 1; }
  .company-panel { order: 3; }

  .level-list {
    grid-template-columns: repeat(5, 1fr);
    padding-right: 0;
    overflow: visible;
  }

  .level-button {
    display: flex;
    justify-content: center;
    min-height: 40px;
    padding: 5px;
  }

  .level-button__copy,
  .level-button__check { display: none; }

  .mission-head {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 13px;
  }

  .mission-tools {
    width: 100%;
  }

  .tool-button { flex: 1; min-height: 44px; }

  .board-stage {
    min-height: 310px;
    padding: 35px 8px 27px;
  }

  .solve-puzzle-button {
    width: min(420px, calc(100% - 12px));
    min-height: 60px;
  }

  .objective-ribbon {
    margin-bottom: 10px;
  }

  .company-panel {
    grid-template-columns: 1fr;
  }

  .company-panel .rules-card {
    grid-column: 1;
    grid-row: auto;
    margin-top: 10px;
    padding-top: 15px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .commander-order { grid-template-columns: 1fr; }

  .designer-head {
    min-height: 96px;
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
    padding: 17px 58px 15px 17px;
  }

  .designer-head__save {
    margin-left: 0;
  }

  .designer-sidebar,
  .designer-workspace {
    padding: 15px;
  }

  .designer-workspace-heading,
  .designer-export__heading {
    align-items: flex-start;
  }

  .designer-grid-scroll {
    min-height: 250px;
    padding: 13px;
  }
}

@media (max-width: 520px) {
  :root { --cell-size: 49px; }

  .brand strong { font-size: 12px; }
  .brand small { font-size: 8px; }
  .brand__crest { width: 38px; height: 38px; }
  .top-actions { gap: 5px; }

  .mission-head h1 { font-size: 34px; }

  .objective-ribbon {
    align-items: flex-start;
    padding: 9px 10px;
  }

  .objective-ribbon span:not(.objective-ribbon__icon) {
    line-height: 1.45;
  }

  .board-stage {
    min-height: 275px;
    border-radius: 12px;
  }

  .solve-puzzle-button {
    grid-template-columns: 34px minmax(0, 1fr) 22px;
    width: calc(100% - 4px);
    min-height: 54px;
    gap: 8px;
    padding: 7px 9px;
  }

  .solve-puzzle-button__crest {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  .solve-puzzle-button__copy strong { font-size: 10px; }
  .solve-puzzle-button__copy small { font-size: 7px; }

  .route-shadow { stroke-width: 9px; }
  .route-line { stroke-width: 5px; }
  .tile-label { display: none; }

  .pack-tab { min-height: 48px; }

  .board-frame--dense .switch-symbol,
  .board-frame--dense .gate-symbol,
  .board-frame--dense .formation-gate,
  .board-frame--dense .maneuver-marker,
  .board-frame--dense .aegis-symbol {
    inset: 12%;
    border-width: 1px;
    border-radius: 3px;
    box-shadow: none;
    font-size: 7px;
  }

  .board-frame--dense .cell--wilds .wild-sprite {
    opacity: 0.42;
  }

  .roster {
    grid-template-columns: 1fr 1fr;
  }

  .roster-card--soldier { grid-column: 1 / -1; }
  .roster-card--healer { grid-column: 1 / -1; }
  .roster-card--aegis { grid-column: 1 / -1; }
  .roster-card { grid-template-columns: 34px 1fr; }
  .roster-card img,
  .roster-card__glyph { width: 34px; }
  .roster-card small { display: none; }

  .designer-head h2 { font-size: 25px; }
  .designer-head p { display: none; }

  .designer-head__save {
    min-height: 27px;
    padding: 5px 7px;
    font-size: 7px;
  }

  .designer-form-grid {
    grid-template-columns: 1fr;
  }

  .designer-field--wide {
    grid-column: auto;
  }

  .designer-section--size {
    max-width: none;
  }

  .designer-mini-actions {
    grid-template-columns: 1fr 1fr;
  }

  .designer-mini-actions .is-danger {
    grid-column: 1 / -1;
  }

  .designer-workspace-heading {
    display: block;
  }

  .designer-workspace-heading > p {
    margin-top: 5px;
    text-align: left;
  }

  .designer-paint-panel,
  .designer-check-panel,
  .designer-export {
    padding: 12px;
  }

  .designer-grid-scroll {
    min-height: 230px;
    padding: 9px;
  }

  .designer-grid {
    --designer-cell-size: 42px;
    min-height: 210px;
  }

  .designer-check-panel,
  .designer-export__heading {
    align-items: stretch;
    flex-direction: column;
  }

  .designer-primary-actions {
    width: 100%;
  }

  .designer-primary-actions .secondary-button,
  .designer-primary-actions .primary-button {
    min-width: 0;
  }

  .designer-export__heading .secondary-button {
    width: 100%;
  }

  footer { flex-direction: column; }
}

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

/* Full-screen playfield: the board is the stage; navigation and roster are HUD drawers. */
:root {
  --hud-topbar-height: 72px;
  --hud-drawer-width: 292px;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
}

.topbar {
  position: fixed;
  z-index: 70;
  inset: 0 0 auto;
  width: 100%;
  min-height: var(--hud-topbar-height);
  height: var(--hud-topbar-height);
  padding-block: 8px;
  background: linear-gradient(180deg, rgba(23, 20, 37, 0.94), rgba(23, 20, 37, 0.72));
  box-shadow: 0 10px 28px rgba(10, 8, 18, 0.24);
}

.game-shell {
  position: relative;
  display: block;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.mission-panel {
  position: absolute;
  inset: 0;
  min-width: 0;
}

.board-stage {
  position: absolute;
  inset: 0;
  display: flex;
  min-height: 0;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 211, 114, 0.09), transparent 48%),
    repeating-linear-gradient(135deg, transparent 0 12px, rgba(255, 255, 255, 0.012) 12px 13px),
    linear-gradient(180deg, rgba(35, 29, 49, 0.88), rgba(18, 16, 28, 0.96));
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.34);
}

.board-stage::before {
  top: calc(var(--hud-topbar-height) + 18px);
  left: 20px;
}

.board-stage::after {
  right: 20px;
  bottom: 20px;
}

.board-viewport {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  place-items: center;
  padding: 8px;
  overflow: hidden;
}

.board-frame {
  width: auto;
  max-width: none;
  flex: 0 0 auto;
  aspect-ratio: auto;
}

.mission-head {
  position: absolute;
  z-index: 18;
  top: calc(var(--hud-topbar-height) + 12px);
  right: clamp(82px, 7vw, 112px);
  left: clamp(82px, 7vw, 112px);
  min-height: 76px;
  align-items: center;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(30, 25, 43, 0.88), rgba(30, 25, 43, 0.58));
  box-shadow: 0 12px 28px rgba(7, 6, 13, 0.22);
  backdrop-filter: blur(12px);
}

.mission-head h1 {
  margin: 4px 0 1px;
  font-size: clamp(28px, 3vw, 43px);
}

.mission-head p {
  max-width: min(58vw, 720px);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.objective-ribbon {
  position: absolute;
  z-index: 19;
  top: calc(var(--hud-topbar-height) + 100px);
  right: clamp(94px, 11vw, 180px);
  left: clamp(94px, 11vw, 180px);
  width: auto;
  max-width: none;
  margin: 0;
  background: linear-gradient(90deg, rgba(67, 48, 59, 0.9), rgba(35, 29, 49, 0.7));
  box-shadow: 0 10px 24px rgba(7, 6, 13, 0.2);
  backdrop-filter: blur(10px);
}

.draw-callout {
  max-width: min(760px, calc(100vw - 32px));
  flex: 0 0 auto;
  margin-top: 8px;
  backdrop-filter: blur(10px);
}

.solve-puzzle-button {
  flex: 0 0 auto;
}

.campaign-panel,
.company-panel {
  position: fixed;
  z-index: 60;
  top: calc(var(--hud-topbar-height) + 12px);
  bottom: 12px;
  width: min(var(--hud-drawer-width), calc(100vw - 82px));
  max-height: none;
  align-self: auto;
  padding: 18px;
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(44, 38, 59, 0.97), rgba(25, 22, 36, 0.97));
  box-shadow: 0 25px 70px rgba(4, 3, 9, 0.55);
  backdrop-filter: blur(18px);
  visibility: hidden;
  transition: transform 220ms ease, visibility 0s linear 220ms;
}

.campaign-panel {
  left: 12px;
  display: flex;
  overflow: hidden;
  transform: translateX(calc(-100% - 26px));
}

.company-panel {
  right: 12px;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  transform: translateX(calc(100% + 26px));
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.company-panel .panel-heading,
.company-panel .route-meters,
.company-panel .commander-order,
.company-panel .seal-meter,
.company-panel .legend,
.company-panel .rules-card {
  grid-column: auto;
  grid-row: auto;
}

.company-panel .rules-card {
  margin-top: 19px;
  padding-top: 18px;
  padding-left: 0;
  border-top: 1px solid var(--line);
  border-left: 0;
}

body.hud-campaign-open .campaign-panel {
  visibility: visible;
  transform: translateX(0);
  transition-delay: 0s;
}

.hud-drawer-toggle {
  position: fixed;
  z-index: 65;
  top: 50%;
  display: grid;
  width: 66px;
  min-height: 76px;
  place-items: center;
  gap: 4px;
  padding: 8px 5px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(30, 25, 43, 0.9);
  box-shadow: 0 10px 26px rgba(5, 4, 10, 0.35);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transform: translateY(-50%);
  transition: left 220ms ease, right 220ms ease, border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.hud-drawer-toggle:hover {
  border-color: color-mix(in srgb, var(--pack-accent), transparent 38%);
  background: rgba(47, 40, 62, 0.96);
}

.hud-drawer-toggle:focus-visible {
  outline-color: var(--pack-accent);
}

.hud-drawer-toggle:disabled {
  opacity: 0.45;
  cursor: default;
}

.hud-drawer-toggle > span:not(.hud-drawer-toggle__glyph) {
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.hud-drawer-toggle small {
  color: var(--pack-accent);
  font-size: 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hud-drawer-toggle__glyph {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: var(--ink);
  background: var(--pack-accent);
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--pack-accent), #342334 45%);
}

.hud-drawer-toggle--campaign { left: 14px; }

body.hud-campaign-open .hud-drawer-toggle--campaign {
  border-color: color-mix(in srgb, var(--pack-accent), transparent 20%);
  background: rgba(55, 46, 68, 0.98);
}

@media (min-width: 1100px) {
  body.hud-campaign-open .hud-drawer-toggle--campaign {
    left: calc(var(--hud-drawer-width) + 24px);
  }

}

.hud-scrim {
  display: none;
}

footer {
  display: none;
}

@media (max-width: 1099px) {
  .hud-scrim:not([hidden]) {
    position: fixed;
    z-index: 58;
    inset: var(--hud-topbar-height) 0 0;
    display: block;
    width: 100%;
    height: auto;
    padding: 0;
    border: 0;
    background: rgba(11, 9, 18, 0.48);
    backdrop-filter: blur(3px);
    cursor: default;
  }
}

@media (max-width: 820px) {
  :root {
    --hud-topbar-height: 64px;
    --hud-drawer-width: 310px;
  }

  .topbar {
    min-height: var(--hud-topbar-height);
    height: var(--hud-topbar-height);
    padding: 7px 10px;
  }

  .brand__crest {
    width: 40px;
    height: 40px;
  }

  .game-shell {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .hud-drawer-toggle {
    top: calc(var(--hud-topbar-height) + 8px);
    width: min(142px, calc(50vw - 16px));
    min-height: 44px;
    grid-template-columns: 26px 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0 7px;
    padding: 5px 8px;
    transform: none;
  }

  .hud-drawer-toggle__glyph {
    grid-row: 1 / -1;
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .hud-drawer-toggle > span:not(.hud-drawer-toggle__glyph),
  .hud-drawer-toggle small {
    justify-self: start;
  }

  .hud-drawer-toggle--campaign { left: 10px; }

  .mission-head {
    top: calc(var(--hud-topbar-height) + 60px);
    right: 9px;
    left: 9px;
    min-height: 72px;
    padding: 8px 10px;
    backdrop-filter: none;
  }

  .mission-head h1 {
    margin-top: 3px;
    font-size: clamp(25px, 7.5vw, 34px);
  }

  .mission-head p {
    max-width: calc(100vw - 28px);
    font-size: 9px;
  }

  .mission-tools {
    position: fixed;
    z-index: 56;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(25, 21, 36, 0.92);
    box-shadow: 0 12px 30px rgba(5, 4, 10, 0.42);
    backdrop-filter: blur(12px);
  }

  .tool-button {
    min-height: 44px;
  }

  .objective-ribbon {
    top: calc(var(--hud-topbar-height) + 140px);
    right: 10px;
    left: 10px;
    min-height: 44px;
    padding: 7px 10px;
  }

  .objective-ribbon__icon {
    width: 27px;
    height: 27px;
  }

  .board-stage {
    min-height: 0;
    padding: 6px;
    border-radius: 0;
  }

  .board-viewport {
    padding: 4px;
  }

  .draw-callout {
    min-height: 38px;
    margin-top: 5px;
    padding: 6px 9px;
    font-size: 8px;
  }

  .solve-puzzle-button {
    width: min(420px, calc(100% - 10px));
    min-height: 54px;
  }

  .campaign-panel,
  .company-panel {
    top: calc(var(--hud-topbar-height) + 6px);
    bottom: 6px;
    width: min(var(--hud-drawer-width), calc(100vw - 62px));
    padding: 15px;
    border-radius: 12px;
  }

  .campaign-panel {
    display: flex;
    max-height: none;
    position: fixed;
    order: initial;
    overflow: hidden;
  }

  .company-panel {
    display: block;
    grid-template-columns: none;
    order: initial;
  }

  .level-list {
    grid-template-columns: 1fr;
    padding-right: 4px;
    overflow-y: auto;
  }

  .level-button {
    display: grid;
    justify-content: initial;
    min-height: 44px;
    padding: 7px 8px;
  }

  .level-button__copy,
  .level-button__check {
    display: block;
  }

  .company-panel .rules-card {
    grid-column: auto;
    grid-row: auto;
    margin-top: 19px;
    padding-top: 18px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .top-actions {
    gap: 3px;
  }

  .icon-button {
    min-width: 38px;
    min-height: 38px;
  }

  .brand span:last-child {
    display: none;
  }

  .mission-head {
    align-items: flex-start;
  }

  .mission-head p {
    line-height: 1.35;
  }

  .objective-ribbon span:not(.objective-ribbon__icon) {
    line-height: 1.3;
  }

  .draw-callout__mouse {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
}

@media (max-height: 620px) and (min-width: 600px),
  (max-height: 420px) and (orientation: landscape) {
  :root {
    --hud-topbar-height: 54px;
  }

  .topbar {
    min-height: var(--hud-topbar-height);
    height: var(--hud-topbar-height);
    padding-block: 5px;
  }

  .brand__crest {
    width: 36px;
    height: 36px;
  }

  .brand strong,
  .brand small,
  .chapter-mark {
    display: none;
  }

  .hud-drawer-toggle {
    top: 50%;
    width: 54px;
    min-height: 60px;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    padding: 5px 3px;
    transform: translateY(-50%);
  }

  .hud-drawer-toggle__glyph {
    grid-row: auto;
  }

  .hud-drawer-toggle > span:not(.hud-drawer-toggle__glyph) {
    font-size: 6px;
  }

  .hud-drawer-toggle small {
    display: none;
  }

  .mission-head {
    top: calc(var(--hud-topbar-height) + 5px);
    right: 67px;
    left: 67px;
    min-height: 42px;
    padding: 5px 9px;
    backdrop-filter: none;
  }

  .mission-head h1 {
    margin: 2px 0 0;
    font-size: 23px;
  }

  .mission-head p {
    display: none;
  }

  .mission-tools {
    position: fixed;
    right: 66px;
    bottom: 6px;
    left: 66px;
    padding: 4px;
  }

  .tool-button {
    min-height: 44px;
    padding: 5px 8px;
  }

  .objective-ribbon {
    top: calc(var(--hud-topbar-height) + 54px);
    right: 82px;
    left: 82px;
    min-height: 34px;
    padding: 4px 8px;
  }

  .objective-ribbon__icon {
    width: 24px;
    height: 24px;
  }

  .objective-ribbon span:not(.objective-ribbon__icon) {
    display: none;
  }

  .board-stage {
    padding: 5px;
  }

  .draw-callout {
    min-height: 32px;
    margin-top: 3px;
    padding: 4px 7px;
  }
}

/* Persistent gameplay HUD: company state is always visible; only navigation and help use drawers. */
:root {
  --company-hud-width: clamp(230px, 18vw, 270px);
}

.topbar {
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(12px, 2vw, 28px);
}

.top-actions {
  min-width: 0;
  flex-wrap: nowrap;
}

.icon-button {
  min-width: 44px;
}

.icon-button__status {
  color: var(--pack-accent);
  font-size: 6px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

body.hud-campaign-open #campaignToggleButton,
body.hud-help-open #helpToggleButton {
  border-color: color-mix(in srgb, var(--pack-accent), transparent 25%);
  background: rgba(255, 255, 255, 0.09);
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--company-hud-width);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  height: 100dvh;
  padding: calc(var(--hud-topbar-height) + 12px) 12px 12px;
}

.mission-panel {
  position: relative;
  inset: auto;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
}

.board-stage {
  position: relative;
  inset: auto;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  justify-content: stretch;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 14px;
}

.board-stage::before {
  top: 12px;
  left: 12px;
}

.board-stage::after {
  right: 12px;
  bottom: 12px;
}

.board-viewport {
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  padding: 6px;
}

.gameplay-footer-hud {
  position: relative;
  z-index: 20;
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: auto minmax(150px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

.gameplay-footer-hud .mission-tools {
  position: static;
  display: flex;
  width: auto;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  background: rgba(25, 21, 36, 0.82);
  box-shadow: 0 8px 22px rgba(5, 4, 10, 0.3);
  backdrop-filter: blur(10px);
}

.gameplay-footer-hud .tool-button {
  min-height: 40px;
  padding: 7px 9px;
}

.gameplay-footer-hud .draw-callout {
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  justify-self: center;
  margin: 0;
  overflow: hidden;
}

.gameplay-footer-hud #statusText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gameplay-footer-hud .solve-puzzle-button {
  width: min(320px, 29vw);
  min-height: 54px;
  margin: 0;
}

.company-hud {
  position: relative;
  z-index: 59;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  align-self: start;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(44, 38, 59, 0.94), rgba(25, 22, 36, 0.95));
  box-shadow: 0 18px 42px rgba(4, 3, 9, 0.35);
  backdrop-filter: blur(16px);
  scrollbar-width: thin;
}

.company-hud .panel-heading {
  margin-bottom: 9px;
}

.company-hud .roster {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.company-hud .roster-card {
  min-width: 0;
  min-height: 54px;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 5px;
  padding: 5px 6px;
}

.company-hud .roster-card img {
  width: 27px;
}

.company-hud .roster-card__glyph {
  width: 27px;
  height: 31px;
  border-width: 2px;
  font-size: 13px;
}

body[data-pack="teal"] .company-hud .roster-card--aegis {
  grid-column: 1 / -1;
}

.company-hud .roster-card span {
  overflow: hidden;
  font-size: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-hud .roster-card strong {
  margin-top: 2px;
  font-size: 18px;
}

.company-hud .roster-card small {
  display: none;
}

.company-hud .roster-card--soldier small {
  display: block;
  grid-column: 1 / -1;
  padding: 0;
  font-size: 6px;
}

.company-hud .route-meters {
  margin-top: 7px;
}

.company-hud .route-meter {
  padding: 7px;
}

.company-hud .route-meter strong {
  margin-top: 4px;
  font-size: 15px;
}

.company-hud .commander-order {
  margin-top: 7px;
}

.company-hud .commander-chip {
  min-height: 38px;
}

.company-hud .seal-meter {
  margin-top: 7px;
  padding: 8px;
}

.help-panel {
  position: fixed;
  z-index: 60;
  top: calc(var(--hud-topbar-height) + 12px);
  right: calc(var(--company-hud-width) + 24px);
  bottom: 12px;
  display: flex;
  width: min(var(--hud-drawer-width), calc(100vw - var(--company-hud-width) - 48px));
  max-height: none;
  flex-direction: column;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(44, 38, 59, 0.98), rgba(25, 22, 36, 0.98));
  box-shadow: 0 25px 70px rgba(4, 3, 9, 0.55);
  backdrop-filter: blur(18px);
  visibility: hidden;
  transform: translateX(calc(100% + var(--company-hud-width) + 48px));
  transition: transform 220ms ease, visibility 0s linear 220ms;
  scrollbar-width: thin;
}

body.hud-help-open .help-panel {
  visibility: visible;
  transform: translateX(0);
  transition-delay: 0s;
}

.help-panel__heading {
  flex: 0 0 auto;
}

.help-panel__heading h2 {
  margin: 0;
}

.help-panel__mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: var(--ink);
  background: var(--pack-accent);
  font-weight: 900;
}

.mission-intel {
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
}

.mission-intel__eyebrow,
.mission-intel strong,
.mission-intel p {
  display: block;
}

.mission-intel__eyebrow {
  color: var(--muted);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.mission-intel strong {
  margin-top: 6px;
  color: var(--pack-accent);
  font-size: 9px;
  line-height: 1.35;
}

.mission-intel p {
  margin: 6px 0 0;
  color: #a49cad;
  font-size: 8px;
  line-height: 1.5;
}

.help-panel .legend {
  margin-top: 12px;
  padding: 11px 0;
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

.help-panel .rules-card {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 0;
}

.campaign-chapter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 7px;
  letter-spacing: 0.11em;
}

.campaign-chapter span:first-child {
  color: var(--pack-accent);
}

.campaign-chapter i {
  width: 18px;
  height: 1px;
  background: var(--line);
}

.selected-mission-summary {
  flex: 0 0 auto;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.selected-mission-summary h2 {
  margin: 7px 0 0;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 500;
}

.selected-mission-summary p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.45;
}

@media (max-width: 1200px) {
  :root {
    --company-hud-width: clamp(220px, 24vw, 250px);
  }

  .gameplay-footer-hud {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .gameplay-footer-hud .solve-puzzle-button {
    grid-column: 1 / -1;
    width: min(340px, 100%);
    justify-self: center;
  }

  .icon-button__label {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
  }

  .top-actions {
    gap: 3px;
  }

  .icon-button {
    min-width: 40px;
    min-height: 40px;
    padding: 6px;
  }

  .icon-button__status {
    display: none;
  }

  .game-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    padding: calc(var(--hud-topbar-height) + 8px) 8px 8px;
  }

  .company-hud {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    min-height: 66px;
    grid-template-columns: 52px minmax(0, 1fr) 94px;
    align-items: center;
    gap: 6px;
    padding: 6px;
    overflow: visible;
    border-radius: 11px;
  }

  .company-hud .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    margin: 0;
  }

  .company-hud .eyebrow,
  .company-hud .live-dot {
    font-size: 6px;
    letter-spacing: 0.06em;
  }

  .company-hud .roster {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  body[data-pack="teal"] .company-hud .roster:has(.roster-card--aegis:not([hidden])) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  body[data-pack="teal"] .company-hud .roster-card--aegis:not([hidden]) {
    grid-column: auto;
  }

  .company-hud .roster-card {
    min-height: 46px;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 2px;
    padding: 3px;
  }

  .company-hud .roster-card img {
    width: 22px;
  }

  .company-hud .roster-card__glyph {
    width: 22px;
    height: 26px;
    font-size: 11px;
  }

  .company-hud .roster-card span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .company-hud .roster-card strong {
    margin: 0;
    font-size: 16px;
  }

  .company-hud .roster-card--soldier small {
    overflow: hidden;
    font-size: 5px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .company-hud .route-meters {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 0;
  }

  .company-hud .route-meter {
    display: grid;
    min-height: 40px;
    grid-template-columns: auto minmax(0, 1fr);
    place-items: center;
    gap: 2px;
    padding: 4px;
  }

  .company-hud .route-meter::before {
    content: "↗";
    color: var(--pack-accent);
    font-size: 9px;
  }

  .company-hud .route-meter--objective::before {
    content: "◎";
  }

  .company-hud .route-meter span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .company-hud .route-meter strong {
    margin: 0;
    font-size: 12px;
    text-align: center;
  }

  .company-hud .commander-order,
  .company-hud .seal-meter {
    grid-column: 1 / -1;
    width: 100%;
  }

  .company-hud .commander-order {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .company-hud .commander-chip {
    min-width: 0;
    grid-template-columns: 24px minmax(0, 1fr);
    padding: 4px;
  }

  .company-hud .commander-chip img {
    width: 24px;
  }

  .company-hud .commander-chip > i {
    display: none;
  }

  .mission-panel {
    grid-column: 1;
    grid-row: 2;
  }

  .board-stage {
    padding: 6px;
    border-radius: 11px;
  }

  .board-viewport {
    padding: 3px;
  }

  .gameplay-footer-hud {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    padding-top: 5px;
  }

  .gameplay-footer-hud .mission-tools {
    width: 100%;
  }

  .gameplay-footer-hud .tool-button {
    min-height: 40px;
    flex: 1;
    padding: 6px;
  }

  .gameplay-footer-hud .draw-callout {
    width: min(100%, 420px);
    min-height: 34px;
    padding: 5px 8px;
    font-size: 7px;
  }

  .gameplay-footer-hud .solve-puzzle-button {
    width: min(100%, 360px);
    min-height: 50px;
  }

  .campaign-panel {
    top: calc(var(--hud-topbar-height) + 82px);
    bottom: 8px;
  }

  .help-panel {
    top: auto;
    right: 8px;
    bottom: 8px;
    width: min(var(--hud-drawer-width), calc(100vw - 16px));
    height: min(55dvh, 480px);
    max-height: calc(100dvh - var(--hud-topbar-height) - 96px);
    padding: 15px;
    border-radius: 12px;
    transform: translateY(calc(100% + 18px));
  }

  body.hud-help-open .help-panel {
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .brand {
    gap: 0;
  }

  .topbar {
    padding-inline: 8px;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .icon-button {
    min-width: 37px;
    min-height: 40px;
  }

  .icon-button__glyph {
    width: 22px;
    height: 22px;
  }

  .company-hud {
    grid-template-columns: 46px minmax(0, 1fr) 82px;
    gap: 4px;
  }

  .company-hud .roster-card {
    grid-template-columns: 18px minmax(0, 1fr);
    place-items: center;
  }

  .company-hud .roster-card--soldier,
  .company-hud .roster-card--healer {
    grid-column: auto;
  }

  .company-hud .roster-card img {
    display: block;
    width: 18px;
  }

  .company-hud .roster-card__glyph {
    width: 18px;
    height: 22px;
    font-size: 9px;
  }

  .gameplay-footer-hud .draw-callout__mouse {
    display: none;
  }
}

@media (max-height: 620px) and (min-width: 600px),
  (max-height: 420px) and (orientation: landscape) {
  :root {
    --company-hud-width: clamp(190px, 25vw, 210px);
  }

  .game-shell {
    grid-template-columns: minmax(0, 1fr) var(--company-hud-width);
    grid-template-rows: minmax(0, 1fr);
    gap: 6px;
    padding: calc(var(--hud-topbar-height) + 6px) 6px 6px;
  }

  .mission-panel {
    grid-column: 1;
    grid-row: 1;
  }

  .company-hud {
    grid-column: 2;
    grid-row: 1;
    display: block;
    min-height: 0;
    padding: 7px;
    overflow-y: auto;
  }

  .company-hud .panel-heading {
    flex-direction: row;
    margin-bottom: 5px;
  }

  .company-hud .roster {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .company-hud .roster-card {
    min-height: 38px;
    grid-template-columns: 20px minmax(0, 1fr);
    padding: 3px;
  }

  .company-hud .roster-card img {
    display: block;
    width: 20px;
  }

  .company-hud .roster-card__glyph {
    width: 20px;
    height: 24px;
    font-size: 10px;
  }

  .company-hud .roster-card--soldier small {
    display: none;
  }

  .company-hud .route-meters {
    margin-top: 4px;
  }

  .company-hud .route-meter {
    min-height: 34px;
    padding: 3px;
  }

  .company-hud .route-meter span {
    display: block;
    font-size: 5px;
  }

  .company-hud .route-meter strong {
    margin-top: 2px;
    font-size: 11px;
  }

  .company-hud .commander-order {
    grid-template-columns: 1fr;
  }

  .board-stage {
    padding: 5px;
  }

  .gameplay-footer-hud {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px;
    padding-top: 4px;
  }

  .gameplay-footer-hud .mission-tools {
    width: auto;
    padding: 3px;
  }

  .gameplay-footer-hud .tool-button {
    min-height: 38px;
    padding: 4px 6px;
    font-size: 7px;
  }

  .gameplay-footer-hud .draw-callout {
    min-height: 38px;
    margin: 0;
  }

  .gameplay-footer-hud .solve-puzzle-button {
    grid-column: 1 / -1;
    min-height: 46px;
  }

  .campaign-panel {
    top: calc(var(--hud-topbar-height) + 6px);
  }

  .help-panel {
    top: calc(var(--hud-topbar-height) + 6px);
    right: calc(var(--company-hud-width) + 12px);
    bottom: 6px;
    width: min(var(--hud-drawer-width), calc(100vw - var(--company-hud-width) - 24px));
    height: auto;
    max-height: none;
    transform: translateX(calc(100% + var(--company-hud-width) + 24px));
  }

  body.hud-help-open .help-panel {
    transform: translateX(0);
  }
}

/* ==========================================================================
   LEVEL WORKSHOP — a full page that borrows the gameplay anatomy:
   big canvas, right-hand inspector where Company sits, hotbar where the
   mission tools sit. Nothing about it should read as a dialog.
   ========================================================================== */

:root {
  --editor-inspector-width: clamp(250px, 20vw, 300px);
  --editor-hotbar-slot: clamp(44px, 4.4vw, 58px);
}

.game-shell[hidden],
.editor-shell[hidden] {
  display: none !important;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--editor-inspector-width);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  height: 100dvh;
  padding: calc(var(--hud-topbar-height) + 12px) 12px 12px;
  overflow: hidden;
}

/* ---------- canvas column ---------- */

.editor-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(169, 151, 255, 0.07), transparent 55%),
    rgba(17, 15, 25, 0.28);
}

.editor-viewport {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 6px;
}

.editor-frame {
  position: relative;
  overflow: hidden;
  border: 3px solid rgba(255, 201, 92, 0.32);
  border-radius: 10px;
  background: rgba(13, 12, 20, 0.5);
  box-shadow: 0 22px 48px rgba(4, 3, 9, 0.42), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.editor-frame .designer-grid {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  grid-template-columns: repeat(var(--design-cols, 9), var(--designer-cell-size, 46px));
  grid-auto-rows: var(--designer-cell-size, 46px);
  align-content: start;
  justify-content: start;
  touch-action: none;
  user-select: none;
}

/* ---------- hotbar ---------- */

/* An empty mirror column keeps the hotbar centred under the board rather than under the stage minus controls. */
.editor-footer {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 12px;
}

.editor-hotbar-wrap {
  min-width: 0;
  grid-column: 2;
}

.editor-footer__controls {
  grid-column: 3;
  justify-self: end;
}

.editor-hotbar {
  display: flex;
  gap: 5px;
  min-width: 0;
  padding: 6px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(13, 12, 20, 0.72);
  box-shadow: 0 10px 26px rgba(4, 3, 9, 0.34), inset 0 1px rgba(255, 255, 255, 0.05);
  scrollbar-width: none;
}

.editor-hotbar::-webkit-scrollbar {
  display: none;
}

.editor-hotbar__slot {
  position: relative;
  display: grid;
  width: var(--editor-hotbar-slot);
  height: var(--editor-hotbar-slot);
  flex: 0 0 auto;
  padding: 3px;
  place-items: stretch;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(34, 29, 47, 0.9);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.editor-hotbar__slot:hover {
  border-color: rgba(255, 201, 92, 0.5);
}

.editor-hotbar__slot[aria-pressed="true"] {
  transform: translateY(-4px);
  border-color: #fff1bd;
  box-shadow: 0 0 0 2px var(--gold), 0 0 20px rgba(255, 201, 92, 0.34);
}

.editor-hotbar__slot .designer-palette__button {
  width: 100%;
  height: 100%;
  transform: none;
  border-radius: 5px;
  outline: 0;
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.editor-hotbar__key {
  position: absolute;
  top: -7px;
  left: -5px;
  display: grid;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  color: #cfc6dc;
  background: #221d2f;
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 8px;
  line-height: 1;
}

.editor-hotbar__slot[aria-pressed="true"] .editor-hotbar__key {
  border-color: rgba(255, 201, 92, 0.6);
  color: var(--gold);
}

.editor-hint {
  margin: 7px 0 0;
  color: #7c748a;
  text-align: center;
  font-size: 8px;
  letter-spacing: 0.04em;
  line-height: 1.6;
}

.editor-hint strong {
  color: #b9afc8;
  font-weight: 600;
}

.editor-hint kbd,
.tool-button kbd,
.shortcut-key {
  display: inline-grid;
  min-width: 13px;
  height: 13px;
  padding: 0 3px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 3px;
  color: #d5ccdf;
  background: rgba(255, 255, 255, 0.05);
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 8px;
  line-height: 1;
  vertical-align: middle;
}

/* ---------- brush size + library toggle ---------- */

.editor-footer__controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-brush-sizes {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(13, 12, 20, 0.72);
}

.editor-size {
  min-width: 40px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #a49bb3;
  background: transparent;
  font-family: inherit;
  font-size: 8px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.editor-size:hover {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.06);
}

.editor-size[aria-pressed="true"] {
  border-color: rgba(255, 201, 92, 0.55);
  color: #1c1626;
  background: var(--gold);
  font-weight: 700;
}

.editor-footer__controls .tool-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  white-space: nowrap;
}

/* ---------- tile library tray ---------- */

.editor-tray {
  display: grid;
  max-height: min(36dvh, 320px);
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 201, 92, 0.24);
  border-radius: 12px;
  background: rgba(20, 17, 30, 0.94);
  box-shadow: 0 -12px 34px rgba(4, 3, 9, 0.42);
  animation: dialogIn 160ms ease-out;
}

.editor-tray[hidden] {
  display: none;
}

.editor-tray__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.editor-tray__head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 8px;
}

.editor-tray__close {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.editor-tray__close:hover {
  color: var(--cream);
  border-color: rgba(255, 255, 255, 0.3);
}

.editor-library {
  display: flex;
  min-height: 0;
  flex-wrap: wrap;
  gap: 14px 22px;
  overflow-y: auto;
  scrollbar-color: #685d74 #211c2c;
  scrollbar-width: thin;
}

.editor-library__group h4 {
  margin: 0 0 6px;
  color: #8d8499;
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.editor-library__tiles {
  display: flex;
  max-width: 300px;
  flex-wrap: wrap;
  gap: 5px;
}

/* ---------- inspector column ---------- */

.editor-inspector {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(44, 38, 59, 0.94), rgba(25, 22, 36, 0.95));
  box-shadow: 0 18px 42px rgba(4, 3, 9, 0.35);
  backdrop-filter: blur(16px);
  scrollbar-color: #685d74 #211c2c;
  scrollbar-width: thin;
}

.editor-inspector__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.editor-inspector__head h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.editor-inspector .dialog-close {
  position: static;
  flex: 0 0 auto;
}

.editor-inspector .designer-head__save {
  margin-left: 0;
}

.editor-check {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  background: rgba(13, 12, 20, 0.4);
}

.editor-check .designer-primary-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
}

.editor-check .primary-button,
.editor-check .secondary-button {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 10px;
}

.editor-inspector .designer-section {
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}

.editor-inspector .designer-section__heading {
  margin-bottom: 9px;
}

.designer-section--fold > summary {
  list-style: none;
  cursor: pointer;
}

.designer-section--fold > summary::-webkit-details-marker {
  display: none;
}

.designer-section--fold > summary .designer-section__heading {
  margin-bottom: 0;
}

.designer-section--fold > summary .designer-section__heading::after {
  margin-left: auto;
  color: var(--muted);
  content: "▾";
  font-size: 9px;
}

.designer-section--fold[open] > summary .designer-section__heading {
  margin-bottom: 9px;
}

.designer-section--fold[open] > summary .designer-section__heading::after {
  content: "▴";
}

.designer-copy-button {
  width: 100%;
  min-height: 38px;
  margin-bottom: 8px;
}

/* A key badge sits where each button's decorative glyph used to, so the
   shortcut is legible on the control it triggers. */
.shortcut-key {
  margin-right: 2px;
}

.designer-mini-actions .shortcut-key {
  min-width: 12px;
  height: 12px;
  font-size: 7px;
}

/* The primary button is gold, so a translucent-white badge would wash out. */
.primary-button .shortcut-key {
  border-color: rgba(38, 26, 6, 0.34);
  color: #3a2a08;
  background: rgba(38, 26, 6, 0.14);
}

/* ---------- narrow screens ---------- */

@media (max-width: 1080px) {
  :root {
    --editor-inspector-width: 232px;
  }

  .editor-hint {
    display: none;
  }
}

@media (max-width: 860px) {
  .editor-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    overflow-y: auto;
  }

  .editor-inspector {
    max-height: 46dvh;
  }

  .editor-footer {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-hotbar-wrap,
  .editor-footer__controls {
    grid-column: 1;
  }

  .editor-footer__controls {
    justify-content: space-between;
  }
}

#designerButton[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--gold), transparent 35%);
  color: var(--gold);
  background: rgba(255, 201, 92, 0.12);
}

/* ---------- workshop tiles are board tiles ---------- */

/* Brush chips are real cells shrunk to thumbnail size; only the caption is dropped,
   because a 40px chip cannot legibly render "RIGHT-ANGLE TURN". */
.tile-chip {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  font: inherit;
  cursor: pointer;
}

.tile-chip .tile-label {
  display: none;
}

.editor-library__tiles .tile-chip {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

.editor-library__tiles .tile-chip:hover {
  z-index: 1;
  transform: translateY(-2px);
  border-color: rgba(255, 201, 92, 0.65);
}

.editor-library__tiles .tile-chip.is-selected {
  border-color: #fff1bd;
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* Replaces the native title tooltip, which is far too slow for sweeping a palette. */
.editor-tooltip {
  position: fixed;
  z-index: 90;
  max-width: 240px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 201, 92, 0.34);
  border-radius: 7px;
  color: #f4efff;
  background: rgba(20, 17, 30, 0.97);
  box-shadow: 0 10px 26px rgba(4, 3, 9, 0.5);
  font-size: 10px;
  letter-spacing: 0.03em;
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
}

.editor-tooltip[hidden] {
  display: none;
}

.editor-tooltip::after {
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 7px;
  height: 7px;
  border-right: inherit;
  border-bottom: inherit;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
  content: "";
}

.editor-tooltip.is-below::after {
  top: -4px;
  bottom: auto;
  border: 0;
  border-top: 1px solid rgba(255, 201, 92, 0.34);
  border-left: 1px solid rgba(255, 201, 92, 0.34);
}

/* The solved route rides above the painted cells, and its stroke does not scale with
   the viewBox, so a workshop cell smaller than a board cell needs a thinner line. */
.editor-frame .route-layer {
  z-index: 5;
}

.editor-frame .route-shadow { stroke-width: 9px; }
.editor-frame .route-line { stroke-width: 5px; }
.editor-frame--dense .route-shadow { stroke-width: 6px; }
.editor-frame--dense .route-line { stroke-width: 3px; }

/* The footprint a wide brush is about to commit to. */
.designer-grid > .designer-cell.is-brush-preview {
  z-index: 4;
  outline: 2px solid rgba(255, 241, 189, 0.92);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 99px rgba(255, 201, 92, 0.22);
}
