/* 2.0：配色、字体、圆角、按钮手感由后加载的 ../shared/game-2.css 覆盖（说明见 work/round2/theme-2.md §8），本文件管布局。 */
/* Earthquake sandbox — round 4 layout: header (scene button, challenge, "⋯"), data card, tool tray + action bar.
   "Compact" = (max-width: 800px), (max-height: 500px); keep in sync with dsCQ in the bundle. */
:root {
  --ink: #313d35;
  --muted: #858979;
  --accent: #b65e3b;
  --line: #dedfd3;
  --paper: #f7f7ee;
  --panel: #f9faefeb;
  --green: #687958;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #e7ebdf;
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: 13px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button,
select,
input {
  font: inherit;
}
button,
select {
  color: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf5;
  padding: 9px 13px;
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover {
  background: #e7eadc;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}
button,
select,
label,
summary {
  touch-action: manipulation;
}
#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#world,
header,
.bottom,
.telemetry,
.scene-heading,
.ds-pill {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
[hidden] {
  display: none !important;
}

/* ---- Header: brand, scene button, challenge and the "⋯" menu ---- */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  height: calc(66px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 18px;
  padding: env(safe-area-inset-top) calc(26px + env(safe-area-inset-right)) 0 calc(28px + env(safe-area-inset-left));
  pointer-events: none;
}
header > * {
  pointer-events: auto;
}
/* The page header rule above must not reach the drawers (DSKit drawer header): keep it in the flow. */
.dsk-drawer header {
  position: static;
  height: auto;
  z-index: auto;
  gap: 8px;
  padding: 14px 12px 8px 18px;
  pointer-events: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 2px;
}
.brand small {
  display: block;
  font-family: Consolas, monospace;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 1.6px;
  margin-top: 4px;
}
.brand-mark {
  font-size: 40px;
  line-height: 40px;
  color: var(--accent);
}
.dsq-scene-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 14px;
  border-radius: 21px;
  background: #f8faefe6;
  box-shadow: 0 4px 16px #4b634b10;
  white-space: nowrap;
}
.dsq-scene-btn small {
  font-size: 10px;
  color: var(--muted);
}
.dsq-scene-btn b {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
}
.dsq-scene-btn i {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}
.header-right {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}
.header-right button {
  background: #f8faefe6;
  min-height: 40px;
}
.header-right .dsk-more-btn {
  min-width: 46px;
  font-size: 20px;
  line-height: 1;
  padding: 4px 10px;
}
.live {
  font-size: 11px;
  margin-right: 6px;
  color: #66745d;
  white-space: nowrap;
}
.live i,
.signal-title i,
.legend i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7f9564;
  margin-right: 6px;
}
#dsq-ch-btn {
  color: var(--accent);
  border-color: #e3bfa8;
}
.dsq-ch #dsq-ch-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8e9;
}
.scene-heading {
  position: fixed;
  top: calc(70px + env(safe-area-inset-top));
  left: calc(32px + env(safe-area-inset-left));
  pointer-events: none;
}
.scene-heading h2 {
  font-family: "Songti SC", SimSun, serif;
  font-size: 26px;
  letter-spacing: 4px;
  font-weight: 400;
  margin: 6px 0 4px;
}
.scene-heading p {
  margin: 0;
  font-size: 10px;
  color: #84917e;
  letter-spacing: 1px;
}
.scene-heading .eyebrow span {
  margin-left: 12px;
}
.eyebrow {
  font:
    10px Consolas,
    monospace;
  letter-spacing: 2px;
  color: #7f8a74;
}

