:root {
  color-scheme: dark;
  --ink: #f6edcf;
  --muted: #b7b59f;
  --panel: rgba(17, 29, 45, 0.97);
  --panel-strong: #111d2d;
  --panel-soft: #23384c;
  --line: rgba(239, 217, 158, 0.24);
  --gold: #d8b65d;
  --gold-bright: #f0d986;
  --teal: #4ec4b1;
  --teal-dark: #176e65;
  --red: #db6559;
  --red-dark: #7e302e;
  --amber: #eda94f;
  --green: #6fd08c;
  --shadow: 0 20px 60px rgba(3, 12, 9, 0.45);
  --radius: 18px;
  --hud-height: 72px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0b1420;
  color: var(--ink);
}

body {
  min-height: 100dvh;
}

button,
input,
select {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

[hidden] {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-bright);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.button-primary,
.button-secondary,
.button-danger {
  min-height: 48px;
  padding: 12px 18px;
  font-weight: 850;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 22px rgba(2, 10, 7, 0.22);
}

.button-primary {
  background: linear-gradient(180deg, #e4c56b, #b98a37);
  color: #172119;
}

.button-secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.button-danger {
  background: linear-gradient(180deg, #df6f60, #a6433b);
  color: #fff8e6;
}

.icon-button,
.panel-close {
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.2rem;
  font-weight: 800;
}

.panel-close {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
}

.setup-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: auto;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 16% 10%, rgba(216, 182, 93, 0.15), transparent 34%),
    radial-gradient(circle at 88% 82%, rgba(66, 39, 24, 0.38), transparent 42%),
    #0b1420;
}

.setup-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(30deg, transparent 46%, rgba(240, 217, 134, 0.09) 48%, transparent 50%),
    linear-gradient(-30deg, transparent 46%, rgba(240, 217, 134, 0.06) 48%, transparent 50%);
  background-size: 46px 80px;
}

.setup-card {
  position: relative;
  width: min(880px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 38px);
  border: 1px solid rgba(240, 217, 134, 0.25);
  border-radius: 26px;
  background:
    linear-gradient(90deg, rgba(118, 70, 38, 0.12), transparent 16%, transparent 84%, rgba(118, 70, 38, 0.12)),
    linear-gradient(155deg, rgba(24, 43, 63, 0.98), rgba(12, 24, 38, 0.99));
  box-shadow: var(--shadow);
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
}

.title-logo {
  width: clamp(94px, 18vw, 154px);
  height: clamp(94px, 18vw, 154px);
  flex: 0 0 auto;
  border-radius: 26%;
  object-fit: contain;
  background: #111d2b;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
}

.title-lockup h1,
.title-lockup h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 0.96;
  text-wrap: balance;
}

.title-lockup h1 {
  font-size: clamp(2rem, 7vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.045em;
}

.title-lockup h1 span {
  color: var(--gold-bright);
  font-style: italic;
}

.title-lockup h2 {
  margin-top: 8px;
  color: var(--gold-bright);
  font-size: clamp(1.15rem, 4vw, 1.7rem);
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.setup-intro {
  max-width: 740px;
  margin: 0 0 24px;
  color: #ddd8bd;
  font-size: clamp(0.95rem, 2.4vw, 1.08rem);
  line-height: 1.55;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.setup-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.setup-grid select,
.setup-grid input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(240, 217, 134, 0.2);
  background: #111d2b;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
  text-transform: none;
}

.setup-grid option {
  background: #111d2b;
}

.seed-entry {
  display: flex;
  gap: 8px;
}

.seed-entry input {
  min-width: 0;
}

.company-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 14px;
}

.company-chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #e8e1c7;
  font-size: 0.78rem;
  font-weight: 750;
}

.company-chip i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.company-red {
  color: #ef8d82;
}

.company-blue {
  color: #83b9e6;
}

.company-green {
  color: #8bc79b;
}

.company-gold {
  color: #f0ce72;
}

.company-black {
  color: #858c96;
}

.company-white {
  color: #e7e2d2;
}

.company-culture-select {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  margin-left: 2px;
}

.setup-map-summary {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 14px 16px;
  border: 1px solid rgba(78, 196, 177, 0.3);
  border-radius: 14px;
  background: rgba(31, 96, 78, 0.2);
  color: #d9efdf;
  line-height: 1.4;
}

.setup-map-summary strong {
  color: #fff2c5;
}

.setup-map-summary small {
  color: #bdcfbf;
}

.setup-map-summary.is-error {
  border-color: rgba(219, 101, 89, 0.5);
  background: rgba(126, 48, 46, 0.25);
  color: #ffbbb2;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.setup-footnote {
  margin: 14px 0 0;
  color: #858f82;
  font-size: 0.78rem;
  text-align: right;
}

.top-hud {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  min-height: calc(var(--hud-height) + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(250px, 1.4fr) auto auto;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(240, 217, 134, 0.22);
  background: linear-gradient(180deg, rgba(23, 39, 58, 0.99), rgba(12, 24, 38, 0.98));
  box-shadow: 0 7px 24px rgba(0, 0, 0, 0.28);
}

.hud-brand,
.turn-identity,
.economy-strip,
.hud-actions {
  display: flex;
  align-items: center;
}

.hud-brand {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.hud-brand strong {
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 1.08rem;
}

.hud-brand small,
.turn-identity small,
.economy-strip small {
  color: var(--muted);
  font-size: 0.67rem;
}

.hud-brand small {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.turn-identity {
  min-width: 0;
  gap: 9px;
}

.turn-identity > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.turn-identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.faction-swatch,
.result-swatch {
  display: inline-block;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  background: #777;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.faction-red {
  background: #c94b43 !important;
}

.faction-blue {
  background: #3478b8 !important;
}

.faction-green {
  background: #3e8a55 !important;
}

.faction-gold {
  background: #c99825 !important;
}

.faction-black {
  background: #34383f !important;
}

.faction-white {
  background: #e7e2d2 !important;
}

.faction-neutral {
  background: #898674 !important;
}

.round-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid rgba(240, 217, 134, 0.22);
  border-radius: 999px;
  background: rgba(216, 182, 93, 0.09);
  color: #e9dcaf;
  font-size: 0.72rem;
  white-space: nowrap;
}

.wind-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid rgba(150, 196, 214, 0.26);
  border-radius: 999px;
  background: rgba(96, 158, 184, 0.11);
  color: #cfe4ee;
  white-space: nowrap;
}

.wind-chip small {
  display: block;
  color: rgba(207, 228, 238, 0.68);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wind-chip strong {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
}

.wind-arrow {
  display: inline-block;
  font-size: 1.02rem;
  line-height: 1;
  color: #8fc9e4;
  /* Matches the board's facing convention: face 0 is East and each face is a
     further 60 degrees counter-clockwise, same as the unit facing marker. */
  transform: rotate(0deg);
  transition: transform 220ms ease;
}

.wind-chip.is-shift-pending {
  border-color: rgba(233, 179, 96, 0.62);
  background: rgba(216, 150, 61, 0.18);
  color: #f3ddb4;
  animation: wind-warning 1.6s ease-in-out infinite;
}

.wind-chip.is-shift-pending .wind-arrow {
  color: #f0c073;
}

.wind-chip.is-shift-pending small {
  color: rgba(243, 221, 180, 0.78);
}

@keyframes wind-warning {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233, 179, 96, 0); }
  50% { box-shadow: 0 0 0 3px rgba(233, 179, 96, 0.22); }
}

@media (prefers-reduced-motion: reduce) {
  .wind-arrow { transition: none; }
  .wind-chip.is-shift-pending { animation: none; }
}

