:root {
  color-scheme: dark;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", system-ui, sans-serif;
  background: #101d32;
  color: #f5ecd6;
  font-synthesis: none;
  --muted: #aebeb3;
  --quiet: #91a49b;
  --stroke: #425e71;
  --paper: #f3dfb0;
  --gold: #ffd066;
  --ink: #202b25;
  --panel: #1c2e45;
  --gap: clamp(12px, 1.5vw, 22px);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 64% -10%, #294962 0, transparent 62%),
    radial-gradient(ellipse at 7% 62%, #213c49 0, transparent 58%),
    repeating-linear-gradient(90deg, #c3c6a904 0 1px, transparent 1px 96px),
    repeating-linear-gradient(0deg, #c3c6a904 0 1px, transparent 1px 96px),
    #111f34;
}

button { font: inherit; touch-action: manipulation; }
button:not(:disabled) { cursor: pointer; }
button:focus-visible {
  outline: 2px solid #ffe5ac;
  outline-offset: 3px;
  z-index: 2;
}
button:disabled { cursor: default; }
h1, h2, p, dl, dd { margin: 0; }
h2 { font-size: 1.05rem; font-weight: 800; }
[hidden] { display: none !important; }

.game-shell {
  width: min(100% - 44px, 1360px);
  margin-inline: auto;
  padding-block: clamp(15px, 2vw, 28px) 28px;
}
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  margin-bottom: clamp(13px, 1.6vw, 22px);
}
.identity { display: flex; align-items: center; gap: 17px; }
.brand-mark {
  position: relative;
  flex: 0 0 59px;
  width: 59px;
  height: 59px;
  display: grid;
  place-content: center;
  gap: 5px;
  border: 1px solid #647061;
  border-radius: 15px;
  background: radial-gradient(ellipse at 75% 5%, #405249, #243b36 77%);
  box-shadow: inset 0 0 0 4px #172f2c85, 0 7px 16px #06161346;
}
.brand-mark span {
  position: relative;
  height: 2px;
  width: 25px;
  border-radius: 4px;
  background: #efcd91;
}
.brand-mark span:first-child { width: 17px; margin-left: 5px; }
.brand-mark span:last-child { width: 16px; margin-left: 4px; background: #e88f70; }
.brand-mark span::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 8px;
  right: -2px;
  bottom: 0;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  color: #efcd91;
}
.brand-mark span:last-child::after { transform: scaleY(-1); bottom: auto; top: 0; color: #e88f70; }
h1 {
  font-size: clamp(1.8rem, 3.2vw, 2.7rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.082em;
  color: #fcf0d4;
}

.hud { display: flex; gap: 8px; }
.gauge {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr);
  align-items: center;
  column-gap: 9px;
  width: clamp(94px, 9.25vw, 136px);
  min-height: 63px;
  padding: 8px 10px;
  background: linear-gradient(150deg, #263c36, #1a302d);
  border: 1px solid #465b51;
  border-radius: 11px;
  font-variant-numeric: tabular-nums;
}
.gauge dt { grid-area: 1 / 2; color: #c4c7b2; font-size: 0.69rem; font-weight: 700; white-space: nowrap; }
.gauge dd { display: contents; }
.gauge dd > span:nth-child(2) { grid-area: 2 / 2; font-size: 1.48rem; line-height: 1.05; font-weight: 820; }
.gauge-life { --stat: #f6a090; --icon-bg: #4c3833; }
.gauge-money { --stat: #f0ca76; --icon-bg: #474431; }
.gauge-wave { --stat: #a2d7bd; --icon-bg: #304940; }
.gauge-icon {
  grid-area: 1 / 1 / 3;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--icon-bg);
  color: var(--stat);
}
.gauge-total { grid-area: 2 / 2; justify-self: end; align-self: end; color: #aeb8a5; font-size: 0.7rem; margin-bottom: 1px; white-space: nowrap; }

.icon-heart {
  position: relative;
  height: 9px;
  width: 9px;
  margin-top: 3px;
  background: currentColor;
  transform: rotate(-45deg);
  border-radius: 1px;
}
.icon-heart::before, .icon-heart::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}
.icon-heart::before { top: -4px; left: 0; }
.icon-heart::after { top: 0; left: 4px; }
.icon-coin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: radial-gradient(ellipse, currentColor 0 28%, transparent 31% 53%, currentColor 58% 69%, transparent 71%);
}
.icon-flag { width: 14px; height: 15px; border-left: 2px solid; position: relative; }
.icon-flag::before {
  content: "";
  position: absolute;
  inset: 1px 0 auto;
  height: 9px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 80% 53%, 100% 100%, 0 100%);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(274px, 302px);
  align-items: start;
  gap: var(--gap);
}
.board-panel, .side-panel {
  min-width: 0;
  background: linear-gradient(154deg, #213936, var(--panel) 57%, #1a2e2c);
  border: 1px solid var(--stroke);
  box-shadow: 0 12px 30px #06171653, inset 0 1px #e8d4a610;
  border-radius: 17px;
}
.board-panel { padding: 13px; }
.board-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 11px;
  min-height: 45px;
}
.board-heading h2 { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.map-symbol {
  display: block;
  width: 18px;
  height: 18px;
  border: 1px solid #9bc2a8;
  border-radius: 50%;
  position: relative;
  transform: rotate(30deg);
}
.map-symbol::after {
  content: "";
  position: absolute;
  inset: 2px 5px;
  background: #9bc2a8;
  clip-path: polygon(50% 0, 100% 53%, 50% 100%, 0 53%);
}
.wind-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #f7e3b2;
  border-radius: 8px;
  padding: 5px 10px 5px 6px;
  background: #ecdbab;
  color: #465346;
  font-size: 0.71rem;
  font-weight: 700;
  white-space: nowrap;
}
.wind-chip strong { color: #23382d; font-size: 0.78rem; }
.wind-needle {
  display: grid;
  place-items: center;
  background: #cdd0a7;
  color: #344b3b;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font: 700 0.98rem/1 system-ui, sans-serif;
  transform: rotate(27deg);
}
[data-route="south"] .wind-needle { transform: rotate(153deg); background: #e2c390; }

.map-frame {
  width: 100%;
  position: relative;
  isolation: isolate;
  aspect-ratio: 1000 / 555;
  border-radius: 10px;
  overflow: hidden;
  background: #295254;
  box-shadow: 0 0 0 1px #89957970, 0 5px 12px #071c1960;
}
#map-canvas, .pads { position: absolute; inset: 0; width: 100%; height: 100%; }
#map-canvas { display: block; touch-action: manipulation; }
.map-frame[data-building="true"] #map-canvas { cursor: crosshair; }

.board-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.pop-counter { display: inline-flex; gap: 4px; align-items: center; padding: 6px 8px; border: 1px solid #d2ecf84a; border-radius: 8px; color: #c5eaf3; white-space: nowrap; font-size: .75rem; }
.pop-counter > span { color: #ffd16e; }
.pop-counter strong { color: #fff1be; font-variant-numeric: tabular-nums; }
.pop-chain {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 50%;
  translate: -50% 0;
  pointer-events: none;
  padding: 6px 13px;
  border: 2px solid #fff1bc;
  border-radius: 20px;
  background: #f5983f;
  color: #253242;
  box-shadow: 0 3px 0 #a44c39, 0 5px 14px #22334b60;
  font-size: clamp(.73rem, 1.5vw, 1.03rem);
  font-weight: 900;
  white-space: nowrap;
}
.wave-strip { display: flex; align-items: center; gap: 10px; margin-top: 10px; min-height: 16px; color: #c9dae6; font-size: .73rem; font-variant-numeric: tabular-nums; }
.wave-strip progress { flex: 1; width: 0; height: 6px; border: 0; border-radius: 20px; appearance: none; overflow: hidden; background: #111e31; }
.wave-strip progress::-webkit-progress-bar { background: #111e31; }
.wave-strip progress::-webkit-progress-value { background: linear-gradient(90deg, #41d6ad, #c7f98a 85%, #ffdf75); border-radius: 20px; }
.wave-strip progress::-moz-progress-bar { background: #77e6b4; }
.sound-control[aria-pressed="false"] { color: #a5b9c6; }
.pads { pointer-events: none; }
.pad {
  --disc: clamp(18px, 2.65vw, 32px);
  width: max(var(--disc), 42px);
  height: max(var(--disc), 42px);
  position: absolute;
  translate: -50% -50%;
  border: 0;
  background: transparent;
  color: #f6e5ba;
  padding: 0;
  border-radius: 50%;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.pad::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  width: var(--disc);
  height: var(--disc);
  border: 1px dashed #fff2bb9c;
  border-radius: 50%;
  background: #1a395da6;
  box-shadow: 0 0 0 2px #203d3151;
  transition: background-color 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.pad-plus {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: 12px;
  height: 12px;
}
.pad-plus::before, .pad-plus::after { content: ""; position: absolute; inset: 5px 0; border-radius: 1px; background: currentColor; }
.pad-plus::after { transform: rotate(90deg); }
.pad:is(:hover, :focus-visible)::before { border-style: solid; border-color: #ffe0a0; }
.pad[data-mode="open"] { opacity: 0.62; }
.pad:not([data-mode="built"]) { pointer-events: none; }
.pad:not([data-mode="built"]):not(:focus-visible) { opacity: 0; }
.pad[data-mode="open"]:is(:hover, :focus-visible) { opacity: 1; }
.pad[data-mode="valid"]::before {
  background: #574729ee;
  border: 1px solid #ffdd93;
  box-shadow: 0 0 0 3px #fbd28657, 0 0 16px #f8cf7880;
}
.pad[data-mode="valid"]:is(:hover, :focus-visible)::before { background: #e7bd72; box-shadow: 0 0 0 4px #fff0c487; }
.pad[data-mode="valid"]:is(:hover, :focus-visible) .pad-plus { color: #1f2920; }
.pad[data-mode="short"]::before { border-color: #e0a592; background: #543c35df; }
.pad[data-mode="point"]::before { border-style: solid; box-shadow: 0 0 0 3px #eac78391; }
.pad[data-mode="built"] .pad-plus { display: none; }
.pad[data-mode="built"]::before {
  border: 0;
  background: transparent;
  box-shadow: none;
}
.pad[data-mode="built"][aria-pressed="true"]::before,
.pad[data-mode="built"]:hover::before {
  border: 1px solid #fae4ac;
  box-shadow: 0 0 0 3px #ffe9aa39;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding-top: 13px;
}
.control {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 43px;
  border-radius: 8px;
  padding: 6px 11px;
  border: 1px solid #52665b;
  background: #293e37;
  color: #f1e8cf;
  font-size: 0.77rem;
  font-weight: 800;
  white-space: nowrap;
  transition: background-color 140ms, border-color 140ms;
}
.control:not(:disabled):hover { background: #3b5145; border-color: #a1b396; }
.control:disabled { color: #a9b3a4; border-color: #3b5149; background: #233833; }
.control.primary {
  background: linear-gradient(160deg, #f6d590, #e9b963);
  border-color: #ffe0a1;
  color: #283126;
  box-shadow: inset 0 1px #fff2c792;
  padding-inline: 13px;
}
.control.primary:not(:disabled):hover { background: #ffe1a6; border-color: #fff4d1; }
.control.primary:disabled { background: #35443a; border-color: #576354; color: #cad0b7; box-shadow: none; }
.control[aria-disabled="true"] { border-color: #856e59; }
.control[aria-pressed="true"] { color: #ffe0a1; border-color: #bd9b63; background: #514831; }
.icon-play { width: 10px; height: 11px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.icon-pause { width: 9px; height: 10px; border-inline: 2px solid currentColor; }
[data-paused="true"] .icon-pause { width: 10px; height: 11px; border: 0; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.speed-control { min-width: 45px; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.gust-control:not(:disabled) { color: #bdf1d1; border-color: #709c86; }
.gust-control[data-blowing="true"] { background: #244f42; }
.icon-gust {
  width: 14px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(7% 40%, 38% 12%, 100% 12%, 100% 27%, 45% 27%, 33% 40%, 84% 40%, 84% 55%, 8% 55%, 0 49%, 7% 40%, 36% 72%, 100% 72%, 100% 87%, 36% 87%);
}
.control-count { font-size: 0.68rem; padding: 2px 4px; background: #102c2680; border-radius: 4px; font-variant-numeric: tabular-nums; }
.restart-control { margin-inline-start: auto; background: transparent; }
.icon-restart { line-height: 0; font-style: normal; font-size: 1.15rem; }

.board-status {
  min-height: 39px;
  display: flex;
  align-items: start;
  gap: 9px;
  padding: 11px 2px 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}
.board-status p { align-self: center; overflow-wrap: anywhere; }
.board-status p[data-tone="warning"] { color: #ffb7a1; }
.board-status p[data-tone="good"] { color: #e8d9ad; }
.phase {
  flex: none;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #c8dec1;
  font-weight: 750;
  padding-right: 9px;
  border-right: 1px solid #587065;
}
.phase i { width: 7px; height: 7px; border-radius: 50%; background: #a1d4ab; box-shadow: 0 0 7px #a1d4ab37; }
.phase[data-phase="active"] { color: #f0d598; }
.phase[data-phase="active"] i { background: #efc16d; }
.phase[data-phase="lost"] { color: #ffc0a8; }
.phase[data-phase="lost"] i { background: #ff9c82; }

.sidebar { display: grid; gap: 13px; min-width: 0; }
.side-panel { padding: 16px; }
.shop-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.shop h2 { font-size: 1.16rem; }
.tower-count { color: #e9d9a7; font-size: 0.75rem; font-weight: 750; white-space: nowrap; }
.instruction { margin-top: 6px; color: var(--muted); font-size: 0.77rem; line-height: 1.55; }
.shop-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.shop-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 64px;
  min-width: 0;
  width: 100%;
  text-align: start;
  padding: 5px;
  color: #f7ecd2;
  border: 1px solid #486056;
  border-radius: 9px;
  background: linear-gradient(145deg, #2c453e, #263a34);
  transition: background-color 140ms, border-color 140ms;
}
.shop-card:not(:disabled):hover, .shop-card[aria-pressed="true"] {
  border-color: var(--tower-hue);
  background: linear-gradient(145deg, #3b5145, #2f4137);
}
.shop-card[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--tower-hue); }
.shop-card:disabled { opacity: 0.66; }
.tower-tile {
  display: block;
  aspect-ratio: 1;
  width: 100%;
  max-width: 41px;
  border: 1px solid #9d9f7559;
  border-radius: 7px;
  background: radial-gradient(ellipse at 50% 35%, #3f5141, #1a2e29 84%);
  background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--tower-hue) 27%, #253830), #1a2e29 84%);
  box-shadow: inset 0 0 0 2px #13292260;
}
.tower-tile canvas { display: block; width: 100%; height: 100%; }
.tower-copy { display: grid; min-width: 0; gap: 4px; }
.tower-card-title { font-size: 0.83rem; line-height: 1.2; word-break: keep-all; overflow-wrap: anywhere; }
.tower-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 5px; }
.tower-role { color: #c3d4c7; font-size: 0.66rem; line-height: 1.2; word-break: keep-all; }
.price {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  border-radius: 4px;
  color: #f6d697;
  background: #192d27;
  border: 1px solid #aa966258;
  font-size: 0.68rem;
  line-height: 1.05;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.price .icon-coin { width: 9px; height: 9px; }
.shop-card.is-short .price { color: #ffb7a1; border-color: #ba8a7275; }

.field-panel { background: linear-gradient(145deg, #293e35, #213630 70%); }
.field-heading {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}
.field-heading > span {
  border: 1px solid #67765e;
  background: #26392e;
  color: #e9d9a7;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 0.68rem;
  font-weight: 750;
  white-space: nowrap;
}
.roster { display: grid; gap: 8px; padding: 0; margin: 0; }
.roster li {
  list-style-type: none;
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: #dddfc8;
  font-size: 0.78rem;
  border-radius: 6px;
  background: #162b265e;
}
.roster strong { color: #f4e7c7; font-variant-numeric: tabular-nums; }
.roster .roster-empty { display: block; color: var(--muted); }
.roster-bird { width: 15px; height: 13px; clip-path: polygon(0 18%, 44% 32%, 64% 2%, 74% 39%, 100% 48%, 75% 65%, 65% 99%, 42% 72%, 0 80%, 22% 49%); }
.roster-bird.drift { background: radial-gradient(at 35% 29%, #ffce9f, #ee8777 63%, #ac5153); color: #ee8777; }
.roster-bird.dart { background: radial-gradient(at 35% 29%, #e2ffd1, #84dbae 63%, #4b917c); color: #84dbae; }
.roster-bird.armor { background: radial-gradient(at 35% 29%, #edd9fa, #bba9ed 63%, #7669a4); color: #bba9ed; border-radius: 30%; }
.tower-location { color: var(--muted); font-size: 0.75rem; line-height: 1.5; margin: -5px 0 9px; word-break: keep-all; }
.tower-stats { border-block: 1px solid #4c675749; padding-block: 6px; }
.tower-stats div { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; padding: 3px 0; font-size: 0.75rem; }
.tower-stats dt { color: #b9c7b7; }
.tower-stats dd { color: #f4e6c4; font-weight: 750; font-variant-numeric: tabular-nums; }
.tower-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; margin-top: 10px; }
.tower-actions .control { padding-inline: 6px; }

.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  position: absolute;
  z-index: 3;
  inset: 0;
  padding: 8px;
  background: #0c2323c7;
}
.result-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: max-content;
  max-width: 100%;
  text-align: center;
  padding: clamp(10px, 2vw, 23px) clamp(12px, 3vw, 30px);
  border: 1px solid #e0c489;
  border-radius: 13px;
  background: radial-gradient(ellipse at 50% -20%, #526354, #243b34 74%);
  box-shadow: 0 10px 35px #071613a8, inset 0 0 0 4px #182f2b85;
}
.result-mark {
  width: 22px;
  height: 22px;
  background: #f0cf89;
  clip-path: polygon(50% 0, 61% 32%, 100% 50%, 61% 68%, 50% 100%, 39% 68%, 0 50%, 39% 32%);
}
.result-mark[data-outcome="lost"] { background: #efa68b; }
.result h2 { font-size: clamp(1.25rem, 3.2vw, 1.75rem); line-height: 1.15; }
.result p { color: #d2ddc9; font-size: 0.78rem; white-space: pre-line; overflow-wrap: anywhere; }
.result .control { min-height: 40px; margin-top: 2px; }
.no-script { margin: 10px; color: #ffc0a8; }

@media (max-width: 1080px) {
  .game-shell { width: calc(100% - 42px); }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(246px, 27%); }
  .side-panel { padding: 13px; }
}

@media (min-width: 660px) and (max-width: 880px) {
  .game-shell { width: calc(100% - 26px); padding-top: 11px; }
  .masthead { gap: 10px; margin-bottom: 10px; }
  .identity { gap: 9px; }
  .identity h1 { font-size: clamp(1.48rem, 4vw, 2.1rem); }
  .brand-mark { flex-basis: 42px; width: 42px; height: 42px; }
  .hud { gap: 5px; }
  .gauge { width: 90px; min-height: 48px; grid-template-columns: 25px minmax(0, 1fr); column-gap: 5px; padding: 6px; }
  .gauge-icon { width: 24px; height: 25px; border-radius: 6px; }
  .gauge dt { font-size: .62rem; }
  .gauge dd > span:nth-child(2) { font-size: 1.2rem; }
  .gauge-total { font-size: .59rem; }
  .workspace { grid-template-columns: minmax(0, 1fr) clamp(158px, 25vw, 190px); gap: 10px; }
  .board-panel, .side-panel { padding: 9px; }
  .board-heading { min-height: 33px; padding-bottom: 6px; }
  .board-heading h2 { font-size: .84rem; }
  .board-meta { gap: 4px; }
  .wind-chip, .pop-counter { font-size: .66rem; }
  .controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding-top: 7px; }
  .controls .control { min-height: 37px; padding-inline: 5px; }
  .controls .restart-control { margin-inline-start: 0; }
  .shop .instruction { display: none; }
  .shop-list { gap: 5px; margin-top: 9px; }
  .pad { --disc: clamp(18px, 3vw, 28px); }
}

@media (max-width: 659px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .shop-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-shell { width: calc(100% - 30px); }
  .gauge { width: 104px; }
  .pad { --disc: clamp(17px, 3.25vw, 28px); }
  .shop h2 { font-size: 1.09rem; }
  .shop-list { margin-top: 9px; }
  .board-panel, .side-panel { padding: 9px; }
  .board-heading { min-height: 35px; padding-bottom: 6px; }
  .shop .instruction { display: none; }
}

@media (max-width: 585px) {
  .masthead { display: grid; gap: 12px; margin-bottom: 13px; }
  .identity { gap: 11px; }
  .brand-mark { flex-basis: 46px; width: 46px; height: 46px; border-radius: 11px; }
  .hud { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .gauge { width: auto; min-height: 52px; padding: 6px; grid-template-columns: 25px minmax(0, 1fr); column-gap: 6px; }
  .gauge-icon { width: 24px; height: 26px; border-radius: 6px; }
  .gauge dt { font-size: 0.64rem; }
  .gauge dd > span:nth-child(2) { font-size: 1.21rem; }
  .gauge-total { font-size: 0.62rem; }
  .game-shell { width: calc(100% - 20px); padding-top: 10px; }
  .board-panel { padding: 8px; border-radius: 12px; }
  .board-heading { min-height: 35px; padding-bottom: 6px; }
  .board-meta { gap: 4px; }
  .pop-counter { padding: 4px 5px; font-size: .68rem; }
  .board-heading h2 { font-size: 0.93rem; gap: 6px; }
  .map-symbol { width: 16px; height: 16px; }
  .map-frame { border-radius: 7px; }
  .wind-chip { gap: 5px; padding: 3px 6px 3px 4px; }
  .wind-needle { width: 18px; height: 18px; }
  .pad { --disc: clamp(18px, 5.2vw, 30px); width: clamp(36px, 9vw, 43px); height: clamp(36px, 9vw, 43px); }
  .pad-plus { width: 9px; height: 9px; }
  .pad-plus::before, .pad-plus::after { inset: 4px 0; }
  .controls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; padding-top: 9px; }
  .controls .control { min-height: 41px; padding-inline: 5px; }
  .controls .primary, .controls #pause { grid-column: span 2; }
  .controls .speed-control { grid-column: span 2; min-width: 0; }
  .controls .gust-control, .controls .sound-control, .controls .restart-control { grid-column: span 2; }
  .controls .restart-control { margin-inline-start: 0; }
  .board-status { padding-top: 8px; min-height: 35px; font-size: 0.71rem; }
  .sidebar { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .wave-strip { margin-top: 5px; }
  .side-panel { border-radius: 12px; }
  .result-card { gap: 5px; }
  .result-mark { width: 16px; height: 16px; }
}

@media (min-width: 660px) and (max-width: 880px), (max-width: 585px) {
  .shop-card { grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: center; gap: 4px; padding: 5px 3px; text-align: center; }
  .tower-tile { width: 33px; }
  .tower-copy { gap: 3px; }
  .tower-card-title { font-size: 0.74rem; }
  .tower-card-meta { justify-content: center; gap: 3px 4px; }
  .tower-role { font-size: 0.63rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}


.shop-card.mortar { --tower-hue: #9bdbed; --tile-shade: #2f485a; }
.shop-card.mortar [data-unlock] { display: block; }
.wind-chip[data-route="both"] .wind-needle { font-size: 0; }
.wind-chip[data-route="both"] .wind-needle::before { content: "↕"; font-size: .8rem; }
.roster .roster-clue { grid-column: 2 / -1; color: #c7d8ca; font-size: .72rem; line-height: 1.35; margin-top: -4px; }
.roster strong { font-size: .76rem; }
.roster-bird.twin { background: #ffaf59; color: #ffaf59; border-radius: 58% 58% 36% 36%; box-shadow: inset 2px 0 #ffe2aa, inset -2px 0 #964739; }
.roster-bird.foil { background: linear-gradient(135deg, #eaffff, #9bc9dd 45%, #526a99 58%, #d8f6ff); clip-path: polygon(50% 0, 100% 32%, 94% 70%, 50% 100%, 6% 70%, 0 32%); }
.roster-bird.mist { background: #b6eabf; border: 1px dashed #376564; color: #b6eabf; }
.roster-bird.carrier { width: 15px; height: 10px; background: linear-gradient(#fff1a8, #e7a783 65%, #774575 66%); color: #e7a783; border-radius: 45% 45% 30% 30%; }
@media (max-width: 480px) {
  .shop-card { min-width: 0; }
  .phase { white-space: normal; }
}


.wave-strip progress { min-width: 0; }
.score-total { flex: none; white-space: nowrap; }
.score-total strong { color: #fff1be; }

.mission-setup {
  --mission-line: #58777a;
  --mission-gold: #f3cd88;
  color: #fbefdb;
  width: min(900px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid #9b906e;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(ellipse at 100% 0%, #264b4d, transparent 62%), #10252d;
  box-shadow: 0 24px 84px #050d15c7, inset 0 0 0 4px #0c1e27;
}
.mission-setup::backdrop { background: #07131be0; backdrop-filter: blur(4px); }
.mission-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100dvh - 28px);
  min-width: 0;
}
body:has(.mission-setup[open]) { overflow: hidden; }
.mission-header {
  padding: 24px clamp(14px, 4vw, 32px) 18px;
  border-bottom: 1px solid #76918761;
  background: repeating-radial-gradient(ellipse at 92% -85%, transparent 0 17px, #b4d6c314 18px 19px, transparent 20px 33px);
}
#mission-heading { font-size: clamp(1.35rem, 3.6vw, 2rem); font-weight: 850; letter-spacing: -.04em; }
.mission-fields { display: grid; gap: 18px; overflow-y: auto; overscroll-behavior: contain; padding: 16px clamp(14px, 4vw, 32px) 22px; }
.mission-fields fieldset { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
.mission-fields legend { padding: 0 0 8px; color: var(--mission-gold); font-size: .9rem; font-weight: 780; }
.mission-map-grid, .mission-mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mission-map-option, .mission-mode-option {
  position: relative;
  min-width: 0;
  border: 1px solid var(--mission-line);
  border-radius: 10px;
  background: #172f38;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.mission-map-option { display: flex; flex-direction: column; padding: 5px 5px 11px; }
.mission-mode-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: start; gap: 5px 7px; padding: 10px; }
.mission-map-option input, .mission-mode-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--mission-gold); cursor: pointer; }
.mission-map-option input { position: absolute; top: 11px; left: 11px; box-shadow: 0 0 0 4px #10252dd9; border-radius: 50%; }
.mission-mode-option input { position: absolute; top: 12px; left: 10px; }
.mission-map-option:hover, .mission-mode-option:hover { border-color: #a8c8c3; }
.mission-map-option:has(input:checked), .mission-mode-option:has(input:checked) {
  border-color: var(--mission-gold);
  background-color: #263f42;
  box-shadow: inset 0 0 0 1px var(--mission-gold);
}
.mission-map-option:has(input:focus-visible), .mission-mode-option:has(input:focus-visible) { outline: 2px solid #ffefd0; outline-offset: 3px; z-index: 1; }
.mission-map-art { display: block; width: 100%; height: auto; aspect-ratio: 500 / 278; border-radius: 6px; background: #123542; }
.mission-map-name { margin: 8px 7px 3px; color: var(--map-accent, #f3e4bd); font-size: 1rem; font-weight: 820; }
.mission-map-description { margin-inline: 7px; }
.mission-mode-name { padding-inline-start: 23px; font-weight: 820; }
.mission-mode-rounds { align-self: center; color: var(--mission-gold); font-size: .78rem; font-variant-numeric: tabular-nums; }
.mission-mode-description { grid-column: 1 / -1; }
.mission-map-description, .mission-mode-description { color: #c9dcd7; font-size: .8rem; line-height: 1.5; word-break: keep-all; }
.mission-footer {
  display: flex;
  gap: 10px 20px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px clamp(14px, 4vw, 32px);
  border-top: 1px solid #52716e;
  background: #10252d;
}
#mission-selection { min-width: 0; color: #efe3c6; font-size: .85rem; font-weight: 700; overflow-wrap: anywhere; }
.mission-actions { display: flex; gap: 8px; margin-inline-start: auto; }
.mission-actions button, .mission-trigger {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #7a9894;
  border-radius: 7px;
  background: #193842;
  color: #f8eedb;
  font: inherit;
  font-weight: 760;
}
.mission-actions button:hover:not(:disabled), .mission-trigger:hover:not(:disabled) { border-color: #fff2cc; }
#mission-start { background: linear-gradient(135deg, #f5dfa7, #e4b879); border-color: #f8d992; color: #242b25; }
#mission-start:disabled { opacity: .55; }
.board-mode {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid #829890;
  border-radius: 5px;
  color: #ffe1aa;
  background: #173640;
  font-size: .8rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .mission-map-grid, .mission-mode-grid { grid-template-columns: minmax(0, 1fr); }
  .mission-map-option { display: grid; grid-template-columns: minmax(0, 44fr) minmax(0, 56fr); align-content: center; column-gap: 8px; padding: 5px; }
  .mission-map-art { grid-row: 1 / 3; align-self: center; }
  .mission-map-name { margin: 2px 3px 2px 0; align-self: end; }
  .mission-map-description { margin: 0 3px 2px 0; }
  .mission-header { padding-block: 17px 13px; }
}

.mission-trigger { min-height: 34px; padding: 4px 10px; font-size: .82rem; margin-top: 3px; }
@media (max-width: 430px) { .board-heading { flex-wrap: wrap; row-gap: 5px; } }