/* ---- Data card: status, two key numbers, details on demand ---- */
.telemetry {
  position: fixed;
  z-index: 2;
  top: calc(72px + env(safe-area-inset-top));
  right: calc(24px + env(safe-area-inset-right));
  width: 236px;
  max-height: calc(100dvh - 72px - var(--dock-height, 120px) - 40px);
  overflow: auto;
  scrollbar-width: none;
  padding: 11px 14px 8px;
  background: #f7f9efe6;
  border: 1px solid #fff8;
  border-radius: 14px;
  box-shadow: 0 8px 30px #4b634b0c;
  backdrop-filter: blur(8px);
}
.signal-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font: 10px Consolas;
  color: #8c9580;
}
.signal-title b {
  font-family: "Microsoft YaHei UI", sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: #617152;
}
.signal-title i.active {
  background: #b65e3b;
  animation: pulse 0.6s infinite alternate;
}
@keyframes pulse {
  to {
    opacity: 0.3;
  }
}
.dsq-key {
  display: flex;
  gap: 18px;
  margin-top: 6px;
}
.dsq-key strong,
.metrics strong {
  font: 24px Georgia;
}
.dsq-key strong.hot {
  color: var(--accent);
}
.dsq-key em,
.metrics em {
  font: 10px Consolas;
  margin-left: 3px;
  color: #969e8b;
  font-style: normal;
}
.dsq-key span,
.metrics span {
  display: block;
  font-size: 9px;
  color: #8b9480;
  margin-top: 2px;
}
#dsq-data summary {
  margin-top: 6px;
  padding: 4px 0 2px;
  font-size: 10px;
  color: #7f8a74;
  cursor: pointer;
  list-style: none;
  border-top: 1px solid var(--line);
}
#dsq-data summary::-webkit-details-marker {
  display: none;
}
#dsq-data summary::after {
  content: " ▾";
}
#dsq-data[open] summary::after {
  content: " ▴";
}
.failure-stats {
  margin-top: 6px;
  font-size: 10px;
  color: #9b6e48;
}
#seismogram {
  width: 100%;
  height: 44px;
  display: block;
  margin: 8px 0;
}
.metrics {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.metrics strong {
  font-size: 17px;
}
.legend {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 10px;
  color: #7b866f;
}
.legend .hurt {
  background: #d19a52;
}
.legend .fallen {
  background: #ad5b40;
}
.geo-panel {
  margin-top: 6px;
}
.selection-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin: 8px 0 6px;
}
.selection-title b {
  font-size: 12px;
  font-weight: 600;
}
.selection-title small {
  font-size: 9px;
  color: #87927c;
}
.selection-detail,
.hydro-stats {
  display: grid;
  gap: 5px;
  font-size: 10px;
  color: #87917c;
}
.selection-detail > span,
.hydro-stats > span {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.selection-detail b,
.hydro-stats b {
  font-weight: 400;
  color: #596c52;
  text-align: right;
}
.hydro-stats {
  margin-top: 8px;
  border-top: 1px solid #d9dfce;
  padding-top: 8px;
}
#zone-stats {
  margin-top: 8px;
  border-top: 1px solid #d9dfce;
  padding-top: 7px;
  display: grid;
  gap: 5px;
}
.zone-row {
  display: grid;
  grid-template-columns: 76px 1fr 34px;
  gap: 8px;
  align-items: center;
  font-size: 9px;
  color: #7d8c72;
}
.zone-row .bar {
  height: 3px;
  background: #dce1d2;
  border-radius: 2px;
  overflow: hidden;
}
.zone-row .bar i {
  display: block;
  height: 100%;
  background: #bb7950;
}
.zone-row b {
  font: 9px Consolas;
  text-align: right;
}
#geo-legend {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 9px;
  color: #829074;
}
#geo-legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 2px;
}
.dsq-spent {
  margin: 8px 0 0;
  font-size: 10px;
  color: var(--accent);
}
.comparison-note {
  font-size: 9px;
  color: #929a85;
  line-height: 1.6;
  margin: 6px 0 0;
}