.economy-strip {
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.economy-strip > span:not(.coin-icon) {
  display: grid;
}

.coin-icon {
  color: var(--gold-bright);
}

.income-readout {
  margin-left: 2px;
  padding-left: 9px;
  border-left: 1px solid var(--line);
}

.income-readout strong {
  color: var(--green);
}

.hud-actions {
  justify-content: flex-end;
  gap: 7px;
}

.end-turn-button,
.mobile-end-turn {
  padding: 0 18px;
  border: 1px solid rgba(240, 217, 134, 0.38);
  background: linear-gradient(180deg, #d2b25c, #a77c31);
  color: #132019;
  font-weight: 900;
}

.undo-button {
  min-height: 44px;
  padding: 8px 13px;
  font-weight: 800;
}

.mobile-undo {
  display: none;
}

.game-screen {
  position: fixed;
  inset: calc(var(--hud-height) + env(safe-area-inset-top)) 0 0;
}

.battlefield,
.board-viewport {
  position: absolute;
  inset: 0;
}

.board-viewport {
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  background:
    radial-gradient(circle at 50% 45%, rgba(92, 132, 82, 0.22), transparent 44%),
    linear-gradient(160deg, #1a2a35, #0a131e);
}

.board-viewport.is-dragging {
  cursor: grabbing;
}

#board-svg {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  transform-origin: 0 0;
  will-change: transform;
  contain: layout paint style;
}

.terrain-hex {
  stroke: rgba(20, 29, 21, 0.72);
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.terrain-texture {
  pointer-events: none;
}

.fog-hex {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.fog-hex.is-explored {
  fill: rgba(18, 28, 39, 0.58);
  stroke: rgba(225, 207, 157, 0.08);
  stroke-width: 1.5;
}

.fog-hex.is-unexplored {
  fill: rgba(6, 13, 22, 0.96);
  stroke: rgba(70, 91, 106, 0.24);
  stroke-width: 2;
}

/* Checkpoint 7A developer preview panel. Only ever mounted when the page is
   opened with ?elevation=preview, so it cannot appear in normal play. */
.elevation-preview-panel {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(12, 18, 14, 0.9);
  border: 1px solid rgba(224, 208, 160, 0.35);
  color: #efe7cf;
  font-size: 13px;
  max-width: min(320px, 70vw);
}

.elevation-preview-panel select {
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
}

.elevation-preview-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.elevation-preview-note {
  opacity: 0.65;
  font-size: 11px;
}

/* Checkpoint 7A -- macro topography, presentation only.
   The slope face is the SHAPE UNDER the terrain, so it must never compete with
   the terrain art for attention: no strokes on the faces themselves, and every
   piece here is pointer-transparent so an elevation face can never take a click
   or receive an overlay intended for the hex top. */
.elevation-depth {
  pointer-events: none;
  stroke: none;
}

/* The contact shadow a landform throws onto the ground below it. Three stacked
   strokes of decreasing width approximate a blur falloff without an SVG filter,
   which would cost a real blur pass per frame on a phone. */
.elevation-cast {
  pointer-events: none;
  stroke: rgb(6, 13, 18);
  stroke-linecap: round;
}

.elevation-face {
  pointer-events: none;
  stroke: none;
  shape-rendering: crispEdges;
}

/* The contour that marks the rim of a landform.
   Checkpoint 7V1A: a BROKEN contour set inside the high tile, not a solid line
   on its boundary. The dash pattern is computed per segment in the renderer so
   each mark divides its edge evenly and no stub is left at either end -- an
   even run reads as a surveyed contour, a stub reads as a dashed border.
   Round caps keep the marks soft; 2.3 is thin enough that the terrain art stays
   dominant at game scale and still resolves on a phone. */
.elevation-contour {
  pointer-events: none;
  stroke-width: 2.3;
  stroke-linecap: round;
}

/* A two-level step draws a second, deeper contour inside the first (see
   renderElevationDecoration) instead of thickening the first one. Closer
   contours mean steeper ground, which is the relief-map idiom for the same
   information without making the harshest boundaries the loudest marks. */
.elevation-contour-inner {
  stroke-width: 1.8;
}

/* Developer inspection only, off by default. */
.elevation-debug-label {
  pointer-events: none;
  fill: #f6f1dc;
  font-size: 20px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(10, 14, 9, 0.85);
  stroke-width: 4;
}

.hex-hit {
  cursor: pointer;
  fill: transparent;
  stroke: transparent;
  stroke-width: 4;
  pointer-events: all;
}

.settlement-ring {
  fill: rgba(9, 18, 14, 0.48);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.settlement-sprite {
  pointer-events: none;
  filter: drop-shadow(0 7px 5px rgba(0, 0, 0, 0.35));
}

.settlement-income {
  fill: #fff2bb;
  stroke: rgba(18, 29, 22, 0.9);
  stroke-width: 4px;
  paint-order: stroke;
  font-size: 12px;
  font-weight: 900;
  text-anchor: middle;
  pointer-events: none;
}

.unit-group {
  cursor: pointer;
  transition: opacity 160ms ease;
}

.unit-base {
  fill: rgba(9, 18, 14, 0.78);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.unit-team-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.unit-commander-ring {
  fill: none;
  stroke: #f6dd8b;
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 3px rgba(246, 221, 139, 0.55));
}

.unit-sprite {
  pointer-events: none;
  filter: drop-shadow(0 8px 5px rgba(0, 0, 0, 0.42));
  transform-box: fill-box;
  transform-origin: center bottom;
}

.unit-group.is-marching .unit-sprite {
  animation: march-bob 230ms ease-in-out infinite alternate;
}

@keyframes march-bob {
  from {
    translate: 0 0;
  }
  to {
    translate: 0 -2.5px;
  }
}

.unit-facing-marker {
  fill: rgba(240, 217, 134, 0.2);
  stroke: #f6dd8b;
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.unit-health-back {
  fill: rgba(8, 15, 12, 0.82);
}

.unit-health-fill {
  fill: #74d887;
}

.unit-health-fill.is-wounded {
  fill: #f0bb5c;
}

.unit-health-fill.is-critical {
  fill: #e56b61;
}

/* Checkpoint 7F1CG: passengers aboard a friendly transport. */
.unit-cargo-badge {
  pointer-events: none;
}

.unit-cargo-badge rect {
  fill: rgba(12, 24, 38, 0.92);
  stroke: #f0d986;
  stroke-width: 1.5px;
}

.unit-cargo-badge text {
  fill: #fff9df;
  font-size: 10px;
  font-weight: 900;
  text-anchor: middle;
}

.unit-health-text,
.unit-status-glyph {
  fill: #fff9df;
  stroke: #102018;
  stroke-width: 3px;
  paint-order: stroke;
  font-size: 10px;
  font-weight: 900;
  text-anchor: middle;
  pointer-events: none;
}

.unit-status-glyph {
  font-size: 13px;
}

.unit-action-indicators,
.unit-action-indicator {
  pointer-events: none;
}

/* Checkpoint 6D1: compact activation bar. A UniWar-style thin underline
   segment sits below the unit's feet instead of a large glyph pill over the
   sprite. Each half (movement / primary action) only paints its segment
   when that half is still usable -- the segment's absence, not a colour
   change, is what says "spent". Solid vs. dashed keeps the reloading state
   distinguishable without relying on colour alone. */
.unit-action-bar {
  opacity: 0;
  fill: #72d99a;
  stroke: #163021;
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.unit-action-indicator.is-available .unit-action-bar {
  opacity: 0.95;
}

.unit-action-indicator.is-reloading .unit-action-bar {
  opacity: 0.85;
  fill: #8fc9e4;
  stroke-dasharray: 3 2;
  animation: action-reload-pulse 1.15s ease-in-out infinite alternate;
}

.unit-action-indicator.is-used .unit-action-bar,
.unit-action-indicator.is-unavailable .unit-action-bar {
  opacity: 0;
}

@keyframes action-reload-pulse {
  to {
    opacity: 1;
    filter: drop-shadow(0 0 3px rgba(143, 201, 228, 0.85));
  }
}

/* Spent formations remain readable: only the painting is softened, while the
   owner ring, HP, facing, and the two non-colour action marks stay crisp. */
.unit-group.is-fully-spent .unit-sprite {
  opacity: 0.84;
  filter: grayscale(0.34) saturate(0.68) brightness(0.9) drop-shadow(0 7px 4px rgba(0, 0, 0, 0.42));
}

.unit-group.is-fully-spent .unit-base {
  fill: rgba(16, 22, 19, 0.86);
}

.elephant-panic-glyph {
  fill: #ffb052;
  stroke: #37120b;
  stroke-width: 4px;
  font-size: 20px;
  filter: drop-shadow(0 0 4px rgba(255, 112, 65, 0.9));
  transform-box: fill-box;
  transform-origin: center;
}

.elephant-panic-glyph.is-active {
  fill: #ff7045;
  animation: panic-icon-pulse 520ms ease-in-out infinite alternate;
}

.elephant-panic-glyph.is-pending:not(.is-active) {
  fill: #ffc35f;
}

.elephant-panic-glyph.is-active.is-pending {
  stroke-width: 5px;
  filter: drop-shadow(0 0 6px rgba(255, 82, 45, 0.98));
}

.unit-group.is-panic-pending .unit-base {
  stroke: #f2b251;
  stroke-width: 5;
  stroke-dasharray: 3 3;
  animation: panic-ring-pulse 920ms ease-in-out infinite alternate;
}

.unit-group.is-panicked .unit-base {
  stroke: #ff7045;
  stroke-width: 5;
  stroke-dasharray: 8 3;
  animation: panic-ring-pulse 620ms ease-in-out infinite alternate;
}

.unit-group.is-panicked.is-panic-pending .unit-base {
  stroke-dasharray: 8 2 2 2;
}

@keyframes panic-ring-pulse {
  from {
    filter: drop-shadow(0 0 1px rgba(255, 112, 69, 0.38));
  }
  to {
    filter: drop-shadow(0 0 7px rgba(255, 112, 69, 0.96));
  }
}

@keyframes panic-icon-pulse {
  from {
    opacity: 0.8;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1.12);
  }
}

.spear-levy-burn-glyph {
  fill: #ff9d3d;
}

.senapati-raise-glyph {
  fill: #6fe3ac;
}

/* Sereyan specials phase 2D: a declared brace is a committed stance, so it
   reads brighter and larger than the pikeman's free implicit brace. */
.declared-brace-glyph {
  fill: #9fd8ff;
  font-size: 15px;
}

.selection-ring {
  fill: none;
  stroke: #fff0a4;
  stroke-width: 4;
  stroke-dasharray: 10 5;
  vector-effect: non-scaling-stroke;
  animation: selection-spin 6s linear infinite;
}

@keyframes selection-spin {
  to {
    stroke-dashoffset: -60;
  }
}

.move-overlay {
  fill: rgba(57, 199, 179, 0.25);
  stroke: #56d8c3;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.move-overlay.is-difficult {
  fill: rgba(218, 161, 72, 0.24);
  stroke: #f0bb64;
  stroke-dasharray: 4 3;
}

.move-overlay.is-severe {
  fill: rgba(157, 105, 178, 0.28);
  stroke: #d1a3e2;
  stroke-dasharray: 2 4;
  stroke-width: 4;
}

.move-overlay.dragoon-fire-zone {
  fill: rgba(82, 180, 121, 0.3);
  stroke: #80df9b;
}

.move-overlay.dragoon-mounted-zone {
  fill: rgba(74, 142, 190, 0.2);
  stroke: #75afd4;
  stroke-dasharray: 7 4;
}

.attack-range-overlay {
  fill: rgba(238, 169, 79, 0.12);
  stroke: rgba(238, 169, 79, 0.55);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
}

.attack-target-overlay {
  fill: rgba(219, 101, 89, 0.3);
  stroke: #ff8173;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  animation: target-pulse 1.1s ease-in-out infinite alternate;
}

@keyframes target-pulse {
  to {
    fill: rgba(219, 101, 89, 0.46);
  }
}

.burn-target-overlay {
  fill: rgba(240, 132, 40, 0.28);
  stroke: #ff9d3d;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  animation: burn-target-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes burn-target-pulse {
  to {
    fill: rgba(240, 132, 40, 0.5);
  }
}

.ignite-target-icon {
  fill: #fff2b2;
  stroke: #4a190c;
  stroke-width: 4px;
  paint-order: stroke;
  font-size: 28px;
  font-weight: 900;
  text-anchor: middle;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(255, 122, 38, 0.92));
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: ignite-target-flare 720ms ease-in-out infinite alternate;
}

@keyframes ignite-target-flare {
  from {
    transform: translateY(1px) scale(0.94);
  }
  to {
    transform: translateY(-2px) scale(1.08);
  }
}

.ignite-impact,
.ignite-impact-ring,
.ignite-impact-flame,
.ignite-impact-spark {
  pointer-events: none;
}

.ignite-impact-ring,
.ignite-impact-flame,
.ignite-impact-spark {
  transform-box: fill-box;
  transform-origin: center;
}

.ignite-impact-ring {
  fill: rgba(255, 111, 36, 0.18);
  stroke: #ff9d3d;
  stroke-width: 6;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 8px rgba(255, 99, 31, 0.86));
  animation: ignite-impact-ring 520ms ease-out both;
}

.ignite-impact-flame {
  fill: #fff2b2;
  stroke: #4a190c;
  stroke-width: 5px;
  paint-order: stroke;
  font-size: 44px;
  font-weight: 900;
  text-anchor: middle;
  filter: drop-shadow(0 0 10px rgba(255, 112, 31, 0.98));
  animation: ignite-impact-flame 520ms ease-out both;
}

.ignite-impact-spark {
  fill: #ffe08b;
  stroke: #ff7d2d;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px rgba(255, 137, 49, 0.9));
  animation: ignite-impact-spark 480ms ease-out both;
}

@keyframes ignite-impact-ring {
  from {
    opacity: 1;
    transform: scale(0.35);
  }
  to {
    opacity: 0;
    transform: scale(1.65);
  }
}

@keyframes ignite-impact-flame {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.45);
  }
  32% {
    opacity: 1;
    transform: translateY(-3px) scale(1.16);
  }
  100% {
    opacity: 0;
    transform: translateY(-17px) scale(0.92);
  }
}

@keyframes ignite-impact-spark {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-25px) scale(0.3);
  }
}

