:root {
  color-scheme: dark;
  --bg: #151f27;
  --panel: rgba(19, 31, 35, 0.84);
  --panel-strong: rgba(8, 23, 24, 0.92);
  --line: rgba(184, 150, 84, 0.42);
  --line-cool: rgba(100, 142, 151, 0.38);
  --text: #f1f4f8;
  --muted: #b9c3bd;
  --gold: #d6b86f;
  --green: #7fb7a2;
  --ink: #071313;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

html {
  background: var(--bg) url("assets/arts/美术交接包-2026-07-12/03_运行时美术/game-ready/backgrounds/background-web.png") center / cover no-repeat fixed;
}

body {
  background: transparent;
}

body {
  display: grid;
  place-items: center;
  padding: clamp(14px, 2vw, 28px);
}

[hidden] {
  display: none !important;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: end center;
  padding: 6vh 6vw 7vh;
  background: #101919 url("assets/arts/美术交接包-2026-07-12/03_运行时美术/game-ready/backgrounds/background-loading.png") center / cover no-repeat;
}

.loading-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 12, 14, 0.36), rgba(4, 12, 14, 0.02) 34%, rgba(4, 12, 14, 0.54)),
    radial-gradient(circle at 50% 9%, rgba(238, 218, 166, 0.18), transparent 30%);
  pointer-events: none;
}

.loading-title {
  position: absolute;
  left: 50%;
  top: clamp(22px, 4.5vh, 58px);
  z-index: 1;
  margin: 0;
  color: #101713;
  font: 900 clamp(62px, 7vw, 136px)/0.95 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.1em;
  text-shadow:
    0 1px 0 rgba(238, 226, 190, 0.36),
    0 0 18px rgba(232, 202, 139, 0.28);
  transform: translateX(-50%);
  white-space: nowrap;
}

.loading-status {
  position: relative;
  z-index: 1;
  width: min(32vw, 520px);
  min-width: 300px;
  color: #ead29a;
  font-family: "STKaiti", "KaiTi", serif;
  text-shadow: 0 2px 3px #071a19, 0 0 8px rgba(218, 177, 94, 0.32);
}

.loading-label {
  display: flex;
  justify-content: space-between;
  margin: 0 16px 10px;
  font-size: clamp(18px, 1.5vw, 26px);
  letter-spacing: 0.16em;
}

.loading-track {
  height: 18px;
  padding: 4px;
  border: 1px solid rgba(185, 148, 80, 0.92);
  border-radius: 999px;
  background: rgba(5, 18, 19, 0.72);
  box-shadow:
    0 0 0 1px rgba(239, 213, 145, 0.16),
    0 10px 28px rgba(0, 0, 0, 0.36),
    inset 0 0 10px rgba(0, 0, 0, 0.78);
  overflow: hidden;
}

.loading-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7770, #8eb9a4 58%, #e2c878);
  box-shadow: 0 0 14px rgba(155, 210, 187, 0.65), 0 0 18px rgba(226, 200, 120, 0.28);
  transition: width 160ms ease-out;
}

.loading-status p {
  margin: 10px 0 0;
  color: #e4d4ad;
  font-size: clamp(13px, 1vw, 17px);
  letter-spacing: 0.08em;
  text-align: center;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #e5d6b9 url("assets/arts/美术交接包-2026-07-12/03_运行时美术/game-ready/ui/start-screen/start-screen-background.png") center / cover no-repeat;
}

.start-menu {
  position: absolute;
  left: 50%;
  bottom: 5.5%;
  display: grid;
  width: min(31vw, 500px);
  gap: 8px;
  transform: translateX(-50%);
}

.start-menu-button {
  width: 100%;
  aspect-ratio: 1024 / 192;
  padding: 0 8% 1%;
  border: 0;
  background: transparent url("assets/arts/美术交接包-2026-07-12/03_运行时美术/game-ready/ui/start-screen/menu-button-background.png") center / 100% 100% no-repeat;
  color: #ead29a;
  cursor: pointer;
  font: 700 clamp(22px, 2vw, 36px)/1 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.16em;
  text-shadow: 0 2px 2px #071a19, 0 0 8px rgba(218, 177, 94, 0.35);
  transition: filter 120ms ease, transform 120ms ease;
}

.start-menu-button:hover,
.start-menu-button:focus-visible {
  filter: brightness(1.16);
  transform: translateY(-2px);
  outline: none;
}

.save-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 440px;
  padding: 28px;
  border: 1px solid #b99450;
  border-radius: 8px;
  background: rgba(13, 39, 38, 0.96);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45), inset 0 0 28px rgba(201, 164, 91, 0.08);
  color: #ead9b4;
  transform: translate(-50%, -50%);
}

.save-panel h2 {
  margin: 0 0 18px;
  font: 700 28px/1.2 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.14em;
  text-align: center;
}

.save-summary {
  min-height: 90px;
  padding: 14px;
  border: 1px solid rgba(185, 148, 80, 0.55);
  background: rgba(3, 18, 18, 0.42);
  color: #d8c8a7;
  line-height: 1.8;
}

.save-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.save-actions button {
  padding: 8px 15px;
  border: 1px solid #9b7a42;
  border-radius: 4px;
  background: #173b38;
  color: #ead9b4;
  cursor: pointer;
}

.save-actions button:disabled {
  cursor: default;
  opacity: 0.42;
}

.shell {
  display: grid;
  grid-template-columns: minmax(186px, 214px) minmax(640px, 760px) minmax(196px, 224px);
  align-items: stretch;
  justify-content: center;
  gap: clamp(10px, 1.25vw, 16px);
  width: min(100%, 1240px);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-width: 0;
}