/* ---- Bottom dock: tool tray (+ undo) and action bar; terrain sub-tools float above ---- */
.bottom {
  position: fixed;
  z-index: 3;
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.bottom > * {
  pointer-events: auto;
}
.dsq-dock {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.dsq-traybox {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
#dsq-tray {
  min-width: 0;
  display: flex;
}
.dsk-tool svg {
  width: 22px;
  height: 22px;
  display: block;
}
.dsk-tool b {
  display: flex;
  justify-content: center;
}
.dsk-tool.dsq-rec::after {
  content: "推荐";
  position: absolute;
  top: 3px;
  right: 3px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff8e9;
  font-size: 8px;
  line-height: 13px;
}
.dsq-undo {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 56px;
  padding: 6px 8px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  box-shadow: 0 8px 30px #2a352816;
  font-size: 11px;
}
.dsq-undo i {
  font-style: normal;
  font-size: 20px;
  line-height: 22px;
}
.dsq-trash {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed #b65e3b;
  border-radius: 16px;
  background: #f7e6dcf0;
  color: #9a4a2c;
  font-size: 14px;
  letter-spacing: 1px;
  pointer-events: none;
}
.dsq-trash b {
  font-size: 22px;
  font-weight: 400;
}
.dsq-trash.hot {
  background: #b65e3bf0;
  color: #fff8e9;
}
.dsq-dragging:not(.dsq-ch) .dsq-trash {
  display: flex;
}
.dsq-sub {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  display: none;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid #fff9;
  border-radius: 14px;
  box-shadow: 0 6px 24px #4b634b10;
}
body[data-tool="raise"] .dsq-sub,
body[data-tool="lower"] .dsq-sub,
body[data-tool="smooth"] .dsq-sub,
body[data-tool="flatten"] .dsq-sub,
body[data-tool="ridge"] .dsq-sub,
body[data-tool="softsoil"] .dsq-sub,
body[data-tool="build"] .dsq-sub,
body[data-tool="remove"] .dsq-sub,
body[data-tool="bedrock"] .dsq-sub,
body[data-tool="improve"] .dsq-sub {
  display: flex;
}
body[data-tool="improve"] .dsq-sub-tools,
body:not([data-tool="build"]) #building,
body[data-tool="build"] .dsq-brush {
  display: none;
}
.dsq-sub-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.dsq-sub-tools button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  padding: 7px 9px;
  font-size: 11px;
  white-space: nowrap;
  border-radius: 9px;
}
.dsq-sub-tools button svg {
  width: 17px;
  height: 17px;
}
.dsq-sub-tools button.selected {
  background: #657953;
  color: #f7fae9;
}
.dsq-sub-sep {
  flex: 0 0 1px;
  align-self: stretch;
  margin: 4px 4px;
  background: var(--line);
}
#building {
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  font-size: 11px;
}
.dsq-brush {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #81916f;
  white-space: nowrap;
}
.dsq-brush input {
  width: 90px;
  margin: 0;
}
.dsq-brush span {
  font: 10px Consolas;
}
.dsq-hint {
  position: absolute;
  left: 4px;
  bottom: calc(100% + 8px);
  margin: 0;
  max-width: min(640px, 100%);
  padding: 6px 12px;
  border-radius: 10px;
  background: #374b3ee6;
  color: #f4f6ea;
  font-size: 11px;
  line-height: 1.5;
  display: none;
}
body[data-tool="fix"] .dsq-hint,
body[data-tool="iso"] .dsq-hint,
body[data-tool="damp"] .dsq-hint,
body[data-tool="move"] .dsq-hint,
body[data-tool="epicenter"] .dsq-hint {
  display: block;
}
body[data-tool="fix"] .dsq-hint::after,
body[data-tool="iso"] .dsq-hint::after,
body[data-tool="damp"] .dsq-hint::after {
  content: "圆环：绿 很适合 · 橙 打折扣 · 灰 效果有限 · 蓝 已安装";
  display: block;
  font-size: 10px;
  opacity: 0.8;
}
.ds-act {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 8px;
  background: var(--panel);
  border: 1px solid #fff9;
  border-radius: 16px;
  box-shadow: 0 8px 30px #2a352816;
  backdrop-filter: blur(10px);
}
#dsq-epi {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 52px;
  min-height: 52px;
  padding: 5px 6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 11px;
}
#dsq-epi svg {
  width: 22px;
  height: 22px;
}
#dsq-epi[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}
.ds-act-mag {
  flex: none;
  width: 66px;
  line-height: 1.15;
}
.ds-act-mag b {
  display: block;
  font:
    26px Georgia,
    serif;
  letter-spacing: -1px;
  color: var(--accent);
}
.ds-act-mag span {
  display: block;
  font-size: 10px;
  color: #7d8471;
  white-space: nowrap;
}
.ds-act.hypo .ds-act-mag b,
.ds-act.hypo .ds-act-mag span {
  color: #8f2f1d;
}
#ds-mag {
  width: 190px;
  margin: 0;
}
#dsq-slow,
#pause {
  display: none;
  min-height: 44px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}