.raise-target-overlay,
.beach-target-overlay,
.disembark-target-overlay {
  fill: rgba(94, 189, 143, 0.28);
  stroke: #6fe3ac;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  animation: raise-target-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes raise-target-pulse {
  to {
    fill: rgba(94, 189, 143, 0.5);
  }
}

/* Checkpoint 7F1B: the FIRING arc of an armed vessel (Prahu, Gunboat), which
   is distinct from the melee facing arcs below -- it covers the whole sector
   out to the hull's max range rather than the adjacent ring. Deliberately
   quieter than the movement and target overlays: it is standing context for a
   selected vessel, not a prompt, and it must stay legible under the
   front/vulnerable arc markers that draw on top of it. */
.firing-arc-overlay {
  fill: rgba(126, 178, 232, 0.13);
  stroke: rgba(148, 196, 240, 0.42);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.front-arc-overlay,
.vulnerable-arc-overlay {
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.front-arc-overlay {
  fill: rgba(65, 183, 133, 0.2);
  stroke: rgba(111, 208, 140, 0.88);
}

.vulnerable-arc-overlay {
  fill: rgba(219, 101, 89, 0.17);
  stroke: rgba(255, 129, 115, 0.8);
  stroke-dasharray: 5 4;
}

.arc-label {
  fill: #fff8d9;
  stroke: rgba(10, 22, 16, 0.9);
  stroke-width: 3px;
  paint-order: stroke;
  font-size: 11px;
  font-weight: 900;
  text-anchor: middle;
  pointer-events: none;
}

.shot-line {
  fill: none;
  stroke: #79e0aa;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 12 7;
  vector-effect: non-scaling-stroke;
  animation: shot-line-flow 750ms linear infinite;
}

.shot-line.is-blocked {
  stroke: #ff675c;
}

@keyframes shot-line-flow {
  to {
    stroke-dashoffset: -38;
  }
}

.shot-crossed {
  fill: rgba(79, 208, 166, 0.15);
  stroke: rgba(121, 224, 170, 0.66);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.shot-crossed.is-blocked {
  fill: rgba(219, 66, 57, 0.4);
  stroke: #ff675c;
  stroke-width: 5;
}

.splash-overlay {
  fill: rgba(237, 169, 79, 0.24);
  stroke: #ffc66d;
  stroke-width: 3;
  stroke-dasharray: 7 4;
  vector-effect: non-scaling-stroke;
}

.splash-overlay.is-friendly {
  fill: rgba(219, 101, 89, 0.35);
  stroke: #ff7468;
}

.move-path {
  fill: none;
  stroke: #e9f8b8;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 7 6;
  vector-effect: non-scaling-stroke;
}

.charge-path {
  fill: none;
  stroke: #ffd568;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 14 8;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px rgba(255, 213, 104, 0.65));
  animation: shot-line-flow 650ms linear infinite;
}

.fire-group {
  pointer-events: none;
}

.fire-hex {
  fill: rgba(241, 94, 34, 0.28);
  stroke: #ff8739;
  stroke-width: 3;
  stroke-dasharray: 8 4;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 7px rgba(255, 106, 35, 0.7));
  animation: fire-ground-pulse 1s ease-in-out infinite alternate;
}

.fire-flame {
  fill: #fff0a8;
  stroke: #4a190c;
  stroke-width: 3px;
  paint-order: stroke;
  font-size: 25px;
  font-weight: 900;
  text-anchor: middle;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(255, 105, 29, 0.95));
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: fire-flame-flicker 680ms ease-in-out infinite alternate;
}

.fire-flame-1 {
  animation-delay: -180ms;
}

.fire-flame-2 {
  font-size: 31px;
  animation-delay: -430ms;
}

.fire-flame-3 {
  animation-delay: -310ms;
}

.fire-wisp {
  fill: rgba(64, 55, 48, 0.48);
  stroke: rgba(245, 224, 190, 0.22);
  stroke-width: 1;
  filter: blur(1.2px);
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: fire-wisp-rise 2.2s ease-in-out infinite;
}

.fire-wisp-2 {
  animation-delay: -1.1s;
}

.fire-label {
  fill: #fff5cb;
  stroke: #39160d;
  stroke-width: 4px;
  paint-order: stroke;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 1px;
  text-anchor: middle;
  pointer-events: none;
}

@keyframes fire-ground-pulse {
  to {
    fill: rgba(241, 94, 34, 0.45);
    stroke-width: 4;
  }
}

@keyframes fire-flame-flicker {
  from {
    transform: translateY(1px) rotate(-2deg) scale(0.92, 0.96);
  }
  to {
    transform: translateY(-3px) rotate(2deg) scale(1.06, 1.12);
  }
}

@keyframes fire-wisp-rise {
  0% {
    opacity: 0;
    transform: translate(-2px, 6px) scale(0.72);
  }
  35% {
    opacity: 0.62;
  }
  100% {
    opacity: 0;
    transform: translate(7px, -18px) scale(1.42);
  }
}

.smoke-group {
  pointer-events: none;
}

.smoke-cloud {
  fill: rgba(237, 237, 222, 0.3);
  filter: blur(1.7px);
  transform-box: fill-box;
  transform-origin: center;
  animation: smoke-breathe 4.6s ease-in-out infinite alternate;
}

.smoke-group.is-dense .smoke-cloud {
  fill: rgba(217, 218, 207, 0.58);
  filter: blur(2.3px);
}

.smoke-layer-2,
.smoke-layer-5 {
  animation-delay: -1.3s;
}

.smoke-layer-3,
.smoke-layer-6 {
  animation-delay: -2.4s;
}

.smoke-layer-4 {
  animation-delay: -3.4s;
}

@keyframes smoke-breathe {
  from {
    opacity: 0.82;
    transform: translate(-1.5px, 1px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(2.5px, -2px) scale(1.07);
  }
}

.smoke-label {
  fill: #fff7dd;
  stroke: #24322b;
  stroke-width: 4px;
  paint-order: stroke;
  font-size: 11px;
  font-weight: 900;
  text-anchor: middle;
}

.muzzle-flash {
  fill: #fff2a8;
  stroke: #ef9f39;
  stroke-width: 3;
  filter: drop-shadow(0 0 8px #ffbc50);
}

.muzzle-puff {
  fill: rgba(250, 248, 226, 0.88);
  filter: blur(1.2px);
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
}

.dragoon-transition-dust {
  fill: rgba(218, 200, 153, 0.72);
  filter: blur(1.5px);
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
}

.volley-streak {
  stroke: #fff1b5;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px #ffc65e);
}

.artillery-projectile {
  fill: #201a15;
  stroke: #ffcf6a;
  stroke-width: 2;
  filter: drop-shadow(0 0 5px #ffad45);
}

.impact-ring {
  fill: none;
  stroke: #ffce75;
  stroke-width: 6;
}

.damage-float {
  fill: #fff6cc;
  stroke: #672f2b;
  stroke-width: 5px;
  paint-order: stroke;
  font-size: 21px;
  font-weight: 950;
  text-anchor: middle;
}

.turn-banner,
.ai-banner,
.toast {
  position: absolute;
  z-index: 5;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  background: rgba(16, 35, 28, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.turn-banner,
.ai-banner {
  top: 18px;
  display: flex;
  min-width: min(380px, calc(100% - 30px));
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
}

.turn-banner span:last-child,
.ai-banner span:last-child {
  display: grid;
}

.turn-banner small,
.ai-banner small {
  color: var(--muted);
}

.ai-banner {
  border-color: rgba(216, 182, 93, 0.4);
}

.thinking-pips {
  display: flex;
  gap: 4px;
}

.thinking-pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-bright);
  animation: thinking 900ms ease-in-out infinite alternate;
}

.thinking-pips i:nth-child(2) {
  animation-delay: 180ms;
}

.thinking-pips i:nth-child(3) {
  animation-delay: 360ms;
}

@keyframes thinking {
  to {
    opacity: 0.25;
    transform: translateY(-3px);
  }
}

.toast {
  bottom: 24px;
  max-width: calc(100% - 32px);
  padding: 10px 15px;
  border-radius: 999px;
  color: #fff2c5;
  font-weight: 750;
  text-align: center;
}

.zoom-controls {
  position: absolute;
  z-index: 4;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
}

.zoom-controls button {
  width: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(17, 39, 31, 0.9);
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.28);
}

.mobile-end-turn {
  display: none;
}

.context-panel,
.combat-panel,
.recruit-panel {
  position: absolute;
  z-index: 6;
  bottom: 18px;
  left: 18px;
  width: min(410px, calc(100% - 110px));
  max-height: min(620px, calc(100% - 38px));
  overflow: auto;
  padding: 17px;
  border: 1px solid rgba(240, 217, 134, 0.25);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.context-panel::before,
.combat-panel::before,
.recruit-panel::before,
.modal-card::before {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 5px;
  border: 1px solid rgba(216, 182, 93, 0.15);
  border-radius: calc(var(--radius) - 4px);
}

.context-panel > .panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

.context-heading,
.combat-panel header,
.recruit-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.context-heading {
  align-items: center;
  padding-right: 42px;
}

.context-heading > div {
  min-width: 0;
}

.context-heading small,
.combat-panel small,
.recruit-panel small {
  color: var(--muted);
}

.context-heading h2,
.combat-panel h2,
.recruit-panel h2 {
  margin: 1px 0 0;
  font-family: Georgia, serif;
  font-size: 1.24rem;
}

.health-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
}

.health-track {
  height: 11px;
  flex: 1;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}

.health-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4caf6a, #87df91);
  transition: width 180ms ease, background 180ms ease;
}

.health-track span.is-wounded {
  background: linear-gradient(90deg, #c98f2f, #f0bb5c);
}

.health-track span.is-critical {
  background: linear-gradient(90deg, #b8483e, #e56b61);
}

.health-row strong {
  font-size: 0.78rem;
  white-space: nowrap;
}

.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.stat-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #e9e3ca;
  font-size: 0.75rem;
  font-weight: 750;
}

.action-availability {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 7px;
  margin-top: 9px;
}

.action-availability-chip {
  display: flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #89918b;
  border-radius: 8px;
  background: rgba(20, 28, 23, 0.72);
  color: #e8e5d7;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.action-availability-chip.is-available {
  border-color: rgba(114, 217, 154, 0.72);
  background: rgba(63, 148, 96, 0.16);
  color: #c9f2d4;
}

.action-availability-chip.is-used {
  border-color: rgba(226, 167, 100, 0.72);
  border-style: dashed;
  background: rgba(157, 99, 46, 0.16);
  color: #f0c58d;
}

.action-availability-chip.is-unavailable {
  border-style: dotted;
  background: rgba(77, 83, 78, 0.18);
  color: #c2c7c1;
}

.action-availability-chip.is-reloading {
  border-color: rgba(143, 201, 228, 0.78);
  border-style: dashed;
  background: rgba(61, 127, 158, 0.17);
  color: #c6eaf8;
  animation: action-chip-reload 1.15s ease-in-out infinite alternate;
}

@keyframes action-chip-reload {
  to {
    box-shadow: inset 0 0 0 1px rgba(143, 201, 228, 0.35), 0 0 7px rgba(73, 156, 193, 0.24);
  }
}

.context-status {
  margin: 11px 0;
  color: #c7cab6;
  font-size: 0.86rem;
  line-height: 1.42;
}

.context-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.context-actions button,
.facing-actions button {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.075);
  font-size: 0.82rem;
  font-weight: 800;
}

.context-actions button.is-primary {
  border-color: rgba(78, 196, 177, 0.5);
  background: rgba(49, 145, 124, 0.25);
}

.facing-actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin: 11px 0;
}

.facing-actions button {
  min-width: 0;
  padding: 5px 2px;
  font-size: 1.05rem;
}

.facing-actions button.is-current {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  background: rgba(216, 182, 93, 0.16);
}

.combat-legality {
  margin: 12px 0 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--green);
  border-radius: 5px;
  background: rgba(80, 169, 110, 0.12);
  color: #b9e9c3;
  font-size: 0.83rem;
  font-weight: 750;
}

