/* 2.0：配色、字体、圆角、按钮手感由后加载的 ../shared/game-2.css 覆盖（说明见 work/round2/theme-2.md §8），本文件管布局。 */
/* 核爆地貌实验室 · round 4 layout.
   Page = header + workspace (stage, then the deck: context row [timeline | tool sub-options], tool tray, main bar)
   + a collapsed observation note. Scene cards and custom yield live in a DSKit drawer; everything else is in "⋯".
   html.ds-m = phone/tablet layout (bar fixed to the bottom), html.ds-land = short landscape, html.embedded = homepage frame.
   Per-scene colours (--paper --panel --selected --ink --muted --line --green --world-bg) are set by the game. */
:root {
  --paper: #f7f6ee;
  --panel: #f3f4ea;
  --selected: #e6ebdb;
  --ink: #37463d;
  --muted: #8b9387;
  --line: #e1e4d7;
  --green: #718365;
  --orange: #ba6b43;
  --world-bg: #e8ecdf;
  --shield: #5f9a62;
  --head-h: 60px;
  --chrome: 236px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 12px "Microsoft YaHei", "PingFang SC", sans-serif;
  transition: background-color 0.35s ease, color 0.35s ease;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.4;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #ba8556;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
input[type="range"] {
  accent-color: var(--green);
  width: 100%;
  height: 5px;
  cursor: pointer;
}

/* Header */
header {
  height: var(--head-h);
  margin: 0 3%;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  font: 600 21px "Songti SC", "SimSun", serif;
  letter-spacing: 2px;
}
.brand small {
  font: 8px Georgia;
  letter-spacing: 2.5px;
  display: block;
  margin-top: 5px;
}
.brand-mark {
  font: 34px Georgia;
  color: var(--green);
  width: 40px;
  height: 40px;
  border: 1px solid #aab69c;
  display: grid;
  place-items: center;
  border-radius: 11px;
  transform: rotate(-8deg);
}
.header-note {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
}
.header-note i,
.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8ba47d;
  margin-right: 9px;
}
main {
  max-width: 1650px;
  margin: auto;
  padding: 12px 3% 0;
}
.eyebrow {
  font-size: 8px;
  letter-spacing: 2px;
  color: #939b87;
}

