/* 2.0：配色、字体、圆角、按钮手感由后加载的 ../shared/game-2.css 覆盖（说明见 work/round2/theme-2.md §8），本文件管布局。 */
/* 海啸沙盒 · round 4 layout: header (brand · 场景 ▾ · 挑战 · ⋯), a stats line, and one bottom stack
   (floating tool bar · defence tray + 撤销 · cause / strength / trigger). Drawers and the ⋯ menu come from DSKit. */
:root {
  --ink: #344a41;
  --muted: #879087;
  --paper: #fffdf3;
  --green: #426b53;
  --line: #dfe2d3;
  --orange: #b85d3d;
  --selected: #e0e9d4;
}
* {
  box-sizing: border-box;
}
html,
body {
  overscroll-behavior: none;
}
body {
  margin: 0;
  overflow: hidden;
  background: #dedfd0;
  color: var(--ink);
  font: 13px "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
button,
select,
input {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid #c89552;
  outline-offset: 2px;
}
#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---- header ---- */
body > header {
  position: fixed;
  z-index: 20;
  left: calc(26px + env(safe-area-inset-left));
  right: calc(26px + env(safe-area-inset-right));
  top: calc(18px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: none;
}
body > header > * {
  pointer-events: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font: 600 21px "Noto Serif SC", "Songti SC", serif;
  letter-spacing: 3px;
  white-space: nowrap;
  pointer-events: none;
}
.brand-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  color: #fff9de;
  font: 34px/30px Georgia, serif;
  text-align: center;
}
.brand small {
  display: block;
  margin-top: 5px;
  font: 9px "Microsoft YaHei", sans-serif;
  letter-spacing: 2.3px;
}
.chip,
.ds-scene-btn,
.top-actions button {
  height: 40px;
  border-radius: 999px;
  border: 1px solid #ffffffa8;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px #2a352812;
}
.ds-scene-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 14px 0 16px;
}
.ds-scene-btn span {
  font-size: 11px;
  color: var(--muted);
}
.ds-scene-btn b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 1px;
}
.ds-scene-btn em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}
.ds-scene-btn:hover,
.top-actions button:hover {
  background: var(--paper);
}
body.ds-chal .ds-scene-btn {
  opacity: 0.6;
}
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-actions button {
  min-width: 40px;
  padding: 0 16px;
  font-size: 12px;
  white-space: nowrap;
}
.top-actions #ds-challenge {
  background: var(--green);
  border-color: var(--green);
  color: #fffbea;
}
.top-actions .dsk-more-btn {
  width: 44px;
  padding: 0;
  font-size: 18px;
  letter-spacing: 1px;
}
.tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.tag i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6d9370;
}
body.ds-chal .tag i {
  background: var(--orange);
}