#dsq-slow[aria-pressed="true"] {
  color: var(--accent);
  font-weight: 700;
  border-color: #e3bfa8;
}
.dsq-quaking #dsq-slow,
.dsq-quaking #pause {
  display: block;
}
.dsq-quaking #dsq-epi {
  display: none;
}
.ds-go {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff8e9;
  font-size: 15px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.ds-go i {
  font-style: normal;
  font-size: 22px;
  line-height: 1;
}
.ds-go:hover {
  background: #a65333;
}
.ds-act.hypo .ds-go {
  background: #8f2f1d;
}
input[type="range"] {
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: pan-y;
}

/* ---- Drawers: scene cards and settings ---- */
.dsq-scenes .scene-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 2px;
}
.scene-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 78px;
  padding: 6px 2px;
  background: #f0f2e6;
  border: 1px solid #dce1d0;
  border-radius: 10px;
  color: #485d46;
}
.scene-card svg {
  display: block;
  width: 100%;
  height: 44px;
  flex-shrink: 0;
}
.scene-card > span {
  display: block;
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}
.scene-card:hover {
  background: #e8eddb;
  border-color: #a5b693;
}
.scene-card.selected {
  background: #e3ead6;
  border-color: #7e976c;
  box-shadow: inset 0 0 0 1px #7e976c;
}
/* ---- Mode switch at the top of the scene drawer: 防护模式 / 破坏模式 ---- */
.ds-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 0 2px 12px;
  background: #e4e8de;
  border-radius: 12px;
}
.ds-mode button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-height: 46px;
  padding: 6px 4px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #5d6a5c;
  cursor: pointer;
}
.ds-mode button b {
  font-size: 14px;
}
.ds-mode button small {
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
}
.ds-mode button[aria-checked="true"] {
  background: #fff;
  color: #2c5d77;
  box-shadow: 0 1px 6px #2a352826;
}
.ds-mode button[data-mode="destroy"][aria-checked="true"] {
  color: #8f3a24;
}
body:not(.ds-mode-destroy) #ds-preset,
.ds-mode-destroy #ds-haz {
  display: none;
}
.ds-haz-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.ds-haz .ds-preset-row button[aria-pressed="true"] {
  background: #2c5d77;
}
/* 破坏模式: the defence tools leave the tray (the preset decides them); challenges belong to 防护模式. */
.ds-mode-destroy .dsk-tool[data-tool="fix"],
.ds-mode-destroy .dsk-tool[data-tool="iso"],
.ds-mode-destroy .dsk-tool[data-tool="damp"],
.ds-mode-destroy .dsk-tool[data-tool="soil"],
.ds-mode-destroy .dsk-tool[data-tool="move"],
.ds-mode-destroy #dsq-ch-btn {
  display: none;
}
.ds-mode-destroy .live {
  color: #8f3a24;
}
/* Reference labels over the buildings (防护模式 → 参考破坏模式的抗震思路). */
.ds-ref {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.ds-ref-tag {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  gap: 1px;
  padding: 1px;
  border-radius: 6px;
  background: #fffffff0;
  box-shadow: 0 1px 4px #0000004d;
  will-change: transform;
}
.ds-ref-tag b {
  display: block;
  min-width: 15px;
  padding: 0 2px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  line-height: 15px;
  text-align: center;
}
/* ---- Strength presets under the scene cards: 无 / 低 / 中 / 高 / 极高 / 最高 ---- */
.ds-preset {
  margin: 14px 2px 0;
  padding: 10px 10px 8px;
  background: #eef1ea;
  border: 1px solid #d9dfd2;
  border-radius: 12px;
}
.ds-preset-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.ds-preset-h b {
  font-size: 13px;
  color: #2f4f5c;
}
.ds-preset-h span {
  font-size: 10px;
  color: #8a8f7e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-preset-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}
.ds-preset-row button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 42px;
  padding: 5px 0 6px;
  background: #fbfcf7;
  border: 1px solid #cfd8cc;
  border-radius: 9px;
  color: #3d5560;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ds-preset-row button i {
  display: block;
  width: calc(var(--lv) * 6px);
  min-width: 4px;
  max-width: 100%;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
  opacity: calc(0.25 + var(--lv) * 0.15);
}
.ds-preset-row button:hover {
  border-color: #3f7896;
  background: #f0f5f6;
}
.ds-preset-row button[aria-pressed="true"] {
  background: #3f7896;
  border-color: #2c5d77;
  color: #fff;
  box-shadow: 0 2px 8px #3f789655, inset 0 0 0 1px #2c5d77;
}
.ds-preset-row button[aria-pressed="true"] i {
  opacity: 1;
}
.ds-preset-row button[data-preset="high"][aria-pressed="true"] {
  background: #8f3a24;
  border-color: #6f2a18;
  box-shadow: 0 2px 8px #8f3a2455, inset 0 0 0 1px #6f2a18;
}
.ds-preset-row button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ds-preset-note {
  min-height: 16px;
  margin: 7px 1px 0;
  font-size: 11px;
  line-height: 1.5;
  color: #5d6a5c;
}
.dsq-ch #ds-preset {
  display: none;
}
/* Result banner at the top of the report card when a preset was applied. */
.ds-preset-res {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, #8f3a24, #c0603a);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0.5px;
}
.ds-preset-res.held {
  background: linear-gradient(90deg, #2c5d77, #3f7896);
}
.ds-preset-res small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  opacity: 0.88;
  letter-spacing: 0;
}
/* ---- 破坏模式: energy bar in the dock (replaces the tool tray), cost on the trigger, weak-point rings, hit bursts ---- */
.ds-mode-destroy .dsk-tool[data-tool="terrain"],
.ds-has-energy .dsq-traybox {
  display: none;
}
.ds-energy {
  flex: 0 1 380px;
  min-width: 0;
  padding: 8px 12px 7px;
  background: var(--panel);
  border: 1px solid #fff9;
  border-radius: 16px;
  box-shadow: 0 8px 30px #2a352816;
  backdrop-filter: blur(10px);
}
.ds-energy[hidden] {
  display: none;
}
.ds-en-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #5d6a5c;
}
.ds-en-top b {
  color: #8f3a24;
  font-size: 13px;
}
#ds-en-v {
  font: 600 15px Georgia, serif;
  color: #3d4b3f;
}
#ds-en-depth {
  margin-left: auto;
  min-height: 26px;
  padding: 2px 9px;
  border: 1px solid #d5cdbd;
  border-radius: 999px;
  background: #fbf8ef;
  color: #6f5a40;
  font-size: 11px;
  cursor: pointer;
}
#ds-en-hint,
.ds-hint-btn {
  min-height: 26px;
  padding: 2px 10px;
  border: 1px solid #c9b48a;
  border-radius: 999px;
  background: #fff8e6;
  color: #7a5a14;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
#ds-en-hint.hot {
  background: #e8a33a;
  border-color: #c9801f;
  color: #fff;
  animation: ds-hint-pulse 1.4s ease-in-out infinite;
}
@keyframes ds-hint-pulse {
  50% {
    box-shadow: 0 0 0 5px #e8a33a40;
  }
}
.ds-hint-btn {
  margin-left: 6px;
}
.ds-hint-tag b {
  background: #2c6e8f;
}
.ds-hint-card .dsk-note {
  font-size: 13px;
  line-height: 1.7;
}
.ds-en-stars {
  color: #e0a526;
  font-size: 14px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.ds-en-stars i {
  font-style: normal;
  color: #cfd3c6;
}
.ds-en-bar {
  position: relative;
  height: 12px;
  margin: 6px 0 4px;
  border-radius: 6px;
  background: #e2e5da;
  overflow: hidden;
}
#ds-en-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #c0603a, #e8963c);
  border-radius: 6px;
  transition: width 0.4s;
}
#ds-en-cost {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(135deg, #fff9 0 4px, #8f3a2499 4px 8px);
  border-left: 2px solid #fff;
  transition: left 0.15s, width 0.15s;
}
#ds-en-cost.short {
  background: repeating-linear-gradient(135deg, #fffc 0 4px, #b0281a 4px 8px);
}
.ds-en-bar em {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ffffffcc;
}
.ds-en-weak {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: #6b5a43;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-en-weak span {
  margin-left: 6px;
}
.ds-en-weak span.ok {
  color: #9aa292;
  text-decoration: line-through;
}
.ds-go-cost {
  font-size: 11px;
  letter-spacing: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: #ffffff2e;
}
.ds-go-cost:empty {
  display: none;
}
.ds-go.ds-short {
  background: #8a8f84;
}
.ds-weak {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.ds-weak svg {
  position: absolute;
  inset: 0;
  overflow: visible;
}
.ds-weak path {
  fill: #f0a03a33;
  stroke: #e0661a;
  stroke-width: 3;
  stroke-dasharray: 9 5;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1px #fff);
  animation: ds-weak-dash 1.6s linear infinite;
}
.ds-weak path.ok {
  fill: none;
  stroke: #9aa292;
  stroke-width: 1.2;
  animation: none;
}
@keyframes ds-weak-dash {
  to {
    stroke-dashoffset: -24;
  }
}
.ds-weak-tag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 8px 2px 3px;
  border-radius: 999px;
  background: #fff8ecee;
  color: #7a4a1c;
  font-size: 11px;
  white-space: nowrap;
  box-shadow: 0 1px 5px #0003;
  will-change: transform;
}
.ds-weak-tag b {
  display: inline-block;
  margin-right: 3px;
  color: #fff;
  background: #e8862a;
  border-radius: 999px;
  padding: 0 4px;
  font-weight: 700;
}
.ds-weak-tag.ok {
  opacity: 0.55;
}
.ds-weak-tag.ok b {
  background: #9aa292;
}
.dsq-quaking .ds-weak-tag {
  opacity: 0.75;
}
.ds-burst {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  padding: 10px 22px 9px;
  border-radius: 16px;
  background: linear-gradient(90deg, #b8401f, #e8862a);
  color: #fff;
  text-align: center;
  box-shadow: 0 10px 30px #8f3a2455;
  pointer-events: none;
  animation: ds-burst 1.9s ease-out forwards;
}
.ds-burst b {
  display: block;
  font-size: 22px;
  letter-spacing: 2px;
}
.ds-burst small {
  display: block;
  font-size: 12px;
  opacity: 0.9;
}
.ds-burst.chain {
  top: 31%;
  background: linear-gradient(90deg, #4b2a1c, #8f3a24);
}
.ds-burst.chain b {
  font-size: 18px;
}
@keyframes ds-burst {
  0% {
    opacity: 0.85;
    transform: translateX(-50%) scale(0.75);
  }
  12% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
  }
  22% {
    transform: translateX(-50%) scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-14px);
  }
}
.ds-shake #world {
  animation: ds-shake 0.36s linear;
}
@keyframes ds-shake {
  25% {
    transform: translate(3px, -2px);
  }
  50% {
    transform: translate(-3px, 2px);
  }
  75% {
    transform: translate(2px, 1px);
  }
}
@media (max-width: 800px), (max-height: 500px) {
  .ds-energy {
    flex: none;
    padding: 6px 10px 5px;
  }
  .ds-en-bar {
    height: 10px;
    margin: 4px 0 3px;
  }
  .ds-burst b {
    font-size: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ds-weak path,
  .ds-burst,
  .ds-shake #world {
    animation: none;
  }
}
.scene-note {
  font-size: 11px;
  line-height: 1.8;
  color: #7f8473;
  margin: 12px 2px 0;
}
#scene-index {
  display: block;
  margin: 6px 2px 0;
  font-size: 10px;
  color: #9a9d8e;
}
.dsq-settings .section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  margin: 4px 0 8px;
}
.dsq-settings .section-title > span {
  font: 9px Consolas;
  color: #8d9381;
}
.magnitude-row {
  display: flex;
  align-items: center;
  gap: 15px;
}
.magnitude-row > strong {
  font:
    46px Georgia,
    serif;
  letter-spacing: -3px;
  color: var(--accent);
}
.magnitude-row b {
  display: block;
  font-size: 12px;
  font-weight: 500;
}
.magnitude-row small {
  display: block;
  font-size: 10px;
  color: #97988a;
  margin-top: 5px;
}
.magnitude-row.hypo > strong,
.magnitude-row.hypo b {
  color: #8f2f1d;
}
#magnitude {
  width: 100%;
  margin: 12px 0 8px;
}
.mag-zones {
  display: flex;
  height: 3px;
  margin: -3px 0 7px;
  border-radius: 2px;
  overflow: hidden;
}
.mag-zones i {
  flex: 6.5;
  background: #dcdccb;
}
.mag-zones b {
  flex: 1.5;
  background: repeating-linear-gradient(135deg, #8f2f1d 0 3px, #d9a487 3px 6px);
}
.range-label {
  display: flex;
  justify-content: space-between;
  color: #919582;
  font-size: 10px;
}
.mag-note {
  margin: 7px 0 0;
  font-size: 10px;
  line-height: 1.6;
  color: #9b5a3f;
}
.presets {
  display: flex;
  gap: 5px;
  margin: 12px 0 14px;
}
.presets button {
  flex: 1;
  padding: 6px 0;
  font: 11px Consolas;
  background: transparent;
}
.presets button.active {
  background: #b65e3b;
  color: white;
  border-color: #b65e3b;
}
.presets button.hypo {
  color: #8f2f1d;
  border-color: #e3c6b6;
}
.presets button.hypo.active {
  background: #8f2f1d;
  border-color: #8f2f1d;
  color: #fff;
}
.settings {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.settings > label {
  display: block;
  font-size: 12px;
  margin-bottom: 12px;
}
.settings b {
  float: right;
  font: 11px Consolas;
  font-weight: 400;
}
.settings > label input[type="range"] {
  display: block;
  width: 100%;
  margin: 8px 0 0;
}
.settings label select,
.dsq-opts select {
  float: right;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f0f2e6;
  font-size: 11px;
}
.dsq-opts {
  display: grid;
  gap: 2px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-size: 12px;
}
.check input {
  accent-color: var(--green);
  margin: 0;
}
.check select {
  margin-left: auto;
}
.tiny {
  margin-left: auto;
  font-size: 10px;
  color: #929681;
}
.model-note {
  text-align: center;
  font-size: 10px;
  color: #9b9e8e;
  margin: 14px 0 0;
}

/* ---- Toast, help dialog, quake overlay, tool pill ---- */
#toast {
  position: fixed;
  left: var(--free-cx, 50%);
  top: calc(80px + env(safe-area-inset-top));
  z-index: 58;
  transform: translateX(-50%) translateY(-6px);
  pointer-events: none;
  background: #374b3eea;
  color: #f4f6ea;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.6;
  opacity: 0;
  transition: 0.25s;
  max-width: min(560px, calc(100vw - 24px));
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%);
}
dialog {
  border: 1px solid #d7decd;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  max-width: 540px;
  max-height: calc(100dvh - 32px);
  padding: 34px 36px;
  line-height: 1.9;
  box-shadow: 0 20px 100px #26362540;
}
dialog::backdrop {
  background: #243a3140;
  backdrop-filter: blur(4px);
}
dialog h2 {
  font:
    28px SimSun,
    serif;
  margin: 8px 0;
}
dialog p {
  font-size: 13px;
}
dialog small {
  font-size: 10px;
  color: #7e8b70;
}
.close {
  position: absolute;
  right: 12px;
  top: 12px;
  border: 0;
  background: none;
  font-size: 21px;
  min-width: 44px;
  min-height: 44px;
}
.dsq-help-acts button {
  border-color: #e3bfa8;
  color: var(--accent);
}
#quake-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  --vig: 0;
  --haze: 0;
}
#quake-fx::before,
#quake-fx::after {
  content: "";
  position: absolute;
  inset: 0;
}
#quake-fx::before {
  background: radial-gradient(ellipse 70% 68% at var(--free-cx, 50%) var(--free-cy, 50%), #3a241200 42%, #3a2412a6 100%);
  opacity: var(--vig);
}
#quake-fx::after {
  background: #b38f5e;
  mix-blend-mode: multiply;
  opacity: var(--haze);
}
.ds-pill {
  display: none;
}
#quality[aria-pressed="true"] {
  color: #627653;
}
#sound[aria-pressed="true"],
#dsq-rec[aria-pressed="true"] {
  color: var(--accent);
}
body .dsk-hud {
  top: calc(env(safe-area-inset-top) + 72px);
}
body .dsk-hud button {
  white-space: nowrap;
  flex: none;
}
.dsq-ch .scene-heading {
  visibility: hidden;
}
.dsq-ch .dsq-free {
  display: none;
}
.dsq-ch-run .dsk-tray .dsk-tool:not([data-tool="orbit"]) {
  opacity: 0.45;
}