/* Workspace: stage + deck */
.workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid #dfe4d3;
  background: var(--world-bg);
  isolation: isolate;
}
.stage {
  position: relative;
  flex: none;
  height: clamp(420px, calc(100dvh - var(--chrome)), 880px);
  overflow: hidden;
  overscroll-behavior: none;
}
#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#scene.placing {
  cursor: crosshair;
}
.stage,
.deck {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.stage button,
.deck button,
.deck select,
.deck input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.scene-top {
  position: absolute;
  z-index: 4;
  left: 20px;
  right: 16px;
  top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
}
.ds-status {
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.strike-count {
  display: inline-block;
  margin-left: 10px;
  border: 1px solid #aebc9c;
  border-radius: 12px;
  padding: 3px 8px;
  color: #778966;
  font-size: 10px;
}
.view-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.view-actions [data-ds-more] {
  display: none;
}
.view-actions button {
  position: relative;
  min-height: 34px;
  border: 1px solid #d5ddc7;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 20px;
  font-size: 12px;
  padding: 0 14px;
}
.view-actions .ds-scene-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-color: color-mix(in srgb, var(--green) 55%, #d5ddc7);
}
.view-actions .ds-scene-btn b {
  color: var(--green);
}
.view-actions .ds-scene-btn i {
  font-style: normal;
  font-size: 10px;
  margin-left: 4px;
  color: var(--muted);
}
.view-actions .dsk-more-btn {
  min-width: 40px;
  padding: 0 10px;
  font-size: 16px;
  line-height: 1;
}
.view-actions button[aria-expanded="true"] {
  background: var(--selected);
}
.scene-copy {
  position: absolute;
  top: 62px;
  left: 22px;
  z-index: 2;
  pointer-events: none;
}
.scene-copy h2 {
  font: 500 22px "Songti SC", "SimSun", serif;
  letter-spacing: 2px;
  margin: 8px 0;
}
.scene-copy p {
  font-size: 10px;
  color: #929b83;
  max-width: 270px;
  line-height: 1.9;
  margin: 0;
}
.scene-copy .eyebrow {
  color: #8e9c7b;
}
#annotations {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.annotation {
  position: absolute;
  transform: translate(-50%, -100%);
  color: #6b7e60;
  background: #fbfcf0dd;
  border: 1px solid #d4dec6;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 9px;
  white-space: nowrap;
  box-shadow: 0 2px 10px #34472109;
}
.annotation:after {
  content: "";
  height: 16px;
  width: 1px;
  background: #97a58a;
  position: absolute;
  left: 50%;
  top: 100%;
}
.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
  mix-blend-mode: screen;
  background: radial-gradient(
    ellipse at var(--fx, 50%) var(--fy, 55%),
    #fff 0%,
    #fff3ba calc(17% + var(--fs, 0%)),
    #ff994b88 calc(40% + var(--fs, 0%)),
    transparent calc(75% + var(--fs, 0%) * 1.4)
  );
}
.compass {
  position: absolute;
  right: 22px;
  bottom: 12px;
  text-align: center;
  pointer-events: none;
  color: #9da78e;
}
.compass > span {
  font: 10px Georgia;
}
.compass div {
  font: 30px Georgia;
  margin-top: -5px;
}
.compass small {
  font-size: 8px;
  display: block;
  margin-top: 2px;
}
/* Live readout: shielded groups (the green ring doubles as legend), destroyed buildings, ground changed. */
.ds-live {
  position: absolute;
  z-index: 2;
  left: 20px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px 14px;
  flex-wrap: wrap;
  max-width: 46%;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
.ds-live b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ds-live i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 2px solid var(--shield);
  border-radius: 50%;
}
.ds-live .ds-live-shield b {
  color: var(--shield);
}
.scene-caption {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  text-align: center;
  font-size: 11px;
  color: #8f9b81;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.workspace.ds-tooling #hint {
  visibility: hidden;
}
.ds-chip {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 14px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--green);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 6px 18px #2a33281f;
}
.ds-chip span {
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ds-chip button {
  position: relative;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--selected);
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  padding: 0;
}
.ds-chip button::after {
  content: "";
  position: absolute;
  inset: -7px;
}