.combat-legality.is-blocked {
  border-color: var(--red);
  background: rgba(219, 101, 89, 0.13);
  color: #ffb4aa;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.forecast-grid > div {
  display: grid;
  gap: 2px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}

.forecast-grid strong {
  color: #fff1b9;
  font-size: 1.15rem;
}

.modifier-list {
  display: grid;
  gap: 5px;
  margin: 11px 0;
}

.modifier-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #c8cbb8;
  font-size: 0.8rem;
}

.modifier-row strong {
  color: var(--green);
}

.modifier-row.is-negative strong {
  color: #ff968b;
}

.combat-warning {
  min-height: 20px;
  margin: 8px 0;
  color: #ffb59f;
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.4;
}

.combat-panel .button-danger {
  width: 100%;
}

.recruit-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.recruit-option {
  display: grid;
  min-height: 76px;
  align-content: center;
  gap: 2px;
  padding: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  text-align: left;
}

.recruit-option strong {
  color: #fff1b9;
  font-size: 0.84rem;
}

.recruit-option small {
  color: var(--muted);
  font-size: 0.7rem;
}

.game-menu {
  position: fixed;
  z-index: 30;
  top: calc(var(--hud-height) + env(safe-area-inset-top) + 8px);
  right: max(12px, env(safe-area-inset-right));
  width: min(310px, calc(100% - 24px));
  overflow: hidden;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #111d2d;
  box-shadow: var(--shadow);
}

