@font-face {
  font-family: Outfit;
  src: url('./fonts/outfit.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: Cinzel;
  src: url('./fonts/cinzel.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b171f;
  --ink: #f0ece1;
  --muted: #9fb3b4;
  --subtle: #c3ceca;
  --line: #729b9d36;
  --soft-line: #729b9d25;
  --gold: #ffce86;
  --pink: #f7a5a6;
  --mint: #9ed5c6;
  --surface: #142630;
  --surface-raised: #203841;
  --board-width: min(785px, calc((100dvh - 141px) * 1.0909));
  --command-width: clamp(280px, 30vw, 352px);
  --battle-gap: 15px;
  font-family: Outfit, system-ui, sans-serif;
  font-weight: 400;
  font-synthesis: none;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { overscroll-behavior: none; }
body, button { font-family: Outfit, system-ui, sans-serif; }
button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button:disabled { cursor: default; }
button:focus-visible, canvas:focus-visible {
  outline: 2px solid #ffdc9b;
  outline-offset: 3px;
  position: relative;
  z-index: 1;
}
button:active:not(:disabled) { transform: translateY(1px); }
h1, h2, h3, p { margin: 0; }
strong, b { font-weight: 650; }
.icon { width: 1.17em; height: 1.17em; display: inline-block; flex: 0 0 auto; vertical-align: middle; }
[data-icon] { line-height: 1; }
.view { min-height: 100vh; min-height: 100dvh; }
.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 0 15px;
  background: #1b323b;
  font-weight: 600;
  color: #ecece0;
  transition: background-color 140ms, border-color 140ms, color 140ms;
}
.button:not(:disabled):hover, .icon-button:not(:disabled):hover {
  background-color: #28444b;
  border-color: #91b4ad82;
}
.icon-button { padding: 0; width: 44px; flex: 0 0 auto; font-size: 19px; }
.glass { background-color: #152a34b8; border-color: #a4bbc459; }
.glass:not(:disabled):hover { background-color: #24424bdf; }
.primary {
  background: linear-gradient(180deg, #ffdb9c, #e9aa63);
  border-color: #ffe4abba;
  color: #2a1b18;
  box-shadow: inset 0 1px 0 #fff0c7b5, 0 4px 15px #e4a46218;
  font-weight: 750;
}
.primary:not(:disabled):hover {
  background: linear-gradient(180deg, #ffe8b7, #f8bc74);
  border-color: #fff3cc;
}
.muted-button { background: #16272f; color: var(--subtle); }
.back { background: #132732; }
.back .icon { color: var(--gold); }
.close-button { background: #223840; }

.cover {
  display: grid;
  place-items: center start;
  isolation: isolate;
  position: relative;
  overflow: hidden;
  padding: 86px clamp(36px, 9.5vw, 166px) 57px;
  background: #0a1922;
}
.cover::before, .cover::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
}
.cover::before {
  background: url('./art/lantern-coast.webp') 56% 49% / cover no-repeat;
}
.cover::after {
  z-index: -1;
  background: linear-gradient(90deg, #07141bf7 0%, #091820e6 18%, #0c202a9c 37%, #09182024 59%, #091a2455 100%),
    linear-gradient(0deg,#081820f5,transparent 30%,transparent 86%,#08182054);
}
.sitebar {
  position: absolute;
  inset: max(19px, env(safe-area-inset-top)) max(25px, env(safe-area-inset-right)) auto max(25px, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--gold);
  border: 1px solid #ffda9d60;
  background: #11242bae;
  border-radius: 50%;
  font-size: 24px;
}
.icon-actions { display: flex; gap: 9px; }
.cover-main { width: min(480px, 100%); position: relative; }
.game-title {
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(64px, 9.3vw, 154px);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 0.79;
  margin-left: -0.04em;
  color: #fff1d2;
  text-shadow: 0 3px 4px #04131b, 0 11px 40px #09151b;
}
.game-title span, .game-title em { display: block; white-space: nowrap; }
.game-title em {
  color: var(--gold);
  font-style: normal;
  margin-top: 0.115em;
}
.cover-line {
  color: #d3ded7;
  font-size: clamp(17px, 1.65vw, 23px);
  margin: clamp(18px, 3.2vh, 30px) 0;
  font-weight: 500;
  line-height: 1.35;
}
.home-actions { display: grid; width: min(360px,100%); gap: 8px; }
.sail {
  justify-content: space-between;
  text-align: left;
  min-height: clamp(57px, 8vh, 73px);
  gap: 10px;
  padding: 8px 18px;
  font-size: 20px;
}
.sail span { min-width: 0; }
.sail small { display: block; color: #61462b; margin-top: 2px; font-size: 13px; font-weight: 600; }
.sail .icon { font-size: 24px; }
.home-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.home-modes .icon, #homeEndless .icon { color: var(--gold); }
#homeEndless { min-height: 44px; }

.atlas {
  background: linear-gradient(180deg, #0d1d24e0 0%, #0d1a23 560px),
    url('./art/lantern-coast.webp') center 18% / 100% auto no-repeat, #0c1a21;
  padding: 20px 24px 52px;
}
.atlas-shell { max-width: 1060px; margin: auto; }
.atlas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
}
.small-brand {
  display: flex;
  gap: 9px;
  align-items: center;
  color: #f1e4c9;
  font: 650 clamp(14px, 2.2vw, 23px) Cinzel, Georgia, serif;
  white-space: nowrap;
}
.small-brand span { color: var(--gold); }
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); }
.tab {
  min-height: 44px;
  padding: 0 15px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  color: #a8bbbc;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-weight: 600;
}
.tab:hover { color: #ffebb9; }
.tab[aria-current="page"], .tab[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.atlas-tabs { margin-bottom: clamp(20px, 4vw, 39px); }
.atlas-intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 19px; }
.atlas-intro h1 {
  font: 650 clamp(27px, 5vw, 53px)/1.01 Cinzel, Georgia, serif;
  color: #fbedd1;
  letter-spacing: -0.04em;
}
.atlas-intro p { margin-top: 8px; color: var(--subtle); font-size: clamp(14px, 2.1vw, 17px); line-height: 1.33; }
.atlas-progress { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--gold); font-weight: 650; }
.atlas-progress .icon { fill: #ffcf8a38; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px,1fr)); gap: 12px; }
.stage-card {
  --stage: var(--mint);
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
  background: #152832;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #8aafaf46;
  overflow: hidden;
}
.stage-card:not(:disabled):hover { border-color: var(--stage); background: #1f3842; }
.stage-card:disabled { opacity: 0.68; }
.stage-map { position: relative; width: 100%; min-width: 0; background: #0c1e28; }
.stage-map img { display: block; width: 100%; height: auto; aspect-ratio: 1.74; object-fit: cover; object-position: center; }
.stage-lock {
  position: absolute;
  z-index: 1;
  top: 10px; right: 10px;
  border: 1px solid #7d99986c;
  background: #0a1620e5;
  border-radius: 6px;
  padding: 5px;
  color: #d7dad0;
}
.stage-copy { padding: 12px 14px; flex: 1; min-width: 0; width: 100%; }
.stage-copy small { color: var(--stage); font-weight: 700; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.stage-copy h2 { font-size: 24px; font-weight: 650; margin-top: 1px; line-height: 1.16; }
.stage-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; color: var(--subtle); margin-top: 7px; font-size: 13px; }
.stars { display: inline-flex; gap: 3px; color: #78868a; align-items: center; }
.stars .lit { color: var(--gold); fill: #ffce867d; }
.stage-arrow { color: var(--stage); }
.active-pill { color: var(--gold); font-weight: 650; }
.daily-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(250px, 0.85fr); gap: 12px; align-items: start; }
.daily-card, .daily-tracker, .lock-card {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background-color: #152832;
}
.daily-card { grid-template-columns: minmax(125px,0.78fr) minmax(0,1.22fr); }
.daily-card .stage-map img { height: 100%; min-height: 200px; object-fit: cover; aspect-ratio: 1.05; }
.daily-info { padding: 17px; }
.daily-info .overline { color: var(--mint); }
.daily-info h2 { font-size: clamp(24px, 4vw, 35px); margin: 1px 0 10px; font-weight: 650; }
.weather-card { border: 1px solid #83a89f39; color: #b7cacc; background: #0e2028; border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.weather-card p { margin-top: 4px; line-height: 1.32; }
.weather-card b { color: #e2e4cf; }
.daily-info .primary { margin-top: 13px; width: 100%; }
.daily-tracker { padding: 16px; }
.daily-tracker h2 { font-size: 23px; }
.daily-tracker > p { font-size: 14px; color: var(--subtle); margin-top: 3px; }
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 15px 0 12px; max-width: 385px; }
.day-dot {
  display: grid; place-items: center;
  border-radius: 7px; min-height: 41px; gap: 3px; font-size: 11px; padding: 3px;
  background: #10232c; border: 1px solid #708c9440; color: var(--subtle);
}
.day-dot.today { border-color: #e4c08699; color: var(--gold); }
.day-dot.done { background: #1c3e3b; color: #a1e2c6; }
.day-dot .icon { font-size: 15px; }
.small-metric { display: flex; gap: 9px; align-items: center; color: var(--gold); font-size: 14px; margin: 3px 0; }
.lock-card { max-width: 490px; padding: 24px; gap: 10px; color: var(--subtle); }
.lock-card .icon { color: var(--gold); font-size: 29px; }
.lock-card .button { margin-top: 4px; justify-self: start; }

.battle {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 18px 10px;
  background:
    radial-gradient(ellipse at 33% 7%, #26464a 0%, #152d36 29%, transparent 64%),
    radial-gradient(ellipse at 95% 85%, #1c3440 0%, transparent 38%),
    #0c1b24;
}
.battle-inner {
  width: min(100%, calc(var(--board-width) + var(--command-width) + var(--battle-gap)));
  min-width: 0;
}
.battle-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  margin-bottom: 11px;
}
.menu-button, .sound-battle { border-color: #9fb5ab57; background: #152b33; color: #e1e9dd; }
.site-heading { min-width: 0; flex: 1; }
.site-heading span, .overline {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--mint);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.site-heading h1 {
  color: #f6e8cd;
  font: 700 clamp(24px, 3.2vw, 40px)/1.07 Cinzel, Georgia, serif;
  letter-spacing: -0.045em;
}
.hud {
  display: flex;
  align-items: stretch;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}
.counter {
  display: flex;
  min-width: 77px;
  min-height: 45px;
  gap: 7px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid #9aaca43a;
  background: #101f28a8;
  padding: 5px 9px;
}
.counter .icon { font-size: 19px; }
.counter-name { display: block; text-transform: uppercase; letter-spacing: 0.08em; color: #afc0bb; font-weight: 600; font-size: 9px; }
.counter strong { font-size: 17px; line-height: 1.08; font-weight: 700; }
.counter.light { color: var(--pink); }
.counter.ember { color: var(--gold); }
.counter.waves { color: #a9dfd6; }
.counter.low { border-color: #de879e85; background: #452a36b0; }
.battle-grid { display: grid; grid-template-columns: minmax(0,1fr) var(--command-width); gap: var(--battle-gap); align-items: stretch; }
.playfield { min-width: 0; }
.board-frame {
  position: relative;
  aspect-ratio: 12 / 11;
  border-radius: 11px;
  border: 1px solid #aeb8a678;
  background: #183240;
  box-shadow: 0 12px 45px #040d1460, 0 0 0 3px #101e27a8;
}
.board-frame::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid #d6cbad32;
  border-radius: 9px;
  pointer-events: none;
}
#board { display: block; width: 100%; height: 100%; border-radius: 10px; touch-action: none; cursor: crosshair; }
.battle-hint {
  color: #bdcbc6;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 35px;
  padding: 5px 3px 2px;
  line-height: 1.15;
  font-size: 14px;
}
.hint-mark { color: #b5cdba; font-size: 13px; flex: 0 0 auto; }
.battle-hint.important, .battle-hint.important .hint-mark { color: #ffe0aa; }
.board-banner {
  pointer-events: none;
  position: absolute;
  z-index: 2;
  top: 7%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  max-width: 84%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffe9ba;
  padding: 9px 16px;
  border-radius: 6px;
  background: #15252bea;
  border: 1px solid #dfbc7d79;
  text-align: center;
  font-weight: 650;
  box-shadow: 0 3px 15px #08161a72;
  animation: banner-in 260ms ease both;
}
.board-banner .icon { margin-right: 5px; vertical-align: -0.2em; }
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -5px); } to { opacity: 1; transform: translate(-50%, 0); } }
.boss-hud {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  min-width: 115px;
  width: 30%;
  right: 9px;
  top: 8px;
  background: #191c2bd9;
  border: 1px solid #dfab8c73;
  border-radius: 5px;
  padding: 3px 6px 5px;
  color: #ffe0b0;
  text-align: center;
  font-size: 12px;
  line-height: 1.1;
}
.boss-track { height: 4px; border-radius: 2px; margin-top: 4px; overflow: hidden; background: #574052; }
.boss-track i { display: block; height: 100%; width: 100%; transform-origin: left center; background: #ffb270; }
.command {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid #9cb8b249;
  border-radius: 12px;
  padding: 13px;
  margin-bottom: 35px;
  background: linear-gradient(150deg,#1d353f 0%, #152a34 37%,#10232d 100%);
  box-shadow: 0 12px 45px #040d1440;
}
.brief-row { display: flex; gap: 5px; min-width: 0; }
.forecast {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 61px;
  padding: 7px 8px 7px 10px;
  border-radius: 8px;
  border: 1px solid #9bb5ab43;
  background: #122831;
  text-align: left;
  gap: 3px;
}
.forecast:hover { border-color: #b3c9b380; background: #1a3540; }
.forecast .forecast-text { flex: 1; min-width: 0; }
.forecast .overline { font-size: 9px; color: #bdd9cc; letter-spacing: 0.11em; }
.forecast strong { display: block; margin-top: 2px; font-size: 15px; color: #f1eddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forecast-units { display: flex; align-items: center; }
.forecast-units img { display: block; width: 29px; height: 29px; object-fit: contain; }
.forecast-units b { font-size: 11px; font-weight: 600; color: #b6c8c0; }
.forecast .chevron { color: #9eb4ab; font-size: 13px; }
.salvage-tray { min-height: 43px; width: 43px; color: var(--gold); font-size: 16px; background: #23353a; flex-direction: column; gap: 1px; }
.salvage-tray b { font-size: 12px; line-height: 1; }
.selection { min-width: 0; }
.selection-title {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  color: #d7e2d9; font-size: 13px; font-weight: 650; margin: 1px 1px 7px;
}
.selection-title .icon { color: #d8c194; }
.arsenal {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.tower-card {
  --unit: var(--gold);
  min-width: 0;
  min-height: 77px;
  position: relative;
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr);
  gap: 1px;
  align-items: center;
  padding: 5px 7px 5px 3px;
  text-align: left;
  border: 1px solid #91adae43;
  border-radius: 8px;
  background: linear-gradient(150deg, #29414a99, #1a303a);
  overflow: hidden;
}
.tower-card:hover, .tower-card.chosen { border-color: var(--unit); background: #314751; }
.tower-card.suggested { border-color: #e9bd7aab; }
.tower-card.chosen { box-shadow: inset 0 0 22px #ffc7852f; }
.tower-card img { width: 43px; height: 49px; object-fit: contain; display: block; }
.tower-info { display: block; min-width: 0; }
.tower-card strong { display: block; font-size: 16px; line-height: 1.02; color: #f1ebdb; }
.tower-role { display: block; color: #bdd0ca; font-size: 11px; line-height: 1.08; margin-top: 3px; }
.price {
  color: var(--gold);
  vertical-align: middle;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.price .icon { font-size: 0.9em; margin-right: 2px; margin-bottom: 1px; }
.tower-card .price { display: block; margin-top: 5px; }
.tower-card.poor .price, .needs-gold .price { color: #d89c97; }
.tower-card.poor img { opacity: 0.66; }
.field-note {
  margin: 17px 0 4px;
  line-height: 1.43;
  color: #acbfbc;
  padding: 11px 10px;
  border-top: 1px solid #88a6a539;
  font-size: 14px;
}
.field-note .icon { color: #bcd6c7; margin-right: 4px; font-size: 13px; }
.inspect { --unit: var(--gold); }
.inspect-head { display: flex; min-width: 0; align-items: center; gap: 7px; margin-bottom: 7px; }
.inspect-head img { width: 48px; height: 48px; object-fit: contain; flex: 0 0 auto; }
.inspect-title { flex: 1; min-width: 0; }
.inspect-title h2 { font-size: 23px; line-height: 1.03; }
.inspect-title small { color: var(--unit); font-size: 13px; }
.inspect-head .icon-button { width: 42px; min-height: 42px; }
.inspect-note { font-size: 14px; color: var(--subtle); margin: 7px 0 10px; line-height: 1.33; }
.tower-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-bottom: 11px; }
.tower-stats div { border: 1px solid var(--soft-line); border-radius: 6px; padding: 5px 3px; text-align: center; background: #10242d8a; }
.tower-stats dt { color: #afc7c0; font-size: 11px; white-space: nowrap; }
.tower-stats dd { color: #eae8d9; font-weight: 650; margin: 0; font-size: 16px; }
.manage { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; min-width: 0; }
.manage button, .maxed { min-height: 42px; padding: 3px 6px; text-align: center; font-size: 13px; gap: 4px; }
.manage button .icon { font-size: 14px; }
.manage .upgrade, .maxed { grid-column: 1 / -1; }
.manage .upgrade { background: #4a3d32; border-color: #f3cb8b7e; color: #ffe6af; }
.manage .upgrade:hover { background: #634c35; border-color: #ffe1a3; }
.manage .upgrade:disabled { background: #2e3031; border-color: #947a6250; color: #b6a79b; }
.manage .upgrade .price { margin-left: 4px; }
.maxed { display: flex; justify-content: center; align-items: center; border: 1px solid var(--soft-line); border-radius: 7px; font-weight: 600; color: var(--unit); }
.wave-tape { display: none; margin-top: 2px; padding: 10px 0 0; border-top: 1px solid var(--line); }
.tape-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; color: #e6e9db; margin-bottom: 6px; font-size: 13px; }
.tape-head span, .tape-foot { color: #adbfbb; font-size: 12px; }
.tape-grid { display: grid; grid-template-columns: repeat(var(--slots), minmax(0, 1fr)); gap: 4px; }
.wave-tile {
  display: inline-flex; gap: 2px; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; min-height: 34px; padding: 2px 0;
  border: 1px solid #8eacad4a; border-radius: 6px; background: #102630;
  color: #bbcfc8; font-size: 13px; font-weight: 650;
}
.wave-tile .icon { width: .84em; height: .84em; color: #a9c5bd; }
.wave-tile.has-boss { color: #ffc595; }
.wave-tile.has-boss .icon { color: #ffba90; }
.wave-tile.held { color: #b4e5cf; background: #21423f; border-color: #9dc9b254; }
.wave-tile.current { color: #ffd894; background: #3a3832; border-color: #eec583b2; }
.wave-tile:hover { border-color: #eccc93; background: #3a4d53; }
.tape-foot { margin-top: 7px; }
.tape-foot .icon { color: var(--gold); }
.command-foot { margin-top: auto; display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.flare-button, .speed-button {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  min-height: 49px;
  color: #c8d6ca;
  font-size: 13px;
  border: 1px solid #9caca467;
  border-radius: 8px;
  background: #182d37;
  font-weight: 650;
  overflow: hidden;
}
.flare-button { min-width: 67px; padding: 2px 7px; text-align: left; }
.flare-button .icon { font-size: 17px; }
.flare-button .flare-label { display: inline-flex; flex-direction: column; line-height: 1.02; z-index: 1; }
.flare-label b { font-variant-numeric: tabular-nums; color: #f4d296; padding-top: 3px; font-size: 11px; }
.flare-button i {
  position: absolute;
  bottom: 0; left: 0; width: 100%; height: 3px;
  background: #edb67a;
  transform-origin: left;
  box-shadow: 0 0 7px #edb67a87;
  pointer-events: none;
}
.flare-button:hover, .speed-button:hover { border-color: #e5e9d8; background: #263d45; }
.flare-button.charged { color: #ffdf9a; border-color: #ffc571; background: #46382c; }
.flare-button.aiming { background: #825034; }
.speed-button { min-width: 44px; font-size: 16px; }
.speed-button.fast { color: var(--gold); border-color: #e4b78592; }
.wave-button { flex: 1; padding: 0 8px; min-width: 0; min-height: 50px; font-size: 15px; white-space: nowrap; gap: 5px; }
.wave-button .icon { font-size: 15px; }
.wave-button:disabled { color: #b8c5c0; background: #20323a; border-color: #94a8a156; box-shadow: none; }
.wave-button[aria-disabled="true"] { color: #e4d7b6; background: #39372f; border-color: #d4b88e76; box-shadow: none; }

.dialog {
  padding: 0;
  background: #172a34;
  color: var(--ink);
  width: min(510px, calc(100vw - 30px));
  max-width: none;
  max-height: calc(100dvh - 26px);
  border: 1px solid #b1c2ae65;
  border-radius: 14px;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 18px 65px #030e16b2;
}
.dialog::backdrop { background: #06121bc9; }
.dialog[open] { animation: dialogue-in 150ms ease-out both; }
@keyframes dialogue-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.modal { padding: clamp(14px, 4vw, 24px); background: radial-gradient(ellipse at 8% top,#293f48 0%,#172a34 62%); }
.modal-heading { display: flex; justify-content: space-between; gap: 6px; align-items: flex-start; margin-bottom: 12px; }
.modal-heading .icon-button { width: 42px; min-height: 42px; margin-top: -1px; }
.modal-heading h2 {
  font: 700 clamp(23px, 5vw, 32px)/1.06 Cinzel, Georgia, serif;
  letter-spacing: -0.04em;
  color: #fff0d3;
  margin-top: 2px;
}
.modal-heading .overline { margin-bottom: 4px; color: #b8d5c9; }
.modal-intro { font-size: 15px; color: var(--subtle); line-height: 1.42; margin-bottom: 13px; }
.modal-actions { display: grid; gap: 7px; margin-top: 12px; }
.modal-actions .button { padding: 7px 10px; }
.modal-row { display: flex; gap: 7px; align-items: stretch; }
.modal-row > * { flex: 1; }
.modal-small { color: #aebfbc; margin-top: 8px; font-size: 13px; line-height: 1.37; }
.choice-list { display: grid; gap: 7px; }
.choice {
  --choice: var(--gold);
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 7px 9px;
  min-height: 61px;
  border-radius: 8px;
  border: 1px solid #9db5b05a;
  background: #203640;
}
button.choice:hover { border-color: var(--choice); background: #304951; }
.choice-glyph {
  width: 39px; height: 39px; flex: 0 0 auto; display: grid; place-items: center;
  border: 1px solid #9baea484; border-radius: 7px; color: var(--choice); background: #132530;
  font-size: 20px;
}
.choice img { width: 41px; height: 41px; object-fit: contain; flex: 0 0 auto; }
.choice div { flex: 1; min-width: 0; }
.choice strong { display: block; color: #f3eddf; font-size: 16px; font-weight: 650; }
.choice p { margin-top: 2px; color: var(--subtle); font-size: 14px; line-height: 1.25; }
.choice > .icon { color: var(--choice); font-size: 15px; }
.choice small { color: #b8cdc2; display: block; font-size: 12px; margin-top: 3px; }
.result-stars { font-size: 30px; gap: 7px; margin-bottom: 8px; }
.result-stat {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 12px;
}
.result-stat div { min-width: 0; text-align: center; padding: 7px 3px; background: #10242e; border: 1px solid var(--line); border-radius: 7px; }
.result-stat b { display: block; font-size: clamp(18px,4.7vw,25px); font-weight: 700; color: var(--gold); }
.result-stat span { display: block; font-size: 12px; color: #b3c6c0; }
.record-line { color: #b9deb9; margin-top: 10px; font-size: 14px; }
.guide-tabs { margin-bottom: 10px; }
.guide-tabs .tab { flex: 1; padding: 0 5px; text-align: center; }
.guide-list { padding: 0 0 0 20px; color: #d5dccf; margin: 6px 0 13px; line-height: 1.4; font-size: 15px; }
.guide-list li { padding: 4px 0; }
.guide-list b { color: #fff0c7; }
.control-note { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.control-note p { color: #b8c7c3; line-height: 1.36; font-size: 14px; margin-top: 4px; }
.noscript { padding: 20px; color: var(--gold); }

@media (max-width: 690px) and (orientation: portrait), (max-width: 555px) {
  .cover { padding: 70px max(17px, calc((100vw - 409px) / 2)) max(23px, env(safe-area-inset-bottom)); align-items: end; }
  .cover::before { background-size: auto 74%; background-position: 76% top; }
  .cover::after {
    background: linear-gradient(0deg, #0b1c24 0%, #0b1c24 25%, #0b1c24e8 43%, #0b1c244b 67%, transparent 86%, #07131b4f);
  }
  .sitebar { left: max(15px, env(safe-area-inset-left)); right: max(15px, env(safe-area-inset-right)); top: max(13px, env(safe-area-inset-top)); }
  .game-title { font-size: clamp(55px, 14.2vw, 94px); }
  .cover-line { margin: 17px 0; font-size: 18px; }
  .home-actions { width: 100%; }
  .cover-main { max-width: 410px; }
  .atlas { padding: 12px 13px 28px; background-size: auto, auto 610px; }
  .atlas-header { padding-bottom: 11px; }
  .atlas-header .back { padding: 0 8px; }
  .atlas-tabs .tab { padding: 0 8px; flex: 1; gap: 4px; font-size: 13px; }
  .atlas-intro { gap: 6px; margin-bottom: 11px; }
  .atlas-intro h1 { font-size: clamp(26px, 7.9vw, 35px); }
  .stage-grid { grid-template-columns: 1fr; gap: 6px; }
  .stage-card { flex-direction: row; align-items: stretch; }
  .stage-card .stage-map { width: 107px; flex: 0 0 107px; }
  .stage-card .stage-map img { height: 100%; min-height: 70px; aspect-ratio: 1.2; object-fit: contain; }
  .stage-lock { top: 4px; right: 4px; font-size: 12px; }
  .stage-copy { padding: 8px 10px; }
  .stage-copy small { font-size: 9px; }
  .stage-copy h2 { font-size: 19px; }
  .stage-meta { margin-top: 3px; }
  .daily-layout { grid-template-columns: 1fr; }
  .daily-card { grid-template-columns: minmax(97px, 0.68fr) minmax(0, 1.32fr); }
  .daily-card .stage-map img { object-fit: contain; }
  .daily-info { padding: 10px; }
  .daily-tracker { padding: 11px; }

  .battle { padding: max(2px, env(safe-area-inset-top)) 7px max(7px, env(safe-area-inset-bottom)); align-items: flex-start; }
  .battle-inner { width: min(100%, 520px); }
  .battle-header { gap: 5px; min-height: 50px; margin-bottom: 4px; }
  .battle-header .icon-button { width: 42px; min-height: 44px; font-size: 17px; }
  .site-heading span { font-size: 9px; letter-spacing: 0.045em; }
  .site-heading h1 { font-size: clamp(14px, 4.2vw, 24px); }
  .hud { gap: 3px; }
  .counter { padding: 3px 5px; min-width: 35px; min-height: 35px; gap: 2px; }
  .counter .icon { font-size: 13px; }
  .counter strong { font-size: 13px; }
  .counter-name { display: none; }
  .battle-grid { display: flex; flex-direction: column; gap: 0; }
  .board-frame { width: min(100%, calc((100dvh - 285px) * 1.0909)); margin: 0 auto; }
  .battle-hint { font-size: 12px; min-height: 31px; padding: 3px 1px; }
  .board-banner { font-size: 13px; padding: 7px 10px; }
  .boss-hud { font-size: 11px; }
  .command {
    margin: 0; padding: 6px;
    gap: 5px; border-radius: 9px; background: #142932;
  }
  .forecast { min-height: 43px; padding: 3px 7px; gap: 3px; }
  .forecast .overline { font-size: 9px; }
  .forecast strong { font-size: 13px; margin: 0; }
  .forecast-units img { width: 25px; height: 25px; }
  .salvage-tray { min-height: 42px; flex-direction: row; gap: 2px; }
  .selection-title { display: none; }
  .arsenal { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .tower-card {
    display: flex; flex-direction: column; text-align: center; justify-content: center;
    gap: 0; padding: 1px 2px 4px; min-height: 65px; border-radius: 7px;
  }
  .tower-card img { width: 32px; height: 34px; margin-bottom: -2px; }
  .tower-card .tower-info { display: flex; align-items: center; flex-direction: column; }
  .tower-card strong { font-size: 13px; }
  .tower-role { display: none; }
  .tower-card .price { margin-top: 2px; font-size: 11px; }
  .field-note, .inspect-note, .tower-stats { display: none; }
  .inspect-head { gap: 4px; margin-bottom: 3px; }
  .inspect-head img { width: 34px; height: 35px; }
  .inspect-title h2 { font-size: 17px; display: inline; }
  .inspect-title small { margin-left: 4px; font-size: 11px; }
  .inspect-head .icon-button { width: 34px; min-height: 35px; font-size: 16px; }
  .manage { grid-template-columns: minmax(0, 1.16fr) minmax(0, 0.91fr) minmax(0, 0.93fr); gap: 4px; }
  .manage .upgrade, .maxed { grid-column: auto; }
  .manage button, .maxed { min-height: 43px; font-size: 12px; padding: 2px 3px; gap: 2px; }
  .manage button .icon { font-size: 12px; }
  .manage .upgrade .price { margin-left: 0; font-size: 11px; }
  .flare-button, .speed-button, .wave-button { min-height: 45px; }
  .wave-button { font-size: 15px; }
}

@media (orientation: landscape) and (max-height: 522px) {
  :root { --board-width: calc((100dvh - 80px) * 1.0909); --command-width: min(42vw, 295px); --battle-gap: 8px; }
  .cover { padding: 49px 7vw 15px; }
  .cover::before { background-size: cover; background-position: 58% 45%; }
  .cover::after { background: linear-gradient(90deg,#0b1923f5,#0b1923d1 36%,#0b192302 75%), linear-gradient(0deg,#0b192367,transparent 25%); }
  .sitebar { inset: 7px 15px auto 15px; }
  .sitebar .brand-mark, .sitebar .icon-button { width: 38px; min-height: 38px; height: 38px; }
  .game-title { font-size: clamp(48px, 16dvh, 82px); }
  .cover-line { font-size: 15px; margin: 11px 0; }
  .cover-line br { display: none; }
  .home-actions { width: min(324px,44vw); gap: 4px; }
  .home-actions .button { min-height: 37px; }
  .home-actions .sail { min-height: 46px; }
  .home-actions .home-modes .button { padding: 1px 4px; font-size: 13px; }
  .atlas { padding: 8px 13px 20px; }
  .atlas-header { padding-bottom: 6px; }
  .atlas-tabs { margin-bottom: 10px; }
  .atlas-intro { margin-bottom: 10px; }
  .stage-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
  .stage-map img { aspect-ratio: 2; }
  .stage-copy { padding: 7px 8px; }
  .stage-copy h2 { font-size: 17px; }
  .battle { padding: 5px 10px 4px; }
  .battle-header { margin-bottom: 4px; min-height: 40px; gap: 7px; }
  .battle-header .icon-button { min-height: 39px; width: 42px; }
  .site-heading h1 { font-size: 23px; }
  .site-heading span { font-size: 8px; }
  .counter { min-width: 42px; min-height: 33px; padding: 3px 6px; gap: 4px; }
  .counter .icon { font-size: 14px; }
  .counter strong { font-size: 14px; }
  .counter-name { display: none; }
  .battle-inner { width: min(100%, calc(var(--board-width) + var(--command-width) + var(--battle-gap))); }
  .battle-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--command-width); gap: var(--battle-gap); }
  .board-frame { width: 100%; }
  .battle-hint { min-height: 25px; font-size: 11px; padding: 3px 0; }
  .command { margin-bottom: 25px; padding: 7px; gap: 6px; border-radius: 8px; }
  .forecast { min-height: 38px; padding: 3px 6px; }
  .forecast .overline { font-size: 8px; }
  .forecast strong { font-size: 13px; margin: 0; }
  .forecast-units img { width: 24px; height: 24px; }
  .salvage-tray { width: 38px; min-height: 39px; }
  .selection-title { margin-bottom: 4px; font-size: 11px; }
  .arsenal { gap: 4px; }
  .tower-card { min-height: 43px; grid-template-columns: 34px minmax(0,1fr); padding: 2px; }
  .tower-card img { width: 34px; height: 36px; }
  .tower-card strong { font-size: 13px; }
  .tower-card .price { margin-top: 1px; font-size: 11px; }
  .tower-role, .field-note, .inspect-note { display: none; }
  .inspect-head img { width: 37px; height: 37px; }
  .inspect-title h2 { font-size: 20px; }
  .inspect-title small { font-size: 11px; }
  .inspect-head .icon-button { min-height: 37px; width: 37px; }
  .tower-stats { margin-bottom: 6px; }
  .tower-stats div { padding: 2px 1px; }
  .tower-stats dt { font-size: 10px; }
  .tower-stats dd { font-size: 13px; }
  .manage button, .maxed { min-height: 34px; }
  .command-foot { gap: 4px; }
  .flare-button, .speed-button, .wave-button { min-height: 42px; }
  .flare-button { min-width: 60px; padding: 2px 4px; }
  .speed-button { min-width: 37px; }
  .wave-button { font-size: 13px; }
  .modal { padding: 13px 17px; }
}

@media (min-width: 691px) and (min-height: 720px) {
  .wave-tape { display: block; }
}

@media (max-width: 690px) and (orientation: portrait) and (min-height: 735px) {
  .battle-inner { min-height: calc(100dvh - 13px); display: flex; flex-direction: column; }
  .battle-header { margin-top: 4px; margin-bottom: 6px; }
  .battle-grid { flex: 1; }
  .battle-hint { min-height: 38px; font-size: 13px; }
  .command { flex: 1; padding: 8px; gap: 8px; }
  .forecast { min-height: 48px; }
  .tower-card { min-height: 72px; }
  .tower-card img { width: 35px; height: 36px; }
  .tower-stats { display: grid; margin: 4px 0 6px; }
  .wave-tape { display: block; padding-top: 7px; }
  .wave-tile { min-height: 38px; }
  .command-foot { padding-top: 2px; }
  .flare-button, .speed-button, .wave-button { min-height: 52px; }
}

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}