/* Deck: [timeline | sub-options] over [tool tray · main bar] */
.deck {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 45%, var(--world-bg));
}
.ds-ctx {
  flex: 1 1 100%;
  height: 44px;
  display: flex;
  min-width: 0;
}
.control-dock,
.ds-sub {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid #fff;
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
}
.control-dock button {
  background: transparent;
  border: 0;
  font-size: 14px;
  min-width: 28px;
  min-height: 34px;
  padding: 0;
}
.control-dock .time {
  font: 11px monospace;
  white-space: nowrap;
  color: #708060;
}
.control-dock input {
  flex: 1;
  width: 0;
  min-width: 40px;
}
.duration {
  font: 10px monospace;
  color: #9da78d;
}
.deck.ds-sub-on .control-dock {
  display: none;
}
.ds-sub {
  gap: 8px;
  padding: 0 10px 0 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ds-sub::-webkit-scrollbar {
  display: none;
}
.ds-sub-title {
  flex: none;
  font: 600 13px "Noto Serif SC", "Songti SC", serif;
  color: var(--green);
  margin-right: 4px;
}
.ds-sub-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.ds-sub button,
.ds-sub select {
  flex: none;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: transparent;
  font-size: 12px;
  white-space: nowrap;
}
.ds-sub select {
  background: color-mix(in srgb, var(--selected) 60%, transparent);
  padding: 0 8px;
}
.ds-sub button.active,
.ds-sub button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--green) 18%, transparent);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}
.ds-brush {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.ds-brush input {
  width: 110px;
}
.ds-brush output {
  min-width: 24px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
#edit-note {
  flex: 1 0 auto;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ds-tools {
  flex: 0 0 auto;
  max-width: 100%;
  min-width: 0;
}
.ds-tools .dsk-tray {
  box-shadow: none;
}
.dsk-tool[aria-pressed="true"] b {
  color: var(--green);
}

/* Main bar: yield + burst mode + locate + undo + launch */
.ds-bar {
  flex: 1 1 560px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ds-bar-yield {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
}
.ds-bar-yield label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ds-bar-yield output {
  min-width: 56px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  color: var(--orange);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ds-bar-yield small {
  min-width: 62px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ds-bar-yield input {
  flex: 1;
  min-width: 80px;
  width: auto;
}
.ds-burst {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  white-space: nowrap;
}
.ds-burst b {
  font-weight: 400;
  color: var(--muted);
}
.ds-burst[aria-pressed="true"] {
  background: #f4dec1;
  border-color: #ba8556;
  color: #996834;
}
.ds-bar-actions {
  flex: none;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.ds-bar-actions button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--selected) 55%, var(--paper));
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}
.ds-bar-actions b {
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}
.ds-bar-actions button[aria-pressed="true"],
.ds-bar-actions button[aria-expanded="true"] {
  background: #f4dec1;
  border-color: #ba8556;
  color: #996834;
}
.ds-bar-actions .ds-launch {
  gap: 12px;
  padding: 0 22px;
  background: var(--green);
  border: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--green) 40%, transparent);
}
.ds-bar-actions .ds-launch:hover {
  filter: brightness(0.95);
}
.ds-bar-actions .ds-launch:active {
  transform: scale(0.98);
}
.ds-m-only {
  display: none !important;
}

/* Detonation tint, cinema mode */
.workspace.detonating .scene-top,
.workspace.detonating .scene-copy h2 {
  color: #fff3d8;
}
.workspace.detonating .scene-copy p,
.workspace.detonating .scene-copy .eyebrow,
.workspace.detonating .scene-caption,
.workspace.detonating .ds-live,
.workspace.detonating .ds-live b,
.workspace.detonating .compass {
  color: #dfd5b8;
}
.workspace.detonating .strike-count {
  color: #f6dbac;
  border-color: #c9ad78;
}
.workspace.detonating .deck {
  background: color-mix(in srgb, var(--panel) 35%, #2c2a26);
}
.workspace.cinema {
  position: fixed;
  inset: 12px;
  z-index: 20;
  box-shadow: 0 0 0 30px #292c24dd;
}
.workspace.cinema .stage {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

/* Collapsed observation note */
.observation {
  margin: 16px 0 0;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.observation summary {
  display: flex;
  align-items: baseline;
  gap: 14px;
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
}
.observation summary::-webkit-details-marker {
  display: none;
}
.observation summary b {
  font: 500 16px "Songti SC", "SimSun", serif;
}
.observation summary b::after {
  content: " ▾";
  font-size: 11px;
  color: var(--muted);
}
.observation[open] summary b::after {
  content: " ▴";
}
.observation summary small {
  color: var(--muted);
  font-size: 10px;
}
.observation-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 28px;
  padding-top: 14px;
}
.metric {
  border-left: 1px solid var(--line);
  padding: 2px 0 0 20px;
}
.metric > span {
  font-size: 10px;
  color: #8a9580;
}
.metric strong {
  display: block;
  font: 20px "Songti SC", "SimSun", serif;
  margin: 10px 0;
  color: #78896b;
}
.metric small {
  font-size: 10px;
  color: #9aa18e;
  line-height: 1.8;
  display: block;
}
.science-note {
  grid-column: 1/-1;
  font-size: 10px;
  line-height: 1.8;
  color: #9ca28f;
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px dashed var(--line);
}
footer {
  margin: 10px 3% 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #a3aa98;
  font-size: 9px;
  letter-spacing: 1px;
}

/* Scene + settings drawer (DSKit.drawer) */
.ds-setup-intro {
  margin: 0 0 14px;
  font-size: 11px;
  line-height: 1.9;
  color: var(--muted);
}
.ds-setup section + section {
  margin-top: 20px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.section-title h2 {
  font-size: 12px;
  font-weight: 600;
  margin: 0;
}
.section-title > span {
  font: 8px Georgia;
  color: #9ba38e;
  letter-spacing: 1px;
}
.section-title output {
  color: var(--orange);
  font-size: 12px;
  font-weight: 600;
}
.scene-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.scene-card {
  min-height: 64px;
  padding: 6px 4px 8px;
  background: #f0f1e6;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: transform 0.2s, background 0.2s;
}
.scene-card:hover {
  transform: translateY(-2px);
}
.scene-card.active {
  background: #e6ebdb;
  border-color: #82966f;
  box-shadow: 0 0 0 1px #82966f;
}
.scene-card canvas {
  display: block;
  width: 100%;
  height: 46px;
}
.scene-card span {
  font-size: 11px;
  display: block;
  margin-top: 3px;
}
.yield-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.yield-row label,
.yield-row span {
  color: var(--muted);
  font-size: 11px;
}
.yield-row input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf6;
}
.yield-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.yield-presets button,
.ds-setup select {
  min-height: 38px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  white-space: nowrap;
}
.yield-presets button.active {
  background: var(--selected);
  border-color: var(--green);
  color: var(--green);
}
.ds-setup select {
  width: 100%;
  padding: 0 8px;
  background: #fffdf6;
}
.parameter-note {
  font-size: 10px;
  color: #9b9f90;
  line-height: 1.8;
  margin: 8px 0 0;
}
.quiet-note {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #a0a58e;
  margin-top: 22px;
}
.quiet-note > span {
  font: 30px Georgia;
}
.quiet-note p {
  font-size: 10px;
  line-height: 1.9;
  margin: 0;
}
.dsk-more-menu {
  max-height: calc(100dvh - 80px);
  overflow: auto;
}

/* Report: occlusion observation block */
.ds-occl {
  margin: 2px 0 8px;
  padding: 8px 10px 9px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--shield) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--shield) 30%, transparent);
}
.ds-occl h4 {
  margin: 0 0 4px;
  font: 600 13px "Noto Serif SC", "Songti SC", serif;
  color: #4c7d50;
}
.ds-occl .dsk-rows {
  margin: 0;
}
.ds-occl .dsk-note {
  margin: 5px 0 0;
}
.ds-occl .ds-occl-how {
  font-size: 10px;
  opacity: 0.85;
}