.side-panel-left,
.story-panel {
  align-self: stretch;
  justify-content: center;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(214, 184, 111, 0.08), transparent 44%),
    var(--panel-strong);
  box-shadow: inset 0 0 24px rgba(214, 184, 111, 0.06), 0 14px 32px rgba(0, 0, 0, 0.26);
}

h1,
p {
  margin: 0;
}

h1 {
  color: #f0dca8;
  font: 700 24px/1.1 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.56);
  text-wrap: balance;
}

#roomTitle,
.status,
.control-guide,
.quick-actions,
.settings-panel {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

#roomTitle {
  margin-top: 6px;
}

#coinLabel {
  margin-top: 4px;
  color: #f0dca8;
  font-size: 13px;
}

.status,
.quick-actions,
.control-guide,
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status span {
  min-height: 30px;
  background: rgba(38, 52, 58, 0.68);
  border: 1px solid var(--line-cool);
  border-radius: 6px;
  padding: 6px 8px;
}

.quick-actions,
.control-guide {
  padding: 9px;
  border: 1px solid var(--line-cool);
  border-radius: 8px;
  background: rgba(9, 20, 24, 0.78);
  box-shadow: inset 0 0 18px rgba(127, 183, 162, 0.04);
}

.quick-actions button,
.settings-button {
  min-height: 32px;
  border: 1px solid rgba(214, 184, 111, 0.58);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(52, 86, 82, 0.9), rgba(20, 48, 49, 0.94));
  color: #f2ddb0;
  cursor: pointer;
  font: 700 12px/1 "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 120ms ease, filter 120ms ease, transform 120ms ease;
}

.quick-actions button:hover,
.quick-actions button:focus-visible,
.settings-button:hover,
.settings-button:focus-visible,
.settings-button[aria-expanded="true"] {
  border-color: #e2c878;
  filter: brightness(1.12);
  outline: none;
}

.quick-actions button:active,
.settings-button:active {
  transform: translateY(1px);
}

.quick-actions button:disabled {
  cursor: default;
  filter: grayscale(0.5);
  opacity: 0.45;
}

.control-guide h2 {
  margin: 0;
  color: #e6cc8d;
  font: 700 15px/1.25 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.12em;
}

.control-guide dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

.control-guide div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 6px;
  border: 1px solid rgba(100, 142, 151, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.control-guide dt,
.control-guide dd {
  margin: 0;
}

.control-guide dt {
  color: #f2ddb0;
  font: 700 11px/1.2 Consolas, "Microsoft YaHei", monospace;
  white-space: nowrap;
}

.control-guide dd {
  color: #c9d4cd;
  font-size: 11px;
  line-height: 1.35;
}

.settings-button {
  width: 100%;
}

.settings-panel {
  display: grid;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 21, 23, 0.92);
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel label {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.settings-panel input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.settings-panel output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  align-self: center;
}

canvas {
  display: block;
  position: absolute;
  left: 7.8947368%;
  top: 7.8947368%;
  z-index: 1;
  width: 84.2105263%;
  height: auto;
  margin: 0;
  background: #1b2633;
  border: 1px solid rgba(214, 184, 111, 0.32);
  border-radius: 8px;
  image-rendering: pixelated;
}

.game-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.debug-panel {
  display: none;
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 10;
  min-width: 220px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(59, 71, 87, 0.85);
  border-radius: 6px;
  background: rgba(24, 33, 44, 0.82);
  color: #dfe8ed;
  font: 12px/1.45 Consolas, "Microsoft YaHei", monospace;
  pointer-events: none;
  white-space: pre-wrap;
}

.story-panel {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(127, 183, 162, 0.11), rgba(7, 19, 19, 0.84) 46%),
    rgba(7, 16, 18, 0.88);
  box-shadow: inset 0 0 32px rgba(214, 184, 111, 0.05), 0 14px 34px rgba(0, 0, 0, 0.3);
}

.npc-portrait-wrap {
  display: grid;
  place-items: end center;
  min-height: 252px;
  padding: 14px 12px 0;
  background: linear-gradient(180deg, rgba(214, 184, 111, 0.1), rgba(127, 183, 162, 0.08) 58%, transparent);
}

.npc-portrait {
  display: block;
  width: min(100%, 178px);
  height: auto;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.48)) drop-shadow(0 0 18px rgba(127, 183, 162, 0.22));
  animation: npcFloat 4.2s ease-in-out infinite;
}

.dialogue-box {
  display: grid;
  gap: 8px;
  min-height: 220px;
  padding: 14px;
  border-top: 1px solid rgba(214, 184, 111, 0.34);
  background: rgba(5, 15, 17, 0.62);
}

#storyText {
  margin: 0;
  color: #e3dbca;
  font: 13px/1.72 "Microsoft YaHei", "Segoe UI", sans-serif;
  text-wrap: pretty;
}

@keyframes npcFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@media (max-width: 1080px) {
  body {
    align-items: start;
  }

  .shell {
    grid-template-columns: minmax(190px, 220px) minmax(0, 760px);
    align-items: start;
    width: min(100%, 1000px);
  }

  .story-panel {
    grid-column: 1 / -1;
    min-height: 0;
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
  }

  .npc-portrait-wrap {
    min-height: 200px;
  }

  .npc-portrait {
    width: 145px;
  }

  .dialogue-box {
    border-top: 0;
    border-left: 1px solid rgba(214, 184, 111, 0.34);
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .side-panel-left {
    order: 2;
  }

  .game-stage {
    order: 1;
  }

  .story-panel {
    order: 3;
    grid-template-columns: 1fr;
  }

  .npc-portrait-wrap {
    min-height: 220px;
  }

  .dialogue-box {
    border-top: 1px solid rgba(214, 184, 111, 0.34);
    border-left: 0;
  }
}
