:root {
  --paper: #eef1ec;
  --panel: #fbfaf5;
  --ink: #171a16;
  --muted: #687164;
  --line: #cbd2c4;
  --accent: #b9543c;
  --green: #4d765f;
  --blue: #3f607c;
  --pressed: #8c9288;
  --pressed-border: #aeb4aa;
  --pressed-ring: rgba(238, 241, 236, 0.2);
  --shadow: 0 18px 60px rgba(23, 26, 22, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(23, 26, 22, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 26, 22, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: ui-sans-serif, "Avenir Next", "Helvetica Neue", sans-serif;
}

button, input, textarea, select { font: inherit; }
button:disabled { cursor: wait; opacity: 0.64; transform: none; }

.shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  padding: 18px;
}

.panel {
  background: color-mix(in oklch, var(--panel), white 20%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 22px;
}

.brand span {
  color: var(--panel);
  background: var(--ink);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
  letter-spacing: 0;
}

.brand strong { font-size: 18px; font-weight: 650; }

label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 12px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.help-tooltip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #fffdf7;
  cursor: help;
  font-size: 11px;
  line-height: 1;
}

.help-tooltip::after {
  content: attr(aria-label);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: 280px;
  max-width: min(280px, calc(100vw - 48px));
  padding: 9px 10px;
  border-radius: 6px;
  background: var(--ink);
  box-shadow: 0 12px 36px rgba(23, 26, 22, 0.24);
  color: var(--panel);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.help-tooltip:hover::after,
.help-tooltip:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(185, 84, 60, 0.12); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.output-options {
  align-items: end;
}
.output-options .toggle-row {
  min-height: 40px;
  margin: 12px 0;
}
.actions { display: grid; grid-template-columns: 1fr 0.7fr; gap: 10px; margin-top: 16px; }
.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
}
.toggle-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--ink);
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fffdf7;
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    color 120ms ease,
    transform 120ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--ink);
  background: color-mix(in oklch, #fffdf7, var(--green) 10%);
  box-shadow: 0 8px 18px rgba(23, 26, 22, 0.08);
  transform: translateY(-1px);
}
button:active:not(:disabled),
button.is-pressed:not(:disabled) {
  border-color: var(--pressed-border);
  background: var(--pressed);
  color: #fffdf7;
  box-shadow:
    inset 0 0 0 1px rgba(255, 253, 247, 0.18),
    inset 0 2px 7px rgba(23, 26, 22, 0.16);
  transform: translateY(0);
}
button.is-key-active:not(:disabled) {
  border-color: var(--pressed-border);
  background: var(--pressed);
  color: #fffdf7;
  box-shadow:
    inset 0 0 0 1px rgba(255, 253, 247, 0.22),
    0 0 0 3px var(--pressed-ring),
    0 10px 22px rgba(23, 26, 22, 0.18);
  transform: none;
}
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(185, 84, 60, 0.18);
}
.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.primary:hover:not(:disabled) {
  background: color-mix(in oklch, var(--ink), var(--green) 18%);
  color: var(--panel);
}
.primary:active:not(:disabled),
.primary.is-pressed:not(:disabled) {
  background: var(--pressed);
  border-color: var(--pressed-border);
  color: var(--panel);
}
.wide { width: 100%; margin-top: 10px; }

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  align-self: start;
  justify-self: center;
  min-width: 0;
  width: 100%;
  max-width: min(1500px, 100%);
  overflow: hidden;
  border: 1px solid #11140f;
  border-radius: 8px;
  background: #11140f;
  box-shadow: var(--shadow);
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  justify-self: center;
  width: min(calc(1040px * var(--preview-scale, 1.2)), 100%);
  overflow: hidden;
  background: #11140f;
  contain: paint;
  isolation: isolate;
}

.preview-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(238, 241, 236, 0.045),
    transparent 34%,
    rgba(0, 0, 0, 0.18)
  );
}

.preview-frame::after {
  content: none;
}

.stage[data-preview-state="waiting"] .preview-frame::after {
  animation: none;
}

.topbar, .timeline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  color: #e8eadf;
  background: rgba(17, 20, 15, 0.88);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar > * {
  flex: 0 0 auto;
  align-self: center;
}