.game-menu-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 4px 9px 8px;
  color: var(--gold-bright);
}

.game-menu > button:not(.panel-close) {
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.055);
  text-align: left;
}

.game-menu p {
  margin: 12px 7px 4px;
  color: var(--muted);
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.game-menu > .menu-resign {
  border-color: rgba(219, 101, 89, 0.42);
  background: rgba(166, 67, 59, 0.16);
  color: #f4b7ae;
  font-weight: 800;
}

.menu-backdrop {
  position: fixed;
  z-index: 29;
  inset: 0;
  min-height: 0;
  border-radius: 0;
  background: rgba(2, 8, 6, 0.42);
}

.modal-layer {
  position: fixed;
  z-index: 40;
  inset: 0;
  overflow: auto;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  background: rgba(4, 12, 9, 0.76);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid rgba(240, 217, 134, 0.26);
  border-radius: 22px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.16), rgba(107, 74, 38, 0.08)),
    #eadfbd;
  color: #2e271f;
  box-shadow: var(--shadow);
}

.modal-card > .panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.modal-card h2 {
  margin: 2px 44px 8px 0;
  font-family: Georgia, serif;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
}

.modal-card .eyebrow {
  color: #795623;
}

.modal-card .panel-close,
.modal-card .button-secondary,
.modal-card .balance-export-actions button {
  border-color: rgba(82, 59, 36, 0.28);
  background: rgba(54, 40, 27, 0.08);
  color: #30271d;
}

.modal-card .info-subtitle,
.modal-card .balance-intro,
.modal-card .scale-audit > p,
.modal-card .help-grid p,
.modal-card.help-card > p,
.modal-card .fluff-copy,
.modal-card .info-block p,
.modal-card .info-block ul,
.modal-card .result-card p {
  color: #574d3d;
}

.modal-card .info-health,
.modal-card .info-stat,
.modal-card .info-block,
.modal-card .terrain-card,
.modal-card .help-grid section,
.modal-card .result-score,
.modal-card .balance-controls .balance-check,
.modal-card .scale-audit,
.modal-card .balance-report {
  border-color: rgba(82, 59, 36, 0.22);
  background: rgba(67, 49, 31, 0.055);
}

.modal-card .info-stat small,
.modal-card .result-score small,
.modal-card .balance-controls label,
.modal-card .scale-audit figcaption {
  color: #6d6251;
}

.modal-card .info-stat strong,
.modal-card .help-grid strong,
.modal-card .info-block h3,
.modal-card .terrain-card h3 {
  color: #543a19;
}

.modal-card .effect-row {
  background: rgba(65, 47, 29, 0.06);
  color: #4b4235;
}

.modal-card .balance-controls select,
.modal-card .balance-controls input[type="text"],
.modal-card .balance-controls input[type="number"] {
  border-color: rgba(82, 59, 36, 0.28);
  background: #fff6dc;
  color: #2e271f;
}