/* ---- Clean view ---- */
.clean header,
.clean .bottom,
.clean .telemetry,
.clean .scene-heading,
.clean .ds-pill {
  display: none !important;
}
#restore-ui {
  position: fixed;
  right: calc(24px + env(safe-area-inset-right));
  top: calc(20px + env(safe-area-inset-top));
  background: #f9fbefdd;
}

/* ---- Simple mode (default on phones): advanced parameters fold away ---- */
.ds-simple .dsq-adv,
.ds-simple .mag-zones,
.ds-simple .range-label,
.ds-simple #mag-note {
  display: none !important;
}

/* ---- Desktop tweaks ---- */
@media (max-width: 1240px) and (min-width: 801px) and (min-height: 501px) {
  #ds-mag {
    width: 130px;
  }
  .ds-act-mag {
    width: 58px;
  }
  .live {
    display: none;
  }
}
@media (max-width: 1080px) and (min-width: 801px) and (min-height: 501px) {
  .dsq-dock {
    flex-wrap: wrap;
    justify-content: center;
  }
  .scene-heading {
    display: none;
  }
}
@media (max-height: 760px) and (min-width: 801px) and (min-height: 501px) {
  header {
    height: calc(58px + env(safe-area-inset-top));
  }
  .scene-heading {
    top: calc(60px + env(safe-area-inset-top));
  }
  .scene-heading h2 {
    font-size: 22px;
  }
  .telemetry {
    top: calc(62px + env(safe-area-inset-top));
  }
}