.topbar-spacer { flex: 1; }
.record-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 118px;
  width: 118px;
  min-height: 28px;
  height: 28px;
  padding: 0 9px;
  border-color: rgba(232, 234, 223, 0.22);
  background: rgba(238, 241, 236, 0.08);
  color: #e8eadf;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.record-button:hover:not(:disabled) {
  border-color: rgba(232, 234, 223, 0.44);
  background: rgba(238, 241, 236, 0.14);
  box-shadow: none;
  transform: none;
}
.record-button:active:not(:disabled),
.record-button.is-pressed:not(:disabled),
.record-button:focus-visible {
  transform: none;
}
.record-button.is-recording {
  border-color: color-mix(in oklch, var(--accent), white 18%);
  background: var(--accent);
  color: #fffdf7;
}
.record-button.is-saving {
  cursor: wait;
  opacity: 0.76;
}
#recordLabel {
  flex: 0 0 36px;
  text-align: left;
}
.record-button-icon {
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  min-width: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(185, 84, 60, 0.16);
}
.record-button.is-recording .record-button-icon {
  border-radius: 2px;
  background: #fffdf7;
  box-shadow: none;
}
.record-button-duration {
  display: inline-block;
  flex: 0 0 34px;
  min-width: 34px;
  text-align: right;
  color: rgba(232, 234, 223, 0.7);
}
.record-button.is-recording .record-button-duration {
  color: rgba(255, 253, 247, 0.86);
}
.preview-scale-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 170px;
  min-width: 170px;
  margin: 0;
  color: rgba(232, 234, 223, 0.72);
  font-size: 11px;
  line-height: 1;
}
.preview-scale-control input {
  width: 92px;
  min-width: 72px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: #eef1ec;
}
.preview-scale-control b {
  min-width: 36px;
  color: #fffdf7;
  font-weight: 650;
}
#statusText {
  display: inline-block;
  min-width: 92px;
  line-height: 1;
}
#chunkText {
  display: inline-block;
  min-width: 70px;
  line-height: 1;
}
.stage-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  min-width: 0;
  color: rgba(232, 234, 223, 0.72);
  line-height: 1;
}
.stage-stat b {
  display: inline-block;
  color: #fffdf7;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

#outputSizeText { min-width: 206px; }
#renderFps { min-width: 2ch; text-align: right; }
#theoreticalFpsText { min-width: 116px; }
#stageLatencyText { min-width: 120px; }

@media (max-width: 1180px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 44px;
    padding: 8px 14px;
    row-gap: 7px;
  }
  .topbar-spacer { display: none; }
  .preview-scale-control { flex-basis: 170px; min-width: 170px; }
  #outputSizeText { min-width: 156px; }
  #theoreticalFpsText { min-width: 100px; }
  #stageLatencyText { min-width: 108px; }
}

.timeline { justify-content: flex-end; border-top: 1px solid rgba(232, 234, 223, 0.12); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: #8ecf9d; box-shadow: 0 0 0 4px rgba(142, 207, 157, 0.14); }
.dot.error { background: var(--accent); }

#viewport {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  max-height: min(calc(56vh * var(--preview-scale, 1.2)), 82vh);
  min-height: 0;
  object-fit: contain;
  image-rendering: auto;
  transform: translateZ(0);
}

.preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-items: center;
  pointer-events: none;
  background: transparent;
}

.stage[data-preview-state="waiting"] .preview-overlay {
  display: grid;
}

.preview-loader {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(238, 241, 236, 0.22);
  border-top-color: rgba(238, 241, 236, 0.82);
  animation: previewProgressSpin 0.8s linear infinite;
}

.stage-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  padding: 12px 14px 13px;
  border-top: 1px solid rgba(232, 234, 223, 0.12);
  background: #151912;
}

.control-cluster {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
}

