/* 破云 1947 · CLOUDBREAK — layout & UI ("squadron hangar" visual language).
   Armoured plates with HUD corner brackets, brass-amber primary / selection,
   cyan telemetry, tactile controls. No text selection, no page scroll. */
:root {
  --fx: 0px;
  --fy: 0px;
  --fw: 100vw;
  --fh: 100vh;
  --k: 1;
  --ink: #edf5ff;
  --ink2: #c3d3ea;
  --dim: #8aa0c0;
  --amber: #ffc24b;
  --amber-hi: #ffe39a;
  --amber-lo: #f59e1b;
  --amber-ink: #241300;
  --cyan: #6fd8ff;
  --teal: #5fe3c0;
  --green: #7dffb2;
  --red: #ff6b7d;
  --steel0: #060b17;
  --steel1: #0b1528;
  --steel2: #12203a;
  --steel3: #1b2e4e;
  --edge: rgba(160, 196, 240, 0.22);
  --edge-hi: rgba(205, 225, 255, 0.4);
  --bracket: rgba(111, 216, 255, 0.55);
  --lip: #040812;
  --radius: 0.8em;
  --radius-s: 0.55em;
  /* legacy names used by scripts */
  --accent: var(--amber);
  --accent2: var(--cyan);
  --danger: var(--red);
  --line: var(--edge-hi);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--steel0);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

#screen {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#safe-probe {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* ------------------------------------------------------------ in-game buttons */
#hud-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#hud-controls[hidden] { display: none; }

.hud-btn {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  border: 1px solid rgba(200, 225, 255, 0.5);
  background: linear-gradient(180deg, rgba(28, 46, 78, 0.55), rgba(8, 14, 28, 0.55));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 2px 8px rgba(0, 0, 0, 0.35);
  color: #fff;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  font: 700 11px var(--font);
  -webkit-user-select: none;
  user-select: none;
}
.hud-btn svg { width: 20px; height: 20px; fill: #fff; }
.hud-btn:active { background: rgba(111, 216, 255, 0.35); }
.hud-btn.bomb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 194, 75, 0.75);
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 214, 120, 0.42), rgba(255, 160, 40, 0.1) 55%, rgba(8, 12, 26, 0.55) 72%);
  box-shadow: inset 0 0 0 3px rgba(8, 12, 26, 0.35), 0 0 14px rgba(255, 180, 60, 0.28);
  display: flex;
  flex-direction: column;
  gap: 1px;
  justify-content: center;
  align-items: center;
}
.hud-btn.bomb:active { background: radial-gradient(circle at 50% 40%, rgba(255, 220, 140, 0.7), rgba(255, 160, 40, 0.3) 60%, rgba(8, 12, 26, 0.6) 75%); }
.hud-btn.bomb.empty { opacity: 0.35; filter: saturate(0.2); }
.bomb-label { font-size: 9px; letter-spacing: 1.5px; opacity: 0.9; color: var(--amber-hi); }
.bomb-count { font-size: 19px; font-weight: 900; line-height: 1; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6); }

/* ------------------------------------------------------------ screens */
#ui {
  position: absolute;
  left: var(--fx);
  top: var(--fy);
  width: var(--fw);
  height: var(--fh);
  font-size: calc(14px * var(--k));
  pointer-events: none;
}
#ui.interactive { pointer-events: auto; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 1em 0.95em 0.95em;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(40, 90, 160, 0.18), transparent 60%),
    linear-gradient(180deg, rgba(4, 9, 22, 0.5), rgba(4, 9, 22, 0.82));
}
.screen.active { display: flex; }
.screen[data-screen="title"] { background: radial-gradient(90% 55% at 50% 38%, rgba(4, 9, 22, 0.1), rgba(4, 9, 22, 0.62)); }
.screen.overlay { background: rgba(3, 6, 15, 0.66); justify-content: center; }
.screen[data-screen="result"], .screen[data-screen="mpresult"] { background: linear-gradient(180deg, rgba(3, 6, 15, 0.72), rgba(3, 6, 15, 0.88)); }