/* ---- Touch: 44 px targets, big slider thumbs ---- */
@media (pointer: coarse) {
  button,
  select {
    min-height: 44px;
  }
  button {
    min-width: 44px;
  }
  .check input {
    width: 20px;
    height: 20px;
  }
  input[type="range"] {
    --fill: 0%;
    -webkit-appearance: none;
    appearance: none;
    height: 44px;
    margin: 0;
    background: transparent;
  }
  input[type="range"]::-webkit-slider-runnable-track {
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent) var(--fill), #d6d9c8 var(--fill));
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px;
    height: 26px;
    margin-top: -10.5px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: #fffdf6;
    box-shadow: 0 1px 5px #3a2a1a40;
  }
  input[type="range"]::-moz-range-track {
    height: 5px;
    border-radius: 3px;
    background: #d6d9c8;
  }
  input[type="range"]::-moz-range-progress {
    height: 5px;
    border-radius: 3px;
    background: var(--accent);
  }
  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: #fffdf6;
  }
  #dsq-data summary {
    padding: 10px 0 6px;
  }
}
/* Tool pill on touch screens and compact layouts: names the active tool, x returns to observe. */
@media (pointer: coarse), (max-width: 800px), (max-height: 500px) {
  .ds-pill {
    position: fixed;
    z-index: 4;
    top: calc(118px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 4px 4px 15px;
    border-radius: 24px;
    background: #374b3ef2;
    color: #f4f6ea;
    font-size: 12px;
    white-space: nowrap;
    box-shadow: 0 6px 20px #2a3a2f33;
  }
  .ds-pill button {
    position: relative;
    min-width: 36px;
    min-height: 36px;
    padding: 0 11px;
    border: 0;
    border-radius: 18px;
    background: var(--accent);
    color: inherit;
    font-size: 19px;
    line-height: 1;
  }
  .ds-pill button::after {
    content: "";
    position: absolute;
    inset: -4px -2px;
  }
  .dsq-hint {
    display: none !important;
  }
}

/* ---- Compact layouts (phones and landscape phones) ---- */
@media (max-width: 800px), (max-height: 500px) {
  header {
    height: calc(54px + env(safe-area-inset-top));
    gap: 8px;
    padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
  }
  .brand {
    font-size: 15px;
    letter-spacing: 1px;
    gap: 4px;
  }
  .brand-mark {
    font-size: 28px;
    line-height: 30px;
  }
  .brand small,
  .live,
  .scene-heading {
    display: none;
  }
  .dsq-scene-btn {
    min-height: 40px;
    padding: 4px 10px 4px 12px;
    gap: 5px;
    min-width: 0;
  }
  .dsq-scene-btn small {
    display: none;
  }
  .dsq-scene-btn b {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-right {
    gap: 6px;
  }
  .header-right button {
    padding: 6px 12px;
  }
  .telemetry {
    top: calc(58px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    right: auto;
    width: auto;
    min-width: 0;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 70px - var(--dock-height, 160px) - 30px);
    padding: 6px 12px 4px;
  }
  .telemetry:not(:has(details[open])) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 14px;
  }
  .dsq-key {
    margin-top: 2px;
    gap: 14px;
  }
  .dsq-key strong {
    font-size: 17px;
  }
  .dsq-key span {
    display: none;
  }
  .dsq-key div::before {
    font-size: 10px;
    color: #8b9480;
    margin-right: 4px;
  }
  .dsq-key div:first-child::before {
    content: "倒塌";
  }
  .dsq-key div:last-child::before {
    content: "最大";
  }
  #dsq-data summary {
    margin-top: 0;
    border-top: 0;
    padding: 6px 0;
  }
  #dsq-data[open] summary {
    border-top: 1px solid var(--line);
    margin-top: 4px;
  }
  .telemetry:has(details[open]) {
    width: min(300px, calc(100vw - 16px));
  }
  .bottom {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .dsq-dock {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .dsq-traybox {
    width: 100%;
  }
  #dsq-tray {
    flex: 1;
  }
  #dsq-tray .dsk-tray {
    width: 100%;
  }
  body .dsk-tool {
    min-width: 58px;
  }
  .dsq-undo {
    min-width: 52px;
    padding: 4px 6px;
    font-size: 10px;
  }
  .ds-act {
    gap: 8px;
    padding: 5px 5px 5px 6px;
  }
  #dsq-epi {
    min-width: 46px;
    min-height: 50px;
    padding: 4px 2px;
    font-size: 10px;
  }
  .ds-act-mag {
    width: 54px;
  }
  .ds-act-mag b {
    font-size: 22px;
  }
  #ds-mag {
    flex: 1;
    width: auto;
    min-width: 0;
  }
  .ds-go {
    min-height: 50px;
    padding: 0 14px;
    font-size: 14px;
  }
  #dsq-slow,
  #pause {
    padding: 0 8px;
    font-size: 11px;
  }
  .dsq-sub {
    right: 0;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 5px 6px;
  }
  .dsq-sub-tools {
    flex: 1 1 100%;
  }
  .dsq-sub-tools button {
    flex-direction: column;
    gap: 2px;
    min-width: 46px;
    padding: 5px 4px;
    font-size: 10px;
  }
  .dsq-brush {
    flex: 1;
  }
  .dsq-brush input {
    flex: 1;
    width: auto;
  }
  body .dsk-hud {
    top: calc(env(safe-area-inset-top) + 56px);
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px 10px;
    width: max-content;
    max-width: calc(100vw - 16px);
    padding: 6px 8px 6px 12px;
    border-radius: 16px;
  }
  body .dsk-hud .r {
    flex-wrap: wrap;
    gap: 2px 9px;
  }
  .dsq-ch .telemetry {
    display: none !important;
  }
  .dsq-ch .ds-pill {
    top: calc(132px + env(safe-area-inset-top));
  }
  #toast {
    left: 50%;
    top: calc(60px + env(safe-area-inset-top));
    font-size: 11px;
    padding: 9px 14px;
  }
  dialog {
    padding: 26px 20px;
  }
}
@media (max-width: 380px) {
  .dsq-scene-btn i {
    display: none;
  }
  .ds-go {
    padding: 0 10px;
  }
  .ds-go i {
    display: none;
  }
}
/* Landscape phones: slim header; the tray and the action bar share one row. */
@media (max-height: 500px) and (min-width: 501px) {
  header {
    height: calc(46px + env(safe-area-inset-top));
  }
  .telemetry {
    top: calc(50px + env(safe-area-inset-top));
  }
  .dsq-dock {
    flex-direction: row;
    align-items: flex-end;
  }
  .dsq-traybox {
    flex: 1;
    width: auto;
  }
  .ds-act {
    flex: 0 0 auto;
    width: min(360px, 46vw);
  }
  body .dsk-tool {
    min-height: 50px;
    padding: 4px 6px;
  }
  .ds-pill {
    top: calc(50px + env(safe-area-inset-top));
    left: auto;
    right: calc(8px + env(safe-area-inset-right));
    transform: none;
  }
  body .dsk-hud {
    top: calc(env(safe-area-inset-top) + 4px);
  }
  .dsq-ch header .brand {
    visibility: hidden;
  }
}
@media (prefers-reduced-motion: reduce) {
  #toast {
    transition: none;
  }
}
/* Report rows: labels keep one line, long values wrap on the right. */
body .dsk-rows {
  grid-template-columns: auto minmax(0, 1fr);
}
body .dsk-rows dt {
  white-space: nowrap;
}
body .dsk-rows dd {
  overflow-wrap: anywhere;
}
/* Info cards stay inside short (landscape) screens. */
@media (max-height: 500px) {
  body .dsk-info {
    max-height: calc(100dvh - 24px);
    overflow: auto;
    font-size: 11px;
    line-height: 1.5;
  }
}
