:root {
  color-scheme: dark;
  --page: #101919;
  --panel: #142222;
  --ink: #e7eee5;
  --muted: #879c96;
  --line: #33463f;
  --accent: #e5b777;
  --mint: #a0d9b8;
  --danger: #eb8d7c;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 43%, #33453866, transparent 54%), linear-gradient(135deg, #25352a33, transparent 50%), repeating-linear-gradient(0deg, #ffffff02 0 1px, transparent 1px 4px);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
button:disabled { cursor: default; opacity: .4; }
button svg, [data-icon] svg { display: block; width: 100%; height: 100%; }
[data-icon] { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
[hidden] { display: none !important; }
.app { max-width: 1360px; padding: 0 48px; margin: auto; }
.masthead { height: 90px; display: flex; align-items: center; gap: 22px; border-bottom: 1px solid #a3b39714; }
.brand { display: flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 700; letter-spacing: 3px; }
.brand > [data-icon] { width: 33px; height: 33px; color: var(--accent); }
.brand small { display: block; font: 8px "Consolas", monospace; letter-spacing: 2.2px; color: var(--muted); margin-top: 6px; }
.connection { margin-left: auto; font-size: 11px; color: var(--muted); letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.connection span { color: var(--mint); }
.connection i, .frame-caption i, .combat-state i, .telemetry-status i { width: 5px; height: 5px; background: var(--mint); border-radius: 50%; display: inline-block; box-shadow: 0 0 7px #a0d9b855; }
.icon-button { display: grid; place-items: center; background: transparent; border: 1px solid #96af962b; color: var(--muted); border-radius: 6px; width: 34px; height: 34px; transition: color .2s, border-color .2s; }
.icon-button:hover { color: var(--accent); border-color: var(--accent); }
.stage { display: flex; justify-content: center; align-items: center; gap: clamp(30px, 4.1vw, 60px); padding: 25px 0 20px; min-height: calc(100svh - 142px); }
.briefing, .telemetry { flex: 1; max-width: 218px; align-self: center; }
.eyebrow { font: 9px "Consolas", monospace; letter-spacing: 2px; color: var(--muted); }
.briefing h2 { font-size: 29px; font-weight: 500; letter-spacing: 2px; line-height: 1.7; margin: 22px 0 13px; }
.briefing > p { color: var(--muted); font-size: 12px; line-height: 2.1; }
.sector-map { margin: 27px 0 25px; color: #8fa68c55; }
.sector-map svg { width: 100%; fill: none; stroke: currentColor; stroke-width: .75; }
.sector-map text { stroke: none; fill: #80917f; font: 7px "Consolas", monospace; }
.sector-map .map-terrain { stroke: #71816a44; }
.sector-map .map-core { stroke: var(--accent); fill: #e5b77712; }
.briefing-rule { width: 32px; height: 1px; background: var(--accent); margin-bottom: 27px; }
.protocol { padding: 0; list-style: none; margin: 20px 0; }
.protocol li { display: flex; gap: 16px; margin: 22px 0; font-size: 12px; }
.protocol li > span { font: 10px "Consolas", monospace; color: var(--accent); padding-top: 2px; }
.protocol small { display: block; color: var(--muted); font-size: 10px; margin-top: 8px; }
.briefing-footer { color: #9daa92; font-size: 10px; margin-top: 37px; letter-spacing: 2px; }
.tiny-cross { color: var(--accent); font: 17px "Consolas", monospace; margin-right: 8px; }
.game-shell { flex: 0 0 auto; width: min(480px, calc((100svh - 164px) * 2 / 3)); }
.frame-caption { display: flex; justify-content: space-between; font: 8px "Consolas", monospace; letter-spacing: 1.8px; color: #8e9c8f; height: 23px; }
.frame-caption span:first-child { display: flex; align-items: center; gap: 8px; }
.arena { position: relative; width: 100%; aspect-ratio: 2 / 3; container-type: inline-size; isolation: isolate; overflow: hidden; border: 1px solid #81917a66; border-radius: 8px; background: #283a31; box-shadow: 0 25px 80px #0007, 0 0 0 5px #23302b55; }
.arena::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 9; box-shadow: inset 0 0 60px #08141055; border-radius: 7px; }
canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: manipulation; }
.frame-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; font-size: 9px; color: #89958b; }
.frame-footer > span:first-child { display: flex; align-items: center; gap: 6px; }
.frame-footer [data-icon] { width: 12px; height: 12px; color: var(--accent); }
.frame-footer i, .page-footer i { font-style: normal; padding: 0 5px; color: #48594e; }
.telemetry h2 { margin: 17px 0 12px; font-size: 19px; font-weight: 500; letter-spacing: 1px; }
.telemetry-status { display: flex; align-items: center; gap: 7px; color: var(--mint); font-size: 10px; }
.telemetry-status.offline { color: var(--danger); }
.telemetry-status.offline i { background: var(--danger); box-shadow: 0 0 7px #eb8d7c55; }
.stat-list { margin: 30px 0 38px; }
.stat-list > div { display: flex; align-items: center; gap: 11px; font-size: 11px; color: var(--muted); padding: 13px 0; border-bottom: 1px solid #a3b39717; }
.stat-list [data-icon] { width: 17px; height: 17px; color: #b6c1a9; }
.stat-list strong { margin-left: auto; font: 16px "Consolas", monospace; color: var(--ink); }
.stat-list strong small { font-size: 9px; color: var(--muted); }
.loadout-heading { display: flex; justify-content: space-between; align-items: center; }
.loadout-heading > span:last-child { font: 11px "Consolas", monospace; color: var(--accent); }
.loadout { min-height: 70px; max-height: 104px; overflow-y: auto; display: flex; gap: 8px; flex-wrap: wrap; align-content: flex-start; padding: 18px 0; scrollbar-width: thin; }
.empty-loadout { font-size: 11px; color: #aeb9a5; line-height: 1.8; }
.empty-loadout small { color: #7f9182; font-size: 10px; }
.module-chip { width: 35px; height: 35px; border: 1px solid var(--rarity); border-radius: 6px; color: var(--rarity); display: grid; place-items: center; position: relative; background: #ffffff04; }
.module-chip svg { width: 21px; height: 21px; }
.module-chip b { position: absolute; right: -3px; top: -5px; font: 9px "Consolas", monospace; color: var(--ink); background: var(--page); padding: 1px 3px; }
.enemy-legend { margin-top: 28px; }
.enemy-legend .eyebrow { margin-bottom: 17px; }
.enemy-legend > div:not(:first-child) { display: flex; align-items: center; gap: 9px; color: #aab6a5; font-size: 10px; padding: 6px 0; }
.enemy-legend > div > span { margin-left: auto; color: #718477; font-size: 9px; }
.enemy-dot { display: block; width: 6px; height: 6px; background: #cf8472; border-radius: 50%; }
.enemy-dot.fast { background: #ddb75e; clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.enemy-dot.tank { background: #ada68b; border-radius: 1px; }
.enemy-dot.boss { background: #e67965; border-radius: 0; transform: rotate(45deg); }
.telemetry-note { color: #758879; font-size: 10px; line-height: 1.9; margin-top: 28px; }
.page-footer { display: flex; justify-content: space-between; align-items: center; height: 52px; border-top: 1px solid #a3b39714; font-size: 10px; color: #6f8476; letter-spacing: 1px; }
.overlay { position: absolute; inset: 0; z-index: 5; }
.title-screen { background: linear-gradient(180deg, #0d1c1bba 0%, #0d1c1b66 29%, transparent 53%, #0d1c1b33 61%, #0d1c1bed 100%); }
.title-copy { position: absolute; top: 10%; left: 9%; right: 8%; }
.title-copy .eyebrow { font-size: 1.9cqw; letter-spacing: .35cqw; color: #b7c2a7; display: flex; align-items: center; }
.title-copy h1 { font-size: 11.5cqw; line-height: 1.3; font-weight: 800; letter-spacing: .8cqw; margin: 4cqw 0 3cqw; text-shadow: 0 3px 14px #0002; }
.title-copy h1 em { font-style: normal; color: var(--accent); }
.title-copy p { font-size: 2.55cqw; line-height: 1.7; color: #c0cbb5; margin: 0; }
.title-tower-label { position: absolute; top: 69%; width: 100%; display: flex; align-items: center; justify-content: center; gap: 3cqw; color: #bbd0ba; font: 2.1cqw "Consolas", "Microsoft YaHei", monospace; letter-spacing: .25cqw; }
.title-tower-label span { width: 6cqw; height: 1px; background: #bbd0ba55; }
.title-actions { position: absolute; bottom: 8%; left: 9%; right: 9%; }
.feature-tags { display: flex; align-items: center; justify-content: center; gap: 3cqw; margin-bottom: 4cqw; color: #b9c6b2; font-size: 2.3cqw; letter-spacing: .2cqw; }
.feature-tags i { width: 2px; height: 2px; border-radius: 50%; background: var(--accent); }
.primary-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 2.3cqw; width: 100%; height: 12cqw; background: var(--accent); color: #26322b; border: 1px solid #ffdab0; border-radius: 3px; box-shadow: 0 4px 0 #725b3a, 0 8px 23px #0b151444; font-size: 3.1cqw; font-weight: 700; letter-spacing: .6cqw; transition: background .18s, transform .18s, box-shadow .18s; }
.primary-button [data-icon] { width: 3.5cqw; height: 3.5cqw; }
.primary-button:hover { background: #f4cc90; transform: translateY(-2px); box-shadow: 0 6px 0 #725b3a, 0 8px 23px #0b151444; }
.primary-button:active { transform: translateY(3px); box-shadow: 0 1px 0 #725b3a; }
.button-arrow { position: absolute; right: 4cqw; font-size: 4cqw; font-weight: 400; }
.key-hint { text-align: center; color: #8c9f91; font-size: 2.2cqw; margin: 3.5cqw 0 0; letter-spacing: .1cqw; }
kbd { display: inline-block; font: .9em "Consolas", monospace; color: #b4c3af; border: 1px solid #9fb19744; border-radius: 3px; padding: .12em .38em; margin: 0 .15em; }
.title-bottom { position: absolute; bottom: 3%; left: 6%; right: 6%; display: flex; justify-content: space-between; font-size: 1.8cqw; color: #839789; letter-spacing: .12cqw; }
.hud { position: absolute; z-index: 2; top: 0; left: 0; right: 0; background: linear-gradient(#101f20f5 80%, #101f2000); padding: 4cqw 5cqw 6cqw; pointer-events: none; }
.hud-top { display: flex; align-items: center; gap: 3cqw; }
.wave-heading .eyebrow { font-size: 1.9cqw; letter-spacing: .3cqw; display: block; margin-bottom: .6cqw; }
.wave-heading strong { font: bold 5.8cqw "Consolas", monospace; color: var(--accent); }
.wave-heading small { font: 2.1cqw "Microsoft YaHei", sans-serif; color: #98ae9e; }
.combat-state { margin-left: auto; display: flex; align-items: center; gap: 1.2cqw; font-size: 2.1cqw; color: var(--mint); }
.hud .icon-button { pointer-events: auto; width: 7cqw; height: 7cqw; }
.hud .icon-button [data-icon] { width: 3cqw; height: 3cqw; }
.health-row { display: flex; align-items: center; gap: 1.2cqw; margin-top: 3.5cqw; font-size: 2.1cqw; color: #aec4b0; }
.health-row [data-icon] { width: 2.5cqw; height: 2.5cqw; }
.health-row strong { margin-left: auto; font: 2.3cqw "Consolas", monospace; color: #d2dec5; }
.health-track { height: 1.4cqw; background: #091716; border-radius: 2px; margin-top: 1.2cqw; overflow: hidden; }
.health-track > div { height: 100%; width: 100%; background: linear-gradient(90deg, #679b86, #b1d6ab); transition: width .2s linear; }
.health-track.low > div { background: linear-gradient(90deg, #ae584e, #ec9c7d); }
.experience-row { display: flex; align-items: center; gap: 2cqw; margin-top: 2cqw; color: #88a495; font: 1.9cqw "Consolas", monospace; }
.experience-row > span:first-child { color: var(--accent); }
.experience-track { height: .5cqw; flex: 1; background: #40564b; }
.experience-track > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.mini-stats { display: flex; gap: 3cqw; color: #9eb79e; font-size: 1.9cqw; margin-top: 2cqw; letter-spacing: .1cqw; }
.combat-dock { position: absolute; z-index: 2; bottom: 1.5%; left: 5%; right: 5%; display: flex; align-items: center; justify-content: space-between; color: #c2cbb5; font: 2.2cqw "Consolas", "Microsoft YaHei", monospace; pointer-events: none; }
.combat-dock > span { display: flex; align-items: center; gap: 1.2cqw; }
.combat-dock [data-icon] { width: 2.8cqw; height: 2.8cqw; color: var(--accent); }
.combat-dock svg { width: 2.8cqw; height: 2.8cqw; flex-shrink: 0; }
.combat-dock b { color: var(--ink); font-weight: 400; }
#element-badge { color: #b6c2a9; white-space: nowrap; }
#element-badge i { width: 1cqw; height: 1cqw; background: var(--accent); border-radius: 50%; }
.battle-message { position: absolute; z-index: 2; left: 20%; right: 20%; top: 34%; text-align: center; padding: 3cqw; color: var(--accent); background: #142421dd; border: 1px solid #baaf7844; border-radius: 3px; font-size: 2.7cqw; pointer-events: none; }
.battle-message small { display: block; color: #a4b59f; font-size: 2.2cqw; margin-top: 1.8cqw; }
.modal-screen { background: #102020e8; backdrop-filter: blur(5px); }
.modal-heading { position: absolute; top: 15%; left: 7%; right: 7%; text-align: center; }
.modal-heading .eyebrow { color: var(--accent); font-size: 2cqw; }
.modal-screen h2 { font-size: 6.6cqw; font-weight: 600; letter-spacing: .5cqw; margin: 3cqw 0; }
.modal-screen p { font-size: 2.55cqw; color: #a6b7a3; line-height: 1.8; margin: 0; }
.card-grid { position: absolute; top: 36%; left: 5%; right: 5%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2cqw; }
.upgrade-card { min-width: 0; padding: 3cqw 2.1cqw 2.4cqw; border: 1px solid var(--rarity); background: linear-gradient(155deg, color-mix(in srgb, var(--rarity) 12%, #1c302b), #14231f); color: var(--ink); border-radius: 4px; text-align: left; position: relative; box-shadow: 0 9px 22px #0003; transition: transform .18s, box-shadow .18s, background .18s; min-height: 58cqw; display: flex; flex-direction: column; }
.upgrade-card::before { content: ""; position: absolute; left: 0; top: 0; width: 22%; height: 2px; background: var(--rarity); }
.upgrade-card:hover, .upgrade-card:focus-visible { transform: translateY(-2cqw); box-shadow: 0 14px 30px #0004, 0 0 20px color-mix(in srgb, var(--rarity) 15%, transparent); background: linear-gradient(155deg, color-mix(in srgb, var(--rarity) 21%, #1c302b), #14231f); }
.card-rarity { color: var(--rarity); font-size: 2.1cqw; letter-spacing: .25cqw; display: flex; justify-content: space-between; align-items: center; }
.card-rarity small { font: 1.7cqw "Consolas", monospace; opacity: .7; }
.card-illustration { position: relative; display: grid; place-items: center; height: 21cqw; margin: 3.5cqw 0 3cqw; border-bottom: 1px solid #adbda01f; background: radial-gradient(circle, color-mix(in srgb, var(--rarity) 12%, transparent), transparent 69%); color: var(--rarity); }
.card-illustration::before { content: ""; position: absolute; width: 15cqw; height: 15cqw; border: 1px solid color-mix(in srgb, var(--rarity) 20%, transparent); transform: rotate(45deg); }
.card-illustration svg { width: 12cqw; height: 12cqw; filter: drop-shadow(0 4px 5px #0005); }
.card-name { font-size: 3cqw; font-weight: 700; letter-spacing: .15cqw; margin-bottom: 2cqw; }
.card-description { color: #b9c8b2; font-size: 2.4cqw; line-height: 1.9; overflow-wrap: anywhere; flex: 1; }
.card-select { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #b9c8b226; padding-top: 2.8cqw; margin-top: 3cqw; color: var(--rarity); font-size: 2.2cqw; }
.card-select kbd { color: var(--rarity); border-color: color-mix(in srgb, var(--rarity) 35%, transparent); }
.modal-footnote { position: absolute; top: 82%; left: 5%; right: 5%; display: flex; align-items: center; justify-content: center; gap: 1.1cqw; font-size: 2.1cqw; color: #a3b5a0; }
.modal-footnote > span { margin: 0 .4cqw; }
.modal-footnote [data-icon] { width: 2.4cqw; height: 2.4cqw; color: var(--accent); }
.pause-content { position: absolute; top: 30%; left: 12%; right: 12%; text-align: center; }
.modal-symbol { width: 12cqw; height: 12cqw; color: var(--accent); margin: 0 auto 5cqw; }
.pause-content .primary-button { margin: 9cqw 0 4cqw; }
.pause-content .eyebrow, .end-content .eyebrow, .help-content .eyebrow { font-size: 2cqw; }
.end-screen { background: linear-gradient(#172524ea, #192522f5); }
.end-content { position: absolute; top: 14%; left: 10%; right: 10%; text-align: center; }
.end-content .modal-symbol { color: var(--danger); }
.end-content .eyebrow { color: var(--danger); letter-spacing: .28cqw; }
.end-content h2 { line-height: 1.5; margin: 4cqw 0; font-size: 8cqw; }
.end-stats { display: flex; justify-content: space-between; padding: 5cqw 0; margin-top: 6cqw; border-block: 1px solid #a9b39733; }
.end-stats > div { flex: 1; }
.end-stats > div + div { border-left: 1px solid #a9b39733; }
.end-stats strong { display: block; font: 6cqw "Consolas", monospace; color: var(--accent); }
.end-stats span { display: block; font-size: 2.4cqw; color: #8fa08e; margin-top: 2cqw; }
.end-level { font: 2.5cqw "Consolas", "Microsoft YaHei", monospace; color: #a6b7a3; margin: 5cqw 0 8cqw; }
.help-screen { z-index: 8; }
.help-content { position: absolute; top: 16%; left: 9%; right: 9%; }
.help-content .close-help { position: absolute; top: -6cqw; right: -2cqw; width: 7cqw; height: 7cqw; }
.help-content .close-help [data-icon] { width: 3cqw; height: 3cqw; }
.help-content dl { margin: 5cqw 0; font-size: 2.55cqw; }
.help-content dt { margin-top: 3cqw; color: #d1dcc5; }
.help-content dd { margin: 1.3cqw 0 0; color: #9db197; font-size: 2.4cqw; }
.help-elements { display: flex; align-items: center; justify-content: space-between; font-size: 2.3cqw; color: #b0bfaa; border-block: 1px solid #9fb19733; padding: 4cqw 0; margin-bottom: 6cqw; }
.help-elements [data-icon] { width: 3cqw; height: 3cqw; color: var(--accent); }
.reward-toast { position: absolute; z-index: 7; left: 16%; right: 16%; top: 22%; display: flex; align-items: center; justify-content: center; gap: 2cqw; padding: 3cqw; background: #152a23ef; border: 1px solid #94ba8d88; border-radius: 4px; color: var(--ink); font-size: 2.8cqw; pointer-events: none; animation: toast-arrive .3s ease-out; }
.reward-toast svg { width: 5cqw; height: 5cqw; color: var(--accent); }
@keyframes toast-arrive { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1120px) {
  .app { padding: 0 28px; }
  .stage { gap: 28px; }
  .briefing { max-width: 190px; }
  .telemetry { max-width: 180px; }
  .briefing h2 { font-size: 25px; }
}
@media (max-width: 960px) {
  .briefing, .telemetry { display: none; }
  .app { padding: 0 20px; }
  .masthead { height: 68px; }
  .stage { min-height: calc(100svh - 108px); padding: 20px 0 16px; }
  .game-shell { width: min(480px, calc((100svh - 152px) * 2 / 3), calc(100vw - 40px)); }
  .page-footer { height: 40px; }
}
@media (max-width: 540px) {
  .app { padding: 0 12px; }
  .masthead { height: 59px; gap: 12px; }
  .brand { font-size: 15px; gap: 9px; letter-spacing: 2px; }
  .brand > [data-icon] { width: 27px; height: 27px; }
  .brand small { font-size: 6px; letter-spacing: 1.6px; margin-top: 4px; }
  .connection { font-size: 0; gap: 5px; }
  .connection span { font-size: 9px; }
  .masthead .icon-button { width: 29px; height: 29px; }
  .masthead .icon-button [data-icon] { width: 15px; height: 15px; }
  .stage { padding: 14px 0; min-height: calc(100svh - 92px); }
  .game-shell { width: min(calc(100vw - 24px), calc((100svh - 145px) * 2 / 3)); }
  .frame-caption { font-size: 7px; letter-spacing: 1px; height: 19px; }
  .frame-footer { font-size: 7px; padding-top: 11px; }
  .page-footer { height: 33px; font-size: 8px; letter-spacing: 0; }
  .arena { border-radius: 5px; }
}
@container (max-width: 400px) {
  .modal-heading { top: 10%; }
  .card-grid { top: 27%; display: flex; flex-direction: column; gap: 2.8cqw; }
  .upgrade-card { min-height: 25cqw; padding: 3.1cqw 4cqw 3.1cqw 27cqw; display: grid; grid-template-columns: 1fr auto; gap: 1cqw 2cqw; }
  .card-rarity { font-size: 2.5cqw; grid-column: 1 / -1; }
  .card-illustration { position: absolute; left: 3cqw; top: 2cqw; width: 21cqw; height: 21cqw; margin: 0; border: 0; }
  .card-name { font-size: 3.8cqw; margin: .8cqw 0; grid-column: 1 / -1; }
  .card-description { font-size: 3cqw; line-height: 1.7; grid-column: 1; }
  .card-select { padding: 0; margin: 0; border: 0; font-size: 3cqw; align-self: end; }
  .card-select > span { display: none; }
  .modal-footnote { top: 86%; font-size: 2.4cqw; }
  .modal-screen p { font-size: 3cqw; }
  .help-content { top: 12%; }
  .help-content dt, .help-content dd { font-size: 3cqw; }
}
@media (max-height: 540px) and (orientation: landscape) {
  .briefing, .telemetry { display: none; }
  .game-shell { width: min(420px, calc(100vw - 40px)); }
  .stage { min-height: auto; }
  .masthead { height: 59px; }
  .page-footer { height: 33px; }
}
@media (pointer: coarse) {
  .hud .icon-button, .help-content .close-help { min-width: 40px; min-height: 40px; }
  .masthead .icon-button { min-width: 40px; min-height: 40px; }
  .primary-button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