.info-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
}

.unit-showcase {
  --unit-accent: #c94b43;
  --showcase-terrain: none;
  position: relative;
  min-height: 250px;
  margin: 8px 0 16px;
  overflow: hidden;
  border: 1px solid var(--unit-accent);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 38%, rgba(239, 222, 167, 0.2), transparent 47%),
    linear-gradient(150deg, rgba(61, 78, 53, 0.88), rgba(25, 45, 35, 0.97));
  box-shadow: inset 0 0 50px rgba(4, 11, 8, 0.4);
}

.unit-showcase::before,
.unit-showcase::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  width: 9px;
  height: 100%;
  background: var(--unit-accent);
  box-shadow: 0 0 16px var(--unit-accent);
}

.unit-showcase::before {
  left: 0;
}

.unit-showcase::after {
  right: 0;
}

.unit-showcase-map {
  position: absolute;
  inset: 16px 16% 36px;
  background-image: var(--showcase-terrain);
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: min(280px, 76%) auto;
  filter: drop-shadow(0 16px 9px rgba(0, 0, 0, 0.58));
  opacity: 0.88;
}

.unit-showcase img {
  position: absolute;
  z-index: 1;
  top: 4px;
  left: 50%;
  width: min(330px, 72%);
  height: 218px;
  object-fit: contain;
  object-position: center bottom;
  transform: translateX(-50%);
  transform-origin: center bottom;
  filter: drop-shadow(0 14px 8px rgba(0, 0, 0, 0.55));
}

.unit-showcase figcaption {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(90deg, rgba(8, 19, 14, 0.95), rgba(8, 19, 14, 0.76));
}

.unit-showcase figcaption strong {
  color: #fff1bd;
  font-family: Georgia, serif;
}

.unit-showcase figcaption span {
  color: #d7d4bd;
  font-size: 0.78rem;
  text-align: right;
}

.info-health {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  background: rgba(255, 255, 255, 0.045);
  font-weight: 800;
}

.info-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.info-stat {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}

.info-stat small {
  color: var(--muted);
  font-size: 0.68rem;
}

.info-stat strong {
  color: #fff0b7;
}

.info-block {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.info-block h3,
.terrain-card h3 {
  margin: 0 0 7px;
  font-family: Georgia, serif;
}

.info-block p,
.info-block ul,
.fluff-copy {
  margin: 6px 0;
  color: #d5d2bc;
  font-size: 0.88rem;
  line-height: 1.5;
}

.info-block ul {
  padding-left: 20px;
}

.status-list,
.terrain-effects {
  display: grid;
  gap: 6px;
}

.effect-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  color: #d6d4be;
  font-size: 0.8rem;
}

.effect-row .positive {
  color: var(--green);
  font-weight: 850;
}

.effect-row .negative {
  color: #ff9388;
  font-weight: 850;
}

.effect-row .neutral {
  color: #f0d986;
  font-weight: 800;
}

.terrain-card {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 18px;
  align-items: center;
  margin: 20px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.terrain-art {
  width: 132px;
  aspect-ratio: 1;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.4));
}

.info-sheet > .button-primary,
.help-card > .button-primary {
  width: 100%;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.help-grid section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.help-grid strong {
  color: var(--gold-bright);
}

.help-grid p,
.help-card > p {
  margin: 6px 0;
  color: #d5d2bc;
  font-size: 0.87rem;
  line-height: 1.5;
}

.result-card {
  text-align: center;
}

.result-swatch {
  width: 48px;
  height: 48px;
  margin: 10px auto;
}

.result-card p {
  color: #d3d2bd;
  line-height: 1.5;
}

.result-scores {
  display: grid;
  gap: 7px;
  margin: 17px 0;
}

.result-score {
  display: grid;
  grid-template-columns: 1fr repeat(4, auto);
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

.result-score small {
  color: var(--muted);
}

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

.result-actions .button-primary {
  grid-column: 1 / -1;
}

.balance-card {
  width: min(920px, 100%);
}

.balance-intro,
.scale-audit > p {
  color: #d5d2bc;
  line-height: 1.5;
}

.balance-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 12px;
}

.balance-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.balance-controls select,
.balance-controls input[type="text"],
.balance-controls input[type="number"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 18, 13, 0.72);
  color: var(--ink);
}

.balance-seed {
  grid-column: span 2;
}

.balance-controls .balance-check {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-self: end;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.balance-check input {
  width: 22px;
  height: 22px;
}

.balance-actions,
.balance-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.balance-progress {
  margin: 15px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 18, 13, 0.45);
}

.balance-progress > div {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.balance-progress > div span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6eb97c, #f0d476);
  transition: width 180ms ease;
}

.balance-progress p {
  margin: 9px 0 0;
  color: #d5d2bc;
  font-size: 0.82rem;
}

.balance-report,
.scale-audit {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.balance-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.balance-metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.balance-metric small,
.balance-metric strong {
  display: block;
}

.balance-metric small {
  color: var(--muted);
  font-size: 0.67rem;
  text-transform: uppercase;
}

.balance-metric strong {
  margin-top: 3px;
  color: #fff0b8;
}

.balance-unit-table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.balance-unit-table th,
.balance-unit-table td {
  padding: 7px 5px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.balance-unit-table th:first-child,
.balance-unit-table td:first-child {
  text-align: left;
}

.balance-seeds {
  max-height: 190px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(1, 8, 5, 0.55);
  color: #d6d4c0;
  white-space: pre-wrap;
  font-size: 0.7rem;
}

.scale-audit-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0;
}

.scale-audit-token {
  flex: 0 0 116px;
  margin: 0 -5px;
  text-align: center;
}

.scale-audit-token svg {
  display: block;
  width: 116px;
  height: 144px;
  overflow: visible;
}

.scale-audit-token figcaption {
  min-height: 30px;
  color: #e8e1c2;
  font-size: 0.67rem;
}

.scale-audit-row.is-zoomed {
  padding-top: 2px;
}

.scale-audit-row.is-zoomed .scale-audit-token {
  flex-basis: 82px;
  margin: 0 -6px;
}

.scale-audit-row.is-zoomed .scale-audit-token svg {
  width: 82px;
  height: 102px;
}

.scale-audit-row.is-zoomed figcaption {
  font-size: 0.58rem;
}

.modal-card.result-card p {
  color: #574d3d;
}

.modal-card .balance-progress,
.modal-card .balance-metric {
  border-color: rgba(82, 59, 36, 0.22);
  background: rgba(67, 49, 31, 0.055);
}

.modal-card .balance-progress > div {
  background: rgba(62, 45, 28, 0.15);
}

.modal-card .balance-progress p,
.modal-card .balance-metric small {
  color: #6d6251;
}

.modal-card .balance-metric strong,
.modal-card .balance-unit-table {
  color: #3c3124;
}

.modal-card .balance-unit-table th,
.modal-card .balance-unit-table td {
  border-color: rgba(82, 59, 36, 0.2);
}

.modal-card .balance-seeds {
  border-color: rgba(82, 59, 36, 0.24);
  background: #282219;
  color: #f3e7c3;
}

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

  .unit-action-indicator.is-reloading .unit-action-bar,
  .action-availability-chip.is-reloading,
  .unit-group.is-panic-pending .unit-base,
  .unit-group.is-panicked .unit-base,
  .elephant-panic-glyph.is-active,
  .ignite-target-icon,
  .ignite-impact-ring,
  .ignite-impact-flame,
  .ignite-impact-spark,
  .fire-hex,
  .fire-flame,
  .fire-wisp {
    animation: none !important;
  }
}