/* ---- live numbers (details live in 设置) ---- */
.ds-stats {
  position: fixed;
  z-index: 10;
  left: calc(26px + env(safe-area-inset-left));
  top: calc(72px + env(safe-area-inset-top));
  display: flex;
  gap: 6px;
  pointer-events: none;
}
.ds-stats span {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #ffffff90;
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.ds-stats b {
  margin-left: 3px;
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ds-stats em {
  font-style: normal;
  font-size: 10px;
}
html.ds-simple .ds-stats {
  display: none;
}

/* ---- bottom stack ---- */
.bottom {
  position: fixed;
  z-index: 15;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(100vw - 24px);
}
.ds-dock {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.ds-tray {
  display: flex;
  min-width: 0;
}
.ds-tray .dsk-tray {
  border-radius: 18px;
}
.ds-tray .dsk-tool small {
  white-space: nowrap;
}
.ds-undo {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 60px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px #2a352816;
  font-size: 11px;
}
.ds-undo b {
  font-size: 20px;
  font-weight: 400;
  line-height: 22px;
}
.ds-undo:hover {
  background: var(--paper);
}
.ds-act {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px #2a352816;
}
.ds-src-btn {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 7px;
  align-items: center;
  min-height: 54px;
  padding: 4px 12px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff70;
  text-align: left;
}
.ds-src-btn b {
  grid-row: span 2;
  font: 22px Georgia, serif;
}
.ds-src-btn span {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.ds-src-btn small {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}
.ds-src-btn[aria-pressed="true"] {
  border-color: var(--orange);
  color: var(--orange);
}
.ds-power {
  width: 240px;
  display: grid;
}
.ds-power label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ds-power label span:last-child {
  color: var(--ink);
  font-weight: 600;
}
input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 4px 0 0;
  accent-color: var(--green);
  cursor: pointer;
}
body:not([data-src="quake"]) .ds-quake-only,
body[data-src="quake"] .ds-wave-only {
  display: none !important;
}
body[data-wave="big"] #power-label {
  color: #a0682f;
}
body[data-wave="super"] #power-label {
  color: #b2442b;
}
.summon {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 20px 8px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #fffbea;
  box-shadow: 0 5px 12px #426b5326;
  text-align: left;
  white-space: nowrap;
}
.summon:hover {
  filter: brightness(0.93);
}
.summon > span:nth-child(2) {
  font-size: 14px;
  letter-spacing: 1px;
}
.summon small {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.5px;
  color: #cfdcc4;
}
.wave-symbol {
  font: 28px Georgia, serif;
}
body[data-wave="big"]:not([data-src="quake"]) .summon {
  background: #8d6236;
}
body[data-wave="super"]:not([data-src="quake"]) .summon {
  background: #9c4330;
}
body[data-src="quake"] .summon {
  background: #6d5a4a;
}

/* Floating bar of the active tool: what a drag does, its options, × back to 观察. */
.ds-build-bar {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 16px);
  padding: 5px 5px 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 26px #2a352820;
  font-size: 12px;
  white-space: nowrap;
}
body:not([data-tool="view"]) .ds-build-bar {
  display: flex;
}
.focus-view .ds-build-bar {
  display: none !important;
}
#ds-build-text {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-opts {
  display: flex;
  gap: 4px;
}
.ds-opts:empty {
  display: none;
}
.ds-opts button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff90;
  font-size: 12px;
}
.ds-opts button[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fffbea;
}
.ds-bsel {
  display: none;
  height: 34px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
body[data-tool="building"] .ds-bsel {
  display: block;
}
.ds-bar-brush {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
body[data-tool="raise"] .ds-bar-brush,
body[data-tool="lower"] .ds-bar-brush,
body[data-tool="smooth"] .ds-bar-brush {
  display: flex;
}
.ds-bar-brush input {
  width: 96px;
  margin: 0;
}
#ds-build-exit {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #0000000d;
  font-size: 18px;
  line-height: 1;
}
#ds-build-exit:hover {
  background: #0000001a;
}

/* Live chips: 慢放 while a wave runs, 暂停 / 继续 while it runs or is paused. */
/* div: <body> also carries .ds-live while a wave runs */
div.ds-live {
  position: fixed;
  z-index: 16;
  left: 50%;
  bottom: calc(var(--ui-bottom, 120px) + 12px);
  transform: translateX(-50%);
  display: none;
  gap: 8px;
}
body.ds-live .ds-live,
body.ds-paused .ds-live {
  display: flex;
}
body:not([data-tool="view"]) .ds-live {
  bottom: calc(var(--ui-bottom, 120px) + 64px);
}
body:not(.ds-live) #ds-slow {
  display: none;
}
.focus-view .ds-live {
  bottom: calc(20px + env(safe-area-inset-bottom));
}
.ds-slow {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid #ffffff90;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px #29372c26;
  font-size: 12px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.ds-slow[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #fffbea;
}

/* ---- toast, recording badge, challenge HUD ---- */
#toast {
  position: fixed;
  z-index: 30;
  top: calc(74px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  /* Centred under the header, never squeezed between the buttons (round 4 hotfix: it used to shrink to ~120 px). */
  width: max-content;
  max-width: min(560px, calc(100vw - 48px));
  padding: 10px 20px;
  border-radius: 30px;
  background: color-mix(in srgb, var(--paper) 93%, transparent);
  box-shadow: 0 4px 20px #52614c18;
  font-size: 12px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
}
body.ds-chal #toast {
  top: calc(124px + env(safe-area-inset-top));
}
body .dsk-rec {
  right: auto;
  left: calc(26px + env(safe-area-inset-left));
  top: calc(108px + env(safe-area-inset-top));
}
body .dsk-hud {
  top: calc(70px + env(safe-area-inset-top));
}
body .dsk-hud button {
  white-space: nowrap;
}
body.ds-chal .ds-stats {
  top: calc(118px + env(safe-area-inset-top));
}