/* Help dialog + settings */
dialog {
  border: 1px solid #dbe2ce;
  border-radius: 20px;
  background: #fafbf2;
  color: var(--ink);
  width: 520px;
  max-width: 92vw;
  max-height: 88dvh;
  padding: 28px;
  box-shadow: 0 20px 100px #35473c22;
}
dialog::backdrop {
  background: #35473c55;
  backdrop-filter: blur(5px);
}
dialog h2 {
  font: 22px "SimSun", serif;
}
dialog p {
  font-size: 12px;
  line-height: 2;
  color: #7e8975;
}
dialog a {
  color: var(--green);
}
.close {
  position: absolute;
  right: 12px;
  top: 8px;
  min-width: 40px;
  min-height: 40px;
  border: 0;
  background: none;
  font-size: 24px;
}
.launch {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 14px;
  margin-top: 16px;
}
.ds-settings {
  display: grid;
  gap: 8px;
  margin: 4px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--green) 6%, transparent);
}
.ds-settings > b {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
}
.ds-settings label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.5;
}
.ds-settings input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--green);
}
.ds-settings small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
}
.ds-settings button {
  justify-self: start;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 11px;
}

/* Simple mode: fewer sub-options */
html.ds-simple .observation,
html.ds-simple .ds-sub [data-tool="smooth"],
html.ds-simple .ds-sub [data-tool="square"],
html.ds-simple .duration {
  display: none;
}

/* Embedded in the homepage */
html.embedded {
  --head-h: 46px;
  --chrome: 214px;
}
html.embedded .brand {
  font-size: 16px;
}
html.embedded .brand small,
html.embedded .header-note {
  display: none;
}
html.embedded .brand-mark {
  width: 30px;
  height: 30px;
  font-size: 24px;
  border-radius: 8px;
}
html.embedded main {
  padding-top: 8px;
}

@media (min-width: 1500px) {
  .stage {
    height: clamp(420px, calc(100dvh - var(--chrome)), 900px);
  }
}
/* Narrow desktop: tray and bar on separate rows */
@media (max-width: 1180px) {
  :root {
    --chrome: 300px;
  }
  html.embedded {
    --chrome: 278px;
  }
  .ds-bar {
    flex-basis: 100%;
  }
  .header-note {
    display: none;
  }
  .compass small {
    display: none;
  }
}

