:root {
  --bg-top: #fff4d8;
  --bg-bottom: #f39f86;
  --panel: rgba(95, 45, 35, 0.82);
  --panel-soft: rgba(255, 247, 224, 0.2);
  --text-main: #fff7e8;
  --text-dark: #422116;
  --accent: #ffd447;
  --accent-deep: #ff9f1c;
  --danger: #ff6f61;
  --cell-bg: rgba(255, 252, 245, 0.82);
  --enemy: #622569;
  --unit: #1f7a8c;
  --merge: #f4a261;
  --shot: #ffe56b;
  --shadow: 0 18px 35px rgba(80, 31, 17, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(255, 220, 140, 0.9), transparent 18%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button {
  font: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: grid;
  gap: 18px;
}

.hud-card,
.game-card {
  background: var(--panel);
  border: 1px solid rgba(255, 247, 224, 0.22);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hud-card {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
  opacity: 0.78;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-family: "Baloo 2", cursive;
  line-height: 0.95;
}

h1 {
  font-size: clamp(2rem, 7vw, 3.6rem);
}

h2 {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
}

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

.stat-pill {
  background: var(--panel-soft);
  border-radius: 22px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-pill span {
  font-size: 0.9rem;
  opacity: 0.8;
}

.stat-pill strong {
  font-size: 1.2rem;
}

.game-card {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.combat-note {
  font-size: 0.95rem;
  line-height: 1.4;
  color: rgba(255, 247, 224, 0.88);
  background: rgba(255, 247, 224, 0.08);
  border-radius: 18px;
  padding: 12px 14px;
}

.support-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.support-button {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.button-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.button-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.support-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 212, 71, 0.22);
}

.forecast-panel {
  background: rgba(255, 247, 224, 0.1);
  border-radius: 18px;
  padding: 12px 14px;
}

.forecast-copy {
  color: rgba(255, 247, 224, 0.92);
  line-height: 1.4;
}

.board-header,
.action-row,
.status-panel {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.summon-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active {
  transform: scale(0.97);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--text-dark);
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.secondary-button {
  background: rgba(255, 247, 224, 0.16);
  color: var(--text-main);
}

.summon-alt {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.ghost-button {
  background: transparent;
  color: var(--text-main);
  border: 1px solid rgba(255, 247, 224, 0.25);
}

.lane-labels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  font-size: 0.82rem;
  opacity: 0.78;
}

.board {
  position: relative;
  display: block;
  isolation: isolate;
}

.map-shell {
  position: relative;
  width: 100%;
  min-height: 520px;
  aspect-ratio: 20 / 13;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.18), transparent 16%),
    radial-gradient(circle at 76% 28%, rgba(124, 173, 140, 0.18), transparent 20%),
    radial-gradient(circle at 48% 74%, rgba(205, 181, 125, 0.18), transparent 22%),
    linear-gradient(180deg, rgba(83, 119, 101, 0.2), rgba(182, 165, 126, 0.22)),
    rgba(250, 243, 224, 0.78);
  border: 1px solid rgba(66, 33, 22, 0.12);
  touch-action: none;
  user-select: none;
}

.map-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 22%, rgba(255, 255, 255, 0.12), transparent 12%),
    radial-gradient(circle at 68% 42%, rgba(255, 255, 255, 0.09), transparent 14%),
    radial-gradient(circle at 84% 76%, rgba(91, 62, 43, 0.08), transparent 10%);
  pointer-events: none;
}

.map-svg,
.map-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-svg {
  z-index: 4;
  pointer-events: none;
}

.map-layer {
  z-index: 2;
}

.map-edge {
  fill: none;
  stroke: rgba(123, 101, 77, 0.56);
  stroke-width: 20;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
  filter: drop-shadow(0 2px 4px rgba(91, 62, 43, 0.12));
}

.map-edge.cross {
  stroke: rgba(89, 126, 138, 0.52);
  stroke-width: 14;
  stroke-dasharray: 20 14;
}

.preview-path {
  fill: none;
  stroke: rgba(255, 212, 71, 0.95);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16 12;
  filter: drop-shadow(0 0 8px rgba(255, 212, 71, 0.65));
}

.preview-step {
  fill: rgba(255, 212, 71, 0.92);
  opacity: 0.9;
}

.active-move-path {
  fill: none;
  stroke: rgba(49, 130, 206, 0.95);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 18 10;
  filter: drop-shadow(0 0 8px rgba(49, 130, 206, 0.55));
}

.range-origin {
  fill: rgba(255, 212, 71, 0.2);
  stroke: rgba(255, 212, 71, 0.95);
  stroke-width: 3;
}

.range-link {
  stroke: rgba(255, 212, 71, 0.38);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 10 8;
}

.range-node {
  fill: rgba(255, 212, 71, 0.12);
  stroke: rgba(255, 212, 71, 0.85);
  stroke-width: 3;
}

.shot-line {
  stroke: rgba(255, 246, 168, 0.98);
  stroke-width: 8;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px rgba(255, 229, 107, 0.9));
  animation: shotFade 320ms linear forwards;
}