@media (max-width: 780px) {
  :root {
    --hud-height: 88px;
  }

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

  .top-hud {
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    gap: 4px 8px;
    padding-bottom: 6px;
  }

  .hud-brand {
    display: none;
  }

  .turn-identity {
    grid-column: 1 / 3;
  }

  .economy-strip {
    grid-column: 1 / 3;
    grid-row: 2;
    justify-self: start;
    min-height: 31px;
    padding: 3px 8px;
  }

  .hud-actions {
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .hud-actions #recenter-button,
  .hud-actions .undo-button,
  .hud-actions .end-turn-button {
    display: none;
  }

  .mobile-end-turn {
    position: absolute;
    z-index: 4;
    right: max(13px, env(safe-area-inset-right));
    bottom: max(128px, calc(env(safe-area-inset-bottom) + 128px));
    display: block;
    min-height: 48px;
    padding: 0 14px;
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.33);
  }

  .mobile-undo {
    position: absolute;
    z-index: 4;
    right: max(13px, env(safe-area-inset-right));
    bottom: max(184px, calc(env(safe-area-inset-bottom) + 184px));
    display: block;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    background: rgba(17, 29, 45, 0.94);
    color: var(--ink);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.33);
  }

  .context-panel,
  .combat-panel,
  .recruit-panel {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: min(48dvh, 430px);
    padding: 14px;
    border-radius: 18px 18px 12px 12px;
  }

  .zoom-controls {
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .context-panel:not([hidden]) ~ .zoom-controls,
  .combat-panel:not([hidden]) ~ .zoom-controls,
  .recruit-panel:not([hidden]) ~ .zoom-controls {
    opacity: 0.25;
    pointer-events: none;
  }

  .toast {
    bottom: max(214px, calc(env(safe-area-inset-bottom) + 214px));
  }

  .turn-banner,
  .ai-banner {
    top: 10px;
  }

  .balance-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .balance-seed {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .unit-showcase {
    min-height: 205px;
  }

  .unit-showcase img {
    width: 82%;
    height: 175px;
  }

  .unit-showcase figcaption {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    padding: 8px 14px;
  }

  .unit-showcase figcaption span {
    text-align: left;
  }

  .setup-screen {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .setup-card {
    padding: 18px 14px;
    border-radius: 19px;
  }

  .title-lockup {
    align-items: flex-start;
    gap: 13px;
  }

  .title-logo {
    width: 86px;
    height: 86px;
    border-radius: 22px;
  }

  .title-lockup h1 {
    font-size: clamp(1.6rem, 9vw, 2.5rem);
  }

  .title-lockup h2 {
    font-size: 0.95rem;
  }

  .setup-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .setup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .setup-actions #continue-match {
    grid-column: 1 / -1;
  }

  .setup-actions #start-match {
    grid-column: 1 / -1;
  }

  .setup-footnote {
    text-align: center;
  }

  .round-chip {
    padding: 4px 7px;
    font-size: 0.67rem;
  }

  .wind-chip {
    gap: 5px;
    padding: 3px 8px;
  }

  .wind-chip strong {
    font-size: 0.68rem;
  }

  .wind-chip small {
    font-size: 0.55rem;
  }

  .turn-identity strong {
    max-width: 150px;
    font-size: 0.86rem;
  }

  .forecast-grid {
    gap: 4px;
  }

  .forecast-grid > div {
    padding: 7px 4px;
  }

  .forecast-grid strong {
    font-size: 0.95rem;
  }

  .info-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .terrain-card {
    grid-template-columns: 94px 1fr;
    gap: 11px;
    padding: 10px;
  }

  .terrain-art {
    width: 94px;
  }

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

  .balance-controls,
  .balance-summary {
    grid-template-columns: 1fr 1fr;
  }

  .balance-card {
    padding: 18px 12px;
  }

  .balance-unit-table {
    font-size: 0.66rem;
  }

  .result-score {
    grid-template-columns: 1fr repeat(2, auto);
  }

  .result-score small:nth-of-type(3),
  .result-score small:nth-of-type(4) {
    display: none;
  }
}

/* Checkpoint 7F1CG: top-HUD fit. The name block's `min-width: 0` rule above
   targets `span:nth-child(2)`, which became the faction swatch once the
   player avatar <img> was added first, so the company name stopped shrinking
   and the wind chip slid under the menu button on phones and into the Coin
   strip at laptop widths. Presentation only. */
@media (max-width: 1180px) {
  .turn-identity > span:not([id]) {
    display: grid;
    min-width: 0;
  }

  .turn-identity .round-chip,
  .turn-identity .wind-chip {
    flex-shrink: 0;
  }
}