/* Touch targets */
@media (pointer: coarse) {
  .view-actions button {
    min-height: 40px;
  }
  .ds-sub button,
  .ds-sub select {
    min-height: 40px;
  }
  .control-dock button {
    min-width: 44px;
    min-height: 44px;
  }
  .scene-card {
    min-height: 66px;
  }
  .yield-presets button,
  .yield-row input,
  .ds-setup select {
    min-height: 44px;
  }
  .ds-settings label {
    min-height: 44px;
    align-items: center;
  }
  .ds-settings button {
    min-height: 44px;
  }
  input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 40px;
    background: transparent;
    touch-action: none;
  }
  input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--green) 30%, var(--line));
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px;
    height: 26px;
    margin-top: -10px;
    border-radius: 50%;
    background: var(--green);
    border: 3px solid var(--paper);
    box-shadow: 0 1px 5px #0003;
  }
  input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--green) 30%, var(--line));
  }
  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--green);
    border: 3px solid var(--paper);
  }
  input[type="range"]:disabled::-webkit-slider-thumb {
    background: var(--muted);
  }
}

/* Phone / tablet layout: the main bar is fixed to the bottom (two rows on phones), the deck keeps context row + tray. */
html.ds-m {
  --ds-bar-h: 112px;
  --deck-m: 132px;
}
html.ds-m body {
  padding-bottom: calc(var(--ds-bar-h) + env(safe-area-inset-bottom));
}
html.ds-m header {
  height: 50px;
  margin: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right));
}
html.ds-m .brand {
  font-size: 16px;
  gap: 9px;
}
html.ds-m .brand small,
html.ds-m .header-note {
  display: none;
}
html.ds-m .brand-mark {
  width: 30px;
  height: 30px;
  font-size: 24px;
  border-radius: 8px;
}
html.ds-m main {
  padding: 8px max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
}
html.ds-m .workspace {
  border-radius: 14px;
}
html.ds-m .stage {
  height: clamp(280px, calc(100svh - 66px - var(--deck-m) - var(--ds-bar-h) - env(safe-area-inset-bottom)), 900px);
}
html.ds-m .scene-top {
  left: 10px;
  right: 8px;
  top: 8px;
}
html.ds-m .ds-scene-btn {
  display: none;
}
html.ds-m .scene-copy {
  left: 14px;
  top: 52px;
}
html.ds-m .scene-copy h2 {
  font-size: 16px;
  margin: 4px 0;
}
html.ds-m .scene-copy p {
  display: none;
}
html.ds-m .ds-live {
  left: 12px;
  bottom: 10px;
  max-width: 70%;
  gap: 2px 10px;
  font-size: 10px;
}
html.ds-m .compass {
  right: 12px;
  bottom: 6px;
}
html.ds-m .compass small {
  display: none;
}
html.ds-m .compass div {
  font-size: 24px;
}
html.ds-m .stage #hint {
  bottom: 34px;
  font-size: 10px;
  white-space: normal;
  width: calc(100% - 24px);
}
html.ds-m .ds-chip {
  bottom: 34px;
  font-size: 13px;
}
html.ds-m .deck {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 6px;
  padding: 8px;
}
html.ds-m .ds-ctx {
  flex: none;
}
html.ds-m .control-dock {
  gap: 10px;
  padding: 0 12px;
}
html.ds-m .control-dock #play {
  display: none;
}
html.ds-m .ds-sub {
  padding: 0 8px;
  gap: 6px;
}
html.ds-m .ds-sub-title,
html.ds-m #edit-note {
  display: none;
}
html.ds-m .ds-brush {
  margin-left: 2px;
  padding-left: 8px;
  gap: 6px;
}
html.ds-m .ds-brush input {
  width: 96px;
}
html.ds-m .ds-tools {
  flex: none;
}
html.ds-m .ds-tools .dsk-tray {
  width: 100%;
}
html.ds-m .ds-m-only {
  display: flex !important;
}
html.ds-m .ds-bar {
  position: fixed;
  z-index: 31;
  left: 0;
  right: 0;
  bottom: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--panel, var(--paper)) 95%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px #2a33281a;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