.shot-hit {
  fill: rgba(255, 244, 186, 0.95);
  filter: drop-shadow(0 0 14px rgba(255, 229, 107, 0.95));
  animation: impactPop 320ms ease-out forwards;
}

.map-node,
.map-unit,
.map-enemy {
  position: absolute;
  transform: translate(-50%, -50%);
}

.map-node {
  width: 66px;
  min-height: 66px;
  padding: 6px 4px 8px;
  border-radius: 18px;
  border: 2px solid rgba(66, 33, 22, 0.22);
  background: rgba(255, 253, 247, 0.88);
  color: var(--text-dark);
  font-weight: 800;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  z-index: 1;
}

.map-node.deployable {
  border-color: rgba(255, 212, 71, 0.95);
  background: linear-gradient(180deg, rgba(255, 248, 214, 0.98), rgba(255, 239, 181, 0.94));
  box-shadow: 0 0 0 5px rgba(255, 212, 71, 0.28);
}

.map-node.entry {
  box-shadow: 0 0 0 4px rgba(181, 101, 118, 0.18);
}

.map-node.open.deployable {
  box-shadow: 0 0 0 6px rgba(255, 212, 71, 0.34), 0 10px 18px rgba(255, 212, 71, 0.18);
}

.map-node.occupied.deployable {
  border-color: rgba(31, 122, 140, 0.6);
  background: linear-gradient(180deg, rgba(228, 242, 246, 0.98), rgba(214, 232, 238, 0.94));
  box-shadow: 0 0 0 5px rgba(31, 122, 140, 0.2);
}

.map-node.selected {
  border-color: var(--accent-deep);
  transform: translate(-50%, -50%) scale(1.06);
}

.map-node.hovered {
  box-shadow: 0 0 0 5px rgba(255, 212, 71, 0.2);
}

.map-node.preview-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 6px rgba(255, 212, 71, 0.28);
}

.map-unit,
.map-enemy {
  border: 0;
  color: white;
  box-shadow: 0 12px 24px rgba(34, 25, 20, 0.22);
  z-index: 3;
}

.map-unit {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  display: block;
  background: linear-gradient(135deg, rgba(31, 122, 140, 0.96), rgba(52, 160, 164, 0.96));
}

.map-enemy {
  min-width: 96px;
  padding: 8px 10px;
  border: 0;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.map-unit.unit-infantry {
  background: linear-gradient(135deg, #548235, #8bc34a);
}

.map-unit.unit-radar {
  background: linear-gradient(135deg, #355070, #7bdff2);
}

.map-enemy {
  background: linear-gradient(135deg, rgba(98, 37, 105, 0.96), rgba(181, 101, 118, 0.96));
}

.map-enemy.enemy-cannon {
  background: linear-gradient(135deg, #6d2e46, #7f5539);
}

.map-unit.selected {
  box-shadow: 0 0 0 4px rgba(255, 212, 71, 0.32), 0 12px 24px rgba(34, 25, 20, 0.22);
}

.map-unit.hit,
.map-enemy.hit {
  box-shadow: 0 0 0 4px rgba(255, 111, 97, 0.3), 0 12px 24px rgba(34, 25, 20, 0.22);
}

.map-unit.firing {
  box-shadow: 0 0 0 4px rgba(255, 229, 107, 0.28), 0 12px 24px rgba(34, 25, 20, 0.22);
}

.map-enemy.blocked {
  transform: translate(-50%, -50%) scale(1.03);
}

.token-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.token-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-unit .token-icon {
  position: absolute;
  inset: 6px;
  width: auto;
  height: auto;
}

.token-level {
  position: absolute;
  right: -4px;
  top: -6px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff8d6;
  color: var(--text-dark);
  font-size: 0.68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 8px rgba(34, 25, 20, 0.18);
}

.token-health {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -8px;
  height: 7px;
  border-radius: 999px;
  background: rgba(66, 33, 22, 0.2);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(34, 25, 20, 0.16);
}

.token-health-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #49c38f, #9be564);
}

.node-number {
  font-size: 1rem;
  line-height: 1;
}

.node-chip {
  font-size: 0.54rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.88;
}

.node-status {
  font-size: 0.58rem;
  opacity: 0.72;
}

.shots-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.shot-beam {
  position: absolute;
  height: 4px;
  border-radius: 999px;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(31, 122, 140, 0.2), var(--shot), rgba(255, 255, 255, 0.95));
  box-shadow: 0 0 12px rgba(255, 229, 107, 0.8);
  animation: shotFade 160ms linear forwards;
}

.shot-impact {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,255,255,0.95) 0%, rgba(255,229,107,0.9) 45%, rgba(255,111,97,0.2) 100%);
  box-shadow: 0 0 16px rgba(255, 229, 107, 0.9);
  animation: impactPop 160ms ease-out forwards;
}