/* Title rule: text flanked by fading hairlines. */
.screen-head { display: flex; align-items: center; gap: 0.7em; margin: 0.1em 0 0.65em; }
.screen-head::before, .screen-head::after {
  content: "";
  flex: 1 1 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--edge-hi));
}
.screen-head::after { background: linear-gradient(270deg, transparent, var(--edge-hi)); }
.screen-head h2 {
  margin: 0;
  font-size: 1.5em;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 18px rgba(111, 216, 255, 0.3);
}
.screen-head small, .btn small, label small, .section-label small, h3 small {
  font-size: 0.55em;
  letter-spacing: 0.22em;
  color: var(--dim);
  font-weight: 800;
}
.screen-head h2 small { color: var(--cyan); opacity: 0.75; }
.screen-head.ribbon h2 {
  color: var(--amber-hi);
  padding: 0.18em 0.9em;
  border-radius: 0.3em;
  background: linear-gradient(180deg, rgba(255, 194, 75, 0.18), rgba(255, 160, 30, 0.06));
  border: 1px solid rgba(255, 194, 75, 0.45);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 194, 75, 0.35);
}

/* Armoured plate with HUD corner brackets (brackets stay put while content scrolls). */
.panel, .plate {
  position: relative;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 0.95em 0.9em;
  background:
    linear-gradient(var(--bracket), var(--bracket)) top 7px left 7px / 13px 1.5px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) top 7px left 7px / 1.5px 13px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) top 7px right 7px / 13px 1.5px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) top 7px right 7px / 1.5px 13px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom 7px left 7px / 13px 1.5px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom 7px left 7px / 1.5px 13px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom 7px right 7px / 13px 1.5px no-repeat,
    linear-gradient(var(--bracket), var(--bracket)) bottom 7px right 7px / 1.5px 13px no-repeat,
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0) 35%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, rgba(18, 33, 60, 0.94), rgba(7, 13, 27, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 0 0 1px rgba(0, 0, 0, 0.35), 0 14px 34px rgba(0, 0, 0, 0.45);
}
.panel { flex: 1 1 auto; min-height: 0; }
.plate { width: min(100%, 24em); margin: 0 auto; max-height: 100%; }
.scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(160, 196, 240, 0.3) transparent;
}

.section-label {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  margin: 0.95em 0 0.45em;
  font-size: 0.82em;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--ink2);
}
.section-label::before {
  content: "";
  width: 0.35em;
  height: 0.9em;
  align-self: center;
  border-radius: 1px;
  background: linear-gradient(180deg, var(--amber-hi), var(--amber-lo));
  box-shadow: 0 0 8px rgba(255, 194, 75, 0.5);
}
.section-label:first-child { margin-top: 0.1em; }

.screen-foot {
  display: flex;
  gap: 0.6em;
  margin-top: 0.8em;
}
.screen-foot .btn { flex: 1 1 0; }