/* ---- focus view ---- */
.focus-view .bottom,
.focus-view .ds-stats {
  display: none;
}

/* ---- drawers: scene cards and settings ---- */
.ds-pane {
  display: none;
}
.dsk-drawer .ds-pane {
  display: block;
}
.scene-note {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}
#ds-settings-pane h4 {
  margin: 16px 0 6px;
  font: 600 12px "Noto Serif SC", "Songti SC", serif;
  letter-spacing: 1px;
  color: var(--muted);
}
#ds-settings-pane h4:first-child {
  margin-top: 4px;
}
.ds-row,
.ds-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  font-size: 12px;
}
.ds-row span {
  flex: 1;
}
.ds-row select {
  min-width: 128px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.ds-check {
  cursor: pointer;
}
.ds-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}
.ds-check small {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
}
.ds-detail {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin: 0;
  font-size: 12px;
}
.ds-detail dt {
  color: var(--muted);
}
.ds-detail dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ds-pane-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.ds-pane-acts button,
.ds-guide-again {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 12px;
}
.ds-guide-again {
  color: var(--green);
}

/* ---- help dialog ---- */
dialog {
  width: 460px;
  max-width: 92vw;
  max-height: 88dvh;
  overflow: auto;
  padding: 30px 32px;
  border: 1px solid #fff;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 100px #29372c33;
}
dialog::backdrop {
  background: #33443755;
  backdrop-filter: blur(5px);
}
dialog .eyebrow {
  font: 9px Georgia, serif;
  letter-spacing: 2px;
  color: var(--muted);
}
dialog h2 {
  margin: 14px 0;
  font: 600 21px "Noto Serif SC", "Songti SC", serif;
}
dialog p {
  font-size: 12px;
  line-height: 1.95;
  color: #6f7c6d;
}
dialog p b {
  color: var(--ink);
}
dialog small {
  display: block;
  font-size: 10px;
  line-height: 1.8;
  color: #a2a78f;
}
.close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  font-size: 24px;
}