@media (min-width: 781px) and (max-width: 1180px) {
  .top-hud {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .hud-brand {
    display: none;
  }
}

@media (max-width: 360px) {
  .turn-identity {
    gap: 6px;
  }

  .turn-identity small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The arrow still shows the direction; the chip keeps its title. */
  .wind-chip small {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Correspondence multiplayer (phase M1).

   Additive only: nothing above this rule is modified, so the single-player
   screens render exactly as they did before this pass.
   --------------------------------------------------------------------------- */

.mp-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 40;
}

.mp-card {
  position: relative;
  width: min(680px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mp-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.mp-header h1 {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.mp-account {
  font-size: 0.76rem;
  color: var(--muted);
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-profile-button {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  max-width: 42%;
  padding: 4px 9px 4px 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.mp-profile-button img,
.mp-avatar,
.mp-row-avatar,
.active-player-avatar {
  border-radius: 50%;
  object-fit: contain;
  background: var(--panel-strong);
}

.mp-profile-button img {
  width: 34px;
  height: 34px;
}

.mp-profile-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 750;
}

.mp-profile-button-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
  text-align: left;
}

.mp-favorite-badge {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid rgba(216, 182, 93, 0.36);
  border-radius: 999px;
  background: rgba(216, 182, 93, 0.1);
  color: var(--gold-bright);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-transform: uppercase;
  white-space: nowrap;
}

.mp-favorite-badge.is-maravese {
  border-style: double;
}

.mp-favorite-badge.is-sereyan {
  border-style: dashed;
}

.mp-favorite-badge.is-nusarai {
  border-width: 2px;
}

.mp-profile h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.mp-profile-name,
.mp-profile-favorite {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.mp-profile-name input,
.mp-profile-favorite select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.mp-profile-favorite {
  margin-top: 12px;
}

.mp-profile-favorite small {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 600;
}

.mp-field-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.mp-inline-error {
  min-height: 1.25em;
  margin: 6px 0 10px;
  color: #f2b3ac;
  font-size: 0.78rem;
}

.mp-avatar-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.mp-avatar-fieldset legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.mp-avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.mp-avatar-choice {
  min-height: 0;
  aspect-ratio: 1;
  padding: 3px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.05);
}

.mp-avatar-choice[aria-checked="true"] {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(216, 182, 93, 0.25);
}

.mp-avatar-choice img {
  display: block;
  width: 100%;
  height: 100%;
}

.mp-profile-summary {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(35, 56, 76, 0.34);
}

.mp-profile-summary > header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mp-profile-summary h3 {
  flex: 1;
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.mp-profile-summary > header button {
  min-height: 40px;
  padding: 7px 11px;
}

.mp-profile-summary-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.mp-profile-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.mp-profile-stat {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 29, 45, 0.52);
  color: var(--muted);
  font-size: 0.7rem;
}

.mp-profile-stat strong {
  display: block;
  color: var(--ink);
  font-size: 0.86rem;
}

.mp-status {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(35, 56, 76, 0.55);
  font-size: 0.82rem;
  color: var(--muted);
}

.mp-status[hidden] {
  display: none;
}

.mp-status.is-error {
  border-color: rgba(219, 101, 89, 0.5);
  color: #f2b3ac;
}

.mp-status.is-busy {
  border-color: rgba(216, 182, 93, 0.45);
  color: var(--gold-bright);
}

.mp-intro {
  margin: 0 0 14px;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
}

.mp-auth label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.mp-auth input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
}

.mp-auth-actions,
.mp-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.mp-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(17, 29, 45, 0.75);
  border: 1px solid var(--line);
}

.mp-tab {
  flex: 1;
  padding: 9px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.mp-tab[aria-selected="true"] {
  background: var(--panel-soft);
  color: var(--gold-bright);
}

.mp-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.mp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(35, 56, 76, 0.4);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.mp-row:hover {
  border-color: rgba(239, 217, 158, 0.45);
}

.mp-row.is-your-turn {
  border-color: var(--gold);
  background: rgba(216, 182, 93, 0.14);
}

/* Checkpoint 7F1CI: completed / abandoned server matches are history only. */
.mp-row.is-closed {
  opacity: 0.72;
}

.mp-row.is-closed .mp-badge {
  background: transparent;
  color: var(--muted);
}

.mp-row-body {
  flex: 1;
  min-width: 0;
}

.mp-row-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 1px solid var(--line);
}

.mp-row-opponents {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.mp-row-opponents img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.mp-history-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mp-history-stat {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(35, 56, 76, 0.35);
  color: var(--muted);
  font-size: 0.76rem;
}

.mp-history-stat strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 0.9rem;
}

.mp-row-title {
  display: block;
  font-weight: 650;
  font-size: 0.92rem;
}

.mp-row-meta {
  display: block;
  margin-top: 3px;
  font-size: 0.76rem;
  color: var(--muted);
}

.mp-badge {
  flex-shrink: 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--panel-soft);
  color: var(--muted);
}

.mp-badge.is-turn {
  background: var(--gold);
  color: #21170a;
}

.mp-empty {
  padding: 22px 12px;
  text-align: center;
  font-size: 0.84rem;
  color: var(--muted);
}

.mp-seats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.mp-seat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(35, 56, 76, 0.35);
}

.mp-seat-label {
  flex: 1;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-seat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: contain;
}

.mp-seat select {
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.8rem;
}

.mp-seat-open-copy {
  max-width: 46%;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.35;
  text-align: right;
}

.mp-note {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

/* In-match ---------------------------------------------------------------- */

.mp-waiting {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(17, 29, 45, 0.92);
  color: var(--muted);
  font-size: 0.78rem;
  pointer-events: none;
  z-index: 8;
}

.active-player-avatar {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
}

.end-turn-confirm-card {
  width: min(440px, 100%);
}

.end-turn-confirm-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.end-turn-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.mp-confirm-card {
  width: min(460px, 100%);
}

.mp-confirm-card > p:not(.eyebrow) {
  color: #574d3d;
  line-height: 1.55;
}

.mp-confirm-select {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: #574d3d;
  font-size: 0.78rem;
  font-weight: 800;
}

.mp-confirm-select select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(82, 59, 36, 0.3);
  background: rgba(255, 252, 239, 0.72);
  color: #30271d;
}

.mp-confirm-error {
  min-height: 1.35em;
  margin: 10px 0 0;
  color: #852e2a !important;
  font-size: 0.78rem;
  font-weight: 750;
}

.mp-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.mp-recap {
  position: absolute;
  right: 14px;
  top: 14px;
  width: min(340px, calc(100% - 28px));
  max-height: min(64vh, 520px);
  display: flex;
  flex-direction: column;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 12;
}

.mp-recap header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.mp-recap header h2 {
  margin: 2px 0 0;
  font-size: 1rem;
}

.mp-recap-summary {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.mp-recap-lines {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mp-recap-line {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-left: 3px solid var(--panel-soft);
  border-radius: 8px;
  background: rgba(35, 56, 76, 0.4);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: left;
}

.mp-recap-line[data-hex] {
  cursor: pointer;
}

.mp-recap-line[data-hex]:hover {
  border-color: rgba(239, 217, 158, 0.4);
}

.mp-recap-line.is-critical {
  border-left-color: var(--red);
}

.mp-recap-line.is-warning {
  border-left-color: var(--amber);
}

.mp-recap-line.is-good {
  border-left-color: var(--green);
}

@media (max-width: 640px) {
  .mp-card {
    padding: 16px;
  }

  .mp-recap {
    right: 8px;
    left: 8px;
    top: 8px;
    width: auto;
    max-height: 52vh;
  }

  .mp-account {
    display: none;
  }

  .mp-profile-button {
    max-width: 44px;
    padding-right: 4px;
  }

  .mp-profile-button span {
    display: none;
  }

  .mp-tabs {
    overflow-x: auto;
  }

  .mp-tab {
    min-width: 88px;
  }

  .mp-avatar-grid {
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .mp-profile-summary-grid {
    grid-template-columns: 1fr;
  }

  .mp-seat-open-copy {
    max-width: 42%;
  }

  .end-turn-confirm-actions,
  .mp-confirm-actions {
    flex-direction: column-reverse;
  }

  .end-turn-confirm-actions button,
  .mp-confirm-actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mp-row,
  .mp-recap-line {
    transition: none;
  }
}

.mp-start-early {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 4px;
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(216, 182, 93, 0.08);
}

.mp-start-early .mp-note {
  flex: 1;
  margin: 0;
}

.mp-start-now {
  flex-shrink: 0;
}

/* ---- Checkpoint 7F1BM: installation-first PWA shell --------------------- */

/* Pull-to-refresh or rubber-band scrolling must never reload or shift an
   active game in the installed app. */
html,
body {
  overscroll-behavior: none;
}

/* pwa.js sets data-app-mode in <head> before first paint: a browser tab shows
   only the install screen, the installed app (and the Android WebView) shows
   only the game. */
.install-screen {
  display: none;
}

html[data-app-mode="install"] #app {
  display: none;
}

html[data-app-mode="install"] .install-screen {
  display: grid;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  place-items: start center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse at top, rgba(228, 197, 107, 0.16), transparent 60%),
    #0b1420;
}

.install-card {
  width: min(560px, 100%);
  margin: auto 0;
  padding: 28px 24px;
  border-radius: 20px;
  background: rgba(17, 29, 43, 0.92);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.install-logo {
  width: min(168px, 42vw);
  height: auto;
  border-radius: 28px;
}

.install-card h1 {
  margin: 4px 0 10px;
  font-size: clamp(2rem, 8vw, 2.8rem);
}

.install-lead {
  margin: 0 0 18px;
  line-height: 1.5;
  opacity: 0.92;
}

.install-button {
  width: 100%;
  min-height: 52px;
  font-size: 1.1rem;
}

.install-status,
.install-installed,
.install-link-notice {
  margin: 14px 0 0;
  line-height: 1.45;
}

.install-link-notice,
.install-installed {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  text-align: left;
}

.install-guide {
  margin: 18px 0 0;
  padding-left: 1.4em;
  line-height: 1.55;
  text-align: left;
}

.install-guide li + li {
  margin-top: 6px;
}

.install-note {
  list-style: none;
  margin-left: -1.4em;
  opacity: 0.8;
  font-size: 0.92em;
}

/* In-app update offer and notices: above the game, clear of notches and the
   system navigation area, never covering the whole board. */
.pwa-banner {
  position: fixed;
  z-index: 60;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  justify-content: flex-end;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(17, 29, 43, 0.96);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.pwa-banner[hidden] {
  display: none;
}

.pwa-banner span {
  flex: 1 1 220px;
  line-height: 1.4;
}

html[data-app-mode="install"] #update-banner {
  display: none;
}

/* The notice sits above the update banner so the two never overlap. */
#pwa-notice {
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px);
}