/* ------------------------------------------------------------ buttons */
.btn {
  position: relative;
  font: inherit;
  font-weight: 800;
  font-size: 1.03em;
  letter-spacing: 0.06em;
  color: var(--ink);
  min-height: max(46px, 3.1em);
  padding: 0.45em 0.9em;
  border-radius: var(--radius-s);
  border: 1px solid rgba(170, 205, 250, 0.3);
  background: linear-gradient(180deg, #27406a 0%, #1a2d4f 52%, #13223e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22),
    0 3px 0 var(--lip),
    0 6px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.12s ease;
}
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 var(--lip), 0 2px 6px rgba(0, 0, 0, 0.3); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (hover: hover) {
  .btn:hover { filter: brightness(1.12); }
}
.btn.primary {
  color: var(--amber-ink);
  border-color: var(--amber-hi);
  background: linear-gradient(180deg, #ffe7a6 0%, #ffc24b 46%, #f39c1b 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -2px 0 rgba(150, 80, 0, 0.3),
    0 3px 0 #6e3f00,
    0 6px 18px rgba(255, 170, 40, 0.3);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn.primary:active { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 0 #6e3f00, 0 2px 8px rgba(255, 170, 40, 0.25); }
.btn.primary small { color: rgba(60, 30, 0, 0.72); }
.btn.mp {
  border-color: rgba(120, 255, 210, 0.55);
  background: linear-gradient(180deg, #1f7a68 0%, #145a4d 52%, #0e4038 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22),
    0 3px 0 #03241f,
    0 6px 16px rgba(40, 200, 160, 0.18);
}
.btn.mp small { color: rgba(200, 255, 235, 0.72); }
.btn.big { min-height: max(52px, 3.6em); font-size: 1.12em; }
.btn.small { min-height: 40px; min-width: max(44px, 3.6em); font-size: 0.88em; padding: 0.3em 0.8em; }
.btn.wide { width: 100%; margin-top: 0.45em; }
.btn .chev { font-size: 0.75em; margin-left: 0.25em; }
.btn[disabled] {
  pointer-events: none;
  opacity: 0.62;
  filter: saturate(0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  background-image:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.22) 0 6px, transparent 6px 12px),
    linear-gradient(180deg, #27406a, #13223e);
}
.btn.primary[disabled] { background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.16) 0 6px, transparent 6px 12px), linear-gradient(180deg, #e3c88a, #b88a3e); }

.menu { display: flex; flex-direction: column; gap: 0.65em; }
.menu-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5em; }
.menu-row.two { grid-template-columns: repeat(2, 1fr); }
.btn.compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
  padding: 0.4em 0.3em;
  font-size: 0.9em;
  min-height: max(52px, 3.8em);
}
.btn.compact svg { width: 1.35em; height: 1.35em; fill: none; stroke: var(--cyan); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ title */
.title-wrap {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 1.1em;
}
.logo { text-align: center; }
.emblem { width: 8.4em; height: 2.6em; display: block; margin: 0 auto 0.25em; overflow: visible; }
.emblem .wing { fill: rgba(214, 232, 255, 0.9); }
.emblem .wing.lo { fill: rgba(170, 200, 240, 0.6); }
.emblem .ring { fill: #0b1a33; stroke: var(--amber); stroke-width: 1.6; }
.emblem .star { fill: var(--amber); filter: drop-shadow(0 0 3px rgba(255, 194, 75, 0.8)); }
.logo-cn {
  font-size: 3.6em;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 20%, #cfeaff 58%, #7cc0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0 16px rgba(111, 200, 255, 0.45));
}
.logo-cn span { font-size: 0.42em; letter-spacing: 0.05em; margin-left: 0.2em; vertical-align: 0.9em; color: var(--amber); -webkit-text-fill-color: var(--amber); }
.logo-en { margin-top: 0.3em; font-size: 1.25em; font-weight: 900; letter-spacing: 0.5em; color: var(--amber); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 14px rgba(255, 194, 75, 0.35); padding-left: 0.5em; }
.logo-sub { margin-top: 0.45em; font-size: 0.8em; color: var(--ink2); letter-spacing: 0.14em; }
.title-menu { width: min(100%, 22em); margin: 0 auto; }
.hint { text-align: center; color: var(--dim); font-size: 0.8em; margin: 0.5em 0 0; line-height: 1.45; }
.footer { text-align: center; color: rgba(150, 175, 205, 0.7); font-size: 0.72em; margin: 0; }

/* ------------------------------------------------------------ selectable cells */
.ship-btn, .diff-btn, .tabs button, .seg button {
  position: relative;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: linear-gradient(180deg, #172a49 0%, #0f1d36 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 0 var(--lip);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}
.ship-btn:active, .diff-btn:active, .tabs button:active, .seg button:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.ship-btn:focus-visible, .diff-btn:focus-visible, .tabs button:focus-visible, .seg button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.ship-btn[aria-checked="true"], .diff-btn[aria-checked="true"], .tabs button[aria-selected="true"], .seg button[aria-pressed="true"] {
  --sel: var(--amber);
  border-color: var(--sel);
  background:
    radial-gradient(120% 85% at 50% 0%, rgba(255, 200, 90, 0.26), transparent 70%),
    linear-gradient(180deg, #243f6a, #182c4c);
  box-shadow: 0 0 0 1px rgba(255, 194, 75, 0.38), 0 0 14px rgba(255, 194, 75, 0.24), inset 0 0 10px rgba(255, 194, 75, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 2px 0 var(--lip);
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 194, 75, 0.45);
}
/* LED on the selected cell */
.ship-btn[aria-checked="true"]::after, .diff-btn[aria-checked="true"]::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sel);
  box-shadow: 0 0 6px var(--sel);
}

/* ------------------------------------------------------------ hangar */
.bay {
  display: grid;
  grid-template-columns: minmax(6.5em, 36%) 1fr;
  gap: 0.75em;
  align-items: center;
  padding: 0.55em 0.65em 0.55em 0.45em;
  border-radius: 0.7em;
  border: 1px solid var(--edge);
  background:
    radial-gradient(60% 55% at 22% 78%, rgba(111, 216, 255, 0.24), transparent 70%),
    radial-gradient(90% 60% at 22% 100%, rgba(255, 194, 75, 0.1), transparent 70%),
    linear-gradient(180deg, #081222 0%, #0d1b33 70%, #0a1528 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -18px 30px rgba(0, 0, 0, 0.25);
}
.bay-stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1.1;
  border-radius: 0.55em;
  background:
    repeating-linear-gradient(90deg, rgba(111, 216, 255, 0.1) 0 1px, transparent 1px 14px) bottom / 100% 34% no-repeat,
    repeating-linear-gradient(0deg, rgba(111, 216, 255, 0.1) 0 1px, transparent 1px 10px) bottom / 100% 34% no-repeat,
    radial-gradient(50% 30% at 50% 82%, rgba(111, 216, 255, 0.3), transparent 72%);
}
.bay-stage::before {
  /* hangar floor marking under the fighter */
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 12%;
  height: 12%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 194, 75, 0.45);
}
#ship-hero {
  position: relative;
  width: 82%;
  height: auto;
  filter: drop-shadow(0 12px 8px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 10px rgba(111, 216, 255, 0.25));
  animation: hover 3.2s ease-in-out infinite;
}
@keyframes hover {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4%); }
}
.bay-info { min-width: 0; }
.code-tag {
  display: inline-block;
  font-size: 0.68em;
  font-weight: 900;
  letter-spacing: 0.28em;
  padding: 0.12em 0.5em 0.12em 0.6em;
  border-radius: 0.25em;
  color: var(--cyan);
  border: 1px solid rgba(111, 216, 255, 0.45);
  background: rgba(111, 216, 255, 0.08);
}
.ship-title { font-size: 1.45em; margin: 0.12em 0 0.05em; line-height: 1.15; }
.ship-title strong { font-weight: 900; letter-spacing: 0.08em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
.ship-weapon { color: var(--amber-hi); font-weight: 800; font-size: 0.84em; margin-bottom: 0.35em; }
.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.28em 0.55em;
  margin: 0;
  font-size: 0.78em;
  align-items: center;
}
.stats dt { color: var(--ink2); white-space: nowrap; }
.stats dd { margin: 0; display: flex; gap: 0.18em; align-items: center; }
.pip {
  width: 1.15em;
  height: 0.62em;
  transform: skewX(-18deg);
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.pip.on { background: linear-gradient(180deg, #b8f2ff, #57c8f2); box-shadow: 0 0 6px rgba(111, 216, 255, 0.45); }
.pip.on.max { background: linear-gradient(180deg, var(--amber-hi), var(--amber-lo)); box-shadow: 0 0 6px rgba(255, 194, 75, 0.55); }
.ship-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.38em;
  margin-top: 0.6em;
}
.ship-btn {
  aspect-ratio: 1 / 1.08;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1em;
  padding: 0.2em;
}
.ship-btn canvas { width: 66%; height: auto; image-rendering: auto; }
.ship-btn span { font-size: 0.78em; font-weight: 800; letter-spacing: 0.08em; }
.ship-btn[aria-checked="true"] canvas { filter: drop-shadow(0 0 5px rgba(255, 194, 75, 0.55)); }
.brief {
  margin-top: 0.65em;
  padding: 0.55em 0.7em;
  border-radius: 0.55em;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(160, 196, 240, 0.12);
}
.ship-blurb { margin: 0 0 0.35em; color: var(--ink2); font-size: 0.88em; line-height: 1.45; }
.trait { margin: 0.18em 0 0; font-size: 0.84em; display: flex; gap: 0.5em; align-items: baseline; line-height: 1.4; }
.trait-tag {
  flex: 0 0 auto;
  font-size: 0.8em;
  font-weight: 900;
  padding: 0 0.45em;
  border-radius: 0.25em;
  letter-spacing: 0.1em;
}
.trait.good .trait-tag { color: #062a17; background: var(--green); }
.trait.weak .trait-tag { color: #3a0710; background: #ff9aa6; }
.trait.good span:last-child { color: #b9ffd6; }
.trait.weak span:last-child { color: #ffc8cf; }

.diff-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.38em;
}
.diff-btn {
  min-height: 46px;
  font-weight: 900;
  line-height: 1.1;
  padding: 0.35em 0.1em 0.3em;
  border-bottom: 3px solid var(--dc, var(--edge));
}
.diff-btn small { display: block; font-size: 0.58em; color: var(--dim); letter-spacing: 0.12em; margin-top: 0.15em; }
.diff-btn[data-diff="easy"] { --dc: #5fe3c0; }
.diff-btn[data-diff="normal"] { --dc: #6fb8ff; }
.diff-btn[data-diff="hard"] { --dc: #ff9a4d; }
.diff-btn[data-diff="ace"] { --dc: #ff5a6e; }
.diff-btn[aria-checked="true"] {
  --sel: var(--dc);
  background: radial-gradient(120% 85% at 50% 0%, color-mix(in srgb, var(--dc) 30%, transparent), transparent 72%), linear-gradient(180deg, #243f6a, #182c4c);
  text-shadow: 0 0 8px color-mix(in srgb, var(--dc) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--dc) 45%, transparent), 0 0 16px color-mix(in srgb, var(--dc) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.diff-btn[aria-checked="true"] small { color: var(--dc); }
.diff-desc { font-size: 0.84em; color: var(--ink2); margin: 0.5em 0 0; min-height: 2.5em; line-height: 1.45; }

/* ------------------------------------------------------------ volume & options */
.volume-box { display: grid; gap: 0.55em; margin: 0.3em 0 0.4em; }
.vol-row { display: grid; grid-template-columns: 4.2em 1fr 2.6em; align-items: center; gap: 0.5em; font-size: 0.92em; }
.vol-row output { text-align: right; color: var(--cyan); font-variant-numeric: tabular-nums; font-weight: 800; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;
  background: transparent;
  touch-action: pan-x;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(111, 216, 255, 0.7), rgba(255, 194, 75, 0.85));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid var(--amber-hi);
  background: radial-gradient(circle at 40% 35%, #fff4cf, var(--amber) 60%, var(--amber-lo));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, rgba(111, 216, 255, 0.7), rgba(255, 194, 75, 0.85)); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--amber-hi); background: var(--amber); }
input[type="range"]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
.mute-btn { justify-self: stretch; }
.opt {
  display: grid;
  grid-template-columns: 5.2em 1fr;
  align-items: center;
  gap: 0.5em;
  margin: 0.55em 0;
  font-size: 0.92em;
}
.opt > span { color: var(--ink2); font-weight: 700; }
.seg {
  display: flex;
  gap: 0.3em;
  flex-wrap: wrap;
  padding: 0.22em;
  border-radius: 0.6em;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}
.seg button {
  flex: 1 1 0;
  min-width: 3.4em;
  min-height: 40px;
  border-radius: 0.45em;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* ------------------------------------------------------------ result & board */
.result-hero {
  text-align: center;
  padding: 0.45em 0.4em 0.6em;
  margin-bottom: 0.2em;
  border-radius: 0.6em;
  background: radial-gradient(70% 90% at 50% 0%, rgba(255, 194, 75, 0.16), transparent 70%);
}
.result-label { font-size: 0.72em; font-weight: 900; letter-spacing: 0.3em; color: var(--dim); }
.result-score {
  text-align: center;
  font-size: 2.5em;
  font-weight: 900;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 22px rgba(255, 194, 75, 0.38);
  letter-spacing: 0.05em;
  line-height: 1.15;
}
.result-hero .hint { margin-top: 0.2em; }
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.38em;
  margin: 0.4em 0 0.8em;
}
.result-stats .tile {
  padding: 0.35em 0.5em 0.4em;
  border-radius: 0.5em;
  border: 1px solid rgba(160, 196, 240, 0.16);
  background: linear-gradient(180deg, rgba(27, 46, 78, 0.7), rgba(12, 22, 40, 0.7));
  min-width: 0;
}
.result-stats dt { font-size: 0.68em; color: var(--dim); letter-spacing: 0.12em; font-weight: 800; }
.result-stats dd { margin: 0.1em 0 0; font-weight: 800; font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-entry {
  padding: 0.6em 0.65em;
  border-radius: 0.6em;
  border: 1px dashed rgba(255, 194, 75, 0.4);
  background: rgba(255, 194, 75, 0.04);
}
.name-entry label { display: block; font-weight: 800; margin-bottom: 0.4em; }
.name-entry label small { animation: blink 1.1s steps(2, start) infinite; color: var(--amber); }
@keyframes blink { to { visibility: hidden; } }
.name-row { display: flex; gap: 0.5em; }
.name-row .btn { flex: 0 0 auto; white-space: nowrap; min-width: 4.6em; }
#name-input, .mp-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 1.2em;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.35em 0.6em;
  min-height: 46px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(170, 205, 250, 0.4);
  background: linear-gradient(180deg, #040914, #0a1426);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
  color: #fff;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  caret-color: var(--amber);
}
#name-input { border-color: rgba(255, 194, 75, 0.75); }
#name-input:focus, .mp-input:focus { outline: none; border-color: var(--amber); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55), 0 0 0 2px rgba(255, 194, 75, 0.25); }
#name-input:disabled { opacity: 0.6; }
.status { min-height: 1.3em; margin: 0.45em 0; font-size: 0.85em; color: var(--dim); line-height: 1.4; }
.status.ok { color: var(--green); }
.status.warn { color: #ffd35a; }
.status.err { color: #ff9aa4; }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3em;
  margin-bottom: 0.6em;
  padding: 0.25em;
  border-radius: 0.7em;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.tabs button { min-height: 42px; font-weight: 900; letter-spacing: 0.08em; }

.board-list { list-style: none; margin: 0; padding: 0; }
.board-list li {
  display: grid;
  grid-template-columns: 2.3em 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.55em;
  align-items: center;
  padding: 0.42em 0.45em;
  margin-bottom: 0.25em;
  border-radius: 0.5em;
  border: 1px solid rgba(160, 196, 240, 0.08);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
  font-size: 0.92em;
}
.board-list li.me {
  border-color: rgba(255, 194, 75, 0.55);
  background: linear-gradient(90deg, rgba(255, 194, 75, 0.18), rgba(255, 194, 75, 0.04));
}
.board-list .rank {
  grid-row: span 2;
  width: 1.9em;
  height: 1.9em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: 0.95em;
  color: var(--ink2);
  font-variant-numeric: tabular-nums;
  background: #142540;
  border: 1px solid rgba(160, 196, 240, 0.25);
}
.board-list li.p1 .rank { color: #2b1700; border-color: #ffe7a6; background: radial-gradient(circle at 35% 30%, #fff5cc, #ffc24b 50%, #b8741a); box-shadow: 0 0 10px rgba(255, 194, 75, 0.45); }
.board-list li.p2 .rank { color: #17202c; border-color: #f2f6fb; background: radial-gradient(circle at 35% 30%, #ffffff, #c9d5e3 50%, #7d8ca0); }
.board-list li.p3 .rank { color: #2a1405; border-color: #f6c79c; background: radial-gradient(circle at 35% 30%, #ffe2c4, #d99258 50%, #8a4f22); }
.board-list .name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .score { font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.board-list li.p1 .score { color: var(--amber); }
.board-list .meta { grid-column: 2 / span 2; color: var(--dim); font-size: 0.76em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list.compact li { padding: 0.3em 0.4em; }
.board-list .empty { display: block; text-align: center; color: var(--dim); border: 0; background: none; padding: 1.2em 0; }

.help-card {
  padding: 0.6em 0.75em 0.7em;
  margin-bottom: 0.55em;
  border-radius: 0.6em;
  border: 1px solid rgba(160, 196, 240, 0.14);
  background: rgba(255, 255, 255, 0.03);
}
.help h3 { margin: 0 0 0.35em; color: var(--amber); font-size: 1em; letter-spacing: 0.1em; }
.help ul { margin: 0; padding-left: 1.15em; line-height: 1.6; font-size: 0.88em; color: var(--ink2); }
.help li::marker { color: var(--cyan); }
.tag { display: inline-block; min-width: 1.4em; text-align: center; border-radius: 0.3em; color: #fff; font-size: 0.85em; }
.tag.p { background: #e8384c; }
.tag.b { background: #2f7fe0; }

/* ------------------------------------------------------------ info chips, dialog */
.info-chip {
  margin: 0 0 0.75em;
  padding: 0.45em 0.65em;
  border-radius: 0.5em;
  font-size: 0.84em;
  line-height: 1.45;
  text-align: center;
  color: var(--ink2);
  background: rgba(111, 216, 255, 0.07);
  border: 1px solid rgba(111, 216, 255, 0.22);
}
.info-chip:empty { display: none; }
.info-chip.warn { text-align: left; color: #ffe4a3; background: rgba(255, 194, 75, 0.08); border-color: rgba(255, 194, 75, 0.3); }
.overlay .volume-box { margin-top: 0.9em; }

.dialog {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  z-index: 5;
}
.dialog[hidden] { display: none; }
.dialog-box {
  width: min(88%, 22em);
  padding: 1.1em 1em 1em;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 194, 75, 0.45);
  background: linear-gradient(180deg, #16284a, #0b1528);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 18px 40px rgba(0, 0, 0, 0.55);
}
.dialog-icon {
  width: 2em;
  height: 2em;
  margin: 0 auto 0.4em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
  color: var(--amber-ink);
  background: radial-gradient(circle at 40% 35%, #fff1c4, var(--amber) 60%, var(--amber-lo));
}
.dialog-box p { margin: 0; line-height: 1.5; }
.dialog-actions { display: flex; gap: 0.6em; margin-top: 0.95em; }
.dialog-actions .btn { flex: 1 1 0; }

#rotate-hint {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: max(8px, env(safe-area-inset-left, 0px));
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--dim);
  font-size: 12px;
  pointer-events: none;
}
#rotate-hint[hidden] { display: none; }
.noscript { position: absolute; inset: 0; display: grid; place-items: center; }

/* ------------------------------------------------------------ multiplayer */
.linkish {
  font: inherit;
  font-size: 0.72em;
  letter-spacing: 0.05em;
  background: none;
  border: 1px solid rgba(111, 216, 255, 0.35);
  border-radius: 999px;
  color: var(--cyan);
  cursor: pointer;
  padding: 0.15em 0.9em;
  min-height: 40px;
  min-width: 48px;
  margin-left: auto;
}
.mp-panel h3 {
  display: flex;
  align-items: center;
  gap: 0.45em;
  margin: 0 0 0.5em;
  font-size: 0.95em;
  color: var(--amber);
  letter-spacing: 0.1em;
}
.mp-block {
  margin-top: 0.75em;
  padding: 0.65em 0.7em;
  border-radius: 0.6em;
  border: 1px solid rgba(160, 196, 240, 0.13);
  background: rgba(255, 255, 255, 0.025);
}
.mp-lead { margin: 0 0 0.75em; font-size: 0.84em; line-height: 1.5; color: var(--ink2); }
.field-label { display: block; font-weight: 800; margin-bottom: 0.35em; font-size: 0.9em; }
.mp-input { width: 100%; font-size: 1.1em; }
#mp-invite-link { font-size: 0.85em; -webkit-touch-callout: default; margin: 6px 0 12px; }
.mp-input.code { flex: 1 1 auto; text-transform: uppercase; letter-spacing: 0.45em; text-align: center; font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-weight: 900; }
.room-list, .member-list { list-style: none; margin: 0; padding: 0; }
.room-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55em;
  padding: 0.4em 0.45em;
  margin-bottom: 0.3em;
  border-radius: 0.5em;
  border: 1px solid rgba(160, 196, 240, 0.12);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.88em;
}
.room-list .code {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--cyan);
  padding: 0.1em 0.4em;
  border-radius: 0.3em;
  border: 1px solid rgba(111, 216, 255, 0.35);
  background: rgba(111, 216, 255, 0.07);
}
.room-list .empty { display: block; color: var(--dim); text-align: center; border: 0; background: none; padding: 0.8em 0; }
.room-code {
  color: var(--amber);
  letter-spacing: 0.22em;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  padding: 0 0.3em;
  border-bottom: 2px solid rgba(255, 194, 75, 0.5);
}
.invite-row { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; margin-bottom: 0.2em; }
.invite-row .hint { margin: 0; text-align: left; }
.member-list li {
  --slot: var(--cyan);
  display: grid;
  grid-template-columns: auto 2.1em 1fr auto;
  align-items: center;
  gap: 0.55em;
  padding: 0.4em 0.55em 0.4em 0;
  margin-bottom: 0.3em;
  border-radius: 0.5em;
  border: 1px solid rgba(160, 196, 240, 0.12);
  background: linear-gradient(90deg, color-mix(in srgb, var(--slot) 14%, transparent), rgba(255, 255, 255, 0.02) 60%);
  overflow: hidden;
}
.member-list .stripe { width: 0.3em; align-self: stretch; background: var(--slot); box-shadow: 0 0 8px var(--slot); }
.member-list canvas { width: 2.1em; height: auto; }
.member-list .who { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-list .who small { display: block; font-size: 0.72em; color: var(--dim); font-weight: 700; letter-spacing: 0.05em; }
.member-list .tag {
  display: flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.76em;
  font-weight: 800;
  color: var(--dim);
  white-space: nowrap;
  background: none;
  min-width: 0;
}
.member-list .tag::before { content: ""; width: 0.6em; height: 0.6em; border-radius: 50%; background: #3a4a66; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); }
.member-list .tag.ok { color: var(--green); }
.member-list .tag.ok::before { background: var(--green); box-shadow: 0 0 6px var(--green); }
.member-list .tag.host { color: var(--amber); }
.member-list .tag.host::before { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.member-list .tag.off { color: #ff9aa4; }
.member-list .tag.off::before { background: var(--red); box-shadow: 0 0 6px var(--red); }
body:not(.is-host) .host-only { display: none; }

#net-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20;
}
#net-overlay[hidden] { display: none; }
.net-box {
  background: linear-gradient(180deg, #16284a, #0b1528);
  border: 1px solid var(--edge-hi);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  text-align: center;
  max-width: 80vw;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
.net-spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 0.5em;
  border-radius: 50%;
  border: 3px solid rgba(111, 216, 255, 0.25);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#toasts {
  position: fixed;
  left: 50%;
  top: max(10px, env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  z-index: 15;
}
.toast {
  background: linear-gradient(180deg, rgba(22, 40, 74, 0.94), rgba(10, 20, 40, 0.94));
  border: 1px solid var(--edge-hi);
  border-left: 3px solid var(--amber);
  color: var(--ink);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Tall hangar plates: show the fighter bigger (container query; older browsers
   simply keep the compact bay). */
.screen[data-screen="hangar"] .panel { container-type: size; container-name: hangar; }
@container hangar (min-height: 32em) {
  .bay { grid-template-columns: minmax(8em, 44%) 1fr; padding: 0.7em 0.75em 0.7em 0.5em; }
  .ship-title { font-size: 1.6em; }
  .stats { font-size: 0.82em; gap: 0.36em 0.6em; }
}

/* ------------------------------------------------------------ compact screens */
/* Short portrait phones (e.g. 320x568): tighter hangar so ship, difficulty and
   take-off controls stay visible without scrolling. */
@media (max-height: 640px) and (orientation: portrait) {
  .screen { padding: 0.7em 0.8em 0.75em; }
  .screen-head { margin-bottom: 0.45em; }
  .screen-head h2 { font-size: 1.32em; }
  .bay { grid-template-columns: minmax(5.5em, 30%) 1fr; padding: 0.4em 0.55em 0.4em 0.35em; }
  .ship-title { font-size: 1.25em; }
  .ship-row { margin-top: 0.45em; }
  .brief { margin-top: 0.45em; padding: 0.4em 0.55em; }
  .section-label { margin: 0.6em 0 0.35em; }
  .diff-desc { min-height: 0; margin-top: 0.35em; }
  .title-wrap { gap: 0.8em; }
  .logo-cn { font-size: 3.1em; }
}

/* Short landscape screens (phones held sideways): two-column hangar so every
   control is visible without scrolling. */
@media (orientation: landscape) and (max-height: 520px) {
  .screen { padding: 0.5em 0.8em 0.6em; }
  .screen-head { margin-bottom: 0.35em; }
  .screen-head h2 { font-size: 1.25em; }
  .screen[data-screen="hangar"] .panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "bay ships" "bay brief" "diffl diffl" "diffs diffs" "desc desc";
    grid-template-rows: auto 1fr auto auto auto;
    gap: 0.4em 0.9em;
    padding: 0.85em 1.1em 1.35em;
    container-type: normal;
  }
  #ship-card { align-self: stretch; }
  #ship-card { grid-area: bay; }
  #ship-row { grid-area: ships; margin-top: 0; }
  .brief { grid-area: brief; margin-top: 0; }
  .screen[data-screen="hangar"] .section-label { grid-area: diffl; margin: 0.1em 0 0; }
  #diff-row { grid-area: diffs; }
  .diff-desc { grid-area: desc; min-height: 0; margin: 0; }
  .ship-btn { aspect-ratio: auto; min-height: 52px; }
  .ship-btn canvas { width: 42%; }
  .bay { grid-template-columns: minmax(5em, 40%) 1fr; }
  .bay-stage { aspect-ratio: 1 / 1; max-height: 9em; }
  .screen-foot { margin-top: 0.4em; }
  .title-wrap { gap: 0.6em; }
  .logo-cn { font-size: 2.6em; }
  .emblem { display: none; }
  .title-menu { width: min(100%, 30em); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