/* ---- medium widths: tray row above the action bar ---- */
@media (min-width: 761px) and (max-width: 1220px) {
  .bottom {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
}

/* ---- phones ---- */
@media (max-width: 760px) {
  body > header {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    top: calc(8px + env(safe-area-inset-top));
    gap: 8px;
  }
  .brand-text,
  .tag {
    display: none;
  }
  .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 30px;
    line-height: 27px;
  }
  .ds-scene-btn {
    flex: 1 1 auto;
    height: 44px;
    padding: 0 12px;
  }
  .top-actions {
    gap: 6px;
  }
  .top-actions button {
    height: 44px;
    padding: 0 14px;
  }
  .ds-stats {
    left: 8px;
    right: 8px;
    top: calc(58px + env(safe-area-inset-top));
    justify-content: center;
  }
  .ds-stats span {
    padding: 3px 9px;
    font-size: 10px;
  }
  body.ds-chal .ds-stats {
    display: none;
  }
  .bottom {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    max-width: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 0 calc(6px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(6px + env(safe-area-inset-left));
  }
  .ds-dock {
    gap: 5px;
  }
  .ds-tray {
    flex: 1 1 auto;
  }
  .ds-tray .dsk-tray {
    width: 100%;
    padding: 4px;
    gap: 2px;
  }
  .ds-tray .dsk-tool {
    min-width: 54px;
    min-height: 54px;
    padding: 4px 5px;
    font-size: 10.5px;
  }
  .ds-tray .dsk-tool small {
    font-size: 8.5px;
  }
  .ds-undo {
    min-width: 52px;
    border-radius: 16px;
  }
  .ds-act {
    gap: 8px;
    padding: 6px;
    border-radius: 16px;
  }
  .ds-src-btn {
    min-height: 48px;
    padding: 2px 8px;
    column-gap: 4px;
  }
  .ds-src-btn small {
    display: none;
  }
  .ds-src-btn span {
    font-size: 11px;
  }
  .ds-power {
    flex: 1;
    width: auto;
    min-width: 0;
  }
  .summon {
    min-height: 48px;
    padding: 6px 14px 6px 10px;
    gap: 6px;
  }
  .summon small {
    display: none;
  }
  .wave-symbol {
    font-size: 22px;
  }
  .ds-build-bar {
    bottom: calc(100% + 6px);
    max-width: calc(100vw - 12px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .ds-build-bar::-webkit-scrollbar {
    display: none;
  }
  .ds-opts button {
    padding: 0 10px;
  }
  .ds-bar-brush input {
    width: 72px;
  }
  #toast {
    top: calc(86px + env(safe-area-inset-top));
    max-width: calc(100vw - 24px);
    padding: 8px 14px;
    font-size: 11px;
  }
  body.ds-chal #toast {
    top: calc(116px + env(safe-area-inset-top));
  }
  body .dsk-hud {
    top: calc(58px + env(safe-area-inset-top));
    gap: 6px;
    padding: 5px 5px 5px 12px;
    font-size: 10.5px;
  }
  body .dsk-hud .r {
    gap: 7px;
  }
  body .dsk-rec {
    left: 8px;
    top: calc(92px + env(safe-area-inset-top));
  }
  dialog {
    padding: 24px 20px;
  }
}

/* ---- short landscape (phones turned sideways): one compact bottom row, slim header ---- */
@media (min-width: 761px) and (max-height: 520px) {
  body > header {
    top: calc(6px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
    right: calc(10px + env(safe-area-inset-right));
  }
  .brand-text {
    display: none;
  }
  .brand-icon {
    width: 34px;
    height: 34px;
    font-size: 28px;
    line-height: 25px;
  }
  .ds-stats {
    top: calc(8px + env(safe-area-inset-top));
    left: auto;
    right: calc(var(--actions-w, 200px) + 20px);
  }
  .ds-stats .ds-cost-chip {
    display: none;
  }
  .bottom {
    flex-direction: row;
    align-items: flex-end;
    bottom: calc(6px + env(safe-area-inset-bottom));
    gap: 6px;
    max-width: calc(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }
  .ds-tray .dsk-tray {
    padding: 3px;
    gap: 1px;
  }
  .ds-tray .dsk-tool {
    min-width: 50px;
    min-height: 50px;
    padding: 3px 4px;
    font-size: 10px;
  }
  .ds-tray .dsk-tool small {
    display: none;
  }
  .ds-undo {
    min-width: 50px;
  }
  .ds-act {
    gap: 6px;
    padding: 5px;
  }
  .ds-src-btn {
    min-height: 46px;
    padding: 2px 8px;
  }
  .ds-src-btn small,
  .summon small {
    display: none;
  }
  .ds-power {
    width: 150px;
  }
  .summon {
    min-height: 46px;
    padding: 6px 12px 6px 8px;
  }
  .wave-symbol {
    font-size: 22px;
  }
  #toast {
    top: calc(52px + env(safe-area-inset-top));
  }
  body .dsk-hud {
    top: calc(50px + env(safe-area-inset-top));
  }
  body .dsk-hud .g {
    display: none;
  }
  body.ds-chal #toast {
    top: calc(96px + env(safe-area-inset-top));
  }
}

/* ---- touch: 44 px targets ---- */
@media (pointer: coarse) {
  .ds-opts button,
  .ds-bsel,
  #ds-build-exit {
    min-height: 40px;
    height: 40px;
  }
  #ds-build-exit {
    width: 40px;
  }
  .ds-slow {
    min-height: 44px;
  }
  .top-actions button,
  .ds-scene-btn {
    height: 44px;
  }
  input[type="range"] {
    height: 32px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #toast {
    transition: none;
  }
}