html.ds-m .ds-bar button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
html.ds-m .ds-bar-yield {
  height: 40px;
  gap: 8px;
}
html.ds-m .ds-bar-yield small {
  min-width: 0;
}
html.ds-m .ds-bar-yield output {
  min-width: 50px;
}
html.ds-m .ds-burst {
  min-height: 40px;
  padding: 0 10px;
  font-size: 11px;
}
html.ds-m .ds-bar-actions {
  gap: 6px;
}
html.ds-m .ds-bar-actions button {
  flex: 0 0 52px;
  height: 52px;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  font-size: 10px;
}
html.ds-m .ds-bar-actions b {
  font-size: 19px;
}
html.ds-m .ds-bar-actions .ds-launch {
  flex: 1 1 auto;
  flex-direction: row;
  gap: 10px;
  padding: 0;
  font-size: 15px;
}
html.ds-m .workspace.cinema {
  inset: 5px 5px calc(var(--ds-bar-h) + env(safe-area-inset-bottom) + 5px);
}
html.ds-m .dsk-layer {
  padding-bottom: calc(var(--ds-bar-h) + env(safe-area-inset-bottom) + 8px);
}
html.ds-m .dsk-card {
  max-height: calc(100svh - var(--ds-bar-h) - env(safe-area-inset-bottom) - 24px);
}
html.ds-m .dsk-toast {
  bottom: calc(var(--ds-bar-h) + env(safe-area-inset-bottom) + 14px);
}
html.ds-m .dsk-drawer {
  z-index: 62;
}
html.ds-m .observation-body {
  grid-template-columns: 1fr;
}
html.ds-m footer {
  flex-direction: column;
}
@media (max-width: 380px) {
  html.ds-m .ds-bar-yield small {
    display: none;
  }
  html.ds-m .ds-bar-actions button {
    flex-basis: 48px;
  }
}
/* Tablets: one-row bar */
@media (min-width: 600px) {
  html.ds-m {
    --ds-bar-h: 68px;
  }
  html.ds-m .ds-bar {
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }
  html.ds-m .ds-bar-actions .ds-launch {
    flex: 0 0 auto;
    padding: 0 22px;
  }
}
/* Short landscape: no header; the stage fills the screen above the bar; the tray stands on the left edge and the
   timeline / sub-options row floats over the bottom of the stage. */
html.ds-land {
  --ds-bar-h: 64px;
}
html.ds-land header {
  display: none;
}
html.ds-land main {
  padding-top: max(6px, env(safe-area-inset-top));
}
html.ds-land .stage {
  height: calc(100svh - var(--ds-bar-h) - env(safe-area-inset-bottom) - 12px);
  min-height: 220px;
}
html.ds-land .scene-copy,
html.ds-land .compass {
  display: none;
}
html.ds-land .deck {
  padding: 0;
  border: 0;
  gap: 0;
}
html.ds-land .ds-tools {
  position: fixed;
  z-index: 8;
  left: max(14px, env(safe-area-inset-left));
  top: calc(max(6px, env(safe-area-inset-top)) + 48px);
  bottom: calc(var(--ds-bar-h) + env(safe-area-inset-bottom) + 8px);
  display: flex;
  align-items: flex-start;
  max-width: none;
}
html.ds-land .ds-tools .dsk-tray {
  flex-direction: column;
  width: auto;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 100%;
  padding: 4px;
}
html.ds-land .dsk-tray .dsk-sep {
  display: none;
}
html.ds-land .dsk-tool {
  min-width: 58px;
  min-height: 42px;
  padding: 3px 4px;
  gap: 1px;
  font-size: 10px;
}
html.ds-land .dsk-tool b {
  font-size: 16px;
  line-height: 18px;
}
html.ds-land .ds-ctx {
  position: fixed;
  z-index: 8;
  left: calc(max(14px, env(safe-area-inset-left)) + 78px);
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(var(--ds-bar-h) + env(safe-area-inset-bottom) + 12px);
  height: 44px;
}
html.ds-land .ds-ctx .control-dock,
html.ds-land .ds-ctx .ds-sub {
  box-shadow: 0 6px 18px #2a33281a;
}
html.ds-land .ds-live {
  left: 50%;
  bottom: auto;
  top: 16px;
  transform: translateX(-50%);
  max-width: 50%;
  flex-wrap: nowrap;
  white-space: nowrap;
}
html.ds-land .stage #hint,
html.ds-land .ds-chip {
  bottom: 64px;
  left: calc(50% + 40px);
}
html.ds-land .stage #hint {
  width: auto;
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  body,
  .scene-card {
    transition: none;
  }
}
/* Closed drawer is also invisible (not just slid away), so it never takes focus or counts as on-screen. */
.dsk-drawer:not(.open) {
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s 0.25s;
}
html.ds-m .ds-tools .dsk-tool {
  flex: 1 1 0;
  min-width: 46px;
  padding: 6px 2px;
}
html.ds-land .ds-tools .dsk-tool {
  flex: none;
  min-height: 40px;
}
html.ds-m .ds-tools .dsk-tool span {
  white-space: nowrap;
}
@media (max-width: 380px) {
  html.ds-m .ds-tools .dsk-tool {
    font-size: 10px;
    min-width: 0;
  }
}

