/* Pocket Front v1.12 — field navy, warm paper, restrained teal framing.
   The map geometry is shared with layout.js: 27px horizontal chrome,
   62px vertical chrome (54px on compact screens). Keep these in sync. */
:root {
  color-scheme: dark;
  --navy: #052b42;
  --navy-deep: #032237;
  --panel: #09364b;
  --frame: #27778e;
  --frame-soft: #477f91;
  --cream: #fff1cf;
  --paper: #f8edcd;
  --ink: #0a2c41;
  --muted: #b8cdd6;
  --teal: #70dfdd;
  --coral: #f0876b;
  --gold: #f0c55d;
  --paper-ink: #234858;
  --paper-muted: #51676b;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-synthesis: none;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--navy); color: var(--cream); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, a { touch-action: manipulation; }
button { font: inherit; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: 1; filter: none; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

/* One static vector layer; no animated backgrounds or backdrop blur. */
.texture {
  position: fixed; inset: 0; pointer-events: none;
  background: url("./assets/field-atmosphere.svg") center / cover no-repeat,
    radial-gradient(ellipse at 25% 5%, #0b415d 0, transparent 65%),
    linear-gradient(150deg, #072f48, #032237);
}
.game {
  position: relative; height: 100vh; height: 100dvh; max-width: 920px; margin: auto;
  padding: calc(9px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  display: grid; grid-template-rows: 56px 30px minmax(0, 1fr) 130px 20px; gap: 4px;
}
.topbar {
  display: flex; align-items: center; gap: 9px; min-width: 0;
  padding: 5px 10px; border: 1px solid var(--frame); border-radius: 14px;
  background: linear-gradient(115deg, #0a394fef, #052b42f5);
  color: var(--cream); box-shadow: inset 0 1px 0 #8edbe210, 0 2px 5px #00152333;
}
.brand { display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1; }
.brandmark { width: 41px; height: 43px; flex: none; }
.brand h1 { font-size: clamp(16px, 4.4vw, 22px); line-height: 1.25; letter-spacing: -.04em; white-space: nowrap; font-weight: 900; text-shadow: 0 1px #001b2c; }
.brand span { display: block; font-size: 7px; font-weight: 700; letter-spacing: .3em; margin-top: 4px; white-space: nowrap; }
.funds { display: flex; align-items: center; gap: 5px; white-space: nowrap; flex: none; }
.funds strong { font-size: 23px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.coin { display: grid; place-content: center; width: 24px; height: 24px; background: linear-gradient(140deg, #ffe6a4, #dfad40); border: 2px solid #fbe09a; border-radius: 50%; color: #805713; font-size: 13px; font-weight: 900; box-shadow: inset 0 0 0 1px #bd8f2f, 0 1px 2px #001b2c; }
.icon-button { width: 44px; height: 44px; flex: none; display: grid; place-content: center; background: #123f55; border: 1px solid #6095a8; border-radius: 9px; color: var(--cream); font-size: 22px; line-height: 1; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.mission { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; padding: 0 4px; font-size: 10px; color: var(--cream); font-weight: 700; letter-spacing: .03em; }
.mission-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 10.5px; letter-spacing: 0; font-weight: 800; }
.mission b { font-size: 18px; color: var(--cream); margin: 0 3px; font-weight: 900; font-variant-numeric: tabular-nums; }
#round-label { flex: none; white-space: nowrap; }
.faction { display: inline-block; width: 9px; height: 9px; flex: none; background: var(--teal); border: 2px solid #f0fbeb; border-radius: 50%; box-shadow: 0 0 0 2px #267f89; vertical-align: middle; }
.faction.coral { background: var(--coral); border: 0; box-shadow: none; border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 10px; height: 10px; }

/* Board frame only. Canvas art and playable space are unchanged. */
.battle-layout { display: flex; justify-content: center; align-items: center; gap: 32px; min-width: 0; min-height: 0; }
.battlefield { --board-chrome-x: 27px; --board-chrome-y: 62px; height: 100%; display: flex; flex-direction: column; min-width: 0; max-width: 440px; aspect-ratio: 800 / 1100; border: 2px solid var(--frame); border-radius: 12px; background: var(--panel); box-shadow: 0 3px 8px #001b2c33; overflow: hidden; padding: 0 5px; }
.board-top, .board-bottom { height: 23px; min-height: 23px; display: flex; align-items: center; justify-content: space-between; color: var(--cream); font-size: 10px; letter-spacing: .01em; padding: 0 4px; }
.board-top > span:first-child { color: #8ceae5; font-weight: 800; cursor: pointer; }
.board-bottom { height: 20px; min-height: 20px; font-size: 9px; color: var(--muted); gap: 7px; white-space: nowrap; }
.board-bottom b { font-size: 11px; font-weight: 800; color: var(--cream); }
#income-label { color: #a8e4e6; }
#difficulty-label { color: var(--cream); font-weight: 800; white-space: nowrap; }
.board-shell { flex: 1; display: flex; min-height: 0; flex-direction: column; background: #103e52; box-shadow: 0 0 0 1px #5591a3; }
.cols { height: 15px; min-height: 15px; display: grid; grid-template-columns: repeat(8, 1fr); padding-left: 13px; color: var(--cream); text-align: center; font-size: 9px; font-weight: 700; }
.map-wrap { display: flex; flex: 1; min-height: 0; }
.rows { display: flex; flex-direction: column; justify-content: space-around; width: 13px; min-width: 13px; color: var(--cream); text-align: center; font-size: 9px; font-weight: 700; }
#board { display: block; min-height: 0; min-width: 0; width: calc(100% - 13px); height: 100%; touch-action: none; cursor: pointer; border: 1px solid #75a6b0; }
.tiny-flag { display: inline-block; width: 7px; height: 8px; border-left: 1px solid var(--cream); border-top: 4px solid var(--cream); }
.desktop-note { display: none; }

/* The guide, selection and action row consume the existing 130px deck. */
.control-deck { position: relative; align-self: end; width: 100%; max-width: 440px; min-width: 0; margin: auto; }
.guide { display: flex; align-items: center; gap: 7px; height: 34px; margin-bottom: 4px; padding: 3px 7px; border: 1px solid #d6bd81; border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 #001b2c33; font-size: 10.5px; line-height: 1.2; font-weight: 800; }
.guide-step { flex: none; max-width: 54px; font-size: 10px; letter-spacing: .03em; color: #79591c; border-right: 1px solid #bdaa7e; padding-right: 6px; white-space: nowrap; }
.guide > span:nth-child(2) { min-width: 0; flex: 1; line-height: 1.2; }
.guide button { flex: none; width: 24px; height: 26px; background: none; color: #5b6258; padding: 0; font-size: 23px; line-height: 1; }
.guide.complete { background: #e8efd8; border-color: #b1cba8; }
.guide.threat-guide { background: #f9e2ce; border-color: #d4a583; }
.threat-guide .guide-step { color: #895032; font-size: 9px; }
.selection { height: 44px; display: flex; justify-content: space-between; align-items: center; gap: 5px; padding: 2px 4px 4px; color: var(--cream); }
.selection > div:first-child { flex: 1; min-width: 0; }
.selection strong { display: block; font-size: 12px; line-height: 1.4; font-weight: 900; letter-spacing: .01em; }
.selection :where(span:not(.hp-chip):not(.selection-mini)) { display: block; font-size: 10px; line-height: 1.3; color: var(--muted); margin-top: 2px; }
.selection .selection-mini { flex: none; font-size: 8px; letter-spacing: .06em; text-align: right; white-space: nowrap; align-self: center; color: #a8c6d2; }
.hp-chip { display: inline-block; border: 1px solid #528b9c; border-radius: 4px; background: #16475c; color: var(--cream); font-size: 9px; line-height: 1.3; padding: 1px 5px; white-space: nowrap; vertical-align: 1px; }
.hp-chip.enemy-hp { background: #774631; border-color: #c99275; }
.selection span.threat-key { color: #ffc4a7; font-weight: 700; letter-spacing: 0; }
.selection span.pending-tag { color: #f3d591; }
.inline-actions { display: flex; gap: 5px; flex: none; }
.inline-action { min-height: 30px; border: 1px solid #6492a4; background: #1d4b60; border-radius: 6px; font-size: 10px; font-weight: 700; padding: 5px 7px; color: var(--cream); }
.action-bar { display: grid; grid-template-columns: 1fr 1fr 1fr 1.4fr; gap: 6px; height: 48px; }
.action { display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 4px; border: 1px solid #87c0c6; border-radius: 9px; box-shadow: inset 0 1px 0 #ffffff18, 0 2px 0 #001c2b66; font-size: 12px; font-weight: 900; color: var(--cream); white-space: nowrap; }
.action .icon { width: 19px; height: 19px; }
.teal-button { background: linear-gradient(#206e79, #145767); border-color: #6ebbbf; }
.coral-button { background: linear-gradient(#9f513e, #7c3d30); border-color: #e0a18a; }
.steel-button { background: linear-gradient(#3a6073, #28495e); border-color: #83a7b6; }
.gold-button { background: linear-gradient(#ffe398, #e5b748); border-color: #ffedb2; color: var(--ink); }
.action:disabled, .icon-button:disabled, .inline-action:disabled { color: #bacdd7; background: linear-gradient(#31566b, #24475c); border-color: #668fa2; box-shadow: inset 0 1px 0 #c4e9ff10; text-shadow: none; }
.action:not(:disabled):active, .icon-button:not(:disabled):active, .btn:not(:disabled):active, .inline-action:not(:disabled):active { transform: translateY(1px); }
.footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; font-size: 9.5px; line-height: 1.2; color: var(--muted); letter-spacing: .015em; max-width: 440px; width: 100%; margin: auto; }
.footer > span:last-child { flex: none; white-space: nowrap; }
.footer b { color: var(--muted); font-weight: 600; }
#save-status { min-width: 0; }
.toast { position: fixed; z-index: 15; left: 50%; transform: translate(-50%, 10px); bottom: calc(164px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding: 9px 15px; border: 1px solid #6a98a9; border-radius: 12px; background: #0c354a; color: var(--cream); text-align: center; font-size: 12px; opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; box-shadow: 0 4px 14px #001a2c40; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Menus are paper panels. Only their bodies scroll, inside the safe viewport. */
.overlay { position: fixed; inset: 0; z-index: 30; background: #011b2bce; display: flex; align-items: center; justify-content: center; padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
.modal { width: 100%; min-width: 0; max-width: 440px; max-height: 100%; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #72a2ae; border-radius: 15px; background: var(--paper); color: var(--paper-ink); color-scheme: light; box-shadow: 0 12px 35px #00152280; }
.modal-header { flex: none; padding: 16px 18px; background: linear-gradient(120deg, #103e54, #062c43); border-bottom: 1px solid #59899b; color: var(--cream); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-header h2 { font-size: 18px; font-weight: 900; letter-spacing: .04em; }
.modal-close { flex: none; display: grid; place-items: center; font-size: 25px; background: #174459; border: 1px solid #5c899a; border-radius: 7px; color: var(--cream); width: 44px; height: 44px; line-height: 1; }
.modal-body { min-height: 0; padding: 18px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-color: #527885 #eadfbd; line-height: 1.6; }
.modal-body > p { font-size: 12px; color: var(--paper-muted); margin-bottom: 13px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.btn { min-width: 0; min-height: 45px; padding: 10px 15px; border: 1px solid #a7b2a5; border-radius: 9px; font-weight: 800; font-size: 13px; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-decoration: none; text-align: center; background: #e7e8d6; color: #234858; box-shadow: 0 1px 0 #19374322; }
.btn.primary { color: var(--ink); background: linear-gradient(#ffe6a1, #ecc567); border-color: #b38a39; }
.btn.navy { color: var(--cream); background: linear-gradient(#28586c, #123b51); border-color: #315e70; }
.btn.coral { background: #914631; color: #fff2d5; border-color: #a95a42; }
.btn.small { min-height: 38px; font-size: 11px; padding: 7px; }
.btn:disabled { color: #5e6b6d; background: #dadfda; border-color: #aeb8b4; box-shadow: none; }
.eyebrow { font-size: 9px; font-weight: 800; letter-spacing: .2em; color: #866623; }
.intro-hero { text-align: center; position: relative; padding: 15px 0 4px; background: radial-gradient(ellipse at center, #d2e3d6, transparent 68%); }
.intro-hero .eyebrow { margin-bottom: 5px; }
.intro-hero h2 { font-size: 29px; font-weight: 900; letter-spacing: -.04em; line-height: 1.3; color: var(--ink); }
.intro-hero h3 { font-size: 10px; letter-spacing: .34em; margin-top: 5px; }
.intro-art { position: relative; height: 122px; max-width: 290px; margin: auto; }
.intro-art::before { content: ''; position: absolute; left: 10%; right: 10%; height: 25px; bottom: 7px; background: radial-gradient(ellipse, #869a814a, transparent 70%); border-radius: 50%; }
.intro-art img { position: absolute; object-fit: contain; bottom: 0; width: 150px; height: 120px; }
.intro-art .tank { left: 28px; z-index: 1; }
.intro-art .infantry { width: 105px; height: 115px; right: 14px; }
.intro-tagline { font-size: 13px; text-align: center; letter-spacing: .08em; font-weight: 700; color: #436253; }
.intro-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 12px 0 18px; }
.intro-badges span { font-size: 10px; border: 1px solid #b5b99a; border-radius: 14px; padding: 3px 9px; color: #536650; }
.intro-options { display: grid; gap: 8px; }
.modal-body .fine-print { font-size: 10px; color: #5e6b63; text-align: center; margin: 13px 0 0; }
.win-brief { display: flex; align-items: center; gap: 10px; background: #e3e9d0; border: 1px solid #adbda0; border-radius: 10px; padding: 11px 10px; margin: 3px 0 10px; }
.win-icon { width: 35px; height: 35px; display: grid; place-items: center; background: #204d5b; color: #ffe1a0; border-radius: 50%; flex: none; }
.win-icon .icon { width: 22px; height: 22px; }
.win-brief b { font-size: 13px; display: block; }
.win-brief span:not(.win-icon) { font-size: 10px; display: block; color: #4b6454; margin-top: 4px; }
.modal-body .legacy-notice { padding: 9px; background: #efe0b8; border-left: 3px solid #a38337; font-size: 11px; line-height: 1.6; }
.win-help { padding: 10px; border-radius: 9px; background: #e3e9d0; border: 1px solid #b6c0a0; }
.route-brief { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 16px; }
.route-brief > div { border: 1px solid #adbe9d; background: #e5ecd5; border-radius: 9px; padding: 9px 8px; }
.route-brief > div:last-child { background: #f0e3c9; border-color: #c4ad83; }
.route-brief b { font-size: 11px; display: block; color: #345646; }
.route-brief > div:last-child b { color: #835037; }
.route-brief span { display: block; font-size: 10px; line-height: 1.6; margin-top: 4px; color: #546451; }
.modal-body .difficulty-summary { font-size: 10px; text-align: center; color: #5c6c61; margin: -7px 0 12px; }
.difficulty-picker { margin: 12px 0 15px; padding: 12px; background: #e4e9d9; border: 1px solid #b0bda6; border-radius: 11px; }
.difficulty-picker h3 { font-size: 12px; margin-bottom: 9px; color: #294b50; }
.difficulty-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.difficulty-option { min-height: 54px; padding: 8px 3px; border: 1px solid #a4b3a2; border-radius: 8px; background: #fbf2d9; color: #345453; font-size: 12px; font-weight: 900; line-height: 1.4; }
.difficulty-option small { display: block; font-size: 9px; font-weight: 600; margin-top: 3px; white-space: nowrap; }
.difficulty-option[aria-pressed=true] { background: #174a5c; border-color: #b88623; color: var(--cream); box-shadow: inset 0 0 0 2px #e9c66e; }
.difficulty-picker #difficulty-description { font-size: 11px; line-height: 1.7; min-height: 3.4em; margin: 9px 0 6px; color: #415e51; }
.difficulty-fairness { font-size: 10px; color: #53634f; line-height: 1.6; }
.production-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.unit-card { background: #faf1d7; border: 1px solid #b8b493; border-radius: 11px; padding: 9px 7px; position: relative; text-align: center; color: #244751; min-height: 161px; }
.unit-card img { width: 100%; height: 71px; object-fit: contain; }
.unit-card h3 { font-size: 14px; }
.unit-card .price { font-size: 14px; color: #795c20; font-weight: 900; }
.unit-card .stats { font-size: 10px; color: #55665b; }
.unit-card .reason { font-size: 10px; margin-top: 3px; color: #844b31; }
.unit-card:disabled { background: #e2e5d9; border-color: #aab5a8; color: #57695f; }
.unit-card:disabled img { opacity: .6; }
.unit-card:disabled .price, .unit-card:disabled .stats { color: #57695f; }
.combat-scene { display: flex; align-items: center; gap: 8px; background: linear-gradient(#cddfcd, #e6e7cd); border: 1px solid #adbaa0; border-radius: 12px; padding: 7px; position: relative; overflow: hidden; min-height: 114px; }
.combat-unit { text-align: center; flex: 1; z-index: 1; }
.combat-unit img { width: 100%; height: 87px; object-fit: contain; }
.combat-vs { font-size: 24px; color: #827743; font-weight: 900; }
.combat-stats { display: flex; justify-content: space-between; gap: 18px; margin-top: 12px; }
.combat-stats > div { flex: 1; }
.combat-stats strong { font-size: 13px; }
.combat-stats p { font-size: 20px; font-weight: 900; color: #294650; }
.hpbar { margin-top: 3px; height: 9px; border: 1px solid #234853; border-radius: 5px; background: #cdd5bc; overflow: hidden; }
.hpbar i { display: block; background: #249b9b; height: 100%; }
.hpbar.enemy i { background: #c55f47; }
.combat-note { margin-top: 12px; padding: 8px; border-radius: 7px; background: #e7e1c6; font-size: 11px; color: #526450; }
.damage-title { text-align: center; margin: 12px 0 0; color: #7e5a20; font-size: 12px; }
.damage-title b { font-size: 30px; display: block; line-height: 1.2; color: #1d4352; }
.help-section { margin-bottom: 17px; }
.help-section h3 { font-size: 13px; color: #214c59; margin-bottom: 6px; }
.help-section p, .help-section li { font-size: 12px; color: #4f6556; }
.help-section ul { margin: 0; padding-left: 18px; }
.help-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.help-legend div { font-size: 11px; background: #e6e4cc; padding: 8px; border-radius: 6px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid #c5c3a5; padding-top: 12px; font-size: 12px; }
.result-crest { text-align: center; color: #ad7921; font-size: 60px; line-height: 1.2; margin-bottom: 5px; text-shadow: 0 1px #ffe7a4; }
.result-title { text-align: center; font-size: 27px; color: #805723; font-weight: 900; letter-spacing: .1em; }
.result-sub { text-align: center; font-size: 12px; color: #526448; margin: 6px 0 20px; }
.scoreboard { background: #e8e5cd; border: 1px solid #b9b897; border-radius: 9px; overflow: hidden; font-size: 12px; }
.score-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; padding: 7px 10px; border-bottom: 1px solid #c8c5a5; }
.score-row:last-child { border: 0; background: #d5dfc5; font-weight: 900; font-size: 16px; }
.score-row span:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.score-row.head { color: #54684f; font-size: 10px; }
.result-link { display: block; text-align: center; color: #3d6759; font-size: 11px; margin-top: 13px; text-underline-offset: 3px; }

/* Transient states preserve readable controls and never move the board. */
.cpu .board-top > span:first-child { color: #ffc5a9; }
.cpu #board, .animating #board { cursor: wait; }
.animating .action-bar { pointer-events: none; }
.animating .guide { background: #e7ead3; }
.victory-controls { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 12px; border: 1px solid #e3c670; border-radius: 12px; background: linear-gradient(125deg, #103c50, #052b42); box-shadow: 0 0 0 2px #06293e; }
.victory-controls[hidden] { display: none; }
.victory-controls > strong { font-size: 14px; color: #ffe49a; text-align: center; }
.victory-controls > div { display: flex; gap: 8px; }
.celebrating .guide, .celebrating .selection, .celebrating .action-bar { visibility: hidden; }
.celebrating #menu-btn { pointer-events: none; }
.celebrating .mission-name { color: #ffe2a0; }

@media (min-width: 740px) and (min-height: 660px) {
  .game { grid-template-rows: 68px 34px minmax(0, 1fr) 130px 22px; padding-top: calc(20px + env(safe-area-inset-top)); max-width: 880px; }
  .topbar { padding: 9px 17px; }
  .brand h1 { font-size: 24px; }
  .brand span { font-size: 8px; }
  .brandmark { width: 52px; }
  .funds strong { font-size: 28px; }
  .funds { gap: 9px; }
  .icon-button { margin-left: 10px; }
  .mission { padding: 0 10px; font-size: 11px; }
  .mission-name { font-size: 12px; }
  .battle-layout { justify-content: flex-start; gap: 38px; padding-left: 10px; }
  .battlefield { width: auto; max-width: 440px; flex: none; }
  .desktop-note { display: block; flex: 1; max-width: 285px; align-self: center; position: relative; min-height: 375px; }
  .desktop-note .eyebrow { color: #dcc285; }
  .desktop-note h2 { font-size: 29px; line-height: 1.6; letter-spacing: .05em; margin-top: 16px; color: var(--cream); font-weight: 900; }
  .note-rule { width: 36px; height: 2px; background: #bfa467; margin: 19px 0; }
  .desktop-note p { font-size: 12px; color: var(--muted); line-height: 1.9; }
  .note-item { display: flex; gap: 11px; margin-top: 18px; }
  .note-item > b { font-family: Georgia, serif; color: #dec78c; font-size: 19px; }
  .note-item strong { display: block; font-size: 12px; letter-spacing: .06em; color: var(--cream); }
  .note-item span { font-size: 11px; color: var(--muted); display: block; margin-top: 3px; }
  .note-tag { font-size: 8px; letter-spacing: .12em; color: #8eb2c1; margin-top: 24px; }
  .note-tank { position: absolute; width: 140px; height: 110px; object-fit: contain; right: -15px; bottom: -18px; opacity: .7; pointer-events: none; }
  .control-deck, .footer { margin-left: 10px; max-width: 440px; width: min(440px, calc((100dvh - 282px) * .72727)); }
  .footer { font-size: 10px; }
  .toast { bottom: calc(170px + env(safe-area-inset-bottom)); }
  .guide { font-size: 11px; }
  .selection strong { font-size: 13px; }
}
@media (max-height: 690px) {
  .game { grid-template-rows: 49px 24px minmax(0, 1fr) 120px 16px; gap: 3px; padding-top: calc(5px + env(safe-area-inset-top)); }
  .topbar { border-radius: 11px; padding-top: 1px; padding-bottom: 1px; }
  .brandmark { height: 35px; width: 33px; }
  .brand h1 { font-size: 16px; }
  .brand span { font-size: 6px; }
  .funds strong { font-size: 21px; }
  .guide { height: 31px; margin-bottom: 3px; font-size: 10px; padding-top: 2px; padding-bottom: 2px; }
  .selection { height: 41px; }
  .selection span:not(.hp-chip):not(.selection-mini) { font-size: 9.5px; }
  .action-bar { height: 45px; }
  .battlefield { --board-chrome-y: 54px; }
  .board-top { height: 20px; min-height: 20px; font-size: 9px; }
  .board-bottom { height: 17px; min-height: 17px; font-size: 8px; }
  .cols { height: 13px; min-height: 13px; }
  .intro-art, .intro-art img, .intro-art .infantry { height: 82px; }
  .intro-hero h2 { font-size: 25px; }
  .modal-body { padding: 13px 16px; }
  .modal-header { padding: 11px 16px; }
  .intro-badges { margin: 8px 0 12px; }
  .intro-hero { padding-top: 6px; }
  .route-brief { margin-bottom: 13px; }
  .route-brief > div { padding: 7px; }
  .victory-controls { gap: 8px; padding: 9px; }
  .victory-controls > strong { font-size: 12px; }
  .victory-controls .btn { min-height: 44px; }
}
@media (max-width: 360px) {
  .game { padding-left: calc(7px + env(safe-area-inset-left)); padding-right: calc(7px + env(safe-area-inset-right)); }
  .brand h1 { font-size: 15.5px; }
  .brandmark { width: 30px; }
  .topbar { gap: 6px; padding-left: 6px; padding-right: 6px; }
  .funds strong { font-size: 20px; }
  .coin { display: none; }
  .mission { font-size: 9px; }
  .mission-name { font-size: 10px; gap: 5px; }
  .mission b { font-size: 17px; margin: 0 2px; }
  .action { font-size: 11px; gap: 3px; }
  .action .icon { width: 17px; }
  .action-bar { gap: 4px; }
  .selection strong { font-size: 11.5px; }
  .guide { gap: 5px; font-size: 10px; }
  .guide-step { font-size: 9px; padding-right: 5px; }
  .desktop-note { display: none; }
  .difficulty-picker { padding: 10px; }
  .difficulty-options { gap: 4px; }
  .difficulty-option { font-size: 11px; }
  .difficulty-option small { font-size: 8px; }
}
/* Landscape gives the board the full safe-area height. Its controls stay in
   the right column, with the same 44px-or-larger primary touch targets. */
@media (max-height: 530px) and (orientation: landscape) {
  .game { max-width: 880px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 50px 24px minmax(0, 1fr) 18px; column-gap: 12px; }
  .topbar { grid-column: 2; grid-row: 1; gap: 4px; padding: 2px 5px; }
  .brand { gap: 0; }
  .brandmark, .brand span, .coin { display: none; }
  .brand h1 { font-size: clamp(12px, 2.1vw, 16px); letter-spacing: -.05em; }
  .funds { gap: 0; }
  .funds strong { font-size: 16px; }
  .icon-button { width: 44px; height: 44px; font-size: 24px; }
  .mission { grid-column: 2; grid-row: 2; font-size: 9px; gap: 4px; padding: 0 2px; }
  .mission-name { font-size: 10px; gap: 5px; line-height: 1.2; }
  .mission b { font-size: 17px; margin: 0 2px; }
  .round-word { display: none; }
  .battle-layout { grid-column: 1; grid-row: 1 / -1; }
  .battlefield { max-width: 440px; }
  .control-deck { grid-column: 2; grid-row: 3; align-self: center; }
  .footer { grid-column: 2; grid-row: 4; font-size: 9px; gap: 5px; }
  .guide { height: 34px; margin-bottom: 4px; }
  .action-bar { grid-template-columns: 1fr 1fr; height: 94px; }
  .desktop-note { display: none; }
  .selection { height: 50px; }
  .selection .selection-mini { font-size: 7.5px; letter-spacing: 0; }
  .modal { max-width: 520px; }
}
@media (max-height: 530px) and (orientation: landscape) and (max-width: 740px) {
  .footer > span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
  .action:not(:disabled):active, .icon-button:not(:disabled):active, .btn:not(:disabled):active, .inline-action:not(:disabled):active { transform: none; }
}

/* Save diagnostics preserve both stored generations and use existing screen slots. */
.save-status{padding:0;background:none;color:inherit;font:inherit;text-align:left;min-width:0;line-height:1.2;text-decoration:underline;text-underline-offset:2px}.save-status:focus-visible{outline-offset:1px}.guide.save-error{background:#ffe0c7;border-color:#c8794b;color:#552e20}.guide.save-error .guide-step{color:#7f3d20}.save-info-button{width:100%;margin-bottom:16px}.resume-panel{padding:12px;border:1px solid #bd9c4c;border-radius:10px;background:#eee4bd;margin-bottom:12px}.resume-panel p{font-size:11px;color:#425b4c;margin-bottom:7px}.resume-panel .btn{width:100%}.save-report{border:1px solid #b3bfac;border-radius:8px;padding:10px;background:#e5ead5;margin:10px 0 14px}.save-report p{font-size:11px;color:#294b50;line-height:1.75}.save-warning{padding:10px;border-left:3px solid #ab643e;background:#f7dfc6;color:#593924!important;font-weight:700}.save-notice{padding:9px;background:#e5ead5;border-radius:7px;font-size:11px!important;color:#35534d!important}

/* Stage selection lives inside the existing scrollable menu, not board chrome. */
.stage-picker { margin-bottom: 12px; }
.stage-picker h3 { font-size: 12px; color: #294b50; margin-bottom: 7px; }
.stage-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.stage-option { min-width: 0; min-height: 88px; text-align: left; border: 1px solid #a7b5a5; border-radius: 9px; padding: 7px 6px; color: #294b50; background: #eee8cc; overflow-wrap: anywhere; line-height: 1.4; }
.stage-option > span, .stage-option > strong { display: block; }
.stage-option .stage-number { font-size: 9px; letter-spacing: .08em; font-weight: 800; }
.stage-option strong { font-size: 11px; margin: 2px 0 4px; }
.stage-theme { font-size: 10px; }
.stage-save { font-size: 9px; margin-top: 4px; line-height: 1.45; font-weight: 800; }
.stage-option[aria-pressed=true] { color: var(--cream); background: #174a5c; border-color: #b88623; box-shadow: inset 0 0 0 2px #e9c66e; }
.stage-access { font-size: 10px; margin-top: 6px; color: #51676b; }
/* The selected stage has a full-width description; small choices never clip titles. */
.stage-detail { margin-top: 8px; padding: 8px 10px; background: #e4e9d9; border-left: 3px solid #315e70; border-radius: 5px; }
.stage-detail b { display: block; font-size: 12px; }
.stage-detail .stage-theme { margin-top: 2px; }
.campaign-hero { padding-top: 4px; }
.campaign-hero h2 { font-size: 21px; }
.campaign-hero .intro-art { display: none; }
.campaign-hero h3 { margin-bottom: 9px; }
.campaign-steps { padding: 0; margin: 0 0 16px; list-style: none; counter-reset: campaign-step; display: grid; gap: 7px; }
.campaign-steps li { counter-increment: campaign-step; position: relative; padding: 9px 9px 9px 32px; background: #e5ecd5; border: 1px solid #adbe9d; border-radius: 8px; overflow-wrap: anywhere; }
.campaign-steps li::before { content: counter(campaign-step); position: absolute; left: 10px; top: 10px; font-size: 12px; font-weight: 900; color: #294b50; }
.campaign-steps b, .campaign-steps span { display: block; }
.campaign-steps b { font-size: 11px; }
.campaign-steps span { font-size: 10px; margin-top: 3px; color: #546451; }
@media (max-width: 350px) { .modal-body { padding: 14px; } .stage-option { padding: 7px 5px; } }
@media (max-height: 530px) { .overlay { padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: calc(8px + env(safe-area-inset-bottom)); } .modal-header { padding: 8px 14px; } .modal-body { padding: 12px; } .resume-panel { padding: 8px; } }


@media (min-width: 740px) and (min-height: 660px) {
  .desktop-note.campaign-note h2 { font-size: 24px; line-height: 1.4; margin-top: 12px; }
  .desktop-note.campaign-note p { font-size: 11px; line-height: 1.6; }
  .campaign-note .note-rule { margin: 12px 0; }
  .campaign-note .note-item { margin-top: 12px; }
  .campaign-note .note-item span { font-size: 10px; line-height: 1.5; }
  .campaign-note .note-tag { margin-top: 12px; }
  .campaign-note .note-tank { width: 100px; height: 78px; right: 0; bottom: 0; opacity: .35; }
}

/* Six chapter groups stay in the scrollable sheet; the board and deck keep their size. */
.stage-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.stage-tabs button { min-width: 0; min-height: 44px; padding: 7px 5px; border: 1px solid #a7b5a5; border-radius: 8px; background: #e4e9d9; color: #294b50; font-size: 12px; font-weight: 800; overflow-wrap: anywhere; }
.stage-tabs button[aria-pressed=true] { background: #174a5c; color: var(--cream); border-color: #b88623; box-shadow: inset 0 0 0 1px #e9c66e; }
.layer-options { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.layer-option { min-width: 0; min-height: 58px; padding: 10px 12px; border: 1px solid #8caa9f; border-left: 5px solid #438a83; border-radius: 9px; background: #e4ecdb; color: #214b50; text-align: left; overflow-wrap: anywhere; }
.layer-option strong { display: block; font-size: 13px; line-height: 1.45; }
.layer-option span { display: block; font-size: 11px; line-height: 1.5; margin-top: 3px; }
.layer-option.coral { border-left-color: #c56748; background: #f3dfcb; }
.layer-option.move-choice { border-left-color: #277f9c; background: #d9edf0; }
.layer-option.site-choice { border-left-color: #b69437; background: #efe7c5; }
.building-access, .threat-toggle { flex: none; max-width: 58px; padding: 4px; font-size: 9px; }
.combat-stats small { display: block; overflow-wrap: anywhere; font-size: 10px; }
.aviation .selection strong, .aviation .selection > div:first-child > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (max-width: 350px) { .stage-tabs button { font-size: 11px; } .layer-option { padding: 9px; } }

.current-return-panel { padding: 8px; margin-bottom: 8px; }
.current-return-panel p { margin-bottom: 4px; }
.current-return-panel .btn { font-size: 11px; }

/* Stage14 recovery choices are contextual and stay inside the menu sheet. */
.capture-route-warning { margin-bottom: 14px; }
.capture-route-warning .btn { width: 100%; margin-top: 9px; }

/* Contextual naval actions use the existing selection area; details scroll in sheets. */
.naval-access { flex: none; min-width: 44px; min-height: 44px; max-width: 48px; padding: 4px; font-size: 10px; }
.cargo-status { padding: 8px 12px; margin: 10px 0; border-left: 4px solid #438a83; background: #e4ecdb; border-radius: 6px; overflow-wrap: anywhere; }
.unavailable-reason { color: #804628; background: #f3dfcb; padding: 10px; border-radius: 6px; overflow-wrap: anywhere; }
.landing-choice { border-left-color: #b69437; }

.cargo-loss-warning { color: #8a3d22; font-weight: 800; overflow-wrap: anywhere; }
/* A 44px naval target fits inside the unchanged selection/deck allocation. */
.naval .selection { padding-top: 0; padding-bottom: 0; }
@media (max-height: 690px) and (orientation: portrait) {
  .naval .selection { height: 44px; }
  .naval .guide { margin-bottom: 0; }
}

/* Final chapters stay inside the same scrollable sheet and keep 44px choices. */
.finale-victory-rules, .campaign-complete { padding: 10px 12px; border: 1px solid #b99a4e; border-radius: 8px; background: #eee4bd; color: #294b50; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.finale-victory-rules { margin-bottom: 12px; }
.campaign-complete { margin-bottom: 16px; text-align: center; }

/* Music stays in the scrollable dialog, never takes space from the battlefield. */
.music-settings{margin:12px 0;padding:12px 14px;border:1px solid #7bada9;border-radius:12px;background:#e8eee3;color:#15383e;text-align:left}
.music-heading{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:6px}
.music-heading .btn{min-height:44px;min-width:136px;font-size:13px}
.music-settings label{display:block;font-size:13px;font-weight:800}
.music-settings input[type=range]{display:block;width:100%;min-height:44px;margin:0;accent-color:#146c68;cursor:pointer;touch-action:pan-y}
.music-settings .fine-print{margin:3px 0 0;color:#36514f;font-size:11px;line-height:1.55}
.music-settings input:focus-visible{outline:3px solid #d09629;outline-offset:2px;border-radius:5px}

.backup-text{display:block;width:100%;box-sizing:border-box;min-height:180px;max-height:40vh;margin:12px 0;padding:10px;font:16px monospace;color:#163338;background:#fff;border:2px solid #47777b;border-radius:8px;resize:vertical}#backup-error{color:#a42d2d;overflow-wrap:anywhere}

.modal-actions.backup-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}#backup-file{display:block;box-sizing:border-box;width:100%;max-width:100%;min-height:44px}#backup-file::file-selector-button{min-height:44px}

.hub-return{display:block;width:100%;min-height:44px;margin-top:18px}