.cell {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 22px;
  background: var(--cell-bg);
  min-height: 138px;
  padding: 10px;
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 50%),
    linear-gradient(135deg, rgba(255, 168, 76, 0.2), transparent 60%);
  pointer-events: none;
}

.cell.empty {
  border-style: dashed;
  border-color: rgba(66, 33, 22, 0.18);
}

.cell.selected {
  border-color: var(--accent-deep);
  transform: translateY(-2px);
}

.cell.merge-target {
  border-color: var(--merge);
  box-shadow: 0 0 0 4px rgba(244, 162, 97, 0.24);
}

.cell.enemy-threat {
  animation: pulse 700ms infinite alternate;
}

.cell.duel {
  background:
    linear-gradient(135deg, rgba(31, 122, 140, 0.22), rgba(98, 37, 105, 0.24)),
    var(--cell-bg);
  border-color: rgba(255, 111, 97, 0.45);
}

.cell.has-forecast {
  border-color: rgba(255, 229, 107, 0.35);
}

.cell.has-air-unit {
  border-style: solid;
}

.cell.air-selected {
  box-shadow: 0 0 0 3px rgba(239, 71, 111, 0.22);
}

.cell.firing {
  box-shadow: 0 0 0 3px rgba(255, 229, 107, 0.35);
}

.cell.hit {
  box-shadow: 0 0 0 3px rgba(255, 111, 97, 0.32);
}

.cell-top,
.cell-bottom {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cell-body {
  position: relative;
  z-index: 1;
  width: 100%;
  display: grid;
  gap: 8px;
}

.unit-badge,
.enemy-badge {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.1);
}

.unit-badge svg,
.enemy-badge svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.unit-badge {
  background: linear-gradient(135deg, #34a0a4, var(--unit));
}

.unit-badge.unit-cannon {
  background: linear-gradient(135deg, #34a0a4, var(--unit));
}

.unit-badge.unit-infantry {
  background: linear-gradient(135deg, #8bc34a, #386641);
}

.unit-badge.unit-radar {
  background: linear-gradient(135deg, #7bdff2, #355070);
}

.enemy-badge {
  background: linear-gradient(135deg, #b56576, var(--enemy));
}

.enemy-badge.enemy-infantry {
  background: linear-gradient(135deg, #c08497, #8c3a71);
}

.enemy-badge.enemy-cannon {
  background: linear-gradient(135deg, #7f5539, #6d2e46);
}

.occupant-card {
  display: grid;
  gap: 4px;
}

.occupant-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.occupant-copy {
  display: grid;
  gap: 2px;
  flex: 1;
}

.cell small {
  font-size: 0.72rem;
  opacity: 0.72;
}

.cell strong {
  font-size: 1rem;
}

.health-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(66, 33, 22, 0.16);
}

.health-fill {
  height: 100%;
  border-radius: inherit;
}

.health-fill.unit {
  background: linear-gradient(90deg, #49c38f, #1f7a8c);
}

.health-fill.enemy {
  background: linear-gradient(90deg, #ff8f70, #622569);
}

.attack-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.attack-line {
  flex: 1;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--unit), var(--danger));
  position: relative;
  overflow: hidden;
}

.attack-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  animation: beam 900ms linear infinite;
}

.cell-path {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 1;
  font-size: 0.68rem;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--text-dark);
}

.forecast-marker {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  display: grid;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 14px;
  background: rgba(53, 80, 112, 0.14);
  border: 1px solid rgba(255, 229, 107, 0.3);
}

.forecast-chip {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dark);
}

.forecast-stack {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dark);
}

.forecast-types {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.forecast-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 999px;
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
}

.forecast-type.enemy-infantry {
  background: linear-gradient(135deg, #c08497, #8c3a71);
}

.forecast-type.enemy-cannon {
  background: linear-gradient(135deg, #7f5539, #6d2e46);
}


.status-panel {
  align-items: flex-start;
  background: rgba(255, 247, 224, 0.11);
  border-radius: 22px;
  padding: 14px 16px;
}

.status-copy {
  max-width: 52ch;
}

.legend {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.offense {
  background: var(--unit);
}

.legend-dot.enemy {
  background: var(--enemy);
}

.legend-dot.merge {
  background: var(--merge);
}

.legend-dot.shot {
  background: var(--shot);
}

@keyframes pulse {
  from {
    box-shadow: 0 0 0 0 rgba(255, 111, 97, 0.12);
  }
  to {
    box-shadow: 0 0 0 6px rgba(255, 111, 97, 0.28);
  }
}

@keyframes beam {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes shotFade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes impactPop {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.55);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.3);
  }
}

@media (max-width: 760px) {
  .board-header,
  .action-row,
  .status-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .summon-buttons {
    justify-content: stretch;
  }

  .support-bar {
    flex-direction: column;
  }

  .lane-labels {
    font-size: 0.7rem;
  }

  .cell {
    min-height: 126px;
    border-radius: 18px;
    padding: 8px;
  }

  .unit-badge,
  .enemy-badge {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    font-size: 1rem;
  }
}
