:root {
  --ink: #17201d;
  --muted: #68716c;
  --paper: #f3f0e8;
  --paper-deep: #e9e5db;
  --white: #fbfaf6;
  --green: #173f35;
  --green-soft: #dce5df;
  --red: #bf3f36;
  --red-soft: #f2d8d2;
  --gold: #b28a3a;
  --hit: #c9dfd1;
  --hit-dark: #2b5a43;
  --line: #c8c8be;
  --cell: min(5.45vw, 58px);
  --shadow: 0 18px 50px rgba(23, 32, 29, 0.11);
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background-color: var(--paper);
}

button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid rgba(178, 138, 58, 0.5); outline-offset: 3px; }

body.intro-active { overflow: hidden; }
body.intro-active > .topbar,
body.intro-active > .app-shell,
body.intro-active > .legend-bar,
body.intro-active > .result-overlay,
body.intro-active > dialog:not(#playModeDialog):not(#roomDialog),
body.intro-active > .toast { display: none !important; }

.welcome-view {
  position: fixed;
  z-index: 80;
  inset: 0;
  min-height: 100svh;
  overflow-y: auto;
  color: var(--white);
  background: #111b18;
}
.welcome-header {
  min-height: 64px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #46514c;
}
.welcome-brand { display: flex; align-items: baseline; gap: 14px; }
.welcome-brand-code { color: #d26155; font: 700 11px ui-monospace, monospace; }
.welcome-brand strong { font-family: "Songti SC", "STSong", serif; font-size: 21px; }
.welcome-header-meta { display: flex; align-items: center; gap: 9px; color: #b9c3be; font: 12px ui-monospace, monospace; }
.welcome-header-meta span { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(191,63,54,.15); }
.welcome-main {
  width: min(1120px, calc(100% - 40px));
  min-height: calc(100svh - 64px);
  margin: 0 auto;
  padding: 22px 0 20px;
  display: grid;
  align-content: center;
  gap: 16px;
}
.welcome-hero { display: grid; justify-items: center; text-align: center; }
.welcome-logo-stage { position: relative; width: 172px; height: 128px; display: grid; place-items: center; margin-bottom: 9px; }
.welcome-target-ring { position: absolute; inset: 0 22px; border: 1px solid #5f6c66; border-radius: 50%; }
.welcome-target-ring::before, .welcome-target-ring::after { content: ""; position: absolute; background: #5f6c66; }
.welcome-target-ring::before { width: 1px; height: 144px; left: 50%; top: -8px; }
.welcome-target-ring::after { width: 164px; height: 1px; left: -18px; top: 50%; }
.welcome-plane-logo { position: relative; z-index: 1; padding: 13px; background: #111b18; }
.welcome-plane-logo .model-shape { --shape-cell: 19px; gap: 3px; }
.welcome-plane-logo .model-shape i { background: #dce5df; }
.welcome-plane-logo .model-shape i.is-head { background: #d95348; }
.welcome-eyebrow { margin: 0 0 4px; color: #d26155; font: 700 11px ui-monospace, monospace; }
.welcome-hero h1 { margin: 0; color: #fffdf7; font-family: "Songti SC", "STSong", serif; font-size: 66px; line-height: 1; }
.welcome-tagline { max-width: 620px; margin: 10px 0 0; color: #c5cfca; font-size: 15px; line-height: 1.65; }
.welcome-rules { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #46514c; border-bottom: 1px solid #46514c; }
.welcome-rules article { min-width: 0; display: grid; grid-template-columns: 34px 1fr; gap: 13px; padding: 14px 22px; border-right: 1px solid #46514c; }
.welcome-rules article:last-child { border-right: 0; }
.welcome-rule-index { padding-top: 2px; color: #d26155; font: 700 11px ui-monospace, monospace; }
.welcome-rules strong { display: block; margin-bottom: 4px; color: #fffdf7; font-size: 15px; }
.welcome-rules p { margin: 0; color: #aeb9b3; font-size: 12px; line-height: 1.55; }
.welcome-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 330px)); justify-content: center; gap: 10px; }
.welcome-action { min-height: 68px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border: 1px solid #65716b; color: #fffdf7; background: transparent; text-align: left; cursor: pointer; }
.welcome-action span, .welcome-action strong, .welcome-action small { display: block; }
.welcome-action strong { margin-bottom: 3px; font-size: 17px; }
.welcome-action small { color: #aeb9b3; font-size: 11px; }
.welcome-action b { font-size: 22px; }
.welcome-action.is-start { border-color: var(--red); background: var(--red); }
.welcome-action.is-start small { color: #f5dcd8; }
.welcome-action:hover { border-color: #fffdf7; }
.welcome-action.is-start:hover { background: #a8342d; }
.welcome-footnote { margin: 0; color: #7f8d86; font: 11px ui-monospace, monospace; text-align: center; }

.tutorial-view { position: fixed; z-index: 90; inset: 0; overflow-y: auto; color: var(--ink); background: var(--paper); }
.tutorial-header { min-height: 64px; padding: 0 clamp(18px, 4vw, 54px); display: flex; align-items: center; justify-content: space-between; color: var(--white); background: var(--ink); border-bottom: 3px solid var(--gold); }
.tutorial-brand { display: flex; align-items: center; gap: 11px; font-family: "Songti SC", "STSong", serif; font-size: 19px; }
.tutorial-brand > span { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #5c6963; transform: rotate(45deg); }
.tutorial-header-actions { display: flex; align-items: center; gap: 16px; color: #c2ccc7; font: 11px ui-monospace, monospace; }
.tutorial-skip { min-height: 38px; padding: 0 12px; border: 1px solid #5c6963; color: var(--white); background: transparent; cursor: pointer; }
.tutorial-exit { width: 38px; height: 38px; border: 1px solid #5c6963; color: var(--white); background: transparent; font-size: 23px; cursor: pointer; }
.tutorial-shell { width: min(1120px, calc(100% - 40px)); min-height: calc(100svh - 64px); margin: 0 auto; padding: 20px 0 24px; display: grid; grid-template-rows: auto 1fr auto; }
.tutorial-progress { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tutorial-progress span { position: relative; padding: 12px 14px; color: var(--muted); font-size: 12px; text-align: center; }
.tutorial-progress span::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 3px; background: transparent; }
.tutorial-progress b { margin-right: 7px; color: #9da49f; font: 700 10px ui-monospace, monospace; }
.tutorial-progress span.is-active { color: var(--ink); font-weight: 700; }
.tutorial-progress span.is-active::after { background: var(--red); }
.tutorial-progress span.is-complete, .tutorial-progress span.is-complete b { color: var(--green); }
.tutorial-stage { display: grid; align-items: center; min-height: 440px; }
.tutorial-step { display: grid; grid-template-columns: minmax(0, .85fr) minmax(390px, 1.15fr); gap: clamp(36px, 6vw, 80px); align-items: center; padding: 24px 30px; }
.tutorial-step-label { margin: 0 0 12px; color: var(--red); font: 700 11px ui-monospace, monospace; }
.tutorial-copy h2 { margin: 0 0 15px; font-size: 34px; }
.tutorial-copy > p:not(.tutorial-step-label):not(.tutorial-feedback) { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.tutorial-copy strong { color: var(--ink); }
.tutorial-callout { margin-top: 22px; padding: 14px 0 14px 17px; display: grid; gap: 4px; border-left: 4px solid var(--red); }
.tutorial-callout strong { font-size: 14px; }
.tutorial-callout span { color: var(--muted); font-size: 13px; line-height: 1.55; }
.tutorial-demo { min-width: 0; min-height: 330px; display: grid; place-items: center; border: 1px solid var(--line); background: rgba(255,255,255,.38); }
.tutorial-objective-demo { align-content: center; gap: 30px; }
.tutorial-plane-overview .model-shape { --shape-cell: 25px; gap: 3px; }
.tutorial-plane-overview .model-shape i { background: #a9c1b4; }
.tutorial-plane-overview .model-shape i.is-head { background: var(--red); }
.tutorial-marker-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.tutorial-marker-list > span { display: grid; grid-template-columns: 40px auto; grid-template-rows: 20px 20px; column-gap: 9px; align-items: center; }
.tutorial-marker-list i { grid-row: 1 / 3; }
.tutorial-marker-list b { align-self: end; font-size: 13px; }
.tutorial-marker-list small { align-self: start; color: var(--muted); font-size: 11px; }
.tutorial-direction-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 22px; }
.tutorial-direction-row button { height: 44px; border: 1px solid var(--line); background: var(--white); font-size: 22px; cursor: pointer; }
.tutorial-direction-row button.is-active { border-color: var(--green); color: var(--white); background: var(--green); }
.tutorial-feedback { min-height: 42px; margin: 13px 0 0; color: var(--green); font-size: 13px; line-height: 1.6; }
.tutorial-board-demo { align-content: center; }
.tutorial-board { --tutorial-cell: 42px; display: grid; grid-template-columns: repeat(7, var(--tutorial-cell)); gap: 2px; padding: 2px; background: var(--line); box-shadow: 0 12px 28px rgba(23,32,29,.09); }
.tutorial-board[data-size="5"] { grid-template-columns: repeat(5, var(--tutorial-cell)); }
.tutorial-cell { position: relative; width: var(--tutorial-cell); height: var(--tutorial-cell); display: grid; place-items: center; border: 0; background: var(--white); cursor: pointer; }
.tutorial-cell:hover { background: #eeeade; }
.tutorial-cell.is-target { box-shadow: inset 0 0 0 3px var(--red); }
.tutorial-cell.is-target::after { content: attr(data-label); color: var(--red); font: 700 11px ui-monospace, monospace; }
.tutorial-cell.plane-body { background: var(--green-soft); }
.tutorial-cell.plane-head { background: var(--green); }
.tutorial-cell.plane-head::before { content: ""; width: 9px; height: 9px; border: 2px solid var(--white); transform: rotate(45deg); }
.tutorial-cell.has-result::after { content: none; }
.tutorial-cell.shot-miss { color: #68716c; background: #ecebe6; font: 700 26px/1 ui-monospace, monospace; }
.tutorial-cell.shot-hit { color: var(--hit-dark); background: var(--hit); box-shadow: inset 0 0 0 2px #529b7d; font: 700 26px/1 ui-monospace, monospace; }
.tutorial-cell.shot-head { color: var(--white); background: var(--red); font-size: 18px; }
.tutorial-shot-order { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 22px; }
.tutorial-shot-order span { padding: 10px 6px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: center; }
.tutorial-shot-order b { display: block; margin-bottom: 3px; color: var(--ink); font: 700 13px ui-monospace, monospace; }
.tutorial-shot-order span.is-active { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.tutorial-shot-order span.is-complete { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.tutorial-mode-demo { display: block; min-height: 0; }
.tutorial-mode-demo > div { min-height: 92px; padding: 15px 18px; display: grid; grid-template-columns: 74px 1fr; align-content: center; border-bottom: 1px solid var(--line); }
.tutorial-mode-demo > div:last-child { border-bottom: 0; }
.tutorial-mode-demo b { grid-row: 1 / 3; align-self: center; color: var(--red); font-size: 17px; }
.tutorial-mode-demo strong { font: 700 13px ui-monospace, monospace; }
.tutorial-mode-demo p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.tutorial-navigation { min-height: 66px; display: grid; grid-template-columns: 170px 1fr 170px; gap: 20px; align-items: center; border-top: 1px solid var(--line); }
.tutorial-navigation > span { color: var(--muted); font-size: 12px; text-align: center; }
.tutorial-nav-button { min-height: 44px; border: 1px solid var(--line); background: var(--white); font-size: 13px; font-weight: 700; cursor: pointer; }
.tutorial-nav-button.is-next { border-color: var(--red); color: var(--white); background: var(--red); }
.tutorial-nav-button:disabled { color: #9ca29f; background: #dddcd5; cursor: not-allowed; }

@media (max-width: 980px) {
  .welcome-main { width: min(760px, calc(100% - 32px)); }
  .welcome-hero h1 { font-size: 58px; }
  .welcome-rules article { padding-inline: 14px; }
  .tutorial-shell { width: min(690px, calc(100% - 32px)); }
  .tutorial-stage { min-height: 0; }
  .tutorial-step { grid-template-columns: 1fr; gap: 22px; padding: 28px 0; }
  .tutorial-demo { min-height: 320px; }
}

@media (max-width: 580px) {
  .welcome-header { min-height: 58px; padding-inline: 16px; }
  .welcome-brand-code, .welcome-header-meta { display: none; }
  .welcome-brand strong { font-size: 20px; }
  .welcome-main { width: calc(100% - 28px); min-height: calc(100svh - 58px); padding: 18px 0; gap: 14px; }
  .welcome-logo-stage { width: 138px; height: 104px; margin-bottom: 4px; }
  .welcome-target-ring { inset-inline: 18px; }
  .welcome-target-ring::before { height: 116px; top: -6px; }
  .welcome-target-ring::after { width: 132px; left: -15px; }
  .welcome-plane-logo .model-shape { --shape-cell: 15px; gap: 2px; }
  .welcome-hero h1 { font-size: 49px; }
  .welcome-tagline { margin-top: 7px; font-size: 13px; }
  .welcome-rules { grid-template-columns: 1fr; }
  .welcome-rules article { min-height: 66px; grid-template-columns: 28px 1fr; padding: 9px 10px; border-right: 0; border-bottom: 1px solid #46514c; }
  .welcome-rules article:last-child { border-bottom: 0; }
  .welcome-rules strong { margin-bottom: 2px; font-size: 13px; }
  .welcome-rules p { font-size: 11px; }
  .welcome-actions { grid-template-columns: 1fr; }
  .welcome-action { min-height: 60px; }
  .welcome-footnote { font-size: 10px; }
  .tutorial-header { min-height: 58px; padding-inline: 12px; }
  .tutorial-brand { font-size: 15px; }
  .tutorial-brand > span, #tutorialStepCount { display: none; }
  .tutorial-header-actions { gap: 7px; }
  .tutorial-skip { min-height: 36px; }
  .tutorial-exit { width: 36px; height: 36px; }
  .tutorial-shell { width: calc(100% - 24px); min-height: calc(100svh - 58px); padding: 12px 0 18px; }
  .tutorial-progress span { padding: 10px 3px; font-size: 10px; }
  .tutorial-progress b { display: block; margin: 0 0 3px; }
  .tutorial-step { padding: 22px 0; }
  .tutorial-copy h2 { font-size: 28px; }
  .tutorial-copy > p:not(.tutorial-step-label):not(.tutorial-feedback) { font-size: 14px; }
  .tutorial-demo { min-height: 292px; }
  .tutorial-plane-overview .model-shape { --shape-cell: 19px; }
  .tutorial-marker-list { gap: 9px; }
  .tutorial-marker-list > span { grid-template-columns: 34px auto; column-gap: 6px; }
  .tutorial-marker-list .guide-mark { width: 34px; height: 34px; }
  .tutorial-board { --tutorial-cell: min(42px, calc((100vw - 62px) / 7)); }
  .tutorial-attack-board { --tutorial-cell: min(48px, calc((100vw - 62px) / 5)); }
  .tutorial-mode-demo > div { min-height: 84px; padding-inline: 13px; }
  .tutorial-navigation { position: sticky; bottom: -1px; z-index: 3; min-height: 72px; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--paper); }
  .tutorial-navigation > span { display: none; }
}

@media (min-width: 981px) and (max-height: 740px) {
  .welcome-main { gap: 11px; padding-block: 10px; }
  .welcome-logo-stage { width: 150px; height: 106px; margin-bottom: 2px; }
  .welcome-target-ring { inset-inline: 23px; }
  .welcome-target-ring::before { height: 118px; top: -6px; }
  .welcome-target-ring::after { width: 140px; left: -18px; }
  .welcome-plane-logo .model-shape { --shape-cell: 15px; }
  .welcome-hero h1 { font-size: 54px; }
  .welcome-tagline { margin-top: 6px; }
  .welcome-rules article { padding-block: 10px; }
  .welcome-action { min-height: 60px; }
  .tutorial-stage { min-height: 398px; }
  .tutorial-step { padding-block: 14px; }
  .tutorial-demo { min-height: 310px; }
}

.topbar {
  height: 70px;
  padding: 0 clamp(18px, 4vw, 64px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  color: var(--white);
  background: var(--ink);
  border-bottom: 3px solid var(--gold);
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-family: "Songti SC", "STSong", serif;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  transform: rotate(45deg);
}
.brand-mark::first-letter { transform: rotate(-45deg); }

.mission-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  color: #c9d0cc;
}

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #d05247; box-shadow: 0 0 0 4px rgba(208,82,71,.15); }
.divider { width: 1px; height: 13px; background: #5d6662; }
.icon-button { justify-self: end; width: 44px; height: 44px; border: 1px solid #56605b; background: transparent; color: #e5e6df; font-size: 18px; cursor: pointer; }

.app-shell { width: min(1300px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 92px; }

.briefing {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow, .section-label, .status-kicker {
  margin: 0 0 9px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(30px, 4vw, 48px); font-weight: 700; letter-spacing: 0; }
h2 { margin-bottom: 0; font-family: "Songti SC", "STSong", serif; font-size: 25px; letter-spacing: 0; }

.status-block { width: min(440px, 42%); border-left: 4px solid var(--red); padding-left: 20px; }
.status-block strong { display: block; margin-bottom: 5px; font-size: 18px; }
.status-block p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

.mark-guide { display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 24px; align-items: center; margin-top: 24px; padding: 17px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.32); }
.mark-guide-label { padding-right: 20px; border-right: 1px solid var(--line); color: var(--ink); font: 700 12px ui-monospace, monospace; }
.mark-guide-item { min-width: 0; display: flex; align-items: center; gap: 13px; }
.mark-guide-item > span { min-width: 0; }
.mark-guide-item strong, .mark-guide-item small { display: block; letter-spacing: 0; }
.mark-guide-item strong { margin-bottom: 4px; font-size: 14px; }
.mark-guide-item small { color: var(--muted); font-size: 12px; line-height: 1.45; white-space: normal; }
.guide-mark { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid transparent; font-style: normal; font-weight: 700; }
.guide-mark.miss { color: #68716c; border-color: #c8c8be; background: #ecebe6; font: 700 31px/1 ui-monospace, monospace; }
.guide-mark.hit { color: var(--hit-dark); border-color: #91b29f; background: var(--hit); font: 700 31px/1 ui-monospace, monospace; }
.guide-mark.head { color: var(--white); border-color: #852c27; background: var(--red); font-size: 23px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: clamp(32px, 5vw, 72px); padding-top: 38px; }
.board-panel { min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; min-height: 29px; }
.panel-heading > div { display: flex; align-items: center; gap: 11px; }
.panel-index { padding: 5px 8px; color: var(--white); background: var(--green); font: 700 11px ui-monospace, monospace; }
.panel-index.danger { background: var(--red); }
.panel-index.ally { background: var(--green); }
.coordinates-note, .remaining { color: var(--muted); font: 13px ui-monospace, monospace; }

.board-wrap { position: relative; width: fit-content; max-width: 100%; padding: 22px 0 0 22px; }
.board {
  position: relative;
  display: grid;
  border: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.46);
  box-shadow: var(--shadow);
}
.board[data-size="9"] { grid-template-columns: repeat(9, var(--cell)); grid-template-rows: repeat(9, var(--cell)); width: calc(var(--cell) * 9); height: calc(var(--cell) * 9); }
.board[data-size="12"] { --cell: min(4vw, 43px); grid-template-columns: repeat(12, var(--cell)); grid-template-rows: repeat(12, var(--cell)); width: calc(var(--cell) * 12); height: calc(var(--cell) * 12); }
.board[data-size="15"] { --cell: min(3.2vw, 34px); grid-template-columns: repeat(15, var(--cell)); grid-template-rows: repeat(15, var(--cell)); width: calc(var(--cell) * 15); height: calc(var(--cell) * 15); }

@media (min-width: 981px) {
  .setup-layout .board[data-size="9"] { --cell: min(6.4vw, 64px); }
  .setup-layout .board[data-size="12"] { --cell: min(4.8vw, 48px); }
  .setup-layout .board[data-size="15"] { --cell: min(3.8vw, 38px); }
}

@media (min-width: 981px) {
  .topbar { height: 56px; }
  .app-shell { padding-top: 16px; padding-bottom: 52px; }
  .briefing { align-items: center; padding-bottom: 12px; }
  .briefing h1 { font-size: 36px; }
  .briefing .eyebrow { margin-bottom: 5px; }
  .status-block { width: min(420px, 38%); }
  .status-block strong { font-size: 16px; }
  .status-block p { font-size: 13px; }
  .mark-guide { display: none; }
  .setup-layout {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    grid-template-columns: 500px minmax(0, 1fr);
    gap: clamp(40px, 4vw, 56px);
    padding-top: 16px;
  }
  .setup-layout .board-wrap { margin: 0; }
  .setup-layout .panel-heading { width: min(472px, 100%); margin-right: 0; margin-bottom: 10px; margin-left: 0; }
  .setup-layout .board-wrap { padding-top: 19px; padding-left: 22px; }
  .setup-layout .board[data-size="9"] { --cell: min(50px, calc((100vh - 330px) / 9)); }
  .setup-layout .board[data-size="12"] { --cell: min(37.5px, calc((100vh - 330px) / 12)); }
  .setup-layout .board[data-size="15"] { --cell: min(30px, calc((100vh - 330px) / 15)); }
  .setup-layout .control-panel { padding-left: clamp(28px, 3vw, 40px); }
  .setup-layout .control-section { padding: 2px 0 8px; margin-bottom: 6px; }
  .setup-layout .mode-button { min-height: 56px; }
  .setup-layout .mode-summary { min-height: 30px; margin-top: 8px; font-size: 12px; line-height: 1.5; }
  .setup-layout .model-picker { grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); }
  .setup-layout .model-picker.is-single { grid-template-columns: minmax(180px, 260px); justify-content: center; }
  .setup-layout .model-button { min-height: 46px; padding: 6px 8px; justify-content: center; gap: 8px; font-size: 12px; }
  .setup-layout .model-picker.is-single .model-button { min-height: 54px; justify-content: center; padding-inline: 15px; }
  .setup-layout .model-picker.is-single .model-thumb { --shape-cell: 6px; }
  .setup-layout .fleet-slots { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; }
  .setup-layout .fleet-slot { height: 46px; padding: 3px 5px; flex-direction: column; justify-content: center; gap: 2px; font-size: 12px; }
  .setup-layout .fleet-slot span { white-space: nowrap; }
  .setup-layout .fleet-slot b { font-size: 9px; }
  .setup-layout .direction-button { height: 44px; }
  .setup-layout .silhouette { display: none; }
  .setup-layout .primary-button { min-height: 52px; }
  .setup-layout .text-button { min-height: 40px; padding: 9px; }

}

@media (min-width: 981px) and (max-height: 740px) {
  .app-shell { padding-top: 10px; }
  .briefing { padding-bottom: 8px; }
  .briefing h1 { font-size: 32px; }
  .setup-layout { padding-top: 10px; }
  .setup-layout .model-picker.is-single .model-button { min-height: 46px; }
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.board[data-size="9"] .cell:nth-child(9n), .board[data-size="12"] .cell:nth-child(12n), .board[data-size="15"] .cell:nth-child(15n) { border-right: 0; }
.board[data-size="9"] .cell:nth-last-child(-n+9), .board[data-size="12"] .cell:nth-last-child(-n+12), .board[data-size="15"] .cell:nth-last-child(-n+15) { border-bottom: 0; }
.cell:hover { background: rgba(178, 138, 58, 0.12); }
.cell:disabled { cursor: default; }
.cell::before { content: attr(data-column); position: absolute; top: -20px; left: 50%; transform: translateX(-50%); color: var(--muted); font: 11px ui-monospace, monospace; }
.cell:not([data-row="1"])::before { content: none; }
.cell::after { content: attr(data-row); position: absolute; left: -17px; top: 50%; transform: translateY(-50%); color: var(--muted); font: 11px ui-monospace, monospace; }
.cell:not([data-column="A"])::after { content: none; }

.cell.preview-valid { background: rgba(23, 63, 53, 0.17); }
.cell.preview-invalid { background: rgba(191, 63, 54, 0.16); }
.cell.plane-body { background: var(--green-soft); }
.cell.plane-body::marker { color: var(--green); }
.cell.plane-overlap { background: #b7cbc0; box-shadow: inset 0 0 0 2px rgba(23, 63, 53, 0.34); }
.cell.plane-head { background: var(--green); }
.cell.plane-head span { width: 9px; height: 9px; border: 2px solid var(--white); transform: rotate(45deg); }
.cell.sunken-body { background: #e4c3bd; }
.cell.sunken-body::before { z-index: 3; }
.cell.shot span { z-index: 4; display: grid; place-items: center; width: 100%; height: 100%; transform: none; border: 0; }
.cell.shot-miss { background: rgba(104, 113, 108, 0.08); }
.cell.shot-miss span { color: #7b837f; font: 700 23px/1 ui-monospace, monospace; }
.cell.shot-hit { background: var(--hit); box-shadow: inset 0 0 0 1px #91b29f; }
.cell.shot-hit span { color: var(--hit-dark); font: 700 23px/1 ui-monospace, monospace; }
.cell.shot-head { background: var(--red); box-shadow: inset 0 0 0 2px #852c27; }
.cell.shot-head span { color: var(--white); font: 700 19px/1 serif; }
.cell.shot-head::after { color: #965950; }
.cell.shot-head::before { color: #965950; }
.destroyed-count { position: absolute; z-index: 6; right: 1px; bottom: 1px; min-width: 16px; padding: 1px 2px; color: var(--white); background: var(--ink); font: 700 9px/1.2 ui-monospace, monospace; }

.control-panel { border-left: 1px solid var(--line); padding-left: 32px; }
.control-section { padding: 8px 0 27px; border-bottom: 1px solid var(--line); margin-bottom: 25px; }
.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.mode-button { min-width: 0; min-height: 64px; padding: 9px 5px; border: 1px solid var(--line); background: var(--white); cursor: pointer; }
.mode-button span, .mode-button small { display: block; }
.mode-button span { margin-bottom: 5px; font-size: 15px; font-weight: 700; }
.mode-button small { color: var(--muted); font: 11px ui-monospace, monospace; white-space: nowrap; }
.mode-button.is-active { border-color: var(--green); color: var(--white); background: var(--green); }
.mode-button.is-active small { color: #cbd8d2; }
.mode-summary { min-height: 42px; margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.model-section[hidden] { display: none; }
.model-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.model-button { position: relative; min-width: 0; min-height: 46px; padding: 7px 10px; display: flex; justify-content: flex-start; align-items: center; gap: 8px; overflow: visible; border: 1px solid var(--line); background: var(--white); font-size: 13px; cursor: pointer; }
.model-button.is-active { border-color: var(--red); color: var(--red); background: var(--red-soft); font-weight: 700; }
.model-button-name { min-width: 0; white-space: nowrap; line-height: 1.2; }
.model-shape { --shape-cell: 4px; flex: 0 0 auto; display: grid; grid-template-columns: repeat(var(--shape-cols), var(--shape-cell)); grid-template-rows: repeat(var(--shape-rows), var(--shape-cell)); gap: 1px; }
.model-shape i { display: block; width: var(--shape-cell); height: var(--shape-cell); background: #a9c1b4; }
.model-shape i.is-head { background: var(--red); }
.model-button.is-active .model-thumb i:not(.is-head) { background: #759887; }
.model-hover-card {
  position: absolute;
  z-index: 25;
  left: 50%;
  bottom: calc(100% + 9px);
  width: 142px;
  min-height: 100px;
  padding: 11px 12px 12px;
  display: grid;
  justify-items: center;
  gap: 10px;
  border-top: 3px solid var(--red);
  color: var(--white);
  background: var(--ink);
  box-shadow: 0 14px 30px rgba(23, 32, 29, 0.24);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}
.model-hover-card::after { content: ""; position: absolute; top: 100%; left: 50%; border: 6px solid transparent; border-top-color: var(--ink); transform: translateX(-50%); }
.model-hover-card strong { display: flex; align-items: baseline; gap: 7px; font-size: 13px; }
.model-hover-card em { color: #b9c6c0; font: normal 10px ui-monospace, monospace; }
.model-hover-shape { --shape-cell: 10px; gap: 2px; }
.model-button:hover .model-hover-card, .model-button:focus-visible .model-hover-card { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.model-picker.is-single .model-hover-card { display: none; }
.model-button:last-child .model-hover-card { right: 0; left: auto; transform: translateY(6px); }
.model-button:last-child:hover .model-hover-card, .model-button:last-child:focus-visible .model-hover-card { transform: translateY(0); }
.fleet-slots { display: grid; gap: 9px; }
.fleet-slot { width: 100%; display: flex; align-items: center; justify-content: space-between; height: 46px; padding: 0 13px; border: 1px solid var(--line); background: rgba(255,255,255,.35); font-size: 14px; }
.fleet-slot b { font: 700 11px ui-monospace, monospace; color: var(--muted); }
.fleet-slot.is-deployed { border-color: var(--green); color: var(--green); background: var(--green-soft); cursor: pointer; }
.fleet-slot.is-deployed:hover { box-shadow: inset 0 0 0 1px var(--green); }
.fleet-slot.is-deployed b { color: var(--green); }
.control-title-row { display: flex; justify-content: space-between; align-items: center; }
.direction-name { font-size: 13px; color: var(--muted); }
.direction-tools { display: flex; align-items: center; gap: 13px; }
.keyboard-hint { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.keyboard-hint kbd { min-width: 19px; height: 19px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--white); color: var(--green); font: 700 11px/1 ui-monospace, monospace; }
.direction-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.direction-button { height: 50px; border: 1px solid var(--line); background: var(--white); font-size: 24px; cursor: pointer; }
.direction-button:hover { border-color: var(--green); }
.direction-button.is-active { color: var(--white); border-color: var(--green); background: var(--green); }

.silhouette { padding: 4px 0 25px; }
.silhouette p { margin: 16px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.model-preview { display: grid; gap: 2px; width: fit-content; margin: 0 auto; }
.model-preview i { display: block; width: 18px; height: 18px; background: var(--green-soft); }
.model-preview i.is-head { background: var(--red); }

.primary-button { width: 100%; min-height: 56px; display: flex; justify-content: center; align-items: center; gap: 12px; border: 0; color: var(--white); background: var(--red); font-size: 15px; font-weight: 700; cursor: pointer; }
.primary-button:hover { background: #a8342d; }
.primary-button:disabled { cursor: not-allowed; color: #929995; background: #d5d5ce; }
.text-button { width: 100%; min-height: 48px; padding: 13px; border: 0; background: transparent; color: var(--green); font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }

.battle-view { padding-top: 26px; }
.battle-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 18px; color: var(--white); background: var(--green); font: 13px ui-monospace, monospace; }
.turn-indicator, .battle-stats { display: flex; align-items: center; gap: 10px; }
.turn-lamp { width: 7px; height: 7px; border-radius: 50%; background: #f0c95f; box-shadow: 0 0 0 4px rgba(240,201,95,.15); }
.battle-stats { gap: 24px; color: #cbd5d0; }
.battle-stats strong { color: var(--white); }
.battle-toolbar-actions { display: flex; align-items: stretch; align-self: stretch; }
.battle-menu-button { min-width: 82px; margin-left: 18px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-left: 1px solid rgba(255,255,255,.22); color: var(--white); background: rgba(255,255,255,.08); font: 12px ui-monospace, monospace; cursor: pointer; }
.battle-menu-button:hover { background: rgba(255,255,255,.16); }
.battle-menu-button span:first-child { font-size: 18px; }
.battle-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(24px, 4vw, 54px); padding-top: 26px; }
.battle-grid .board[data-size="9"] { --cell: min(4.45vw, 51px); }
.battle-grid .board[data-size="12"] { --cell: min(3.45vw, 40px); }
.battle-grid .board[data-size="15"] { --cell: min(2.78vw, 32px); }
.battle-board .board-wrap { margin: 0 auto; }
.board-enemy .cell:not(:disabled):hover { background: rgba(191, 63, 54, 0.13); box-shadow: inset 0 0 0 2px var(--red); }
.mobile-tabs { display: none; }
.combat-log { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 28px; padding: 12px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.log-label { padding: 5px 8px; color: var(--white); background: var(--red); font: 700 11px ui-monospace, monospace; }
.combat-round-log { width: 100%; min-width: 0; display: grid; }
.combat-log-row { min-width: 0; min-height: 34px; display: grid; grid-template-columns: 42px 28px minmax(0, 1fr); align-items: center; gap: 10px; }
.combat-log-row + .combat-log-row { border-top: 1px solid rgba(49, 90, 99, 0.1); }
.combat-actor { font-size: 11px; font-weight: 900; }
.combat-actor.is-player { color: var(--red); }
.combat-actor.is-enemy { color: var(--green); }
.combat-log p { min-width: 0; margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); writing-mode: horizontal-tb; overflow-wrap: break-word; }
.combat-mark { width: 28px; height: 28px; display: grid; place-items: center; font-style: normal; font-weight: 700; }
.combat-mark.is-empty { visibility: hidden; }
.combat-mark.miss { color: #68716c; border: 1px solid var(--line); background: #ecebe6; font: 700 20px/1 ui-monospace, monospace; }
.combat-mark.hit { color: var(--hit-dark); border: 1px solid #529b7d; background: var(--hit); font: 700 20px/1 ui-monospace, monospace; }
.combat-mark.head { color: var(--white); border: 1px solid #852c27; background: var(--red); font-size: 15px; }

.legend-bar { min-height: 58px; position: fixed; z-index: 10; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 34px; padding: 8px 20px; color: #d4d8d5; background: var(--ink); font-size: 12px; }
.legend-bar > span { display: inline-flex; align-items: center; gap: 7px; }
.legend-mark { width: 21px; height: 21px; display: inline-grid; place-items: center; font-style: normal; font: 700 17px/1 ui-monospace, monospace; }
.legend-mark.miss { color: #9ca29f; background: #323c38; }
.legend-mark.hit { color: var(--hit-dark); background: var(--hit); }
.legend-mark.head { color: var(--white); background: var(--red); }
.rules-button { position: absolute; right: 28px; min-height: 40px; border: 0; background: transparent; color: #d4d8d5; font-size: 12px; cursor: pointer; }
.rules-button span { display: inline-grid; width: 18px; height: 18px; place-items: center; margin-left: 5px; border: 1px solid #68706c; border-radius: 50%; }

.result-overlay { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: 24px; overflow-y: auto; background: rgba(16, 25, 22, 0.78); }
.result-panel { width: min(540px, 100%); padding: 34px; border-top: 4px solid var(--red); background: var(--white); box-shadow: 0 28px 80px rgba(0,0,0,.3); }
.result-heading { display: grid; grid-template-columns: 72px 1fr; gap: 22px; align-items: center; text-align: left; }
.result-heading .result-seal { width: 66px; height: 66px; margin: 0; }
.result-heading .eyebrow { margin-bottom: 6px; }
.result-heading h2 { margin: 0 0 7px; font-size: 29px; }
.result-heading p:last-child { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.result-actions { display: grid; gap: 12px; }
.next-mission-label { margin-top: 5px; color: var(--muted); font: 700 11px ui-monospace, monospace; text-transform: uppercase; }
.next-mode-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.next-mode-button { position: relative; min-width: 0; min-height: 72px; padding: 12px 38px 12px 14px; border: 1px solid var(--line); background: var(--paper); text-align: left; cursor: pointer; }
.next-mode-button:hover { border-color: var(--green); background: var(--green-soft); }
.next-mode-button span, .next-mode-button small { display: block; }
.next-mode-button span { margin-bottom: 5px; font-size: 14px; font-weight: 700; }
.next-mode-button small { color: var(--muted); font: 11px ui-monospace, monospace; white-space: nowrap; }
.next-mode-button b { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--red); font-size: 17px; }

.dialog { width: min(430px, calc(100% - 32px)); padding: 38px; border: 0; color: var(--ink); background: var(--white); box-shadow: 0 28px 80px rgba(0,0,0,.28); text-align: center; }
.dialog::backdrop { background: rgba(16, 25, 22, 0.72); }
.dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  font-size: 0;
  line-height: 0;
  cursor: pointer;
}

.dialog-close::before,
.dialog-close::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
}

.dialog-close::before { transform: rotate(45deg); }
.dialog-close::after { transform: rotate(-45deg); }
.result-seal { width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 22px; border: 2px solid var(--red); color: var(--red); font-family: "Songti SC", serif; font-size: 34px; transform: rotate(-4deg); }
.dialog h2 { margin-bottom: 12px; font-size: 29px; }
.dialog > p:not(.eyebrow) { color: var(--muted); font-size: 14px; line-height: 1.7; }
.battle-menu-dialog { text-align: left; }
.battle-menu-actions { display: grid; gap: 8px; margin-top: 25px; }
.dialog-action { min-height: 62px; padding: 10px 15px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); background: var(--paper); text-align: left; cursor: pointer; }
.dialog-action:hover { border-color: var(--green); background: var(--green-soft); }
.dialog-action span { flex: 0 0 auto; font-size: 14px; font-weight: 700; }
.dialog-action small { color: var(--muted); font-size: 12px; line-height: 1.45; text-align: right; }
.dialog-action.is-primary { border-color: var(--green); color: var(--white); background: var(--green); }
.dialog-action.is-primary small { color: #d5e0da; }
.dialog-action.is-danger { color: var(--red); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 24px 0; border: 1px solid var(--line); }
.result-stats span { padding: 15px 5px; border-right: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.result-stats span:last-child { border: 0; }
.result-stats strong { display: block; margin-bottom: 3px; color: var(--ink); font: 700 18px ui-monospace, monospace; }
.rules-dialog { text-align: left; }
.rules-dialog ol { margin: 24px 0 28px; padding: 0; list-style: none; counter-reset: rules; }
.rules-dialog li { position: relative; padding: 0 0 20px 38px; counter-increment: rules; }
.rules-dialog li::before { content: "0" counter(rules); position: absolute; left: 0; top: 1px; color: var(--red); font: 700 12px ui-monospace, monospace; }
.rules-dialog li strong { display: block; margin-bottom: 5px; font-size: 15px; }
.rules-dialog li span { display: block; color: var(--muted); font-size: 13px; line-height: 1.65; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 78px; transform: translate(-50%, 20px); padding: 12px 18px; color: var(--white); background: var(--ink); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 981px) {
  .battle-view { padding-top: 12px; }
  .battle-toolbar { min-height: 48px; }
  .battle-grid { gap: 48px; padding-top: 14px; }
  .battle-grid .panel-heading { margin-bottom: 10px; }
  .battle-grid .board-wrap { padding-top: 19px; padding-left: 22px; }
  .battle-grid .board[data-size="9"] { --cell: min(45px, calc((100vh - 430px) / 9)); }
  .battle-grid .board[data-size="12"] { --cell: min(33px, calc((100vh - 430px) / 12)); }
  .battle-grid .board[data-size="15"] { --cell: min(26px, calc((100vh - 430px) / 15)); }
  .combat-log { margin-top: 12px; padding: 12px 16px; }
  .legend-bar { min-height: 52px; }
}

@media (max-width: 980px) {
  :root { --cell: min(8.5vw, 57px); }
  .app-shell { width: min(670px, calc(100% - 32px)); }
  .game-layout { grid-template-columns: 1fr; }
  .board-wrap { margin: 0 auto; }
  .control-panel { border-left: 0; border-top: 1px solid var(--line); padding: 25px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
  .control-section { margin: 0; }
  .silhouette { display: none; }
  .control-panel .primary-button, .control-panel .text-button { align-self: end; }
  .mark-guide { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .mark-guide-label { grid-column: 1 / -1; padding: 0 0 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .battle-grid { display: block; }
  .battle-grid .board[data-size="9"] { --cell: min(8.3vw, 53px); }
  .battle-grid .board[data-size="12"] { --cell: min(6.2vw, 40px); }
  .battle-grid .board[data-size="15"] { --cell: min(4.95vw, 32px); }
  .battle-board { display: none; }
  .battle-board.is-mobile-active { display: block; }
  .mobile-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; border-bottom: 1px solid var(--line); }
  .mobile-tab { padding: 12px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
  .mobile-tab.is-active { border-color: var(--red); color: var(--ink); font-weight: 700; }
}

@media (max-width: 580px) {
  :root { --cell: calc((100vw - 58px) / 9); }
  .topbar { grid-template-columns: 1fr auto; height: 60px; padding: 0 16px; }
  .brand { font-size: 22px; }
  .brand-mark { width: 31px; height: 31px; }
  .icon-button { width: 42px; height: 42px; }
  .mission-meta { display: none; }
  .app-shell { width: calc(100% - 24px); padding-top: 25px; padding-bottom: 92px; }
  .briefing { display: block; padding-bottom: 20px; }
  h1 { font-size: 31px; }
  .status-block { width: 100%; margin-top: 18px; }
  .mark-guide { gap: 8px; padding: 12px 8px; }
  .mark-guide-item { display: grid; justify-items: center; gap: 6px; text-align: center; }
  .mark-guide-item strong { font-size: 11px; }
  .mark-guide-item small { font-size: 11px; line-height: 1.45; }
  .guide-mark { width: 34px; height: 34px; }
  .game-layout { padding-top: 22px; gap: 24px; }
  .coordinates-note { display: none; }
  .board-wrap { padding-top: 19px; padding-left: 19px; }
  .board[data-size="9"], .battle-grid .board[data-size="9"] { --cell: calc((100vw - 58px) / 9); }
  .board[data-size="12"], .battle-grid .board[data-size="12"] { --cell: calc((100vw - 58px) / 12); }
  .board[data-size="15"], .battle-grid .board[data-size="15"] { --cell: calc((100vw - 58px) / 15); }
  .cell::before { top: -17px; }
  .cell::after { left: -15px; }
  .control-panel { grid-template-columns: 1fr; padding-top: 19px; }
  .keyboard-hint { display: none; }
  .model-picker.is-single { grid-template-columns: 1fr; }
  .model-picker.is-single .model-button { min-height: 64px; justify-content: center; }
  .model-picker.is-single .model-thumb { --shape-cell: 7px; }
  .fleet-slots { grid-template-columns: repeat(2, 1fr); }
  .fleet-slot { padding: 0 10px; font-size: 13px; }
  .battle-toolbar { min-height: 50px; padding: 0 10px; font-size: 12px; }
  .battle-stats { gap: 10px; }
  .battle-menu-button { min-width: 48px; margin-left: 9px; padding: 0 10px; }
  .battle-menu-button span:last-child { display: none; }
  .legend-bar { justify-content: flex-start; gap: 14px; overflow: hidden; }
  .rules-button { margin-left: auto; position: static; white-space: nowrap; }
  .rules-button { font-size: 0; }
  .mobile-tab { min-height: 48px; font-size: 14px; }
  .combat-log { grid-template-columns: auto minmax(0, 1fr); gap: 8px; padding-inline: 10px; }
  .combat-log-row { grid-template-columns: 34px 24px minmax(0, 1fr); gap: 6px; }
  .combat-actor { font-size: 10px; }
  .combat-log p { font-size: 12px; }
  .combat-mark { width: 24px; height: 24px; }
  .legend-bar > span { font-size: 0; }
  .dialog { padding: 34px 24px 26px; }
  .dialog-action { align-items: flex-start; flex-direction: column; gap: 3px; }
  .dialog-action small { text-align: left; }
  .result-overlay { padding: 16px; }
  .result-panel { padding: 27px 20px 20px; }
  .result-heading { grid-template-columns: 58px 1fr; gap: 14px; }
  .result-heading .result-seal { width: 54px; height: 54px; font-size: 28px; }
  .result-heading h2 { font-size: 24px; }
  .result-heading p:last-child { font-size: 13px; }
  .next-mode-actions { grid-template-columns: 1fr; }
}

@media (hover: none) {
  .keyboard-hint { display: none; }
  .model-hover-card { display: none; }
  .model-thumb { --shape-cell: 6px; }
}

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

/* 2026 pastel airspace redesign */
:root {
  --ink: #284f58;
  --muted: #617a80;
  --paper: #e8f3f1;
  --paper-deep: #d4e8e4;
  --white: #fffdf8;
  --green: #438b83;
  --green-soft: #d8ece6;
  --red: #d96f6a;
  --red-soft: #f6d9d4;
  --gold: #e7b85e;
  --hit: #9fd8bd;
  --hit-dark: #1f6e57;
  --line: #b8d2cf;
  --sky: #dcefeb;
  --lavender: #d9d8ed;
  --shadow: 0 22px 48px rgba(52, 102, 103, 0.15);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  color-scheme: light;
}

body {
  position: relative;
  min-height: 100dvh;
  background: var(--paper);
  background-image: none;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  opacity: 0.65;
}

body::before {
  width: 180px;
  height: 420px;
  top: 18vh;
  left: -110px;
  background: #f3c9c4;
  transform: rotate(28deg);
}

body::after {
  width: 260px;
  height: 180px;
  right: -120px;
  bottom: 12vh;
  background: #d8d8ec;
  transform: rotate(-18deg);
}

button {
  border-radius: 6px;
  letter-spacing: 0;
  transition: transform 0.16s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

button:active { transform: scale(0.98); }
button:focus-visible { outline: 3px solid rgba(217, 111, 106, 0.42); outline-offset: 3px; }
h1, h2, .brand, .welcome-brand strong, .tutorial-brand { font-family: inherit; }

.welcome-view {
  color: var(--ink);
  background: var(--sky);
  background-image: none;
}

.welcome-view::before,
.welcome-view::after {
  content: "";
  position: fixed;
  pointer-events: none;
}

.welcome-view::before {
  width: 320px;
  height: 140px;
  left: -70px;
  bottom: 4vh;
  background: #f2c6c0;
  clip-path: polygon(0 35%, 70% 0, 100% 55%, 35% 100%);
}

.welcome-view::after {
  width: 260px;
  height: 210px;
  right: -70px;
  top: 13vh;
  background: #d6d5e9;
  clip-path: polygon(30% 0, 100% 20%, 78% 100%, 0 70%);
}

.welcome-header {
  position: relative;
  z-index: 2;
  min-height: 68px;
  border-bottom: 1px solid rgba(40, 79, 88, 0.18);
  color: var(--ink);
}

.welcome-brand-code { color: var(--red); font-family: inherit; font-size: 12px; }
.welcome-brand strong { font-size: 22px; }
.welcome-header-meta { color: var(--muted); font-family: inherit; font-size: 13px; }
.welcome-header-meta span { background: var(--gold); box-shadow: 0 0 0 4px rgba(231, 184, 94, 0.2); }
.welcome-main { position: relative; z-index: 1; width: min(1180px, calc(100% - 48px)); min-height: calc(100dvh - 68px); padding: 28px 0 24px; gap: 20px; }
.welcome-hero { grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.1fr); align-items: center; justify-items: stretch; text-align: left; }
.welcome-copy { max-width: 520px; padding-left: clamp(8px, 3vw, 42px); }
.welcome-eyebrow { margin-bottom: 12px; color: var(--red); font-family: inherit; font-size: 14px; font-weight: 700; }
.welcome-hero h1 { color: var(--ink); font-size: clamp(56px, 7vw, 86px); font-weight: 800; line-height: 1.04; }
.welcome-tagline { max-width: 500px; margin-top: 18px; color: var(--muted); font-size: 17px; line-height: 1.75; }
.welcome-logo-stage { position: relative; width: 100%; height: 330px; margin: 0; }
.welcome-plane-platform {
  position: absolute;
  z-index: 3;
  width: 252px;
  height: 252px;
  left: 50%;
  top: 44%;
  display: grid;
  place-items: center;
  background: var(--white);
  box-shadow: 18px 18px 0 #9dcfc7, 35px 35px 0 #eba49d, var(--shadow);
  transform: translate(-50%, -50%) rotate(30deg) skewY(-11deg) scaleY(0.82);
}
.welcome-plane-logo { padding: 18px; background: transparent; transform: skewY(11deg) rotate(-30deg) scaleY(1.22); }
.welcome-plane-logo .model-shape { --shape-cell: 21px; gap: 4px; }
.welcome-plane-logo .model-shape i { border-radius: 2px; background: #7eb7ac; }
.welcome-plane-logo .model-shape i.is-head { background: var(--red); }
.sky-step { position: absolute; z-index: 1; display: block; background: var(--gold); box-shadow: 12px 12px 0 rgba(40, 79, 88, 0.12); }
.sky-step.step-one { width: 72px; height: 72px; left: 9%; top: 26%; transform: rotate(30deg) skewY(-11deg) scaleY(0.82); }
.sky-step.step-two { width: 54px; height: 116px; right: 8%; bottom: 12%; background: #a7d5ce; transform: rotate(-18deg); }
.sky-arch { position: absolute; z-index: 2; width: 86px; height: 126px; right: 17%; top: 5%; border: 18px solid #f1b0a9; border-bottom: 0; border-radius: 48px 48px 0 0; }
.welcome-rules { border-color: rgba(40, 79, 88, 0.2); }
.welcome-rules article { border-color: rgba(40, 79, 88, 0.2); }
.welcome-rule-index { color: var(--red); font-family: inherit; font-size: 12px; font-weight: 800; }
.welcome-rules strong { color: var(--ink); font-size: 16px; }
.welcome-rules p { color: var(--muted); font-size: 13px; }
.welcome-actions { grid-template-columns: repeat(2, minmax(0, 320px)); }
.welcome-action { min-height: 72px; border-color: rgba(40, 79, 88, 0.35); color: var(--ink); background: rgba(255, 253, 248, 0.58); box-shadow: 0 10px 24px rgba(52, 102, 103, 0.08); }
.welcome-action small { color: var(--muted); }
.welcome-action.is-start { border-color: var(--red); color: var(--white); background: var(--red); }
.welcome-action.is-start small { color: #fff1ee; }
.welcome-action:hover { border-color: var(--ink); box-shadow: 0 13px 28px rgba(52, 102, 103, 0.14); transform: translateY(-2px); }
.welcome-action.is-start:hover { background: #c85f5b; }
.welcome-footnote { color: var(--muted); font-family: inherit; font-size: 12px; }

.tutorial-view { background: #edf6f4; }
.tutorial-header { min-height: 68px; color: var(--ink); background: var(--white); border-bottom: 1px solid var(--line); }
.tutorial-brand > span { border-color: var(--red); color: var(--red); border-radius: 4px; }
.tutorial-header-actions { color: var(--muted); font-family: inherit; font-size: 12px; }
.tutorial-skip, .tutorial-exit { border-color: var(--line); color: var(--ink); background: var(--paper); }
.tutorial-shell { width: min(1220px, calc(100% - 48px)); min-height: calc(100dvh - 68px); }
.tutorial-progress { grid-template-columns: repeat(7, 1fr); border-color: var(--line); }
.tutorial-progress span { color: var(--muted); }
.tutorial-progress b { color: #8da5a5; font-family: inherit; }
.tutorial-progress span.is-active::after { background: var(--red); }
.tutorial-progress span.is-complete, .tutorial-progress span.is-complete b { color: var(--green); }
.tutorial-stage { min-height: 480px; }
.tutorial-step { grid-template-columns: minmax(260px, 0.78fr) minmax(460px, 1.22fr); gap: clamp(34px, 6vw, 82px); padding: 30px; }
.tutorial-step-wide { grid-template-columns: minmax(240px, 0.55fr) minmax(580px, 1.45fr); }
.tutorial-step-label { color: var(--red); font-family: inherit; font-size: 13px; }
.tutorial-copy h2 { color: var(--ink); font-size: 34px; line-height: 1.25; }
.tutorial-demo { min-height: 350px; border: 1px solid rgba(67, 139, 131, 0.28); border-radius: 8px; background: rgba(255, 253, 248, 0.76); box-shadow: 12px 12px 0 rgba(157, 207, 199, 0.58); }
.tutorial-callout { border-left-color: var(--red); }
.tutorial-plane-overview .model-shape i, .tutorial-direction-shape i, .tutorial-starter-shape i { border-radius: 2px; background: #86bdb2; }
.tutorial-plane-overview .model-shape i.is-head, .tutorial-direction-shape i.is-head, .tutorial-starter-shape i.is-head { background: var(--red); }
.tutorial-mode-picker-demo { align-content: center; padding: 34px; }
.tutorial-mode-switch { width: 100%; }
.tutorial-mode-feedback { width: 100%; margin: 22px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; text-align: center; }
.tutorial-game-screen { display: block; padding: 0; overflow: hidden; }
.tutorial-screen-bar { min-height: 52px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; color: var(--white); background: var(--green); }
.tutorial-screen-bar span { font-size: 12px; }
.tutorial-screen-grid { min-height: 296px; padding: 22px; display: grid; grid-template-columns: auto minmax(150px, 1fr); gap: 26px; align-items: center; }
.tutorial-screen-controls { align-self: stretch; padding-left: 20px; display: grid; align-content: center; gap: 14px; border-left: 1px solid var(--line); }
.tutorial-screen-controls .section-label { margin: 0; }
.tutorial-starter-preview { display: grid; place-items: center; min-height: 70px; }
.tutorial-starter-shape { --shape-cell: 10px; gap: 2px; }
.tutorial-mini-fleet { display: grid; gap: 6px; }
.tutorial-mini-fleet span { padding: 8px 10px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: 11px; }
.tutorial-mini-fleet span.is-ready { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.tutorial-screen-controls > button { min-height: 38px; border: 0; color: var(--muted); background: #d6dfdd; }
.tutorial-direction-demo { align-content: center; gap: 26px; }
.tutorial-model-choice { min-width: 160px; padding: 10px 14px; display: flex; justify-content: space-between; border: 1px solid var(--line); background: var(--paper); }
.tutorial-model-choice small { color: var(--muted); }
.tutorial-plane-direction { min-width: 220px; min-height: 170px; display: grid; place-items: center; }
.tutorial-direction-shape { --shape-cell: 22px; gap: 3px; }
.tutorial-direction-demo > p { margin: 0; color: var(--muted); font-size: 13px; }
.tutorial-direction-row button { border-color: var(--line); background: var(--white); }
.tutorial-direction-row button.is-active { border-color: var(--red); color: var(--white); background: var(--red); }
.tutorial-board { border: 1px solid var(--line); border-radius: 4px; background: var(--line); box-shadow: 8px 8px 0 rgba(217, 111, 106, 0.22); overflow: hidden; }
.tutorial-cell { background: var(--white); }
.tutorial-cell.is-target { box-shadow: inset 0 0 0 3px var(--red); animation: target-breathe 1.5s ease-in-out infinite; }
.tutorial-cell.plane-body { background: var(--green-soft); }
.tutorial-cell.plane-head { background: var(--red); }
.tutorial-battle-screen { display: block; padding: 0; overflow: hidden; }
.tutorial-battle-toolbar { min-height: 50px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; color: var(--white); background: var(--green); }
.tutorial-battle-toolbar div { display: flex; gap: 6px; }
.tutorial-battle-toolbar button { min-height: 32px; padding: 0 12px; border: 1px solid rgba(255,255,255,.45); color: var(--white); background: rgba(255,255,255,.12); }
.tutorial-battle-boards { padding: 20px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.tutorial-battle-boards > div { width: min(100%, 240px); display: grid; gap: 10px; justify-self: center; }
.tutorial-battle-boards strong { font-size: 13px; }
.tutorial-mini-board { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); }
.tutorial-mini-board i { aspect-ratio: 1; display: grid; place-items: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--white); font-style: normal; }
.tutorial-mini-board i:nth-child(5n) { border-right: 0; }
.tutorial-mini-board i:nth-last-child(-n+5) { border-bottom: 0; }
.tutorial-mini-board i.plane { background: var(--green-soft); }
.tutorial-mini-board i.hit { color: var(--hit-dark); background: var(--hit); font-size: 22px; }
.tutorial-combat-message { margin: 0 20px 20px; padding-top: 14px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.tutorial-combat-message .guide-mark { width: 30px; height: 30px; font-size: 21px; }
.tutorial-reasoning { min-height: 132px; margin-top: 18px; padding: 15px 17px; border-left: 4px solid var(--gold); background: rgba(255,253,248,.68); }
.tutorial-reasoning > span { display: block; margin-bottom: 7px; color: var(--red); font-size: 11px; font-weight: 800; }
.tutorial-reasoning strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: 14px; line-height: 1.45; }
.tutorial-reasoning p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.tutorial-reasoning[data-reasoning-stage="1"] { border-left-color: #91a8a7; }
.tutorial-reasoning[data-reasoning-stage="2"] { border-left-color: var(--green); background: rgba(216,236,230,.62); }
.tutorial-reasoning[data-reasoning-stage="3"] { border-left-color: var(--red); background: rgba(246,217,212,.56); }
.tutorial-inference-layout { width: 100%; padding: 26px; display: grid; grid-template-columns: auto minmax(150px, 1fr); gap: 30px; align-items: center; }
.tutorial-model-reference { min-height: 250px; padding-left: 26px; display: grid; align-content: center; justify-items: center; gap: 12px; border-left: 1px solid var(--line); text-align: center; }
.tutorial-model-reference > span { color: var(--red); font-size: 12px; font-weight: 800; }
.tutorial-model-reference strong { color: var(--ink); font-size: 14px; }
.tutorial-model-reference small { max-width: 190px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.tutorial-attack-model { min-height: 100px; display: grid; place-items: center; }
.tutorial-attack-shape { --shape-cell: 17px; gap: 3px; }
.tutorial-attack-shape i { border-radius: 2px; background: #86bdb2; }
.tutorial-attack-shape i.is-head { background: var(--red); }
.tutorial-victory-demo { padding: 30px; align-content: center; gap: 22px; }
.tutorial-victory-count { display: grid; justify-items: center; gap: 4px; }
.tutorial-victory-count span { color: var(--muted); font-size: 12px; }
.tutorial-victory-count strong { color: var(--green); font-size: 46px; line-height: 1; }
.tutorial-downed-list { width: min(420px, 100%); display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tutorial-downed-list > span { min-height: 72px; padding: 12px; display: grid; grid-template-columns: 34px 1fr; grid-template-rows: 1fr 1fr; align-items: center; border: 1px solid #e2aaa4; border-radius: 6px; background: var(--red-soft); }
.tutorial-downed-list i { grid-row: 1 / 3; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 4px; color: var(--white); background: var(--red); font-style: normal; }
.tutorial-downed-list b { align-self: end; font-size: 13px; }
.tutorial-downed-list small { align-self: start; color: var(--red); font-size: 11px; }
.tutorial-victory-banner { width: min(420px, 100%); padding-top: 16px; display: grid; justify-items: center; gap: 4px; border-top: 1px solid var(--line); }
.tutorial-victory-banner strong { color: var(--red); font-size: 22px; }
.tutorial-victory-banner span { color: var(--muted); font-size: 12px; }
.tutorial-navigation { border-color: var(--line); }
.tutorial-nav-button { border-color: var(--line); background: var(--white); }
.tutorial-nav-button.is-next { border-color: var(--red); background: var(--red); }

.topbar { height: 68px; color: var(--ink); background: rgba(255, 253, 248, 0.92); border-bottom: 1px solid var(--line); }
.brand { font-size: 23px; }
.brand-mark { border: 0; border-radius: 6px; color: var(--white); background: var(--red); transform: rotate(45deg); }
.mission-meta { color: var(--muted); font-family: inherit; }
.live-dot { background: var(--gold); box-shadow: 0 0 0 4px rgba(231, 184, 94, 0.2); }
.divider { background: var(--line); }
.icon-button { border-color: var(--line); color: var(--ink); background: var(--paper); }
.app-shell { width: min(1320px, calc(100% - 48px)); }
.briefing { border-color: var(--line); }
.eyebrow, .section-label, .status-kicker { color: var(--red); font-family: inherit; text-transform: none; }
h1 { font-size: clamp(32px, 4vw, 48px); }
.status-block { border-left-color: var(--gold); }
.mark-guide { border-color: var(--line); border-radius: 6px; background: rgba(255,253,248,.58); }
.mark-guide-label { border-color: var(--line); font-family: inherit; }
.guide-mark { border-radius: 4px; }
.guide-mark.miss { color: #708486; border-color: var(--line); background: #e4eeec; }
.guide-mark.hit { border-color: #529b7d; background: var(--hit); }
.guide-mark.head { border-color: #c65d58; background: var(--red); }
.panel-index { border-radius: 4px; background: var(--green); font-family: inherit; }
.panel-index.danger { background: var(--red); }
.board { border: 1px solid #7aa49f; border-radius: 4px; background: var(--white); box-shadow: 9px 9px 0 #a9d6cf, 16px 16px 0 #efb5ae, 0 26px 48px rgba(52,102,103,.14); overflow: hidden; }
.cell { border-color: var(--line); background: rgba(255,253,248,.75); }
.cell:hover { background: rgba(231,184,94,.2); }
.cell.preview-valid { background: rgba(67,139,131,.22); }
.cell.preview-invalid { background: rgba(217,111,106,.18); }
.cell.plane-body { background: var(--green-soft); }
.cell.plane-overlap { background: #acd5ca; box-shadow: inset 0 0 0 2px rgba(47,117,103,.28); }
.cell.plane-head { background: var(--red); }
.cell.shot-miss { background: #e4eeec; }
.cell.shot-hit { background: var(--hit); box-shadow: inset 0 0 0 2px #529b7d; }
.cell.shot-head { background: var(--red); box-shadow: inset 0 0 0 2px #bb5753; }
.control-panel { padding: 22px; border: 1px solid rgba(67,139,131,.24); border-radius: 8px; background: rgba(255,253,248,.7); box-shadow: var(--shadow); }
.control-section { border-color: var(--line); }
.mode-button, .model-button, .fleet-slot, .direction-button { border-color: var(--line); background: var(--white); }
.mode-button.is-active, .direction-button.is-active { border-color: var(--green); background: var(--green); }
.model-button.is-active { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.model-picker.is-single { grid-template-columns: minmax(180px, 260px); justify-content: center; }
.model-picker.is-single .model-button { justify-content: center; }
.model-shape i { border-radius: 1px; background: #91beb5; }
.model-shape i.is-head { background: var(--red); }
.model-hover-card { border-top-color: var(--red); border-radius: 6px; color: var(--ink); background: var(--white); box-shadow: var(--shadow); }
.model-hover-card::after { border-top-color: var(--white); }
.model-hover-card em { color: var(--muted); }
.fleet-slot { background: rgba(255,253,248,.8); }
.fleet-slot.is-deployed { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.keyboard-hint kbd { border-color: var(--line); border-radius: 3px; background: var(--white); color: var(--green); }
.model-preview i { border-radius: 2px; background: var(--green-soft); }
.model-preview i.is-head { background: var(--red); }
.primary-button { border-radius: 6px; background: var(--red); }
.primary-button:hover { background: #c85f5b; }
.primary-button:disabled { color: #81918f; background: #d4dfdd; }
.text-button { color: var(--green); }
.random-button {
  width: 100%;
  min-height: 50px;
  margin-top: 10px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 1px solid #6eaea0;
  border-radius: 6px;
  color: #2b7167;
  background: #dff0eb;
  cursor: pointer;
  box-shadow: 0 7px 16px rgba(52, 102, 103, 0.09);
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.random-button-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--green);
  font-size: 20px;
  line-height: 1;
}
.random-button strong { justify-self: center; font-size: 16px; letter-spacing: .04em; }
.random-button small {
  padding: 3px 7px;
  border: 1px solid rgba(67,139,131,.34);
  border-radius: 3px;
  color: var(--green);
  background: rgba(255,253,248,.68);
  font-size: 11px;
  font-weight: 700;
}
.random-button:hover { border-color: var(--green); background: #d2eae3; box-shadow: 0 9px 20px rgba(52,102,103,.14); transform: translateY(-1px); }
.random-button:active { transform: translateY(1px); }
.battle-toolbar { border-radius: 6px; color: var(--white); background: var(--green); box-shadow: 0 10px 24px rgba(52,102,103,.14); }
.turn-lamp { background: var(--gold); box-shadow: 0 0 0 4px rgba(231,184,94,.2); }
.battle-menu-button { border-radius: 0; }
.battle-models-button { margin-left: 18px; }
.battle-toolbar-actions .battle-menu-button + .battle-menu-button { margin-left: 0; }
.board-enemy .cell:not(:disabled):hover { background: rgba(217,111,106,.16); box-shadow: inset 0 0 0 2px var(--red); }
.mobile-tab.is-active { border-color: var(--red); color: var(--ink); }
.combat-log { border-color: var(--line); border-radius: 6px; background: rgba(255,253,248,.62); }
.log-label { border-radius: 4px; background: var(--red); font-family: inherit; }
.legend-bar { color: var(--ink); background: rgba(255,253,248,.96); border-top: 1px solid var(--line); box-shadow: 0 -10px 28px rgba(52,102,103,.08); }
.legend-mark { border-radius: 3px; }
.legend-mark.miss { color: #708486; background: #e4eeec; }
.legend-mark.hit { background: var(--hit); }
.legend-mark.head { background: var(--red); }
.rules-button { color: var(--ink); }
.rules-button span { border-color: var(--line); }
.result-overlay { background: rgba(40,79,88,.56); }
.result-panel, .dialog { border: 1px solid rgba(67,139,131,.25); border-radius: 8px; background: var(--white); box-shadow: 0 28px 80px rgba(40,79,88,.28); }
.result-panel { border-top: 6px solid var(--red); }
.result-seal { border-color: var(--red); border-radius: 6px; color: var(--red); font-family: inherit; }
.dialog::backdrop { background: rgba(40,79,88,.58); }
.dialog-action, .next-mode-button { border-color: var(--line); border-radius: 6px; background: var(--paper); }
.dialog-action.is-primary { border-color: var(--green); background: var(--green); }
.next-mission-label { font-family: inherit; text-transform: none; }
.rules-dialog li::before { color: var(--red); font-family: inherit; }
.toast { border-radius: 6px; background: var(--ink); }
.models-dialog { width: min(560px, calc(100% - 32px)); text-align: left; }
.battle-model-list { margin-top: 22px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.battle-model-item { min-height: 104px; padding: 14px; display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.battle-model-shape { --shape-cell: 10px; gap: 2px; justify-self: center; }
.battle-model-item strong, .battle-model-item small { display: block; }
.battle-model-item strong { margin-bottom: 5px; }
.battle-model-item small { color: var(--muted); font-size: 11px; line-height: 1.5; }

@keyframes target-breathe {
  0%, 100% { box-shadow: inset 0 0 0 3px var(--red); }
  50% { box-shadow: inset 0 0 0 5px rgba(217,111,106,.52); }
}

@media (min-width: 981px) {
  .setup-layout { grid-template-columns: minmax(470px, 0.9fr) minmax(430px, 1.1fr); }
  .setup-layout .control-panel { padding: 20px 24px; }
  .tutorial-inference-step { grid-template-columns: minmax(360px, .72fr) minmax(620px, 1.28fr); gap: clamp(34px, 4vw, 56px); }
}

@media (min-width: 981px) and (max-height: 780px) {
  .tutorial-shell { padding-top: 14px; padding-bottom: 14px; }
  .tutorial-stage { min-height: 410px; }
  .tutorial-step, .tutorial-step-wide { padding-top: 16px; padding-bottom: 16px; }
  .tutorial-demo { min-height: 308px; }
  .tutorial-navigation { min-height: 58px; }
}

@media (max-width: 980px) {
  .welcome-hero { grid-template-columns: 1fr; text-align: center; }
  .welcome-copy { max-width: 640px; margin: 0 auto; padding-left: 0; }
  .welcome-logo-stage { height: 270px; }
  .tutorial-progress { display: flex; overflow-x: auto; scrollbar-width: none; }
  .tutorial-progress span { flex: 0 0 120px; }
  .tutorial-step, .tutorial-step-wide { grid-template-columns: 1fr; }
  .tutorial-screen-grid { grid-template-columns: auto minmax(170px, 1fr); }
  .control-panel { border: 1px solid rgba(67,139,131,.24); padding: 22px; }
}

@media (max-width: 580px) {
  .welcome-view::before { width: 190px; height: 90px; }
  .welcome-view::after { width: 160px; height: 130px; }
  .welcome-header { min-height: 58px; }
  .welcome-main { width: calc(100% - 28px); min-height: calc(100dvh - 58px); }
  .welcome-hero h1 { font-size: 50px; }
  .welcome-tagline { font-size: 14px; }
  .welcome-logo-stage { height: 210px; }
  .welcome-plane-platform { width: 164px; height: 164px; box-shadow: 12px 12px 0 #9dcfc7, 23px 23px 0 #eba49d, var(--shadow); }
  .welcome-plane-logo .model-shape { --shape-cell: 14px; gap: 2px; }
  .sky-step.step-one { width: 48px; height: 48px; }
  .sky-step.step-two { width: 38px; height: 76px; }
  .sky-arch { width: 55px; height: 78px; border-width: 12px; }
  .welcome-rules article { border-color: rgba(40,79,88,.2); }
  .welcome-actions { grid-template-columns: 1fr; }
  .tutorial-shell { width: calc(100% - 24px); }
  .tutorial-step, .tutorial-step-wide { padding-inline: 0; }
  .tutorial-demo { min-height: 300px; box-shadow: 7px 7px 0 rgba(157,207,199,.58); }
  .tutorial-screen-grid { padding: 14px; grid-template-columns: 1fr; gap: 18px; }
  .tutorial-screen-controls { padding: 14px 0 0; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-left: 0; }
  .tutorial-screen-controls .section-label, .tutorial-starter-preview { display: none; }
  .tutorial-screen-controls > button { grid-column: 1 / -1; }
  .tutorial-battle-boards { gap: 10px; padding: 14px; }
  .tutorial-battle-boards > div,
  .tutorial-mini-board { width: 100%; min-width: 0; }
  .tutorial-combat-message { margin-inline: 14px; }
  .tutorial-direction-shape { --shape-cell: 18px; }
  .tutorial-inference-layout { padding: 18px; gap: 18px; }
  .tutorial-model-reference { min-height: 210px; padding-left: 18px; }
  .app-shell { width: calc(100% - 24px); }
  .control-panel { padding: 16px; }
  .model-picker.is-single { grid-template-columns: 1fr; }
  .tutorial-inference-layout { grid-template-columns: 1fr; }
  .tutorial-model-reference { min-height: 0; padding: 18px 0 0; grid-template-columns: 90px 1fr; grid-template-rows: auto auto; justify-items: start; border-top: 1px solid var(--line); border-left: 0; text-align: left; }
  .tutorial-model-reference > span { grid-column: 1 / -1; }
  .tutorial-attack-model { grid-row: 2 / 4; min-height: 90px; }
  .tutorial-model-reference strong { align-self: end; }
  .tutorial-model-reference small { align-self: start; }
  .tutorial-victory-demo { padding: 24px 16px; }
  .tutorial-downed-list { grid-template-columns: 1fr; }
  .battle-stats span:last-child { display: none; }
  .battle-models-button, .battle-menu-button { min-width: 44px; margin-left: 4px; }
  .battle-models-button span:last-child, .battle-menu-button span:last-child { display: none; }
  .battle-model-list { grid-template-columns: 1fr; }
  .battle-model-item { grid-template-columns: 100px 1fr; }
  body.battle-active .app-shell { padding-top: 12px; }
  body.battle-active .briefing,
  body.battle-active .mark-guide { display: none; }
  body.battle-active .battle-view { padding-top: 0; }
  body.battle-active .mobile-tabs { margin-top: 10px; }
  body.battle-active .battle-grid { padding-top: 12px; }
  body.battle-active .battle-grid .panel-heading { margin-bottom: 10px; }
  body.battle-active .combat-log { margin-top: 18px; }
}

@media (prefers-reduced-motion: no-preference) {
  .welcome-plane-platform { animation: platform-float 5s ease-in-out infinite; }
  @keyframes platform-float {
    0%, 100% { transform: translate(-50%, -50%) rotate(30deg) skewY(-11deg) scaleY(.82); }
    50% { transform: translate(-50%, calc(-50% - 8px)) rotate(30deg) skewY(-11deg) scaleY(.82); }
  }
}

/* Miniature airport art direction: 24px scenes, 16px controls, 8px grid cells. */
:root {
  --ink: #315a63;
  --muted: #688188;
  --paper: #eef7f4;
  --paper-deep: #d8ebe4;
  --white: #fffaf0;
  --green: #4b947e;
  --green-soft: #d8eee3;
  --red: #dc776d;
  --red-soft: #f8ded7;
  --gold: #efc66d;
  --hit: #a9dfc3;
  --hit-dark: #28745d;
  --line: #b9d6d1;
  --sky: #d4eceb;
  --lavender: #c2c1df;
  --runway: #709193;
  --shadow: 0 22px 50px rgba(49, 90, 99, 0.14);
  --soft-shadow: 0 12px 26px rgba(49, 90, 99, 0.1);
}

body {
  background: var(--sky);
}

body::before {
  width: 76vw;
  height: 42vh;
  top: auto;
  bottom: -27vh;
  left: -11vw;
  border-radius: 50% 50% 0 0;
  background: #9fcdb4;
  transform: rotate(2deg);
}

body::after {
  width: 48vw;
  height: 30vh;
  right: -12vw;
  bottom: -19vh;
  border-radius: 55% 45% 0 0;
  background: #efc66d;
  transform: rotate(-4deg);
  opacity: 0.42;
}

button { border-radius: 16px; }

.welcome-view {
  background: #d4eceb;
  isolation: isolate;
}

.welcome-view::before {
  z-index: -1;
  width: 78vw;
  height: 42vh;
  left: -14vw;
  bottom: -25vh;
  border-radius: 50% 50% 0 0;
  background: #9fcdb4;
  clip-path: none;
}

.welcome-view::after {
  z-index: -1;
  width: 62vw;
  height: 36vh;
  right: -18vw;
  top: auto;
  bottom: -23vh;
  border-radius: 50% 50% 0 0;
  background: #f0c86f;
  clip-path: none;
  opacity: 0.55;
}

.welcome-header {
  width: min(1380px, calc(100% - 48px));
  min-height: 72px;
  margin: 0 auto;
  padding: 0;
  border: 0;
}

.welcome-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.welcome-logo-badge {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 250, 240, 0.72);
  border-radius: 17px 17px 17px 7px;
  background: var(--red);
  box-shadow: 0 8px 18px rgba(173, 84, 79, 0.2);
  transform: rotate(-5deg);
}

.welcome-logo-badge .welcome-plane-logo {
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  transform: rotate(5deg);
}

.welcome-logo-badge .model-shape {
  --shape-cell: 4px;
  gap: 1px;
}

.welcome-logo-badge .model-shape i,
.welcome-logo-badge .model-shape i.is-head {
  border-radius: 1px;
  background: var(--white);
}

.welcome-brand strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
}

.welcome-main {
  width: min(1380px, calc(100% - 48px));
  min-height: calc(100dvh - 72px);
  padding: 0 0 18px;
  align-content: stretch;
  grid-template-rows: minmax(360px, 1fr) auto auto;
  gap: 12px;
}

.welcome-hero {
  position: relative;
  min-height: 360px;
  display: block;
  overflow: hidden;
  border-radius: 30px 30px 70px 30px;
  background: rgba(255, 250, 240, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 250, 240, 0.48);
  text-align: left;
}

.welcome-copy {
  position: absolute;
  z-index: 4;
  left: clamp(30px, 5vw, 72px);
  top: clamp(30px, 7vh, 68px);
  max-width: 430px;
  padding: 0;
  pointer-events: none;
}

.welcome-terminal {
  width: max-content;
  margin: 0 0 10px;
  padding: 7px 12px;
  border-radius: 12px 12px 12px 4px;
  color: var(--ink);
  background: var(--gold);
  box-shadow: 0 7px 0 rgba(49, 90, 99, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.welcome-hero h1 {
  color: var(--ink);
  font-size: clamp(62px, 7vw, 96px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 5px 0 rgba(255, 250, 240, 0.68);
}

.welcome-airport-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#airportSceneCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
  contain: layout paint;
  will-change: transform;
  transform: translate3d(clamp(68px, calc(68px + (100vw - 580px) * 0.08), 130px), 0, 0);
}

.runway-sign {
  position: absolute;
  z-index: 3;
  min-width: 42px;
  padding: 8px 10px;
  border: 3px solid var(--white);
  border-radius: 12px 12px 12px 4px;
  color: var(--white);
  background: var(--runway);
  box-shadow: 0 8px 0 rgba(49, 90, 99, 0.12);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.runway-sign.sign-left { left: 28%; bottom: 10%; transform: rotate(-5deg); }
.runway-sign.sign-right { right: 7%; top: 12%; color: var(--ink); background: var(--gold); transform: rotate(4deg); }

.welcome-flight-plan {
  min-height: 68px;
  padding: 10px 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 20px;
  border: 1px solid rgba(49, 90, 99, 0.12);
  border-radius: 24px 24px 24px 9px;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--soft-shadow);
}

.flight-plan-label {
  padding: 8px 11px;
  border-radius: 12px 12px 12px 4px;
  color: var(--white);
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.welcome-flight-plan ol {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  list-style: none;
}

.welcome-flight-plan li {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink);
}

.welcome-flight-plan li:not(:last-child)::after {
  content: "";
  position: absolute;
  width: 36%;
  height: 3px;
  right: -18%;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--line) 0 7px, transparent 7px 13px);
}

.welcome-flight-plan b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--gold);
  font-size: 12px;
}

.welcome-flight-plan strong { font-size: 14px; }

.welcome-actions {
  grid-template-columns: repeat(2, minmax(0, 300px));
  gap: 12px;
}

.welcome-action {
  min-height: 64px;
  padding: 0 22px;
  border: 0;
  border-radius: 20px 20px 20px 8px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--soft-shadow);
}

.welcome-action strong { margin: 0; font-size: 18px; }
.welcome-action b { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--paper-deep); font-size: 18px; }
.welcome-action.is-start { color: var(--white); background: var(--red); box-shadow: 0 14px 24px rgba(176, 83, 77, 0.24); }
.welcome-action.is-start b { color: var(--red); background: var(--white); }
.welcome-action:hover { border-color: transparent; transform: translateY(-2px) rotate(-0.5deg); }
.welcome-action.is-start:hover { background: #ca675f; }

.player-feedback {
  color: var(--ink);
  border-top: 1px solid rgba(49, 90, 99, 0.16);
}
.player-feedback p { min-width: 0; margin: 0; }
.player-feedback p strong,
.player-feedback p span { display: block; }
.player-feedback p strong { margin-bottom: 3px; font-size: 13px; }
.player-feedback p span { color: var(--muted); font-size: 11px; line-height: 1.55; }
.welcome-feedback {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 10px 4px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}
.feedback-contact { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.feedback-contact a {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.feedback-contact button {
  min-height: 29px;
  padding: 0 10px;
  border: 1px solid rgba(67, 139, 131, 0.26);
  border-radius: 11px 11px 11px 4px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.48);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.feedback-contact button:hover { color: var(--white); background: var(--green); }
.feedback-contact button:active { transform: translateY(1px); }


.topbar {
  height: 72px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.92);
  border: 0;
  border-radius: 0 0 26px 26px;
  box-shadow: 0 10px 30px rgba(49, 90, 99, 0.1);
  backdrop-filter: blur(16px);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 250, 240, 0.74);
  border-radius: 15px 15px 15px 6px;
  color: var(--white);
  background: var(--red);
  box-shadow: 0 7px 16px rgba(176, 83, 77, 0.2);
  transform: rotate(-5deg);
  font-size: 0;
}

.brand-mark .model-shape,
.tutorial-brand > span .model-shape {
  --shape-cell: 4px;
  gap: 1px;
  transform: rotate(5deg);
}
.brand-mark .model-shape i,
.brand-mark .model-shape i.is-head,
.tutorial-brand > span .model-shape i,
.tutorial-brand > span .model-shape i.is-head { border-radius: 1px; background: var(--white); }
.mission-meta { color: var(--muted); }
.icon-button { border: 0; border-radius: 15px; color: var(--ink); background: var(--paper-deep); }

.app-shell { width: min(1360px, calc(100% - 48px)); }

.briefing {
  padding: 22px 26px;
  align-items: center;
  border: 0;
  border-radius: 26px 26px 26px 10px;
  background: rgba(255, 250, 240, 0.78);
  box-shadow: var(--soft-shadow);
}

.status-block {
  padding: 14px 18px;
  border: 0;
  border-radius: 18px 18px 18px 7px;
  background: var(--green-soft);
}

.mark-guide {
  padding: 14px 18px;
  border: 0;
  border-radius: 22px 22px 22px 9px;
  background: rgba(255, 250, 240, 0.72);
  box-shadow: var(--soft-shadow);
}

.mark-guide-label { border-color: var(--line); }
.guide-mark { border-radius: 13px 13px 13px 5px; }

.panel-index,
.log-label { border-radius: 11px 11px 11px 4px; }

.board {
  gap: 3px;
  padding: 7px;
  border: 0;
  border-radius: 26px 26px 26px 10px;
  background: #9abfbc;
  box-shadow: 11px 12px 0 #83bea8, 20px 22px 0 #efaaa1, 0 30px 54px rgba(49, 90, 99, 0.16);
}

.cell {
  border: 0;
  border-radius: 8px 8px 8px 3px;
  background: rgba(255, 250, 240, 0.95);
}

.cell:hover { background: #ffe9ae; transform: translateY(-1px); }
.cell.plane-body { background: #c8e6dc; box-shadow: inset 0 -4px 0 rgba(75, 148, 126, 0.12); }
.cell.plane-head { background: var(--red); box-shadow: inset 0 -4px 0 rgba(151, 67, 62, 0.22); }
.cell.shot-miss { background: #e3eeee; }
.cell.shot-hit { background: var(--hit); box-shadow: inset 0 -4px 0 rgba(40, 116, 93, 0.18); }
.cell.shot-head { background: var(--red); }

.control-panel {
  padding: 24px;
  border: 0;
  border-radius: 28px 28px 28px 11px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: var(--shadow);
}

.control-section { border-color: rgba(49, 90, 99, 0.14); }
.mode-button,
.model-button,
.fleet-slot,
.direction-button,
.random-button,
.primary-button,
.text-button {
  border-radius: 16px 16px 16px 6px;
}

.mode-button,
.model-button,
.fleet-slot,
.direction-button { border-color: rgba(49, 90, 99, 0.18); }
.mode-button.is-active,
.direction-button.is-active { box-shadow: inset 0 -5px 0 rgba(38, 93, 80, 0.22); }
.model-button.is-active { box-shadow: inset 0 -4px 0 rgba(185, 85, 78, 0.12); }
.random-button { border: 0; background: var(--green-soft); box-shadow: inset 0 -5px 0 rgba(75, 148, 126, 0.1), var(--soft-shadow); }
.primary-button { box-shadow: inset 0 -5px 0 rgba(151, 67, 62, 0.18), 0 10px 20px rgba(176, 83, 77, 0.18); }

.battle-toolbar {
  border-radius: 19px 19px 19px 7px;
  background: var(--green);
  box-shadow: inset 0 -5px 0 rgba(38, 93, 80, 0.16), var(--soft-shadow);
}

.combat-log,
.dialog,
.result-panel {
  border: 0;
  border-radius: 26px 26px 26px 10px;
  background: var(--white);
}

.dialog-action,
.next-mode-button,
.battle-model-item { border-radius: 16px 16px 16px 6px; }
.legend-bar { border: 0; border-radius: 24px 24px 0 0; background: rgba(255, 250, 240, 0.95); }

.tutorial-view { background: var(--sky); }
.tutorial-header {
  border: 0;
  border-radius: 0 0 24px 24px;
  box-shadow: var(--soft-shadow);
}
.tutorial-brand > span,
.tutorial-skip,
.tutorial-exit { border-radius: 13px 13px 13px 5px; }
.tutorial-brand > span {
  border: 3px solid rgba(255, 250, 240, 0.74);
  color: var(--white);
  background: var(--red);
  box-shadow: 0 7px 16px rgba(176, 83, 77, 0.18);
  transform: rotate(-5deg);
}
.tutorial-progress {
  margin-top: 12px;
  padding: 4px;
  border: 0;
  border-radius: 18px 18px 18px 7px;
  background: rgba(255, 250, 240, 0.72);
}
.tutorial-progress span { border-radius: 13px 13px 13px 5px; }
.tutorial-progress span.is-active { background: var(--white); box-shadow: var(--soft-shadow); }
.tutorial-progress span::after { display: none; }
.tutorial-demo {
  border: 0;
  border-radius: 26px 26px 26px 10px;
  background: rgba(255, 250, 240, 0.86);
  box-shadow: 10px 11px 0 #99cbb7, 18px 19px 0 #efaaa1, var(--shadow);
}
.tutorial-board { gap: 3px; padding: 6px; border: 0; border-radius: 20px 20px 20px 8px; background: #9abfbc; }
.tutorial-cell { border-radius: 7px 7px 7px 3px; background: var(--white); }
.tutorial-callout,
.tutorial-reasoning { border: 0; border-radius: 18px 18px 18px 7px; background: rgba(255, 250, 240, 0.7); box-shadow: inset 5px 0 0 var(--red); }
.tutorial-navigation { border: 0; }
.tutorial-nav-button { border: 0; border-radius: 16px 16px 16px 6px; box-shadow: var(--soft-shadow); }
.tutorial-nav-button.is-next { box-shadow: inset 0 -5px 0 rgba(151, 67, 62, 0.18), var(--soft-shadow); }

@media (max-width: 980px) {
  .welcome-main { width: min(760px, calc(100% - 32px)); }
  .welcome-hero { min-height: 410px; }
  .welcome-copy { left: 32px; top: 28px; }
  .welcome-airport-scene { inset: 22px -80px -24px 0; }
  .control-panel { border: 0; padding: 22px; }
}

@media (max-width: 580px) {
  .welcome-header { width: calc(100% - 28px); min-height: 62px; }
  .welcome-logo-badge { width: 40px; height: 40px; border-radius: 14px 14px 14px 5px; }
  .welcome-brand strong { display: block; font-size: 15px; }
  .welcome-main {
    width: calc(100% - 24px);
    min-height: calc(100dvh - 62px);
    padding: 0 0 12px;
    grid-template-rows: minmax(316px, 1fr) auto auto;
    gap: 9px;
  }
  .welcome-hero { min-height: 316px; border-radius: 22px 22px 48px 22px; }
  .welcome-copy { left: 20px; top: 20px; }
  .welcome-terminal { margin-bottom: 7px; padding: 5px 9px; font-size: 10px; }
  .welcome-hero h1 { font-size: 52px; }
  .welcome-airport-scene { inset: 45px -96px -34px -42px; }
  .runway-sign { min-width: 34px; padding: 5px 7px; border-width: 2px; font-size: 10px; }
  .runway-sign.sign-left { left: 14%; bottom: 7%; }
  .runway-sign.sign-right { right: 3%; top: 8%; }
  .welcome-flight-plan { min-height: 62px; padding: 8px 7px; grid-template-columns: 1fr; border-radius: 18px 18px 18px 7px; }
  .flight-plan-label { display: none; }
  .welcome-flight-plan li { gap: 5px; }
  .welcome-flight-plan li:not(:last-child)::after { width: 22%; right: -11%; }
  .welcome-flight-plan b { width: 24px; height: 24px; font-size: 10px; }
  .welcome-flight-plan strong { font-size: 11px; }
  .welcome-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .welcome-action { min-width: 0; min-height: 56px; padding: 0 13px; border-radius: 17px 17px 17px 6px; }
  .welcome-action strong { font-size: 15px; white-space: nowrap; }
  .welcome-action b { width: 29px; height: 29px; font-size: 15px; }
  .welcome-feedback { padding-top: 8px; align-items: flex-start; flex-direction: column; gap: 7px; }
  .welcome-feedback p span { font-size: 10px; }
  .feedback-contact { width: 100%; justify-content: space-between; }

  .topbar { height: 64px; border-radius: 0 0 20px 20px; }
  .brand-mark { width: 38px; height: 38px; }
  .app-shell { width: calc(100% - 20px); padding-top: 18px; }
  .briefing { padding: 18px; border-radius: 22px 22px 22px 8px; }
  .mark-guide { border-radius: 18px 18px 18px 7px; }
  .board { gap: 2px; padding: 5px; border-radius: 20px 20px 20px 8px; box-shadow: 8px 9px 0 #83bea8, 14px 15px 0 #efaaa1, 0 20px 36px rgba(49, 90, 99, 0.15); }
  .cell { border-radius: 5px 5px 5px 2px; }
  .control-panel { padding: 16px; border-radius: 22px 22px 22px 8px; }
  .tutorial-progress { margin-top: 8px; }
  .tutorial-demo { box-shadow: 7px 8px 0 #99cbb7, 12px 13px 0 #efaaa1, var(--soft-shadow); }
}

@media (min-width: 981px) and (max-height: 760px) {
  .welcome-main { gap: 9px; padding-bottom: 10px; }
  .welcome-hero { min-height: 312px; }
  .welcome-copy { top: 28px; }
  .welcome-hero h1 { font-size: 72px; }
  .welcome-flight-plan { min-height: 58px; padding-block: 7px; }
  .welcome-action { min-height: 58px; }
  .welcome-feedback { padding-top: 7px; }
  .welcome-feedback p span { display: block; font-size: 10px; }
}

/* Viewport-fit and guided tutorial refinements */
.welcome-main {
  min-height: auto;
  grid-template-rows: auto auto auto;
  align-content: start;
}

.welcome-hero {
  height: clamp(330px, 55dvh, 560px);
}

body:not(.battle-active):not(.intro-active) > .legend-bar {
  position: relative;
  right: auto;
  bottom: auto;
  left: auto;
  margin-top: 28px;
}

body:not(.battle-active) .app-shell { padding-bottom: 28px; }
body.battle-active .app-shell { padding-bottom: 92px; }

.tutorial-step-label {
  font-size: 14px;
  line-height: 1.4;
}

.tutorial-step-wide .tutorial-copy h2 { font-size: 30px; }

.tutorial-action-list {
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
}

.tutorial-action-list li {
  min-height: 48px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(67, 139, 131, 0.18);
  border-radius: 14px 14px 14px 5px;
  background: rgba(255, 253, 248, 0.58);
}

.tutorial-action-list li > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.tutorial-action-list p,
.tutorial-action-list strong,
.tutorial-action-list small { margin: 0; display: block; }
.tutorial-action-list strong { color: var(--ink); font-size: 13px; }
.tutorial-action-list small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.tutorial-action-list.is-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tutorial-action-list li.is-current { border-color: var(--red); background: var(--red-soft); }
.tutorial-action-list li.is-current > span { background: var(--red); }
.tutorial-action-list li.is-complete { border-color: rgba(67, 139, 131, 0.45); background: var(--green-soft); }
.tutorial-action-list li.is-complete > span::before { content: "✓"; }
.tutorial-action-list li.is-complete > span { font-size: 0; }
.tutorial-action-list li.is-complete > span::before { font-size: 13px; }

.tutorial-tip {
  margin: 12px 0 0 !important;
  padding: 10px 12px;
  border-radius: 12px 12px 12px 4px;
  color: var(--muted) !important;
  background: rgba(231, 184, 94, 0.18);
  font-size: 12px !important;
  line-height: 1.55 !important;
}

.tutorial-tip strong {
  margin-right: 5px;
  color: var(--ink);
}

.tutorial-screen-controls > button.is-ready {
  color: var(--white);
  background: var(--red);
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(151, 67, 62, 0.18);
}

.tutorial-screen-controls > button.is-ready:hover { background: #c85f5b; }

@media (max-width: 980px) {
  .welcome-hero { height: clamp(360px, 50dvh, 430px); }
}

@media (max-width: 580px) {
  .welcome-main { min-height: auto; }
  .welcome-hero { height: 316px; min-height: 316px; }
  .tutorial-action-list.is-compact { grid-template-columns: 1fr; }
  .tutorial-action-list { margin-top: 14px; }
  .tutorial-action-list li { min-height: 44px; }
  .tutorial-step-wide .tutorial-copy h2 { font-size: 28px; }
}

@media (min-width: 981px) and (max-height: 760px) {
  .welcome-hero { height: 330px; }
  .tutorial-action-list { margin-top: 12px; gap: 6px; }
  .tutorial-action-list li { min-height: 42px; padding-block: 6px; }
  .tutorial-tip { margin-top: 8px !important; padding-block: 7px; }
}

/* Interaction and layout refinements */
.welcome-main {
  min-height: calc(100dvh - 72px);
  padding-bottom: 24px;
  grid-template-rows: minmax(340px, 1fr) auto auto;
  align-content: stretch;
}

.welcome-hero {
  height: auto;
  min-height: 340px;
}

.welcome-airport-scene { inset: -16px -26px 12px 0; }
.welcome-actions { margin: 10px 0 4px; }

.tutorial-step[data-tutorial-step="0"] {
  grid-template-columns: minmax(250px, 0.68fr) minmax(500px, 1.32fr);
}

.tutorial-step[data-tutorial-step="0"] .tutorial-copy { max-width: 430px; }
.tutorial-objective-demo { min-height: 320px; }

.tutorial-tip {
  color: var(--muted) !important;
  background: rgba(231, 184, 94, 0.18);
  box-shadow: inset 4px 0 0 var(--gold);
}

.tutorial-tip strong { color: var(--ink); }

.tutorial-screen-controls { gap: 10px; }

.tutorial-random-deploy {
  min-height: 40px !important;
  color: var(--white) !important;
  background: var(--red) !important;
  box-shadow: inset 0 -4px 0 rgba(151, 67, 62, 0.2);
  cursor: pointer !important;
  font-weight: 800;
}

.tutorial-random-deploy:hover { background: #c85f5b !important; }
.tutorial-random-deploy.is-complete { color: var(--red) !important; background: var(--red-soft) !important; box-shadow: none; }

.tutorial-step[data-tutorial-step="3"] .tutorial-copy { max-width: 500px; }
.tutorial-step[data-tutorial-step="3"] .tutorial-direction-row { max-width: 470px; margin-top: 26px; }

.tutorial-battle-screen { position: relative; }

.tutorial-battle-toolbar button[aria-expanded="true"] {
  border-color: var(--white);
  color: var(--red);
  background: var(--white);
}

.tutorial-toolbar-popover {
  position: absolute;
  z-index: 5;
  top: 58px;
  right: 18px;
  width: 190px;
  padding: 14px;
  border: 1px solid rgba(67, 139, 131, 0.26);
  border-radius: 16px 16px 16px 6px;
  color: var(--ink);
  background-color: var(--white);
  box-shadow: 0 18px 38px rgba(40, 79, 88, 0.22);
}

.tutorial-model-popover {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background-image:
    linear-gradient(rgba(184, 210, 207, 0.38) 1px, transparent 1px),
    linear-gradient(90deg, rgba(184, 210, 207, 0.38) 1px, transparent 1px);
  background-size: 24px 24px;
}

.tutorial-model-popover[hidden],
.tutorial-settings-popover[hidden],
.battle-model-popover[hidden] { display: none; }

.tutorial-model-popover strong {
  padding: 4px 9px;
  border-radius: 9px 9px 9px 3px;
  color: var(--white);
  background: var(--green);
  font-size: 13px;
}

.tutorial-battle-model-preview { --shape-cell: 13px; gap: 2px; }
.tutorial-battle-model-preview i { border-radius: 2px; background: #86bdb2; }
.tutorial-battle-model-preview i.is-head { background: var(--red); }

.tutorial-settings-popover { display: grid; gap: 7px; }
.tutorial-settings-popover button {
  min-height: 38px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--paper);
  font-size: 12px;
  font-weight: 700;
}
.tutorial-settings-popover button:first-child { color: var(--white); border-color: var(--green); background: var(--green); }

.tutorial-victory-step .tutorial-copy { max-width: 470px; }
.tutorial-victory-step .tutorial-copy h2 { margin-bottom: 0; font-size: 40px; line-height: 1.25; }

.random-button { grid-template-columns: 30px 1fr 30px; }
.random-button::after { content: ""; width: 28px; height: 1px; }

.battle-models-control {
  position: relative;
  display: flex;
  align-self: stretch;
  margin-left: 18px;
}

.battle-models-control .battle-models-button {
  height: 100%;
  margin-left: 0;
}

#battleMenuButton { margin-left: 0; }

.battle-model-popover {
  position: absolute;
  z-index: 25;
  top: calc(100% + 10px);
  right: 0;
  width: min(420px, calc(100vw - 40px));
  padding: 10px;
  border: 1px solid rgba(67, 139, 131, 0.26);
  border-radius: 18px 18px 18px 7px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 20px 46px rgba(40, 79, 88, 0.25);
}

.battle-model-popover.is-single { width: 220px; }

.battle-model-popover::before {
  content: "";
  position: absolute;
  right: 28px;
  bottom: 100%;
  border: 8px solid transparent;
  border-bottom-color: var(--white);
}

.battle-model-list {
  margin-top: 0;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.battle-model-item {
  min-height: 142px;
  padding: 12px 8px;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: center;
  gap: 9px;
  border: 0;
  text-align: center;
  background: rgba(232, 243, 241, 0.42);
}

.battle-model-board {
  --preview-cell: 12px;
  display: grid;
  grid-template-columns: repeat(var(--preview-cols), var(--preview-cell));
  grid-template-rows: repeat(var(--preview-rows), var(--preview-cell));
  gap: 2px;
  padding: 4px;
  border-radius: 10px 10px 10px 4px;
  background: #b7d2cf;
}

.battle-model-board i {
  width: var(--preview-cell);
  height: var(--preview-cell);
  border-radius: 3px 3px 3px 1px;
  background: rgba(255, 250, 240, 0.96);
}

.battle-model-board i.is-plane { background: #bfe3d6; }
.battle-model-board i.is-head { background: var(--red); }
.battle-model-popover.is-single .battle-model-board { --preview-cell: 20px; }
.battle-model-item strong { margin: 0; font-size: 14px; }

.battle-menu-dialog { text-align: center; }
.dialog-action { justify-content: center; text-align: center; }
.dialog-action span { font-size: 15px; }

body.battle-active .combat-log { margin-top: 38px; }

/* Grid gaps are part of the board footprint, so the rounded frame never clips
   the last column or row. */
.board {
  --board-gap: 3px;
  --board-padding: 7px;
  gap: var(--board-gap);
  padding: var(--board-padding);
}

.board[data-size="9"] {
  width: calc(var(--cell) * 9 + var(--board-gap) * 8 + var(--board-padding) * 2);
  height: calc(var(--cell) * 9 + var(--board-gap) * 8 + var(--board-padding) * 2);
}

.board[data-size="12"] {
  width: calc(var(--cell) * 12 + var(--board-gap) * 11 + var(--board-padding) * 2);
  height: calc(var(--cell) * 12 + var(--board-gap) * 11 + var(--board-padding) * 2);
}

.board[data-size="15"] {
  width: calc(var(--cell) * 15 + var(--board-gap) * 14 + var(--board-padding) * 2);
  height: calc(var(--cell) * 15 + var(--board-gap) * 14 + var(--board-padding) * 2);
}

.mode-summary.is-tip-list {
  min-height: 0;
  display: grid;
  gap: 5px;
}

.mode-summary.is-tip-list span {
  min-height: 27px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 10px 10px 10px 4px;
  color: var(--ink);
  background: rgba(216, 236, 230, 0.72);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.mode-summary.is-tip-list b {
  flex: 0 0 auto;
  min-width: 42px;
  color: var(--red);
  font-size: 10px;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .welcome-main {
    width: calc(100% - 32px);
    min-height: calc(100dvh - 68px);
    grid-template-rows: minmax(360px, 1fr) auto auto;
  }
  .welcome-airport-scene { inset: -16px -26px 12px 0; }
  .tutorial-step[data-tutorial-step="0"] { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  .welcome-main {
    width: calc(100% - 32px);
    min-height: calc(100dvh - 62px);
    grid-template-rows: minmax(316px, 1fr) auto auto;
    padding-bottom: 12px;
  }
  .welcome-hero { min-height: 316px; }
  .welcome-airport-scene {
    top: clamp(-16px, calc(45px - (100vw - 390px) * 0.321), 45px);
    right: clamp(-26px, calc(0px - (100vw - 390px) * 0.137), 0px);
    bottom: clamp(-34px, calc(-34px + (100vw - 390px) * 0.242), 12px);
    left: clamp(-42px, calc(-42px + (100vw - 390px) * 0.221), 0px);
  }
  #airportSceneCanvas {
    transform: translate3d(clamp(18px, calc(18px + (100vw - 390px) * 0.263), 68px), 0, 0);
  }
  .welcome-actions { margin-top: 2px; }
  .tutorial-screen-controls { grid-template-columns: 1fr 1fr; }
  .tutorial-random-deploy { grid-column: 1 / -1; }
  .tutorial-toolbar-popover { top: 54px; right: 12px; width: min(190px, calc(100% - 24px)); }
  .tutorial-victory-step .tutorial-copy h2 { font-size: 32px; }
  .battle-models-control { margin-left: 4px; }
  .battle-model-popover { right: -48px; width: min(320px, calc(100vw - 32px)); }
  .battle-model-popover.is-single { width: 210px; }
  .battle-model-list { grid-template-columns: 1fr; }
  .battle-model-item { min-height: 132px; }
  .board {
    --board-gap: 2px;
    --board-padding: 5px;
  }
  .board[data-size="9"],
  .battle-grid .board[data-size="9"] { --cell: calc((100vw - 84px) / 9); }
  .board[data-size="12"],
  .battle-grid .board[data-size="12"] { --cell: calc((100vw - 90px) / 12); }
  .board[data-size="15"],
  .battle-grid .board[data-size="15"] { --cell: calc((100vw - 96px) / 15); }
  body.battle-active .combat-log { margin-top: 32px; }
}

@media (min-width: 981px) and (max-height: 760px) {
  .welcome-main { min-height: calc(100dvh - 72px); }
  .welcome-hero { height: auto; min-height: 302px; }
  .welcome-actions { margin-top: 4px; }
}

/* Setup and battle density refinements */
@media (min-width: 981px) {
  .setup-layout {
    grid-template-columns: minmax(485px, 0.88fr) minmax(0, 1.12fr);
    grid-template-rows: auto;
    column-gap: clamp(34px, 3.2vw, 50px);
    row-gap: 0;
    align-items: center;
  }

  .setup-layout .board-panel { display: block; min-width: 0; }
  .setup-layout .panel-heading { width: 100%; }
  .setup-layout .control-panel {
    min-width: 0;
    margin-top: 0;
  }

  .setup-layout .board[data-size="9"] {
    --cell: min(43px, calc((100dvh - 315px) / 9));
  }
  .setup-layout .board[data-size="12"] {
    --cell: min(31.5px, calc((100dvh - 315px) / 12));
  }
  .setup-layout .board[data-size="15"] {
    --cell: min(27px, calc((100dvh - 315px) / 15));
  }

  .mode-summary.is-tip-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .mode-summary.is-tip-list span {
    min-width: 0;
    min-height: 36px;
    padding: 4px 7px;
    justify-content: center;
    gap: 6px;
    border: 1px solid rgba(220, 119, 109, 0.2);
    border-radius: 12px 12px 12px 4px;
    background: rgba(248, 222, 215, 0.72);
    text-align: center;
    line-height: 1.2;
  }

  .mode-summary.is-tip-list b {
    min-width: auto;
    color: #bf6c64;
  }

  body.battle-active .battle-grid .board {
    --board-gap: 1px;
    --board-padding: 5px;
    border-radius: 20px 20px 20px 8px;
    background: #b8d1cf;
    box-shadow: 6px 7px 0 #6fad98, 11px 13px 0 #efa59d, 0 22px 42px rgba(49, 90, 99, 0.14);
  }

  body.battle-active .battle-grid .cell {
    border-radius: 6px 6px 6px 2px;
  }

  body.battle-active .battle-grid .board[data-size="15"] {
    --cell: clamp(24px, calc((100dvh - 360px) / 15), 29px);
  }

  body.battle-active .battle-grid .board[data-size="15"] .cell {
    border-radius: 6px 6px 6px 2px;
  }
}

.board { overflow: visible; }

.cell.shot > span {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  display: grid;
  place-items: center;
  transform: none;
  border: 0;
}

.shot-dot {
  display: block;
  width: clamp(6px, 18%, 9px);
  height: clamp(6px, 18%, 9px);
  border-radius: 50%;
  background: currentColor;
}

.board[data-size="15"] .shot-dot {
  width: 5px;
  height: 5px;
}

.cell.shot-miss > .shot-marker { color: #718481; }
.cell.shot-hit > .shot-marker { color: var(--hit-dark); }

.shot-burst {
  display: block;
  color: var(--white);
  font-style: normal;
  font-size: 19px;
  line-height: 1;
}

@media (max-width: 580px) {
  body.battle-active .battle-grid .board {
    --board-gap: 1px;
    --board-padding: 4px;
    box-shadow: 5px 6px 0 #6fad98, 9px 10px 0 #efa59d, 0 18px 32px rgba(49, 90, 99, 0.13);
  }

  .board[data-size="15"] .shot-dot {
    width: 3px;
    height: 3px;
  }
}

@media (max-width: 980px) {
  .setup-layout .board-panel { display: block; }
  .mode-summary.is-tip-list { grid-template-columns: 1fr; }
  .mode-summary.is-tip-list span {
    min-height: 36px;
    padding: 4px 8px;
    border: 1px solid rgba(220, 119, 109, 0.2);
    background: rgba(248, 222, 215, 0.72);
  }
}

/* Setup and battle boards share one visual grid system. */
.setup-layout .board {
  --board-gap: 1px;
  --board-padding: 5px;
  border-radius: 20px 20px 20px 8px;
  background: #b8d1cf;
  box-shadow: 6px 7px 0 #6fad98, 11px 13px 0 #efa59d, 0 22px 42px rgba(49, 90, 99, 0.14);
}

.setup-layout .cell {
  border-radius: 6px 6px 6px 2px;
}

@media (max-width: 580px) {
  .setup-layout .board {
    --board-padding: 4px;
    box-shadow: 5px 6px 0 #6fad98, 9px 10px 0 #efa59d, 0 18px 32px rgba(49, 90, 99, 0.13);
  }
}

/* Room-based two-player mode */
.room-strip {
  min-height: 62px;
  margin-bottom: 14px;
  padding: 10px 14px 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(49, 90, 99, 0.12);
  border-radius: 20px 20px 20px 8px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: var(--soft-shadow);
}

.room-strip-status,
.room-strip-actions {
  display: flex;
  align-items: center;
}

.room-strip-status { min-width: 0; gap: 11px; }
.room-strip-status div { min-width: 0; }
.room-strip-status strong,
.room-strip-status small { display: block; }
.room-strip-status strong { margin-bottom: 2px; font-size: 14px; }
.room-strip-status small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.room-status-lamp {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border: 3px solid rgba(231, 184, 94, 0.28);
  border-radius: 50%;
  background: var(--gold);
  box-sizing: content-box;
}

.room-strip.is-connected .room-status-lamp { border-color: rgba(67, 139, 131, 0.2); background: var(--green); }
.room-strip.is-error .room-status-lamp { border-color: rgba(217, 111, 106, 0.2); background: var(--red); }
.room-strip-actions { flex: 0 0 auto; gap: 8px; }

.room-code-label,
.room-strip-button {
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px 12px 12px 4px;
  font-size: 12px;
  font-weight: 800;
}

.room-code-label { color: var(--ink); background: var(--green-soft); letter-spacing: 0; }
.room-strip-button { border: 0; color: var(--white); background: var(--green); cursor: pointer; }
.room-strip-button:hover { background: #347870; }
.room-strip-button.is-quiet { color: var(--muted); background: var(--paper-deep); }

.play-mode-dialog,
.room-dialog { border-radius: 28px 28px 28px 11px; }
.play-mode-dialog { width: min(520px, calc(100% - 32px)); text-align: left; }
.play-mode-dialog > .eyebrow,
.play-mode-dialog > h2,
.room-dialog > .eyebrow,
.room-dialog > h2 { text-align: center; }

.play-mode-actions { margin-top: 24px; display: grid; gap: 10px; }
.play-mode-option {
  width: 100%;
  min-height: 82px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(49, 90, 99, 0.14);
  border-radius: 18px 18px 18px 7px;
  color: var(--ink);
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}
.play-mode-option:hover { border-color: var(--green); background: var(--green-soft); transform: translateY(-1px); }
.play-mode-option.is-online { border-color: rgba(217, 111, 106, 0.24); background: var(--red-soft); }
.play-mode-option.is-online:hover { border-color: var(--red); }
.play-mode-option > span:nth-child(2) { min-width: 0; }
.play-mode-option strong,
.play-mode-option small { display: block; }
.play-mode-option strong { margin-bottom: 5px; font-size: 16px; }
.play-mode-option small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.play-mode-option > b { color: var(--red); font-size: 20px; text-align: center; }

.play-mode-number {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 15px 15px 15px 6px;
  color: var(--white);
  background: var(--green);
  font-size: 13px;
  font-weight: 900;
}
.play-mode-option.is-online .play-mode-number { background: var(--red); }

.room-dialog { width: min(500px, calc(100% - 32px)); }
.room-dialog > p:not(.eyebrow) { margin: 8px auto 20px; max-width: 360px; text-align: center; }
.room-share-panel { margin: 22px 0 18px; padding: 18px; border-radius: 18px 18px 18px 7px; background: var(--green-soft); }
.room-code-caption,
.room-share-panel label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.room-dialog-code { display: block; margin: 4px 0 17px; color: var(--ink); font-size: 30px; letter-spacing: 0; }
.room-link-row { margin-top: 7px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.room-link-row input {
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border: 1px solid rgba(49, 90, 99, 0.15);
  border-radius: 11px 11px 11px 4px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.84);
  font-size: 12px;
}
.room-link-row button { min-width: 64px; border: 0; border-radius: 11px 11px 11px 4px; color: var(--white); background: var(--green); font-weight: 800; cursor: pointer; }
.room-dialog .primary-button { margin-top: 10px; }

.mode-button:disabled { cursor: not-allowed; opacity: 0.58; }

@media (max-width: 700px) {
  .room-strip { align-items: stretch; flex-direction: column; gap: 9px; }
  .room-strip-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .room-code-label { grid-column: 1 / -1; }
}

@media (max-width: 580px) {
  .room-strip { padding: 11px; border-radius: 17px 17px 17px 6px; }
  .room-strip-button { padding-inline: 9px; }
  .play-mode-dialog,
  .room-dialog { padding-inline: 20px; }
  .play-mode-option { min-height: 76px; padding: 11px; grid-template-columns: 42px minmax(0, 1fr) 22px; gap: 10px; }
  .play-mode-number { width: 40px; height: 40px; border-radius: 13px 13px 13px 5px; }
}

/* 2026-09 gameplay flow, 14 x 14 airspace, and replay */
.difficulty-view {
  width: min(1120px, 100%);
  margin: 30px auto 0;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(67, 139, 131, 0.22);
  border-radius: 28px 28px 28px 10px;
  background: rgba(255, 253, 248, 0.76);
  box-shadow: var(--soft-shadow);
}

.difficulty-heading { max-width: 610px; }
.difficulty-heading h2 { margin: 9px 0 8px; font-size: clamp(29px, 3vw, 42px); }
.difficulty-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

.difficulty-options {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.difficulty-option {
  min-width: 0;
  min-height: 318px;
  padding: 21px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 1px solid rgba(67, 139, 131, 0.18);
  border-radius: 20px 20px 20px 7px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.9);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(49, 90, 99, 0.035);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.difficulty-option:hover { transform: translateY(-2px); border-color: #6ba89c; box-shadow: 0 16px 30px rgba(49, 90, 99, 0.12); }
.difficulty-option:focus-visible { outline: 3px solid rgba(217, 111, 106, 0.28); outline-offset: 3px; }
.difficulty-option.is-active { border-color: var(--red); background: #fff7f3; box-shadow: inset 0 0 0 2px rgba(217, 111, 106, 0.13), 0 14px 30px rgba(174, 85, 78, 0.1); }
.difficulty-option:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }
.difficulty-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.difficulty-name { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.difficulty-name strong { font-family: "Songti SC", "STSong", serif; font-size: 29px; line-height: 1; }
.difficulty-name small { color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.difficulty-select-state { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 800; }
.difficulty-select-state i { width: 15px; height: 15px; display: grid; place-items: center; border: 1px solid rgba(49, 90, 99, 0.3); border-radius: 50%; background: rgba(255, 253, 248, 0.74); }
.difficulty-option.is-active .difficulty-select-state { color: var(--red); }
.difficulty-option.is-active .difficulty-select-state i { border-color: var(--red); background: var(--red); box-shadow: inset 0 0 0 4px #fff7f3; }

.difficulty-stats {
  margin: 20px 0 17px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(67, 139, 131, 0.14);
  border-radius: 14px 14px 14px 5px;
  background: rgba(220, 238, 230, 0.42);
}
.difficulty-stats > span { min-width: 0; padding: 11px 13px 10px; display: flex; flex-direction: column; gap: 3px; }
.difficulty-stats > span + span { border-left: 1px solid rgba(67, 139, 131, 0.14); }
.difficulty-stats small { color: var(--muted); font-size: 10px; font-weight: 800; }
.difficulty-stats strong { color: var(--ink); font-size: 20px; line-height: 1.1; }
.difficulty-stats em { font-size: 11px; font-style: normal; }

.difficulty-rules { margin-top: 6px; display: grid; gap: 7px; }
.difficulty-rules > span {
  min-height: 31px;
  padding: 5px 8px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  border-radius: 9px 9px 9px 3px;
}
.difficulty-rules small { color: #5b8882; font-size: 10px; font-weight: 900; }
.difficulty-rules strong { min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.difficulty-rules .is-key-rule { background: rgba(245, 211, 116, 0.28); }
.difficulty-rules .is-key-rule small { color: #a96c27; }
.difficulty-option.is-active .difficulty-rules .is-key-rule { background: rgba(239, 165, 157, 0.2); }
.difficulty-option.is-active .difficulty-rules .is-key-rule small { color: var(--red); }

.difficulty-continue { width: min(330px, 100%); margin: 0 auto; border-radius: 17px 17px 17px 6px; }

.setup-mode-banner {
  margin: -3px 0 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 15px 15px 15px 5px;
  background: var(--green-soft);
}
.setup-mode-banner span { min-width: 0; }
.setup-mode-banner small, .setup-mode-banner strong { display: block; }
.setup-mode-banner small { margin-bottom: 2px; color: var(--muted); font-size: 10px; }
.setup-mode-banner strong { font-size: 14px; }
.setup-mode-banner button { flex: 0 0 auto; min-height: 34px; padding: 0 11px; border: 0; border-radius: 10px 10px 10px 3px; color: var(--green); background: rgba(255, 253, 248, 0.82); font-size: 11px; font-weight: 800; cursor: pointer; }

.board[data-size="14"] {
  --cell: min(3.45vw, 36px);
  grid-template-columns: repeat(14, var(--cell));
  grid-template-rows: repeat(14, var(--cell));
  width: calc(var(--cell) * 14 + var(--board-gap) * 13 + var(--board-padding) * 2);
  height: calc(var(--cell) * 14 + var(--board-gap) * 13 + var(--board-padding) * 2);
}
.board[data-size="14"] .cell:nth-child(14n) { border-right: 0; }
.board[data-size="14"] .cell:nth-last-child(-n+14) { border-bottom: 0; }
.board[data-size="14"] .shot-dot { width: 5px; height: 5px; }

.cell.is-ai-target {
  z-index: 2;
  background: rgba(239, 165, 157, 0.28);
  box-shadow: inset 0 0 0 2px var(--red), 0 0 0 3px rgba(217, 111, 106, 0.13);
  animation: ai-target-pulse 360ms ease-in-out infinite alternate;
}
@keyframes ai-target-pulse { to { background: rgba(239, 165, 157, 0.62); transform: scale(0.88); } }

.tutorial-cell.is-candidate-head { color: var(--red); background: #fff4e5; box-shadow: inset 0 0 0 2px rgba(217, 111, 106, 0.45); font-weight: 900; }
.tutorial-cell.is-revealed-plane.plane-body { background: #d5e9df; }
.tutorial-cell.is-revealed-plane.plane-head { color: var(--white); background: var(--red); }

.post-game-actions {
  margin-top: 14px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  border-radius: 16px 16px 16px 6px;
  background: rgba(255, 250, 240, 0.86);
  box-shadow: var(--soft-shadow);
}
.post-game-actions span { margin-right: auto; color: var(--muted); font-size: 12px; }
.post-game-actions button, .review-button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px 12px 12px 4px;
  color: var(--white);
  background: var(--green);
  font-weight: 800;
  cursor: pointer;
}
.post-game-actions #openResultButton { color: var(--green); background: var(--green-soft); }
.post-game-actions .post-game-restart { color: var(--white); background: var(--red); }
.result-panel { position: relative; }
.result-close { top: 14px; right: 14px; border-radius: 50%; background: var(--paper-deep); }
.review-button { width: 100%; color: var(--green); background: var(--green-soft); }

.replay-overlay {
  position: fixed;
  z-index: 45;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: rgba(40, 79, 88, 0.62);
}
.replay-panel { width: min(980px, 100%); padding: 24px; border-radius: 26px 26px 26px 10px; background: var(--white); box-shadow: 0 30px 90px rgba(35, 69, 75, 0.32); }
.replay-header { position: relative; min-height: 48px; padding-right: 42px; display: flex; align-items: center; justify-content: space-between; }
.replay-header span { color: var(--red); font-size: 11px; font-weight: 900; }
.replay-header h2 { margin-top: 4px; font-size: 27px; }
.replay-header .dialog-close { top: 0; right: 0; border-radius: 50%; background: var(--paper-deep); }
.replay-tabs { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.replay-tabs button { min-height: 44px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; cursor: pointer; }
.replay-tabs button.is-active { border-color: var(--red); color: var(--ink); font-weight: 900; }
.replay-content { padding-top: 22px; display: grid; grid-template-columns: minmax(0, 1fr) 230px; align-items: center; gap: 34px; }
.replay-board-wrap { min-width: 0; display: grid; place-items: center; padding: 22px; }
.replay-board { --cell: min(3.3vw, 39px); --board-gap: 2px; --board-padding: 6px; }
.replay-sidebar { min-height: 210px; padding: 20px; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--line); }
.replay-sidebar > span { color: var(--red); font: 800 11px ui-monospace, monospace; }
.replay-sidebar > strong { min-height: 72px; margin-top: 10px; font-size: 15px; line-height: 1.65; }
.replay-legend { display: flex; gap: 6px; }
.replay-legend .guide-mark { width: 28px; height: 28px; font-size: 18px; }
.replay-controls { margin-top: 18px; display: grid; grid-template-columns: 42px 1fr 42px; gap: 7px; }
.replay-controls button { min-height: 42px; border: 0; border-radius: 11px 11px 11px 4px; background: var(--paper-deep); font-weight: 900; cursor: pointer; }
.replay-controls button:disabled { cursor: not-allowed; opacity: 0.4; }
.replay-controls button.is-primary { color: var(--white); background: var(--red); }

@media (min-width: 981px) {
  .setup-layout .board[data-size="14"] { --cell: min(29px, calc((100dvh - 315px) / 14)); }
  .battle-grid .board[data-size="14"] { --cell: min(28px, calc((100dvh - 430px) / 14)); }
  body.battle-active .battle-grid .board[data-size="14"] { --cell: clamp(24px, calc((100dvh - 360px) / 14), 29px); }
}

@media (max-width: 980px) {
  .difficulty-view { margin-top: 22px; }
  .difficulty-options { grid-template-columns: 1fr; }
  .difficulty-option { min-height: 0; }
  .board[data-size="14"], .battle-grid .board[data-size="14"] { --cell: min(5.25vw, 34px); }
  .replay-content { grid-template-columns: 1fr; gap: 16px; }
  .replay-sidebar { min-height: 0; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 580px) {
  body.difficulty-active .app-shell { padding-top: 16px; }
  body.difficulty-active .briefing,
  body.difficulty-active .mark-guide { display: none; }
  .difficulty-view { margin-top: 18px; padding: 19px 14px; border-radius: 21px 21px 21px 7px; }
  .difficulty-heading h2 { font-size: 30px; }
  .difficulty-options { margin-top: 20px; gap: 9px; }
  .difficulty-option { padding: 16px; border-radius: 17px 17px 17px 6px; }
  .difficulty-name strong { font-size: 23px; }
  .difficulty-select-state b { display: none; }
  .difficulty-stats { margin: 14px 0 10px; }
  .difficulty-stats > span { padding: 9px 11px; }
  .difficulty-stats strong { font-size: 18px; }
  .difficulty-rules { margin-top: 2px; gap: 3px; }
  .difficulty-rules > span { min-height: 28px; padding-block: 3px; }
  .setup-mode-banner { grid-column: 1 / -1; }
  .board[data-size="14"], .battle-grid .board[data-size="14"], .replay-board[data-size="14"] { --cell: calc((100vw - 98px) / 14); }
  .board[data-size="14"] .shot-dot { width: 3px; height: 3px; }
  .battle-models-button { min-width: 104px; color: var(--ink); background: #f5d38b; font-weight: 900; }
  .battle-models-button span:last-child { display: inline !important; }
  .post-game-actions { align-items: stretch; flex-direction: column; }
  .post-game-actions span { margin: 0 0 2px; text-align: center; }
  .replay-overlay { padding: 10px; align-items: start; }
  .replay-panel { margin: 10px 0; padding: 17px 12px; border-radius: 20px 20px 20px 7px; }
  .replay-header h2 { font-size: 21px; }
  .replay-content { padding-top: 13px; }
  .replay-board-wrap { padding: 18px 8px 8px 21px; }
  .replay-sidebar { padding: 15px 5px 3px; }
  .replay-sidebar > strong { min-height: 58px; }
}

/* 2026-09 feedback polish */
.tutorial-shot-order { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tutorial-shot-order span { padding: 12px 10px; border-radius: 12px 12px 12px 4px; background: rgba(255, 253, 248, 0.5); }
.tutorial-shot-order b { margin: 0; }

.difficulty-option mark {
  padding: 0 3px;
  color: inherit;
  background: linear-gradient(transparent 34%, rgba(245, 211, 116, 0.72) 34%, rgba(245, 211, 116, 0.72) 88%, transparent 88%);
}
.difficulty-continue { margin: 24px auto 0; }

.setup-mode-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.setup-mode-banner > span { grid-column: 2; text-align: center; }
.setup-mode-banner > button { grid-column: 3; justify-self: end; }

.battle-toolbar {
  gap: 9px;
  padding: 0;
  color: var(--white);
  background: transparent;
  box-shadow: none;
}
.battle-toolbar-status {
  min-width: 0;
  min-height: 48px;
  padding: 0 18px;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-radius: 19px 19px 19px 7px;
  background: var(--green);
  box-shadow: inset 0 -5px 0 rgba(38, 93, 80, 0.16), var(--soft-shadow);
}
.battle-toolbar-actions {
  flex: 0 0 auto;
  gap: 8px;
  align-self: auto;
}
.battle-models-control {
  align-self: auto;
  margin-left: 0;
}
.battle-toolbar-actions .battle-menu-button {
  min-height: 48px;
  margin-left: 0;
  padding: 0 17px;
  border: 2px solid var(--green);
  border-radius: 17px 17px 17px 6px;
  color: #285b52;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: inset 0 -3px 0 rgba(67, 139, 131, 0.09), 0 8px 18px rgba(49, 90, 99, 0.08);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.battle-toolbar-actions .battle-models-button { min-width: 118px; }
.battle-toolbar-actions #battleMenuButton { min-width: 88px; }
.battle-toolbar-actions .battle-menu-button:hover {
  color: var(--white);
  background: var(--green);
  box-shadow: inset 0 -3px 0 rgba(38, 93, 80, 0.18), 0 10px 22px rgba(49, 90, 99, 0.13);
  transform: translateY(-1px);
}
.battle-toolbar-actions .battle-menu-button:active { transform: translateY(1px); }
.battle-toolbar-actions .battle-menu-button:focus-visible { outline: 3px solid rgba(67, 139, 131, 0.22); outline-offset: 2px; }
.battle-toolbar-actions .battle-menu-button span:first-child { font-size: 16px; }

.battle-view.is-post-game .combat-log { display: none; }
.battle-view.is-post-game .post-game-actions { margin-top: 28px; }

@media (max-width: 580px) {
  .difficulty-continue { margin-top: 16px; }
  .battle-toolbar { gap: 5px; }
  .battle-toolbar-status { min-height: 46px; padding: 0 10px; gap: 8px; border-radius: 15px 15px 15px 5px; }
  .battle-toolbar-actions { gap: 5px; }
  .battle-toolbar-actions .battle-menu-button { min-height: 46px; padding-inline: 8px; border-width: 1.5px; border-radius: 14px 14px 14px 5px; font-size: 11px; }
  .battle-toolbar-actions .battle-models-button { min-width: 96px; }
  .battle-toolbar-actions #battleMenuButton { min-width: 64px; padding-inline: 7px; }
  .battle-toolbar-actions #battleMenuButton span:last-child,
  .battle-toolbar-actions .battle-models-button span:last-child { display: inline !important; }
}

/* Language controls */
.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(255, 253, 248, 0.34);
  border-radius: 14px 14px 14px 5px;
  background: rgba(255, 253, 248, 0.08);
}
.language-switcher button {
  min-width: 46px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px 10px 10px 4px;
  color: inherit;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.language-switcher button.is-active {
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 4px 10px rgba(23, 32, 29, 0.12);
}
.language-switcher button:focus-visible { outline-offset: 1px; }
.language-switcher.is-compact button { min-width: 41px; min-height: 30px; padding-inline: 8px; font-size: 11px; }
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.topbar .language-switcher {
  color: var(--muted);
  border-color: rgba(49, 90, 99, 0.18);
  background: rgba(220, 229, 223, 0.42);
}
.topbar .language-switcher button.is-active { color: var(--white); background: var(--green); }
.welcome-header .language-switcher,
.tutorial-header .language-switcher { color: var(--white); }

body.language-en { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body.language-en h1,
body.language-en h2,
body.language-en .brand,
body.language-en .welcome-brand strong,
body.language-en .tutorial-brand { font-family: Georgia, "Times New Roman", serif; }
body.language-en .difficulty-rules strong,
body.language-en .tutorial-copy p,
body.language-en .status-block p { line-height: 1.5; }
body.language-en .difficulty-rules > span { grid-template-columns: 54px minmax(0, 1fr); gap: 9px; }
body.language-en .result-seal { font-size: 18px; }

@media (max-width: 760px) {
  .tutorial-header-actions { gap: 8px; }
  .tutorial-header .language-switcher { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar .language-switcher button { min-width: 39px; padding-inline: 7px; }
}

@media (max-width: 580px) {
  .welcome-header { gap: 10px; }
  .welcome-header .language-switcher button { min-width: 40px; min-height: 30px; padding-inline: 7px; font-size: 11px; }
  .topbar .language-switcher { padding: 2px; }
  .topbar .language-switcher button { min-width: 36px; min-height: 28px; padding-inline: 6px; font-size: 10px; }
  .topbar-actions .icon-button { width: 38px; height: 38px; }
  body.language-en .brand > span:last-child { font-size: 17px; }
  body.language-en .welcome-brand strong { font-size: 12px; }
  body.language-en .welcome-flight-plan strong { font-size: 10px; }
  body.language-en .welcome-action strong { white-space: normal; line-height: 1.15; }
  body.language-en .combat-log-row { grid-template-columns: 58px 24px minmax(0, 1fr); }
  body.language-en .combat-actor { font-size: 9px; }
}

/* Consent-controlled analytics */
.analytics-consent {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  width: min(560px, calc(100vw - 40px));
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border: 1px solid rgba(67, 139, 131, 0.32);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 18px 48px rgba(40, 79, 88, 0.22);
}
.analytics-consent[hidden] { display: none; }
.analytics-consent strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 14px; }
.analytics-consent p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.analytics-consent-actions { display: grid; gap: 7px; }
.analytics-consent button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(67, 139, 131, 0.28);
  border-radius: 7px;
  color: var(--green);
  background: var(--green-soft);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.analytics-consent button.is-primary { color: var(--white); border-color: var(--green); background: var(--green); }

@media (max-width: 580px) {
  .analytics-consent {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 15px;
  }
  .analytics-consent-actions { grid-template-columns: 1fr 1fr; }
  .analytics-consent button { min-height: 42px; padding-inline: 9px; white-space: normal; }
}