/* Fortify observation / protection mode (2026-10-23): mode switch, level rows, hazard panel, points readout. */
.ds-mode-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f0f1e6;
}
.ds-mode-seg button {
  min-height: 48px;
  padding: 6px 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  text-align: center;
}
.ds-mode-seg b {
  display: block;
  font-size: 13px;
  font-weight: 600;
}
.ds-mode-seg small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
}
.ds-mode-seg button[aria-pressed="true"] {
  background: var(--panel);
  border-color: var(--green);
  color: var(--ink);
  box-shadow: 0 1px 4px #3a46301f;
}
.ds-lv-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.ds-lv-row button {
  min-height: 40px;
  padding: 4px 0 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}
.ds-lv-row button i {
  display: block;
  width: calc(var(--lv) * 5px);
  height: 3px;
  margin: 4px auto 0;
  background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 5px);
  opacity: 0.55;
}
.ds-lv-row button[aria-pressed="true"] {
  background: var(--selected);
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
  color: var(--green);
  font-weight: 600;
}
.ds-haz-info {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.8;
  color: var(--muted);
}
.ds-haz-info b {
  color: var(--ink);
  font-weight: 600;
}
.ds-haz-go {
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--selected);
  color: var(--green);
  font-weight: 600;
}
.ds-haz-go[hidden] {
  display: none;
}
.ds-live [hidden] {
  display: none;
}
.ds-live-pts.over b {
  color: var(--orange);
}
/* Fortify observation: the preset decides ridges and reinforcement, so the build tray is hidden. */
html.ds-pm-fortify .ds-tools {
  display: none;
}
@media (pointer: coarse) {
  .ds-lv-row button,
  .ds-haz-go {
    min-height: 44px;
  }
}
/* Round 2 (2026-10-23): allowance bar, cost badge on the launch button, weak-point lines and board labels. */
.ds-live .ds-live-energy i {
  position: relative;
  width: 64px;
  height: 6px;
  margin: 0 6px 0 4px;
  vertical-align: 1px;
  border: 1px solid #b6bea8;
  border-radius: 4px;
  overflow: hidden;
  background: #fbfcf0aa;
}
.ds-live .ds-live-energy u {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--green);
  transition: width 0.4s;
}
.ds-live .ds-live-energy.low u {
  background: #c7843d;
}
.ds-bar-actions .ds-launch {
  position: relative;
}
.ds-cost {
  position: absolute;
  top: -9px;
  right: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fbfcf0;
  border: 1px solid var(--green);
  color: var(--green);
  font: 600 10px/1.5 sans-serif;
  font-style: normal;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
}
.ds-cost.over {
  border-color: #c7843d;
  color: #a5642a;
}
.ds-cost[hidden] {
  display: none;
}
.ds-fort-weak b {
  color: #a5642a;
}
.annotation.ds-mark-label {
  color: #8a5a22;
  border-color: #e3c08c;
  background: #fdf6e8e6;
}
.annotation.ds-mark-label:after {
  background: #c99a5a;
}
/* Two-line live readout (allowance / points): keep it clear of the centred caption. */
.ds-live {
  max-width: 34%;
}
html.ds-m.ds-live2 .stage #hint,
html.ds-m.ds-live2 .ds-chip {
  bottom: 50px;
}
/* Hints (提示): next to the panel actions; highlighted after a round or run that fell short. */
.ds-hint-row {
  display: flex;
  gap: 8px;
}
.ds-hint-row .ds-haz-go {
  flex: 2 1 0;
}
.ds-hint-row .ds-hint-btn {
  flex: 1 1 0;
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
  font-weight: 500;
}
.ds-hint-row .ds-hint-btn.hot {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 600;
}