/* ---- round 5: 防护模式 / 破坏模式 switch, 强化预设 and 灾害等级 ---- */
.ds-mode {
  flex: none;
  display: flex;
  padding: 3px;
  gap: 2px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid #ffffffa8;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px #2a352812;
}
.ds-mode button {
  min-width: 0;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.ds-mode button[aria-pressed="true"] {
  background: var(--green);
  color: #fffbea;
  font-weight: 600;
}
.ds-mode button[data-mode="destroy"][aria-pressed="true"] {
  background: var(--orange);
}
body[data-mode="destroy"] .top-actions #ds-challenge,
body[data-mode="destroy"] .ds-tray,
body[data-mode="destroy"] .ds-cost-chip,
body[data-mode="protect"] .ds-tiers-dock,
body[data-mode="destroy"] .ds-only-protect,
body[data-mode="protect"] .ds-only-destroy {
  display: none;
}
.ds-tiers {
  display: flex;
  gap: 4px;
}
.ds-tiers button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffff8c;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}
.ds-tiers button:hover {
  border-color: var(--orange);
}
.ds-tiers button[aria-pressed="true"] {
  border-color: var(--orange);
  background: var(--orange);
  color: #fffbea;
  font-weight: 700;
  box-shadow: 0 3px 10px #b85d3d55;
}
.ds-tiers button[data-tier="high"][aria-pressed="true"] {
  background: linear-gradient(135deg, #8f2f1f, #c8452b);
}
.ds-tiers-dock {
  align-items: stretch;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px #2a352816;
}
.ds-tiers-dock button {
  min-width: 46px;
  min-height: 52px;
}
.ds-tiers-lab {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 6px 0 4px;
  color: var(--orange);
  font: 600 13px "Noto Serif SC", "Songti SC", serif;
  white-space: nowrap;
}
.ds-tiers-lab small {
  color: var(--muted);
  font: 10px "Microsoft YaHei", sans-serif;
}
.ds-msec {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.ds-msec h4 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  font: 600 13px "Noto Serif SC", "Songti SC", serif;
  letter-spacing: 1px;
}
.ds-msec h4 small {
  color: var(--muted);
  font: 10.5px "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
.ds-msec-note {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}
.ds-hz {
  display: grid;
  gap: 5px;
}
.ds-hz button {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffff8c;
  color: var(--ink);
  font-size: 11px;
  text-align: left;
}
.ds-hz button b {
  color: var(--green);
  font: 600 14px "Noto Serif SC", "Songti SC", serif;
}
.ds-hz button em {
  color: var(--muted);
  font-style: normal;
  font-size: 10.5px;
  white-space: nowrap;
}
.ds-hz button:hover {
  border-color: var(--green);
  background: var(--selected);
}
.ds-chal-link {
  margin-top: 10px;
  width: 100%;
  min-height: 40px;
  border: 1px dashed var(--green);
  border-radius: 10px;
  background: transparent;
  color: var(--green);
  font-size: 12px;
}
@media (max-width: 1220px) {
  .ds-mode button span {
    display: none;
  }
}
@media (max-width: 760px) {
  .ds-mode {
    height: 44px;
  }
  .ds-mode button {
    padding: 0 10px;
  }
  .ds-scene-btn span {
    display: none;
  }
  .brand-icon {
    display: none;
  }
  .ds-tiers-dock {
    flex: 1 1 auto;
    padding: 4px;
    border-radius: 16px;
  }
  .ds-tiers-dock button {
    min-width: 0;
    min-height: 50px;
    padding: 0 2px;
    font-size: 12.5px;
  }
  .ds-tiers-lab {
    padding: 0 3px;
    font-size: 12px;
  }
}
@media (max-width: 760px) {
  .ds-opts {
    gap: 3px;
  }
  .ds-opts button {
    padding: 0 8px;
  }
}

/* ---- round 2: 破坏能量, 薄弱点, 来浪方向, 命中提示 ---- */
.ds-energy {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, calc(100vw - 24px));
  padding: 7px 10px 7px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px #2a352816;
}
.ds-energy[hidden] {
  display: none;
}
.ds-en-lab {
  flex: none;
  color: var(--orange);
  font: 600 12.5px "Noto Serif SC", "Songti SC", serif;
  white-space: nowrap;
}
.ds-en-bar {
  position: relative;
  flex: 1 1 auto;
  height: 12px;
  border-radius: 999px;
  background: #2a35281a;
  overflow: visible;
}
#ds-en-fill,
#ds-en-cost {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 999px;
}
#ds-en-fill {
  width: calc(var(--f, 1) * 100%);
  background: linear-gradient(90deg, #d8743f, #f0b04a);
  transition: width 0.35s;
}
#ds-en-cost {
  left: calc((var(--f, 1) - var(--c, 0)) * 100%);
  width: calc(var(--c, 0) * 100%);
  background: repeating-linear-gradient(135deg, #fffbea 0 3px, #b8452b 3px 6px);
  opacity: 0.85;
  transition: left 0.2s, width 0.2s;
}
.ds-energy.over #ds-en-cost {
  display: none;
}
.ds-en-t {
  position: absolute;
  top: -15px;
  left: calc(var(--t) * 100%);
  transform: translateX(-50%);
  color: #b88a2a;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: -1px;
  white-space: nowrap;
  pointer-events: none;
}
.ds-en-t::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 13px;
  width: 1.5px;
  height: 16px;
  background: #fffbeacc;
  box-shadow: 0 0 0 0.5px #2a352833;
}
.ds-en-num {
  flex: none;
  display: grid;
  justify-items: end;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.ds-en-num b {
  font-size: 13px;
}
.ds-en-num small {
  color: #b2442b;
  font-size: 10px;
  white-space: nowrap;
}
.ds-energy.over .ds-en-num small {
  font-weight: 700;
}
#ds-en-end {
  flex: none;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--orange);
  border-radius: 9px;
  background: transparent;
  color: var(--orange);
  font-size: 12px;
}
#ds-en-end[hidden] {
  display: none;
}
.ds-dir-btn {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 6px;
  align-items: center;
  min-height: 54px;
  padding: 4px 11px 4px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff70;
  text-align: left;
}
.ds-dir-btn b {
  grid-row: span 2;
  font-size: 18px;
}
.ds-dir-btn span {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.ds-dir-btn small {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}
.ds-dir-btn[aria-pressed="true"] {
  border-color: var(--orange);
  color: var(--orange);
}
body:not([data-mode="destroy"]) .ds-dir-btn {
  display: none !important;
}
.ds-weak {
  position: fixed;
  z-index: 10;
  left: calc(26px + env(safe-area-inset-left));
  top: calc(106px + env(safe-area-inset-top));
  max-width: 300px;
  padding: 8px 12px;
  border: 1px solid #ffffff90;
  border-radius: 14px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px #2a352812;
  font-size: 11px;
  line-height: 1.5;
  pointer-events: none;
}
.ds-weak[hidden],
body:not([data-mode="destroy"]) .ds-weak {
  display: none;
}
.ds-weak > b {
  display: block;
  margin-bottom: 3px;
  color: var(--orange);
  font: 600 12px "Noto Serif SC", "Songti SC", serif;
}
.ds-weak p {
  display: flex;
  gap: 6px;
  margin: 2px 0;
  color: var(--ink);
}
.ds-weak p i,
.ds-wk-pins i {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #f2a33a;
  color: #fff;
  font: 700 10.5px/1 "Microsoft YaHei", sans-serif;
  font-style: normal;
}
.ds-weak p[data-k="gap"] i,
.ds-wk-pins i[data-k="gap"] {
  background: #e5533d;
}
.ds-weak p[data-k="old"] i,
.ds-wk-pins i[data-k="old"] {
  background: #9b6fd8;
}
.ds-weak p.hit {
  color: var(--muted);
}
.ds-wk-pins i {
  position: fixed;
  z-index: 9;
  left: -10px;
  top: -10px;
  width: 20px;
  height: 20px;
  border: 2px solid #fffbea;
  box-shadow: 0 2px 6px #0003;
  pointer-events: none;
}
#ds-hit {
  position: fixed;
  z-index: 30;
  left: 50%;
  top: 30%;
  max-width: calc(100vw - 40px);
  padding: 10px 22px;
  border-radius: 999px;
  background: #c8452be6;
  color: #fffbea;
  box-shadow: 0 10px 30px #8f2f1f55;
  font: 700 19px "Noto Serif SC", "Songti SC", serif;
  letter-spacing: 1px;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  pointer-events: none;
}
#ds-hit[data-k="chain"] {
  background: #5a2a1ee6;
}
#ds-hit[data-k="old"] {
  background: #7a4fc2e6;
}
#ds-hit.show {
  animation: ds-hit-pop 1.7s ease-out forwards;
}
@keyframes ds-hit-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  22% {
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  #ds-hit.show {
    animation: none;
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}
body.focus-view .ds-energy,
body.focus-view .ds-weak {
  display: none;
}
@media (max-width: 760px) {
  .ds-energy {
    left: calc(6px + env(safe-area-inset-left));
    right: calc(6px + env(safe-area-inset-right));
    width: auto;
    transform: none;
    gap: 7px;
    padding: 6px 8px 6px 10px;
    border-radius: 12px;
  }
  .ds-en-lab {
    font-size: 11.5px;
  }
  .ds-en-num b {
    font-size: 12px;
  }
  #ds-en-end {
    min-height: 30px;
    padding: 0 9px;
  }
  .ds-dir-btn {
    min-height: 48px;
    padding: 2px 7px;
    column-gap: 3px;
  }
  .ds-dir-btn small {
    display: none;
  }
  .ds-dir-btn span {
    font-size: 11px;
  }
  .ds-dir-btn b {
    font-size: 15px;
  }
  .ds-weak {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    top: calc(84px + env(safe-area-inset-top));
    max-width: none;
    padding: 5px 10px;
    font-size: 10.5px;
    line-height: 1.4;
  }
  .ds-weak > b {
    display: none;
  }
  body.ds-en-on #toast {
    top: calc(150px + env(safe-area-inset-top));
  }
  #ds-hit {
    font-size: 16px;
    padding: 8px 16px;
  }
}
/* the 破坏能量 bar sits above the bottom stack: live chips go above it */
body.ds-en-on div.ds-live {
  bottom: calc(var(--ui-bottom, 120px) + 64px);
}
@media (max-width: 760px) {
  body.ds-en-on div.ds-live {
    bottom: calc(var(--ui-bottom, 120px) + 56px);
  }
}

