:root {
  --bg: #04070f;
  --bg-soft: #071022;
  --panel: rgba(10, 18, 36, 0.78);
  --panel-strong: rgba(12, 22, 44, 0.94);
  --line: rgba(126, 171, 255, 0.15);
  --line-bright: rgba(126, 196, 255, 0.34);
  --text: #edf5ff;
  --muted: #8497bd;
  --dim: #56678b;
  --cyan: #5ce7ff;
  --cyan-rgb: 92, 231, 255;
  --blue: #4c8dff;
  --violet: #b57bff;
  --violet-rgb: 181, 123, 255;
  --gold: #ffd166;
  --gold-rgb: 255, 209, 102;
  --danger: #ff5f7f;
  --danger-rgb: 255, 95, 127;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --cell-gap: clamp(3px, 0.42vw, 6px);
  --coord-gap: 6px;
  --coord-size: 17px;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background:
    radial-gradient(1100px 760px at 12% -12%, rgba(76, 141, 255, 0.16), transparent 62%),
    radial-gradient(980px 720px at 102% -4%, rgba(181, 123, 255, 0.17), transparent 60%),
    radial-gradient(850px 620px at 50% 112%, rgba(255, 209, 102, 0.055), transparent 62%),
    linear-gradient(180deg, #050a17 0%, #04070f 55%, #03050c 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.65;
  background-image:
    radial-gradient(1px 1px at 22px 36px, rgba(255, 255, 255, 0.6), transparent 1.5px),
    radial-gradient(1px 1px at 118px 92px, rgba(92, 231, 255, 0.5), transparent 1.5px),
    radial-gradient(1px 1px at 214px 52px, rgba(255, 255, 255, 0.42), transparent 1.5px),
    radial-gradient(1.5px 1.5px at 168px 178px, rgba(181, 123, 255, 0.45), transparent 2px),
    radial-gradient(1px 1px at 48px 208px, rgba(255, 209, 102, 0.4), transparent 1.5px);
  background-size: 260px 260px, 340px 340px, 300px 300px, 380px 380px, 320px 320px;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    linear-gradient(rgba(88, 156, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88, 156, 255, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 15%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 15%, transparent 78%);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; touch-action: manipulation; }
body.modal-open { overflow: hidden; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.game-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 1360px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  min-height: 64px;
  padding: 10px 14px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(120deg, rgba(15, 28, 54, 0.9), rgba(7, 13, 28, 0.72)),
    radial-gradient(500px 90px at 40% 0%, rgba(92, 231, 255, 0.08), transparent 70%);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #04101a;
  font-size: 19px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 0 24px rgba(var(--cyan-rgb), 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brand-text b { color: var(--text); }
.brand:hover .brand-text { color: var(--text); }

.game-id { min-width: 0; }
.game-kicker {
  display: block;
  margin-bottom: 1px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.24em;
  white-space: nowrap;
}

.game-id h1 {
  margin: 0;
  font-size: clamp(21px, 2.1vw, 28px);
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.game-id h1 em {
  color: var(--cyan);
  font-style: normal;
  text-shadow: 0 0 12px rgba(var(--cyan-rgb), 0.75), 0 0 34px rgba(var(--cyan-rgb), 0.3);
}

.top-stats {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.stat {
  min-height: 44px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(4, 10, 22, 0.44);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-label {
  color: var(--dim);
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
  white-space: nowrap;
}

.energy-stat {
  min-width: 118px;
  border-color: rgba(var(--gold-rgb), 0.2);
  background: linear-gradient(120deg, rgba(var(--gold-rgb), 0.07), rgba(4, 10, 22, 0.35));
}

.energy-line {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  line-height: 1;
}

.icon-bolt {
  width: 13px;
  height: 13px;
  fill: var(--gold);
  filter: drop-shadow(0 0 5px rgba(var(--gold-rgb), 0.65));
}

.energy-line strong {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 0 12px rgba(var(--gold-rgb), 0.35);
}

.stat-sub {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 9px;
  opacity: 0.7;
  white-space: nowrap;
}

.turn-stat { min-width: 58px; }
.turn-stat strong {
  margin-top: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1;
}

.sectors-stat { min-width: 82px; }
.sectors-line {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1;
}
.sectors-line b { font-weight: 800; }
.sectors-line .slash { color: var(--dim); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.player { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.dot.ai { background: var(--violet); box-shadow: 0 0 6px var(--violet); }

.top-buttons { display: flex; gap: 6px; }
.icon-btn {
  width: 38px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(4, 10, 22, 0.4);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.18s;
}
.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:hover { color: var(--cyan); border-color: rgba(var(--cyan-rgb), 0.4); background: rgba(var(--cyan-rgb), 0.06); }
.icon-btn:active { transform: scale(0.96); }

/* ---------- layout ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 304px;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.rail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(165deg, rgba(13, 24, 46, 0.82), rgba(6, 12, 26, 0.78)),
    radial-gradient(260px 100px at 20% 0%, rgba(var(--cyan-rgb), 0.05), transparent 70%);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--cyan-rgb), 0.35), transparent);
  opacity: 0.55;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 0;
}

.eyebrow {
  color: var(--cyan);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.2em;
  line-height: 1.2;
  text-transform: uppercase;
}

.panel-note {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8.5px;
  white-space: nowrap;
}

.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
}
.live-tag i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 7px var(--gold);
  animation: blink 2.4s ease-in-out infinite;
}

.mission-copy {
  margin: 10px 14px 9px;
  color: #c5d2ec;
  font-size: 11.5px;
  line-height: 1.45;
}
.mission-copy b { color: var(--gold); font-family: var(--mono); }

.base-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
  margin: 7px 12px;
  padding: 8px 9px 7px;
  border: 1px solid rgba(var(--cyan-rgb), 0.16);
  border-radius: 9px;
  background: linear-gradient(120deg, rgba(var(--cyan-rgb), 0.055), rgba(4, 10, 22, 0.28));
}
.base-card.base-ai {
  border-color: rgba(var(--violet-rgb), 0.18);
  background: linear-gradient(120deg, rgba(var(--violet-rgb), 0.06), rgba(4, 10, 22, 0.28));
}
.base-badge {
  padding: 3px 5px;
  border: 1px solid rgba(var(--cyan-rgb), 0.24);
  border-radius: 5px;
  color: var(--cyan);
  background: rgba(var(--cyan-rgb), 0.08);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
}
.base-ai .base-badge {
  border-color: rgba(var(--violet-rgb), 0.26);
  color: var(--violet);
  background: rgba(var(--violet-rgb), 0.08);
}
.base-copy span {
  display: block;
  color: var(--dim);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.2;
}
.base-copy strong {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.2;
}
.base-copy small { color: var(--muted); font-family: var(--font); font-size: 8px; font-weight: 500; }

.pips {
  grid-column: 1 / -1;
  display: flex;
  gap: 3px;
  margin-top: 2px;
}
.pips i {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
}
.base-player .pips i.on { background: var(--cyan); box-shadow: 0 0 6px rgba(var(--cyan-rgb), 0.6); }
.base-ai .pips i.on { background: var(--violet); box-shadow: 0 0 6px rgba(var(--violet-rgb), 0.6); }

.econ-row, .econ-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 14px;
  padding: 4px 0;
  color: var(--muted);
  font-size: 10px;
}
.econ-row b { color: #dbe7ff; font-family: var(--mono); font-size: 10.5px; }
.econ-total {
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 10.5px;
  font-weight: 700;
}
.econ-total b { color: var(--gold); font-family: var(--mono); font-size: 13px; }

.fine {
  margin: 7px 14px 11px;
  color: var(--dim);
  font-size: 8.5px;
  line-height: 1.35;
}

.tip-panel { padding-bottom: 11px; }
.tip-panel .eyebrow { display: block; padding: 11px 14px 0; }
.tip-panel p {
  margin: 5px 14px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

/* ---------- board ---------- */

.board-column {
  --board-w: min(100%, 520px, calc(100dvh - 235px));
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-head {
  width: var(--board-w);
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid rgba(var(--cyan-rgb), 0.25);
  border-radius: 7px;
  color: var(--cyan);
  background: rgba(var(--cyan-rgb), 0.055);
  font-size: 8.5px;
  font-weight: 850;
  letter-spacing: 0.13em;
  white-space: nowrap;
}
.phase-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.phase-badge.ai {
  border-color: rgba(var(--violet-rgb), 0.3);
  color: var(--violet);
  background: rgba(var(--violet-rgb), 0.06);
}
.phase-badge.over { border-color: rgba(var(--gold-rgb), 0.3); color: var(--gold); background: rgba(var(--gold-rgb), 0.06); }

.board-hint {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.04em;
  text-align: right;
}

.board-frame {
  position: relative;
  width: var(--board-w);
  padding: 11px 11px 10px;
  border: 1px solid var(--line-bright);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(13, 25, 49, 0.9), rgba(5, 10, 22, 0.92)),
    radial-gradient(400px 200px at 50% 0%, rgba(var(--cyan-rgb), 0.05), transparent 70%);
  box-shadow:
    0 24px 65px rgba(0, 0, 0, 0.45),
    0 0 50px rgba(var(--cyan-rgb), 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.board-frame::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(126, 171, 255, 0.06);
  border-radius: 14px;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(var(--cyan-rgb), 0.55);
  border-style: solid;
  pointer-events: none;
  z-index: 2;
}
.corner.tl { top: 4px; left: 4px; border-width: 1px 0 0 1px; border-top-left-radius: 5px; }
.corner.tr { top: 4px; right: 4px; border-width: 1px 1px 0 0; border-top-right-radius: 5px; }
.corner.bl { bottom: 4px; left: 4px; border-width: 0 0 1px 1px; border-bottom-left-radius: 5px; }
.corner.br { bottom: 4px; right: 4px; border-width: 0 1px 1px 0; border-bottom-right-radius: 5px; }

.coord-top {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--cell-gap);
  margin: 0 0 5px calc(var(--coord-size) + var(--coord-gap));
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  text-align: center;
}

.board-row {
  display: grid;
  grid-template-columns: var(--coord-size) minmax(0, 1fr);
  gap: var(--coord-gap);
}

.coord-left {
  display: grid;
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: var(--cell-gap);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7px;
  text-align: center;
  align-items: center;
}

.board-shell {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 8px;
}

.board-shell::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 16px;
  background: radial-gradient(ellipse at center, rgba(var(--cyan-rgb), 0.07), transparent 68%);
  pointer-events: none;
}

.board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: var(--cell-gap);
  z-index: 1;
}
.board:focus { outline: none; }
.board:focus-visible {
  outline: 2px solid rgba(var(--cyan-rgb), 0.45);
  outline-offset: 4px;
  border-radius: 9px;
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(126, 171, 255, 0.13);
  border-radius: clamp(4px, 0.6vw, 7px);
  color: var(--muted);
  background:
    linear-gradient(155deg, rgba(20, 34, 62, 0.8), rgba(7, 13, 27, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.2s, transform 0.16s, filter 0.16s;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(var(--cyan-rgb), 0.16), transparent 68%);
  transition: opacity 0.18s;
  pointer-events: none;
}

.cell:hover {
  z-index: 2;
  border-color: rgba(var(--cyan-rgb), 0.45);
  box-shadow: inset 0 0 20px rgba(var(--cyan-rgb), 0.08), 0 0 14px rgba(var(--cyan-rgb), 0.1);
}
.cell:hover::before { opacity: 1; }
.cell:active { transform: scale(0.975); }

.cell[data-owner="player"] {
  border-color: rgba(var(--cyan-rgb), 0.32);
  color: var(--cyan);
  background:
    linear-gradient(155deg, rgba(27, 83, 112, 0.44), rgba(7, 24, 41, 0.94));
  box-shadow: inset 0 0 22px rgba(var(--cyan-rgb), 0.055), inset 0 1px 0 rgba(255, 255, 255, 0.045);
}
.cell[data-owner="ai"] {
  border-color: rgba(var(--violet-rgb), 0.38);
  color: var(--violet);
  background:
    linear-gradient(155deg, rgba(81, 43, 128, 0.48), rgba(19, 9, 38, 0.94));
  box-shadow: inset 0 0 22px rgba(var(--violet-rgb), 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.cell[data-owner="neutral"] { color: #5f7296; }

.cell[data-type="base"] {
  border-color: rgba(var(--gold-rgb), 0.48);
  box-shadow:
    inset 0 0 26px rgba(var(--gold-rgb), 0.09),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 14px rgba(var(--gold-rgb), 0.08);
}
.cell[data-type="base"]::before {
  opacity: 1;
  background: radial-gradient(circle at 50% 48%, rgba(var(--gold-rgb), 0.14), transparent 66%);
}
.cell[data-type="base"] .cell-icon { color: var(--gold); filter: drop-shadow(0 0 7px rgba(var(--gold-rgb), 0.5)); }
.cell[data-owner="ai"][data-type="base"] { border-color: rgba(var(--gold-rgb), 0.58); }

.cell[data-type="mine"] .cell-icon { color: var(--gold); filter: drop-shadow(0 0 6px rgba(var(--gold-rgb), 0.4)); }
.cell[data-type="barracks"] .cell-icon { color: var(--cyan); filter: drop-shadow(0 0 6px rgba(var(--cyan-rgb), 0.34)); }
.cell[data-owner="ai"][data-type="barracks"] .cell-icon { color: var(--violet); filter: drop-shadow(0 0 6px rgba(var(--violet-rgb), 0.4)); }

.cell-code {
  position: absolute;
  top: 4px;
  left: 5px;
  z-index: 2;
  color: rgba(193, 214, 250, 0.34);
  font-family: var(--mono);
  font-size: clamp(5.5px, 0.55vw, 7.5px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  pointer-events: none;
}

.cell-icon {
  position: absolute;
  top: 48%;
  left: 50%;
  z-index: 1;
  width: 38%;
  max-width: 31px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cell-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cell[data-type="base"] .cell-icon { width: 46%; max-width: 37px; }
.cell[data-type="empty"] .cell-icon { display: none; }

.neutral-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 5px;
  height: 5px;
  border: 1px solid rgba(126, 171, 255, 0.25);
  transform: translate(-50%, -50%) rotate(45deg);
  pointer-events: none;
}
.cell[data-owner="neutral"]:hover .neutral-mark { border-color: var(--cyan); box-shadow: 0 0 6px rgba(var(--cyan-rgb), 0.5); }

.unit-chip {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 17px;
  padding: 1px 3px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 4px;
  color: var(--text);
  background: rgba(3, 8, 18, 0.82);
  font-family: var(--mono);
  font-size: clamp(7.5px, 0.75vw, 10px);
  font-weight: 800;
  line-height: 1.15;
  pointer-events: none;
}
.unit-chip svg { width: 7px; height: 7px; fill: currentColor; stroke: none; opacity: 0.8; }
.cell[data-owner="player"] .unit-chip { border-color: rgba(var(--cyan-rgb), 0.35); color: var(--cyan); }
.cell[data-owner="ai"] .unit-chip { border-color: rgba(var(--violet-rgb), 0.4); color: #d8bfff; }

.cell.is-capturable {
  border-color: rgba(var(--cyan-rgb), 0.28);
  box-shadow: inset 0 0 0 1px rgba(var(--cyan-rgb), 0.08), inset 0 0 18px rgba(var(--cyan-rgb), 0.05);
}
.cell.is-capturable .neutral-mark { border-color: rgba(var(--cyan-rgb), 0.55); }

.cell.is-selected {
  z-index: 3;
  border-color: var(--gold) !important;
  box-shadow:
    0 0 0 1px rgba(var(--gold-rgb), 0.65),
    0 0 22px rgba(var(--gold-rgb), 0.3),
    inset 0 0 24px rgba(var(--gold-rgb), 0.12) !important;
  transform: translateY(-1px) scale(1.018);
}
.cell.is-selected .cell-code { color: var(--gold); }

.cell.is-attackable {
  border-color: rgba(var(--danger-rgb), 0.7) !important;
  box-shadow: 0 0 0 1px rgba(var(--danger-rgb), 0.3), 0 0 18px rgba(var(--danger-rgb), 0.22) !important;
  animation: targetPulse 1.25s ease-in-out infinite;
}
.cell.is-attacker {
  border-color: rgba(var(--gold-rgb), 0.55) !important;
  box-shadow: inset 0 0 0 1px rgba(var(--gold-rgb), 0.18) !important;
}

.cell.is-hit { animation: cellHit 0.32s ease-out; }
.cell.is-capture { animation: cellCapture 0.5s ease-out; }

body[data-phase="ai"] .cell { cursor: progress; }
body[data-phase="ai"] .cell:hover { border-color: rgba(126, 171, 255, 0.2); box-shadow: none; }
body[data-phase="over"] .cell { cursor: default; }

.board-fx {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: visible;
  pointer-events: none;
}

.board-scan {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  border-radius: 8px;
  pointer-events: none;
}
.board-scan::after {
  content: "";
  position: absolute;
  top: -45%;
  left: -15%;
  width: 130%;
  height: 35%;
  background: linear-gradient(180deg, transparent, rgba(var(--cyan-rgb), 0.055), transparent);
  animation: scan 10s linear infinite;
}

.fx-text {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.03em;
  text-shadow: 0 0 8px rgba(var(--cyan-rgb), 0.85), 0 2px 8px rgba(0, 0, 0, 0.9);
  animation: fxFloat 0.9s ease-out forwards;
  white-space: nowrap;
}
.fx-text.ai { color: var(--violet); text-shadow: 0 0 8px rgba(var(--violet-rgb), 0.9), 0 2px 8px rgba(0, 0, 0, 0.9); }
.fx-text.gold { color: var(--gold); text-shadow: 0 0 8px rgba(var(--gold-rgb), 0.9), 0 2px 8px rgba(0, 0, 0, 0.9); }
.fx-text.danger { color: var(--danger); text-shadow: 0 0 8px rgba(var(--danger-rgb), 0.9), 0 2px 8px rgba(0, 0, 0, 0.9); }

.fx-beam {
  position: absolute;
  z-index: 1;
  height: 2px;
  transform-origin: 0 50%;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), #fff);
  box-shadow: 0 0 8px rgba(var(--cyan-rgb), 0.85), 0 0 18px rgba(var(--cyan-rgb), 0.45);
  animation: beamFade 0.42s ease-out forwards;
  pointer-events: none;
}
.fx-beam.ai {
  background: linear-gradient(90deg, transparent, var(--violet), #fff);
  box-shadow: 0 0 8px rgba(var(--violet-rgb), 0.85), 0 0 18px rgba(var(--violet-rgb), 0.45);
}

.hover-info {
  width: var(--board-w);
  min-height: 30px;
  margin: 8px 0 0;
  padding: 6px 0 0 10px;
  border-left: 2px solid rgba(var(--cyan-rgb), 0.24);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}
.hover-info b { color: var(--text); font-family: var(--mono); font-size: 9.5px; }
.hover-info .accent { color: var(--gold); font-family: var(--mono); font-size: 9.5px; }

/* ---------- actions ---------- */

.actions-panel { padding-bottom: 12px; }

.mini-phase {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.mini-phase.ai { color: var(--violet); }
.mini-phase.over { color: var(--gold); }

.selected-card {
  min-height: 88px;
  margin: 9px 12px 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(4, 10, 22, 0.38);
}

.selected-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sector-code {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 850;
  line-height: 1;
}
.owner-tag {
  padding: 2px 5px;
  border: 1px solid rgba(126, 171, 255, 0.18);
  border-radius: 4px;
  color: var(--dim);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.2;
  white-space: nowrap;
}
.owner-tag.player { border-color: rgba(var(--cyan-rgb), 0.3); color: var(--cyan); background: rgba(var(--cyan-rgb), 0.06); }
.owner-tag.ai { border-color: rgba(var(--violet-rgb), 0.3); color: var(--violet); background: rgba(var(--violet-rgb), 0.06); }
.owner-tag.neutral { color: var(--muted); }
.owner-tag.base { border-color: rgba(var(--gold-rgb), 0.35); color: var(--gold); background: rgba(var(--gold-rgb), 0.06); }

.selected-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.selected-units {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 2px 5px;
  border: 1px solid rgba(var(--gold-rgb), 0.22);
  border-radius: 4px;
  color: var(--gold);
  background: rgba(var(--gold-rgb), 0.055);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
}
.selected-units svg { width: 8px; height: 8px; fill: currentColor; stroke: none; }
.selected-units small { color: var(--muted); font-family: var(--font); font-size: 7.5px; font-weight: 500; }

.build-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 0 12px;
}

.action-btn {
  position: relative;
  min-height: 70px;
  padding: 7px 8px;
  border: 1px solid rgba(126, 171, 255, 0.16);
  border-radius: 9px;
  color: var(--text);
  background:
    linear-gradient(150deg, rgba(18, 34, 62, 0.82), rgba(5, 11, 24, 0.88));
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  gap: 1px 6px;
  transition: border-color 0.18s, background 0.18s, transform 0.18s, opacity 0.18s;
}
.action-btn:not(:disabled):hover {
  border-color: rgba(var(--gold-rgb), 0.38);
  background: linear-gradient(150deg, rgba(42, 47, 57, 0.9), rgba(12, 18, 30, 0.92));
  transform: translateY(-1px);
}
.action-btn:not(:disabled):active { transform: scale(0.985); }
.action-btn:disabled {
  opacity: 0.34;
  cursor: not-allowed;
  filter: grayscale(0.35);
}
.action-icon {
  grid-row: 1 / 3;
  align-self: center;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--gold);
}
.action-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#build-barracks .action-icon { color: var(--cyan); }
.action-title {
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.15;
}
.action-sub {
  color: var(--dim);
  font-size: 7.5px;
  line-height: 1.2;
  white-space: nowrap;
}
.action-cost {
  position: absolute;
  top: 5px;
  right: 6px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  opacity: 0.8;
}

.primary-btn {
  width: calc(100% - 24px);
  min-height: 46px;
  margin: 10px 12px 0;
  padding: 0 14px;
  border: 1px solid rgba(var(--cyan-rgb), 0.55);
  border-radius: 9px;
  color: #041018;
  background: linear-gradient(120deg, var(--cyan), #48a9ff);
  box-shadow: 0 0 22px rgba(var(--cyan-rgb), 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.035em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.18s, transform 0.18s, box-shadow 0.18s;
}
.primary-btn:hover { filter: brightness(1.08); box-shadow: 0 0 28px rgba(var(--cyan-rgb), 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(0.55);
  box-shadow: none;
}
.primary-btn .key {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border: 1px solid rgba(4, 16, 24, 0.3);
  border-radius: 4px;
  color: rgba(4, 16, 24, 0.7);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
}

/* ---------- log & legend ---------- */

.log-panel { min-height: 0; }

.log {
  list-style: none;
  margin: 8px 12px 12px;
  padding: 0;
  max-height: 168px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--cyan-rgb), 0.25) transparent;
}
.log::-webkit-scrollbar { width: 4px; }
.log::-webkit-scrollbar-thumb { background: rgba(var(--cyan-rgb), 0.22); border-radius: 4px; }
.log li {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  column-gap: 7px;
  row-gap: 5px;
  padding-left: 6px;
  border-left: 2px solid rgba(126, 171, 255, 0.14);
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.35;
}
.log li b {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 700;
  padding-top: 1px;
}
.log li.player { border-left-color: rgba(var(--cyan-rgb), 0.5); }
.log li.player b { color: var(--cyan); }
.log li.ai { border-left-color: rgba(var(--violet-rgb), 0.5); }
.log li.ai b { color: var(--violet); }
.log li.gold { border-left-color: rgba(var(--gold-rgb), 0.5); }
.log li.gold b { color: var(--gold); }
.log li.danger { border-left-color: rgba(var(--danger-rgb), 0.6); }
.log li.danger b { color: var(--danger); }
.log li.system { border-left-color: rgba(126, 171, 255, 0.3); }
.log-empty { color: var(--dim); font-size: 9.5px; }

.legend-panel { padding-bottom: 10px; }
.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin: 8px 14px 0;
}
.legend-grid span {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.2;
}
.swatch {
  display: inline-grid;
  place-items: center;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: 0 0 auto;
}
.swatch.player { background: var(--cyan); box-shadow: 0 0 6px rgba(var(--cyan-rgb), 0.55); }
.swatch.ai { background: var(--violet); box-shadow: 0 0 6px rgba(var(--violet-rgb), 0.55); }
.swatch.neutral { background: #43526f; border: 1px solid rgba(126, 171, 255, 0.25); }
.swatch.energy { color: var(--gold); font-size: 8px; background: rgba(var(--gold-rgb), 0.12); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  width: max-content;
  max-width: calc(100vw - 28px);
  padding: 9px 15px;
  border: 1px solid rgba(var(--cyan-rgb), 0.32);
  border-radius: 9px;
  color: var(--cyan);
  background: rgba(5, 12, 26, 0.94);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45), 0 0 20px rgba(var(--cyan-rgb), 0.08);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ai { border-color: rgba(var(--violet-rgb), 0.38); color: var(--violet); }
.toast.gold { border-color: rgba(var(--gold-rgb), 0.38); color: var(--gold); }
.toast.error { border-color: rgba(var(--danger-rgb), 0.42); color: #ff9fb2; }

/* ---------- modals ---------- */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 5, 12, 0.74);
  backdrop-filter: blur(11px);
  -webkit-backdrop-filter: blur(11px);
  animation: fadeIn 0.2s ease-out;
}

.modal {
  position: relative;
  width: min(100%, 560px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--line-bright);
  border-radius: 20px;
  background:
    linear-gradient(165deg, rgba(15, 28, 54, 0.985), rgba(5, 11, 24, 0.99)),
    radial-gradient(500px 240px at 50% 0%, rgba(var(--cyan-rgb), 0.08), transparent 70%);
  box-shadow:
    0 35px 100px rgba(0, 0, 0, 0.68),
    0 0 70px rgba(var(--cyan-rgb), 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--cyan-rgb), 0.25) transparent;
}
.modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--cyan-rgb), 0.6), transparent);
}
.modal::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(126, 171, 255, 0.06);
  border-radius: 15px;
  pointer-events: none;
}
.modal > * { position: relative; z-index: 1; }

.modal h2 {
  margin: 8px 0 0;
  font-size: clamp(34px, 5.2vw, 52px);
  font-weight: 850;
  line-height: 0.98;
  letter-spacing: 0.07em;
}
.modal h2 em {
  color: var(--cyan);
  font-style: normal;
  text-shadow: 0 0 16px rgba(var(--cyan-rgb), 0.75), 0 0 46px rgba(var(--cyan-rgb), 0.3);
}
.modal-lead {
  margin: 13px 0 0;
  color: #c4d2ec;
  font-size: 12px;
  line-height: 1.55;
}

.intro-modal { width: min(100%, 620px); }
.intro-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 20px;
}
.intro-steps article {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(4, 10, 22, 0.34);
}
.intro-steps span {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.intro-steps h3 {
  margin: 4px 0 3px;
  font-size: 12px;
  font-weight: 800;
}
.intro-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}
.intro-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 19px;
}
.intro-actions .primary-btn {
  width: auto;
  min-width: 210px;
  margin: 0;
  padding: 0 20px;
}
.intro-foot {
  margin: 12px 0 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.text-btn {
  border: 0;
  min-height: 44px;
  padding: 9px 6px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(126, 171, 255, 0.25);
  text-underline-offset: 3px;
}
.text-btn:hover { color: var(--cyan); }

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(4, 10, 22, 0.5);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--cyan); border-color: rgba(var(--cyan-rgb), 0.35); }

.rules-modal { width: min(100%, 660px); }
.rules-modal h2 { font-size: clamp(30px, 4.4vw, 44px); }
.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}
.rules-grid article {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(4, 10, 22, 0.32);
}
.rules-grid h3 {
  margin: 0 0 3px;
  color: var(--cyan);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.rules-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.45;
}
.rules-grid b { color: var(--gold); font-family: var(--mono); }
.rules-note {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-left: 2px solid rgba(var(--gold-rgb), 0.4);
  color: var(--dim);
  background: rgba(var(--gold-rgb), 0.035);
  font-size: 9px;
  line-height: 1.45;
}
.rules-modal .primary-btn { width: 100%; margin: 16px 0 0; }

.confirm-modal { width: min(100%, 410px); }
.confirm-modal h2 { font-size: clamp(28px, 4.5vw, 38px); }
.modal-actions {
  display: flex;
  gap: 9px;
  margin-top: 20px;
}
.modal-actions .primary-btn {
  width: auto;
  flex: 1;
  margin: 0;
}
.ghost-btn {
  flex: 1;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-bright);
  border-radius: 9px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}
.ghost-btn:hover { border-color: rgba(var(--cyan-rgb), 0.4); color: var(--cyan); }

.end-modal { width: min(100%, 520px); text-align: center; }
.end-emblem {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border: 1px solid rgba(var(--gold-rgb), 0.42);
  border-radius: 50%;
  color: var(--gold);
  background: radial-gradient(circle, rgba(var(--gold-rgb), 0.14), rgba(var(--gold-rgb), 0.02) 65%);
  box-shadow: 0 0 30px rgba(var(--gold-rgb), 0.14), inset 0 0 20px rgba(var(--gold-rgb), 0.08);
  font-size: 26px;
  line-height: 1;
}
.end-modal.defeat .end-emblem {
  border-color: rgba(var(--danger-rgb), 0.45);
  color: var(--danger);
  background: radial-gradient(circle, rgba(var(--danger-rgb), 0.16), rgba(var(--danger-rgb), 0.02) 65%);
  box-shadow: 0 0 30px rgba(var(--danger-rgb), 0.14), inset 0 0 20px rgba(var(--danger-rgb), 0.08);
}
.end-modal h2 { font-size: clamp(30px, 5vw, 44px); }
.end-modal.defeat h2 {
  color: #ffb6c5;
  text-shadow: 0 0 22px rgba(var(--danger-rgb), 0.3);
}
.end-modal .eyebrow { display: block; }
.end-modal .modal-lead { max-width: 380px; margin: 12px auto 0; }
.end-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 20px 0 0;
}
.end-stats div {
  padding: 9px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 10, 22, 0.34);
}
.end-stats span {
  display: block;
  color: var(--dim);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.end-stats b {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
}
.end-modal .modal-actions { justify-content: center; }
.end-modal .modal-actions .primary-btn { flex: 0 1 210px; }
.end-modal .modal-actions .text-btn { flex: 0 0 auto; align-self: center; }

/* ---------- animations ---------- */

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes statBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); box-shadow: 0 0 20px rgba(var(--gold-rgb), 0.18); }
  100% { transform: scale(1); }
}
.stat.bump { animation: statBump 0.35s ease-out; }
@keyframes scan {
  0% { top: -45%; }
  100% { top: 110%; }
}
@keyframes targetPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(var(--danger-rgb), 0.24), 0 0 12px rgba(var(--danger-rgb), 0.14); }
  50% { box-shadow: 0 0 0 1px rgba(var(--danger-rgb), 0.6), 0 0 22px rgba(var(--danger-rgb), 0.34); }
}
@keyframes cellHit {
  0% { transform: translateX(0); filter: brightness(1); }
  25% { transform: translateX(-2px); filter: brightness(1.7); }
  50% { transform: translateX(2px); filter: brightness(1.25); }
  100% { transform: translateX(0); filter: brightness(1); }
}
@keyframes cellCapture {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.06); filter: brightness(1.8); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes fxFloat {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.85); }
  18% { opacity: 1; transform: translate(-50%, -55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -155%) scale(1.02); }
}
@keyframes beamFade {
  0% { opacity: 0; transform-origin: 0 50%; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal { animation: modalIn 0.24s ease-out; }

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

@media (max-width: 1120px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .rail-left { display: none; }
  .board-column { --board-w: min(100%, 540px, calc(100dvh - 210px)); }
}

@media (max-width: 820px) {
  .game-shell { padding: 10px 10px 18px; }
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "brand game"
      "stats stats";
    gap: 7px 10px;
    padding: 9px 10px;
    border-radius: 14px;
  }
  .brand { grid-area: brand; }
  .brand-text { display: none; }
  .brand-mark { width: 31px; height: 31px; border-radius: 9px; font-size: 17px; }
  .game-id { grid-area: game; }
  .game-kicker { font-size: 6.5px; letter-spacing: 0.2em; }
  .game-id h1 { font-size: 21px; letter-spacing: 0.11em; }
  .top-stats {
    grid-area: stats;
    display: grid;
    grid-template-columns: 1.15fr 0.72fr 0.92fr auto;
    gap: 6px;
  }
  .stat { min-height: 40px; padding: 5px 8px; border-radius: 8px; }
  .stat-label { font-size: 6.5px; }
  .energy-stat { min-width: 0; }
  .energy-line strong { font-size: 16px; }
  .stat-sub { font-size: 8px; }
  .turn-stat, .sectors-stat { min-width: 0; }
  .turn-stat strong { font-size: 14px; }
  .sectors-line { font-size: 11px; gap: 3px; }
  .top-buttons { gap: 4px; }
  .icon-btn { width: 44px; min-height: 44px; border-radius: 8px; }

  .layout { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
  .board-column { order: 1; --board-w: min(100%, 540px); }
  .rail-right { order: 2; width: 100%; max-width: 540px; margin: 0 auto; gap: 10px; }
  .rail-left { display: none; }
  .board-head { margin-bottom: 6px; }
  .board-frame { padding: 8px 8px 7px; border-radius: 15px; }
  .coord-top { font-size: 6.5px; }
  .coord-left { font-size: 6.5px; }
  .board-hint { font-size: 7.5px; }
  .hover-info { min-height: 34px; margin-top: 6px; font-size: 9.5px; }
  .toast { bottom: 10px; }

  .selected-card { min-height: 78px; }
  .log { max-height: 160px; }
  .actions-panel { padding-bottom: 10px; }
  .build-grid { gap: 6px; }
  .action-btn { min-height: 62px; }
  .primary-btn .key { display: none; }

  .intro-steps { grid-template-columns: 1fr; gap: 6px; }
  .intro-steps article { display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 7px; padding: 9px; }
  .intro-steps span { grid-row: 1 / 3; align-self: center; }
  .intro-steps h3 { margin: 0; }
  .intro-steps p { grid-column: 2; }
  .intro-steps article h3 { grid-column: 2; }
  .intro-actions { flex-direction: column; align-items: stretch; gap: 7px; }
  .intro-actions .primary-btn { width: 100%; min-width: 0; }
  .intro-actions .text-btn { align-self: center; }
  .modal { padding: 22px 18px; border-radius: 16px; }
  .modal h2 { font-size: clamp(30px, 9vw, 42px); }
  .modal-lead { font-size: 11px; }
  .rules-grid { grid-template-columns: 1fr; }
  .end-stats { grid-template-columns: repeat(2, 1fr); }
  .end-modal .modal-actions { flex-direction: column-reverse; }
  .end-modal .modal-actions .primary-btn { flex: 1 1 auto; width: 100%; }
  .end-modal .modal-actions .text-btn { align-self: center; }
}

@media (max-width: 430px) {
  .game-shell { padding: 8px 8px 16px; }
  .topbar { padding: 8px 8px; gap: 6px 8px; }
  .game-kicker { display: none; }
  .game-id h1 { font-size: 19px; }
  .top-stats { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.66fr) minmax(0, 0.9fr) auto; gap: 4px; }
  .stat { min-height: 38px; padding: 4px 6px; }
  .stat-label { font-size: 6px; letter-spacing: 0.09em; }
  .energy-line { gap: 2px; margin-top: 2px; }
  .icon-bolt { width: 11px; height: 11px; }
  .energy-line strong { font-size: 15px; }
  .stat-sub { font-size: 7px; }
  .turn-stat strong { font-size: 13px; }
  .sectors-line { font-size: 10px; }
  .dot { width: 5px; height: 5px; }
  .icon-btn { width: 44px; min-height: 44px; font-size: 13px; }
  .icon-btn svg { width: 15px; height: 15px; }

  .board-frame { padding: 7px 7px 6px; }
  .coord-top { margin-bottom: 4px; }
  .board-row { gap: 4px; }
  .cell-code { top: 3px; left: 4px; font-size: 5.5px; }
  .unit-chip { right: 2px; bottom: 2px; padding: 0 2px; font-size: 7.5px; }
  .cell-icon { width: 40%; }
  .cell[data-type="base"] .cell-icon { width: 50%; }
  .phase-badge { min-height: 22px; padding: 3px 7px; font-size: 7.5px; }
  .board-hint { font-size: 7px; }
  .hover-info { font-size: 9px; }

  .panel-head { padding: 10px 12px 0; }
  .selected-card { margin: 8px 10px 7px; }
  .build-grid { padding: 0 10px; }
  .primary-btn { width: calc(100% - 20px); margin-left: 10px; margin-right: 10px; }
  .action-title { font-size: 10px; }
  .log { margin-left: 10px; margin-right: 10px; }
  .legend-grid { margin-left: 12px; margin-right: 12px; }
}

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