:root {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  --paper: #f2f0e8;
  --panel: #fbfaf5;
  --ink: #262a27;
  --muted: #777b71;
  --line: #dadbd0;
  --accent: #f2be49;
  --cabinet: #202629;
}
* { box-sizing: border-box; }
body { margin: 0; background-image: radial-gradient(#989b8018 .7px, transparent .7px); background-size: 6px 6px; }
button, select { font: inherit; color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
a { color: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible, #battlefield:focus-visible { outline: 3px solid #d58735; outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.topbar { max-width: 1280px; margin: auto; padding: 17px 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-size: 11px; letter-spacing: 1.7px; font-weight: 800; }
.brand-mark { font-size: 26px; }
.brand-light { font-weight: 400; color: var(--muted); }
.top-actions { display: flex; gap: 7px; align-items: center; }
.top-actions button, .top-actions select, .rules-heading button { border: 1px solid var(--line); border-radius: 7px; background: var(--panel); width: 34px; height: 34px; transition: background .15s, border-color .15s; }
.top-actions button:hover, .secondary:hover { border-color: #a9ae99; background: var(--paper); }
.top-actions select { width: 74px; padding: 0 8px; font-size: 10px; }
main { max-width: 1224px; margin: auto; padding: 0 28px; }
.heading { display: flex; justify-content: space-between; align-items: center; padding: 29px 0 27px; }
.eyebrow { font-size: 9px; font-weight: 700; letter-spacing: 1.65px; margin: 0 0 12px; }
.edition-dot { display: inline-block; width: 6px; height: 6px; background: #da7140; margin-right: 7px; }
.edition { color: var(--muted); margin-left: 13px; font: 9px monospace; letter-spacing: 1px; }
h1 { font-size: clamp(43px, 5.1vw, 66px); line-height: 1; letter-spacing: -3.8px; margin: 0; font-weight: 700; }
em { font-family: Georgia, serif; font-weight: 400; }
h1 em { color: #6b7454; }
.title-star { display: inline-block; font-size: 31px; color: #d88345; margin-left: 19px; vertical-align: middle; }
.tagline { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.heading-note { text-align: right; padding: 14px 0 0; }
.heading-note strong { font: 37px/1 'Courier New', monospace; letter-spacing: -2px; }
.heading-note strong span { font: 9px Arial, sans-serif; letter-spacing: 1.8px; color: var(--muted); }
.heading-note p { font-size: 11px; color: var(--muted); margin: 10px 0 0; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 267px; gap: 20px; align-items: stretch; }
.battle-panel { border: 1px solid #353c3b; border-radius: 14px; overflow: hidden; background: var(--cabinet); box-shadow: 0 3px 0 #101717, 0 16px 30px #1c281514; color: #d7ddcc; position: relative; }
.battle-top, .battle-bottom { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; font-size: 9px; letter-spacing: 1.15px; }
.battle-top { border-bottom: 1px solid #ffffff09; }
.sector { display: flex; align-items: center; gap: 9px; color: #9aa8a2; font-size: 8px; }
.sector b { font: 10px monospace; letter-spacing: 1.3px; color: #ecdfb2; }
.sector i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #f2be49; box-shadow: 0 0 9px #f2be4940; }
.sector-divider { color: #67716c; padding: 0 4px; }
.battle-top button { background: #ffffff05; border: 1px solid #4e5954; border-radius: 5px; padding: 6px 9px; font-size: 10px; color: #cdd5c5; }
.battle-top button:hover:not(:disabled) { background: #ffffff0c; border-color: #89907c; }
.field-wrap { position: relative; margin: 0 9px; height: min(620px, calc(100svh - 180px)); min-height: 350px; background: radial-gradient(ellipse at 50% 35%, #293238 0%, #151c20 72%); overflow: hidden; }
#battlefield { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: #0e15132b; }
.briefing { width: 320px; max-width: 100%; text-align: center; padding: 25px 25px 20px; border: 1px solid #b5c4aa40; border-top: 3px solid var(--accent); border-radius: 10px; background: #202629f5; box-shadow: 0 16px 50px #0008; }
.briefing-emblem { width: 50px; height: 50px; margin: 0 auto 17px; padding: 6px; color: #f2be49; background: #f2be490e; border: 1px solid #f2be4930; border-radius: 9px; }
.briefing-emblem svg { width: 100%; height: 100%; }
.briefing .eyebrow { color: #b8c3ad; font-size: 8px; letter-spacing: 1.9px; }
.briefing h2 { font: italic 37px/1.05 Georgia, serif; letter-spacing: -1.5px; color: #fff8e3; margin: 12px 0; }
.briefing p:not(.eyebrow) { font-size: 12px; line-height: 1.7; color: #b9c2b4; margin: 0 0 21px; }
.primary { background: var(--accent); color: #2c281d; border: 1px solid #ffe39b; border-bottom: 3px solid #b78528; border-radius: 5px; padding: 13px 17px; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; transition: background .15s, transform .15s; }
.primary:hover { background: #ffcf62; transform: translateY(-1px); }
.primary:active { transform: translateY(1px); }
.enter-hint { display: block; font-size: 8px; letter-spacing: 1.6px; color: #89998e; margin-top: 12px; }
kbd { display: inline-block; border: 1px solid #5a6860; border-bottom-width: 2px; background: #ffffff06; border-radius: 3px; min-width: 18px; text-align: center; font: 9px monospace; padding: 3px; margin-right: 3px; letter-spacing: 0; color: #d6dcca; }
.battle-bottom { padding: 15px 20px; border-top: 1px solid #ffffff09; font-size: 8px; letter-spacing: .7px; }
.battle-bottom b { margin-left: 6px; font-weight: 400; color: #9fae9f; }
.dashboard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.score-block { padding: 23px 22px 19px; background: #292f2c; color: #fff4ce; border-bottom: 3px solid #d6a947; }
.score-block .eyebrow { display: flex; justify-content: space-between; color: #aeb8a4; font-size: 8px; }
.score-dot { color: #e4b653; font-size: 7px; }
.score-block > strong { font: 44px/1.2 'Courier New', monospace; font-weight: 700; letter-spacing: -2px; text-shadow: 0 0 22px #f7be3c14; }
.best-line { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 8px; letter-spacing: 1px; color: #9da993; }
.best-line b { font: 11px monospace; color: #dfdfc4; }
.mission { padding: 21px 22px 16px; }
.stat-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stat-heading .eyebrow { margin: 0; font-size: 8px; }
.stat-heading > strong { font: 24px 'Courier New', monospace; white-space: nowrap; }
.stat-heading small { font-size: 12px; color: var(--muted); }
.enemy-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px 5px; margin: 16px 0 21px; }
.enemy-grid i { height: 14px; background: #8e9777; clip-path: polygon(0 22%,30% 22%,30% 0,69% 0,69% 22%,100% 22%,100% 100%,0 100%); border-bottom: 3px solid #626d53; transition: opacity .2s; }
.enemy-grid i.gone { opacity: .15; }
.stat-line { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; margin: 12px 0; font-size: 8px; letter-spacing: 1px; }
.stat-line strong { font-size: 13px; letter-spacing: 3px; }
#lives, #weapon { color: #ab7d23; }
.stat-line .base-status { font-size: 8px; letter-spacing: 1px; color: #698056; }
.effect-label { color: var(--muted); font-size: 8px; letter-spacing: .7px; min-height: 12px; margin: 17px 0 0; }
.dispatch { padding: 14px 18px; margin: 0 13px; border: 1px solid var(--line); border-left: 2px solid #aaa47f; border-radius: 4px; background: var(--paper); min-height: 87px; }
.dispatch .eyebrow { font-size: 8px; color: var(--muted); margin-bottom: 8px; }
.dispatch .eyebrow span { margin-right: 5px; }
.dispatch > p:last-child { font-size: 11px; line-height: 1.6; margin: 0; }
.stage-control { padding: 18px 22px; margin-top: auto; }
.stage-control label { display: block; font-size: 8px; letter-spacing: 1px; }
.stage-control select { width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; padding: 10px; font-size: 11px; }
.stage-control p, .storage-note { font-size: 9px; line-height: 1.6; color: var(--muted); }
.storage-note { padding: 0 22px; }
.secondary { width: 100%; padding: 10px; background: transparent; border: 1px solid var(--line); border-radius: 5px; font-size: 10px; }
.field-guide { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 28px 0; }
.field-guide .eyebrow { font-size: 8px; color: var(--muted); margin-bottom: 8px; }
.field-guide h2 { font-size: 25px; letter-spacing: -.8px; line-height: 1.15; margin: 0; }
.terrain-legend { display: flex; gap: 24px; }
.terrain-legend span { display: grid; grid-template-columns: 29px auto; gap: 4px 9px; align-items: center; }
.terrain-legend i { width: 26px; height: 26px; grid-row: span 2; border-top: 4px solid #ffffff60; border-right: 5px solid #00000021; border-bottom: 5px solid #00000027; transform: rotate(-7deg); box-shadow: 3px 4px 0 #243a2010; }
.terrain-legend b { font-size: 10px; font-weight: 600; }
.terrain-legend small { font-size: 8px; color: var(--muted); }
.brick { background: #e45c10; }
.steel { background: #bcbcbc; }
.water { background: #0058f8; }
.forest { background: #00a800; }
.ice { background: #daeff8; }
footer { border-top: 1px solid var(--line); padding: 20px 0 25px; display: flex; justify-content: space-between; font-size: 8px; letter-spacing: 1px; color: var(--muted); }
footer a { text-decoration: none; }
.touch-controls { display: none; }
.rules-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.rules-heading h2 { font-size: 27px; letter-spacing: -1px; }
dialog { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; max-width: 620px; width: calc(100% - 32px); padding: 24px 30px; max-height: 85vh; }
dialog::backdrop { background: #12191bd9; backdrop-filter: blur(4px); }
dialog p { font-size: 13px; line-height: 1.65; }
.power-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 0; }
.power-guide span { font-size: 11px; line-height: 1.6; color: var(--muted); }
.power-guide b { display: block; color: var(--ink); margin-bottom: 4px; }
.source-note { font-size: 10px !important; color: var(--muted); }
[data-theme=dark] { --paper: #191e20; --panel: #22292a; --ink: #e9e9dc; --muted: #a0aa9b; --line: #39433d; color-scheme: dark; }
[data-theme=dark] h1 em { color: #b8c2a0; }
[data-theme=dark] .battle-panel { border-color: #45504b; }
[data-theme=dark] #lives, [data-theme=dark] #weapon { color: #f2be49; }
[data-theme=dark] .base-status { color: #acbf91; }
@media (max-width: 1000px) {
  main { padding: 0 20px; }
  .game-layout { grid-template-columns: minmax(0,1fr) 237px; gap: 15px; }
  .score-block, .mission, .stage-control { padding-left: 17px; padding-right: 17px; }
  .score-block > strong { font-size: 39px; }
  .field-wrap { aspect-ratio: 1; }
  .terrain-legend { gap: 14px; }
  .terrain-legend span { grid-template-columns: 24px auto; gap: 4px 6px; }
  .terrain-legend i { width: 22px; height: 22px; }
}
@media (max-width: 700px) {
  .topbar { padding: 13px 16px; }
  .brand { font-size: 10px; letter-spacing: .8px; gap: 5px; }
  .brand-mark { font-size: 23px; }
  main { padding: 0 12px; }
  .heading { padding: 23px 4px; }
  h1 { font-size: 45px; letter-spacing: -2.8px; }
  .title-star { font-size: 22px; margin-left: 13px; }
  .heading-note { display: none; }
  .heading .eyebrow { font-size: 7px; }
  .edition { font-size: 7px; }
  .tagline { font-size: 11px; }
  .game-layout { grid-template-columns: 1fr; }
  .field-wrap { margin: 0; aspect-ratio: 1; height: auto; min-height: 0; }
  .battle-top, .battle-bottom { padding: 12px; }
  .sector { font-size: 7px; gap: 6px; }
  .sector b { font-size: 9px; }
  .sector-divider { padding: 0; }
  .briefing { width: 270px; padding: 18px 21px 15px; }
  .briefing-emblem { width: 39px; height: 39px; margin-bottom: 11px; }
  .briefing h2 { font-size: 32px; margin: 10px 0; }
  .briefing p:not(.eyebrow) { font-size: 11px; margin-bottom: 16px; }
  .briefing .eyebrow { font-size: 7px; }
  .primary { padding: 11px 15px; }
  .enter-hint { font-size: 7px; margin-top: 10px; }
  .dashboard { display: grid; grid-template-columns: 1fr 1fr; }
  .score-block { padding: 19px 15px; border-right: 1px solid #4d5347; }
  .mission { grid-column: 2; grid-row: 1/3; padding: 18px 15px; }
  .dispatch { grid-column: 1; min-height: 88px; margin: 12px; padding: 12px; }
  .stage-control { grid-column: 1/-1; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 9px 15px; padding: 17px; margin: 0; }
  .stage-control label { grid-column: 1/-1; margin: 0; }
  .stage-control select { grid-column: 1; }
  .stage-control p { grid-column: 1; margin: 0; }
  .stage-control .secondary { grid-column: 2; grid-row: 2/4; align-self: start; }
  .score-block > strong { font-size: 35px; }
  .best-line { font-size: 7px; gap: 6px; }
  .enemy-grid { gap: 8px 4px; }
  .field-guide { padding: 25px 5px; gap: 20px; flex-direction: column; align-items: start; }
  .field-guide h2 br { display: none; }
  .terrain-legend { gap: 17px; flex-wrap: wrap; }
  footer { font-size: 7px; letter-spacing: .4px; gap: 15px; }
  .power-guide { grid-template-columns: 1fr; }
  .battle-bottom { font-size: 7px; }
  kbd { font-size: 8px; min-width: 15px; padding: 3px 2px; }
  .storage-note { grid-column: 1/-1; }
}
@media (pointer: coarse), (max-width: 700px) {
  .touch-controls { display: flex; justify-content: space-between; align-items: center; padding: 2px 18px 17px; gap: 20px; }
  .dpad { display: grid; grid-template-columns: repeat(3,40px); gap: 4px; }
  .dpad button, .touch-fire { background: #303a3b; border: 1px solid #59665d; border-bottom: 3px solid #121919; border-radius: 5px; color: #dbe1ce; touch-action: none; user-select: none; height: 36px; font-size: 19px; }
  .dpad button:active { background: #59624b; }
  .dpad button:first-child { grid-column: 2; }
  .dpad button:nth-child(2) { grid-row: 2; grid-column: 1; }
  .dpad button:nth-child(3) { grid-row: 2; grid-column: 2; }
  .dpad button:nth-child(4) { grid-row: 2; grid-column: 3; }
  .touch-fire { height: 63px; width: 95px; font-size: 12px; font-weight: bold; background: #e5b343; border-color: #f6d47d; border-bottom-color: #a37422; color: #26291f; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