/* ---- round 2: 分级提示 ---- */
#ds-en-hint {
  flex: none;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--green);
  border-radius: 9px;
  background: var(--green);
  color: #fffbea;
  font-size: 12px;
}
.ds-hz-hint {
  position: fixed;
  z-index: 16;
  right: calc(26px + env(safe-area-inset-right));
  bottom: calc(var(--ui-bottom, 120px) + 12px);
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px 0 6px;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px #2a352818;
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}
.ds-hz-hint b {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #fffbea;
  font-size: 13px;
}
body.ds-hz-on[data-mode="protect"] .ds-hz-hint {
  display: flex;
}
body.focus-view .ds-hz-hint {
  display: none !important;
}
#ds-hint-tip {
  position: fixed;
  z-index: 11;
  left: 0;
  top: 0;
  margin: -44px 0 0 -10px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #23331fe8;
  color: #fffbea;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px #0003;
}
#ds-hint-tip::after {
  content: "";
  position: absolute;
  left: 8px;
  bottom: -6px;
  border: 6px solid transparent;
  border-bottom: 0;
  border-top-color: #23331fe8;
}
.ds-wk-pins i.focus {
  width: 26px;
  height: 26px;
  left: -13px;
  top: -13px;
  font-size: 13px;
  box-shadow: 0 0 0 4px #fffbea99, 0 0 18px 6px #f2a33a;
  animation: ds-pin-pulse 1s ease-in-out infinite alternate;
}
@keyframes ds-pin-pulse {
  to {
    box-shadow: 0 0 0 7px #fffbea55, 0 0 26px 10px #f2a33a;
  }
}
body.ds-demo .ds-tiers-dock,
body.ds-demo #ds-en-end {
  opacity: 0.45;
  pointer-events: none;
}
body.ds-demo .ds-en-lab::after {
  content: " · 示范中";
  color: var(--green);
}
@media (prefers-reduced-motion: reduce) {
  .ds-wk-pins i.focus {
    animation: none;
  }
}
@media (max-width: 760px) {
  .ds-hz-hint {
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(var(--ui-bottom, 120px) + 8px);
    min-height: 34px;
    padding: 0 12px 0 5px;
  }
  #ds-en-hint {
    min-height: 30px;
    padding: 0 9px;
  }
}
body:not([data-tool="view"]) .ds-hz-hint {
  bottom: calc(var(--ui-bottom, 120px) + 64px);
}