.control-title {
  color: rgba(232, 234, 223, 0.62);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stage-controls .camera-pad {
  margin: 0;
}

.stage-controls .camera-pad button {
  position: relative;
  border-color: rgba(232, 234, 223, 0.18);
  background: #eef1ec;
  color: #11140f;
}

.stage-controls .camera-pad button:active:not(:disabled),
.stage-controls .camera-pad button.is-pressed:not(:disabled),
.stage-controls .camera-pad button.is-key-active:not(:disabled) {
  border-color: var(--pressed-border);
  background: var(--pressed);
  color: #fffdf7;
  box-shadow:
    inset 0 0 0 1px rgba(255, 253, 247, 0.22),
    0 0 0 3px var(--pressed-ring),
    0 10px 22px rgba(23, 26, 22, 0.18);
}

.stage-controls .camera-pad button::after {
  content: attr(data-key);
  position: absolute;
  right: 7px;
  top: 5px;
  color: color-mix(in oklch, var(--muted), var(--ink) 18%);
  font-size: 10px;
  font-weight: 650;
}

.stage-controls .camera-pad button:active::after,
.stage-controls .camera-pad button.is-pressed::after,
.stage-controls .camera-pad button.is-key-active::after {
  color: rgba(255, 253, 247, 0.78);
}

.section-title {
  margin: 16px 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.reference-upload {
  margin-top: 0;
}

.reference-upload input {
  border: 1px dashed var(--line);
}

#referencePreview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e5e7df;
}

#referenceName {
  min-height: 18px;
  color: var(--muted);
  font-size: 11px;
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.spec-grid span {
  display: grid;
  gap: 2px;
  min-height: 46px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 9px;
  color: var(--muted);
  font-size: 11px;
}

.spec-grid b {
  color: var(--ink);
  font-size: 14px;
}

.presets {
  position: static;
  max-height: none;
  overflow: visible;
  scrollbar-gutter: stable;
}

.preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 7px;
  min-height: 0;
  max-height: 230px;
  margin-bottom: 12px;
  overflow: auto;
  padding-right: 3px;
}
.preset {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 4px 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  text-align: left;
}
.preset-thumb {
  display: block;
  grid-row: span 2;
  width: 72px;
  height: 46px;
  min-height: 0;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid color-mix(in oklch, var(--line), var(--ink) 8%);
}
.preset b { min-width: 0; font-size: 13px; }
.preset span { min-width: 0; color: var(--muted); font-size: 11px; line-height: 1.25; }
.preset[data-tone="green"] { border-left: 4px solid var(--green); }
.preset[data-tone="blue"] { border-left: 4px solid var(--blue); }
.preset[data-tone="accent"] { border-left: 4px solid var(--accent); }
.preset:hover:not(:disabled) {
  background: color-mix(in oklch, #fffdf7, var(--blue) 9%);
}

.camera-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.camera-pad span { min-height: 36px; }
.camera-pad button { min-height: 36px; font-size: 12px; }
.telemetry { display: grid; gap: 7px; margin-top: 10px; }
.telemetry span {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
.telemetry b { color: var(--ink); font-weight: 650; }

.stage-telemetry {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 0;
  border-top: 1px solid rgba(232, 234, 223, 0.12);
  background: #11140f;
}

.stage-telemetry span {
  min-height: 36px;
  align-items: center;
  gap: 8px;
  border-right: 1px solid rgba(232, 234, 223, 0.1);
  border-bottom: 1px solid rgba(232, 234, 223, 0.1);
  padding: 0 14px;
  color: rgba(232, 234, 223, 0.62);
  font-size: 11px;
}

.stage-telemetry b {
  color: #fffdf7;
  font-size: 12px;
}

.history-list {
  display: grid;
  gap: 7px;
  max-height: 92px;
  overflow: auto;
}

.history-list span {
  display: block;
  border-left: 3px solid var(--blue);
  background: #fffdf7;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .presets { position: static; max-height: none; overflow: visible; }
  .spec-grid { grid-template-columns: repeat(2, 1fr); }
  .preset-list { min-height: 260px; max-height: 420px; }
  #viewport { max-height: 420px; }
  .stage-controls { grid-template-columns: 1fr; }
  .stage-telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; height: auto; min-height: 44px; padding: 10px 14px; }
  .topbar-spacer { display: none; }
  .preview-scale-control { min-width: 160px; }
}

@keyframes previewProgressSpin {
  to { transform: rotate(360deg); }
}


/* ============================================================================
 * 觉梦·三千世界渲染引擎测试台 — 主题升级
 * 深墨青配色 · WASD 简化移动 · 攻击按钮 · 视角摇杆 · 画面拖拽
 * 本块规则置于原样式之后，同优先级下以后者为准
 * ==========================================================================*/

:root {
  --paper: #0d1417;
  --panel: #162126;
  --ink: #e8f0f1;
  --muted: #8fa3ab;
  --line: #2b3d44;
  --accent: #3e8e8a;
  --teal-hi: #7fc4c1;
  --gold: #c9a86a;
  --danger: #b9554a;
  --pressed: #2e5654;
  --pressed-border: #4fa3a0;
  --pressed-ring: rgba(127, 196, 193, 0.25);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

body {
  background:
    radial-gradient(1100px 500px at 70% -10%, rgba(62, 142, 138, 0.14), transparent 60%),
    linear-gradient(90deg, rgba(127, 196, 193, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(127, 196, 193, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 28px 28px, 28px 28px, auto;
}

/* ---------- 品牌区 ---------- */
.brand {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.brand span {
  background: rgba(62, 142, 138, 0.14);
  border: 1px solid rgba(127, 196, 193, 0.25);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--teal-hi);
}
.brand strong {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(100deg, #e8f0f1 30%, var(--teal-hi) 70%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- 面板与输入 ---------- */
.panel {
  background: linear-gradient(180deg, rgba(22, 33, 38, 0.96), rgba(15, 24, 28, 0.96));
  border: 1px solid rgba(127, 196, 193, 0.14);
}

input, textarea, select {
  background: #0f181c;
  border-color: var(--line);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(62, 142, 138, 0.22);
}
input::placeholder, textarea::placeholder { color: #5b6f76; }

/* ---------- 通用按钮 ---------- */
button {
  background: #1c2b31;
  border-color: rgba(127, 196, 193, 0.22);
  color: var(--ink);
}
button:hover:not(:disabled) {
  border-color: var(--teal-hi);
  box-shadow: 0 0 0 3px rgba(127, 196, 193, 0.12), 0 8px 20px rgba(0, 0, 0, 0.35);
}
button.primary {
  background: linear-gradient(150deg, #2e5654, #1f3a40);
  border-color: rgba(127, 196, 193, 0.45);
}

/* ---------- 舞台控制区：三栏（移动 | 战斗 | 视角） ---------- */
.stage-controls {
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  background: linear-gradient(180deg, #101a1e, #0c1417);
  border-top: 1px solid rgba(127, 196, 193, 0.14);
}
.control-cluster {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 8px;
}
.control-title {
  color: rgba(127, 196, 193, 0.6);
  letter-spacing: 0.22em;
  font-weight: 600;
}

/* ---------- WASD 简化移动键 ---------- */
.wasd-pad {
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(2, 46px);
  gap: 6px;
}
.wasd {
  position: relative;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, #1d2e34, #142126);
  border: 1px solid rgba(127, 196, 193, 0.25);
  color: var(--teal-hi);
}
.wasd-w { grid-column: 2; grid-row: 1; }
.wasd-a { grid-column: 1; grid-row: 2; }
.wasd-s { grid-column: 2; grid-row: 2; }
.wasd-d { grid-column: 3; grid-row: 2; }
.wasd:active:not(:disabled),
.wasd.is-pressed:not(:disabled),
.wasd.is-key-active:not(:disabled) {
  background: linear-gradient(180deg, #2e5654, #22484a);
  border-color: var(--teal-hi);
  color: #eafffe;
  box-shadow: 0 0 14px rgba(127, 196, 193, 0.45), inset 0 0 8px rgba(127, 196, 193, 0.25);
}
.wasd::after { content: none; }  /* 简化表达：去掉角标 */

/* ---------- 攻击按钮 ---------- */
.attack-cluster { align-self: stretch; justify-content: center; }
.attack-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 20px 44px;
  border-radius: 14px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: #ffe9d6;
  background: linear-gradient(160deg, #a03d2e 0%, #6e2418 100%);
  border: 1px solid rgba(255, 180, 120, 0.45);
  box-shadow:
    0 0 26px rgba(200, 90, 50, 0.35),
    inset 0 1px 0 rgba(255, 220, 180, 0.25);
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.attack-btn:hover:not(:disabled) {
  filter: brightness(1.15);
  box-shadow:
    0 0 36px rgba(220, 100, 55, 0.55),
    inset 0 1px 0 rgba(255, 220, 180, 0.3);
  transform: translateY(-1px);
}
.attack-btn:active:not(:disabled),
.attack-btn.attacking {
  transform: translateY(1px) scale(0.97);
  filter: brightness(1.3);
  box-shadow: 0 0 44px rgba(255, 120, 60, 0.7);
}
.attack-glyph { font-size: 21px; }

/* ---------- 视角摇杆 ---------- */
.look-cluster { justify-items: center; }
.joystick {
  position: relative;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(62, 142, 138, 0.22), rgba(13, 22, 26, 0.9) 68%),
    #101a1e;
  border: 1px solid rgba(127, 196, 193, 0.28);
  box-shadow:
    inset 0 0 22px rgba(0, 0, 0, 0.55),
    0 6px 18px rgba(0, 0, 0, 0.4);
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
.joystick-ring {
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  border: 1px dashed rgba(127, 196, 193, 0.25);
  pointer-events: none;
}
.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 38% 32%, #8fd3d0, #3e8e8a 62%, #265a58);
  border: 1px solid rgba(200, 240, 238, 0.5);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.55),
    0 0 18px rgba(127, 196, 193, 0.35);
  pointer-events: none;
}
/* 四方向指示：仅视觉，交互由摇杆本体统一处理；键盘/按钮激活态自动同步 */
.joy-zone {
  position: absolute;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(127, 196, 193, 0.55);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  pointer-events: none;
  transition: color 0.12s ease, text-shadow 0.12s ease;
}
.joy-zone::after { content: none; }
.zone-up    { left: 50%; top: 4px;  transform: translateX(-50%); }
.zone-down  { left: 50%; bottom: 4px; transform: translateX(-50%); }
.zone-left  { left: 6px;  top: 50%; transform: translateY(-50%); }
.zone-right { right: 6px; top: 50%; transform: translateY(-50%); }
.joy-zone.is-key-active,
.joy-zone.is-pressed {
  color: #eafffe;
  text-shadow: 0 0 10px rgba(127, 196, 193, 0.9);
}
.joy-hint {
  color: rgba(143, 163, 171, 0.55);
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* ---------- 画面拖拽 ---------- */
#viewport { cursor: grab; touch-action: none; }
#viewport.is-dragging { cursor: grabbing; }

/* ---------- 顶部栏与遥测 ---------- */
.topbar, .timeline {
  background: #0e171b;
  border-bottom: 1px solid rgba(127, 196, 193, 0.12);
}
.timeline { border-top: 1px solid rgba(127, 196, 193, 0.12); border-bottom: none; }
.stage-stat, .telemetry span { color: var(--muted); }
.stage-stat b, .telemetry b { color: var(--teal-hi); }

/* ---------- 小屏适配 ---------- */
@media (max-width: 900px) {
  .stage-controls { grid-template-columns: 1fr; justify-items: center; }
}

/* ---------- 攻击快捷键提示（juemeng-v2） ---------- */
.attack-hint {
  color: rgba(143, 163, 171, 0.55);
  font-size: 11px;
  letter-spacing: 0.08em;
}


/* ============================================================================
 * 觉梦·三千世界渲染引擎测试台 v3 — 淡紫 × 淡青 渐变主题 + 技能系统
 * ==========================================================================*/

:root {
  --purple: #a78bfa;
  --purple-hi: #d4c8f5;
  --cyan-hi: #8fdeda;
  --grad-main: linear-gradient(120deg, #d4c8f5 0%, #8fdeda 100%);
}

/* ---------- 背景：紫青双色晕染 ---------- */
body {
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(167, 139, 250, 0.16), transparent 60%),
    radial-gradient(1000px 560px at 88% 108%, rgba(127, 196, 193, 0.14), transparent 60%),
    linear-gradient(90deg, rgba(167, 139, 250, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(143, 222, 218, 0.045) 1px, transparent 1px),
    #0d1417;
  background-size: auto, auto, 28px 28px, 28px 28px, auto;
}

/* ---------- 品牌：紫→青渐变字 ---------- */
.brand span {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(212, 200, 245, 0.3);
  color: var(--purple-hi);
}
.brand strong {
  background: linear-gradient(100deg, #e8f0f1 15%, var(--purple-hi) 55%, var(--cyan-hi) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- 面板与输入：紫调描边 ---------- */
.panel { border-color: rgba(167, 139, 250, 0.16); }
input:focus, textarea:focus, select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.18);
}

/* ---------- 主按钮：紫青渐变 ---------- */
button.primary {
  background: linear-gradient(150deg, #6d5fc0 0%, #3e8e8a 100%);
  border-color: rgba(212, 200, 245, 0.5);
  box-shadow: 0 0 22px rgba(167, 139, 250, 0.3);
}
button.primary:hover:not(:disabled) {
  box-shadow: 0 0 32px rgba(167, 139, 250, 0.5), 0 8px 22px rgba(0, 0, 0, 0.4);
}

/* ---------- 技能按钮栏（舞台中央） ---------- */
.skill-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}
.skill-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 18px 30px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-indent: 0.1em;
  color: #f5f1fc;
  background:
    linear-gradient(160deg, rgba(167, 139, 250, 0.32), rgba(62, 142, 138, 0.3)),
    #141d24;
  border: 1px solid rgba(212, 200, 245, 0.4);
  box-shadow:
    0 0 22px rgba(167, 139, 250, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.skill-btn:hover:not(:disabled) {
  filter: brightness(1.18);
  transform: translateY(-1px);
  box-shadow:
    0 0 34px rgba(167, 139, 250, 0.5),
    0 0 18px rgba(143, 222, 218, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.skill-btn:active:not(:disabled),
.skill-btn.attacking {
  transform: translateY(1px) scale(0.96);
  filter: brightness(1.35);
  box-shadow:
    0 0 44px rgba(167, 139, 250, 0.65),
    0 0 26px rgba(143, 222, 218, 0.5);
}
.skill-btn .key-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-indent: 0;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(212, 200, 245, 0.16);
  border: 1px solid rgba(212, 200, 245, 0.35);
  color: var(--purple-hi);
}

/* ---------- 技能编辑区（左侧面板） ---------- */
.skill-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.skill-row {
  padding: 10px;
  border-radius: 10px;
  background: rgba(167, 139, 250, 0.06);
  border: 1px solid rgba(167, 139, 250, 0.18);
}
.skill-row-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 8px;
}
.skill-name-input {
  font-weight: 700;
}
.skill-key-btn {
  min-width: 62px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 700;
  color: var(--purple-hi);
  background: rgba(167, 139, 250, 0.12);
  border: 1px dashed rgba(212, 200, 245, 0.45);
}
.skill-key-btn:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.24);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.35);
}
.skill-del-btn {
  width: 34px;
  border-radius: 8px;
  font-size: 16px;
  color: #d98c84;
  background: rgba(185, 85, 74, 0.1);
  border-color: rgba(217, 140, 132, 0.3);
}
.skill-del-btn:hover:not(:disabled) {
  background: rgba(185, 85, 74, 0.28);
  border-color: #d98c84;
  box-shadow: none;
}
.skill-prompt-input {
  width: 100%;
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- 摇杆头：紫青渐变 ---------- */
.joystick-knob {
  background: radial-gradient(circle at 38% 32%, var(--purple-hi), var(--purple) 48%, #3e8e8a 88%);
  border-color: rgba(230, 220, 250, 0.55);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.55),
    0 0 20px rgba(167, 139, 250, 0.45);
}
.joystick { border-color: rgba(167, 139, 250, 0.3); }
.joystick-ring { border-color: rgba(212, 200, 245, 0.28); }
.joy-zone { color: rgba(212, 200, 245, 0.55); }
.joy-zone.is-key-active,
.joy-zone.is-pressed {
  color: #f5f1fc;
  text-shadow: 0 0 12px rgba(167, 139, 250, 0.95);
}

/* ---------- WASD 激活态：青色保留 ---------- */
.wasd:active:not(:disabled),
.wasd.is-pressed:not(:disabled),
.wasd.is-key-active:not(:disabled) {
  box-shadow: 0 0 14px rgba(143, 222, 218, 0.5), inset 0 0 8px rgba(143, 222, 218, 0.28);
}

/* ---------- v3 补遗：卡片类深色统一 ---------- */
.spec-grid span {
  background: rgba(167, 139, 250, 0.07);
  border-color: rgba(167, 139, 250, 0.2);
}
.spec-grid b { color: var(--cyan-hi); }
.preset {
  background: #141d24;
  border-color: rgba(167, 139, 250, 0.18);
  color: var(--ink);
}
.preset:hover:not(:disabled) {
  border-color: rgba(212, 200, 245, 0.5);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.25);
}
.preset b { color: var(--ink); }
.history-list span {
  background: #141d24;
  border-left-color: var(--purple);
  color: var(--muted);
}

/* ---------- v4：全局顶置居中品牌头 ---------- */
body { padding-top: 118px; }

.app-header {
  position: fixed;
  top: 12px;
  left:56%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  user-select: none;
}
.app-logo {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.55));
}
.app-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  background: linear-gradient(100deg, #f5f1fc 10%, var(--purple-hi) 50%, var(--cyan-hi) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(167, 139, 250, 0.25);
}
.app-subtitle {
  font-size: 11px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: rgba(212, 200, 245, 0.65);
}
