:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background: #101820;
  color: #f2efe4;
  --ink: #f2efe4;
  --muted: #a8b3ad;
  --panel: rgba(16, 24, 32, 0.82);
  --panel-strong: rgba(21, 32, 38, 0.94);
  --line: rgba(242, 239, 228, 0.18);
  --amber: #f4be4f;
  --mint: #73e6c2;
  --red: #e85c5c;
  --blue: #82baff;
  --violet: #bd87ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 18% 8%, rgba(130, 186, 255, 0.18), transparent 28%),
    linear-gradient(140deg, #0f1820 0%, #151d1f 48%, #241b22 100%);
}

button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  background: rgba(242, 239, 228, 0.07);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover,
button:focus-visible {
  border-color: rgba(244, 190, 79, 0.78);
  box-shadow: 0 0 0 3px rgba(244, 190, 79, 0.16);
  outline: none;
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  width: 100vw;
  height: 100dvh;
  min-height: 580px;
}

.scene-wrap {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: #11191f;
}

#sceneCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  width: clamp(52px, 7vw, 82px);
  height: clamp(52px, 7vw, 82px);
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  pointer-events: auto;
  display: grid;
  place-items: center;
  background: rgba(16, 24, 32, 0.54);
  border: 1px solid rgba(244, 190, 79, 0.62);
  box-shadow: 0 0 22px rgba(244, 190, 79, 0.22), inset 0 0 20px rgba(115, 230, 194, 0.08);
}

.hotspot::before {
  content: attr(data-icon);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(242, 239, 228, 0.1);
  color: var(--amber);
  font-weight: 800;
}

.hotspot::after {
  content: attr(aria-label);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 150px;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--ink);
  background: rgba(10, 14, 16, 0.82);
  border: 1px solid rgba(242, 239, 228, 0.12);
  white-space: nowrap;
}

.hotspot.visited {
  border-color: rgba(115, 230, 194, 0.78);
}

.hotspot.locked {
  border-color: rgba(232, 92, 92, 0.58);
  filter: grayscale(0.4);
}

.discovery-burst {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  border: 2px solid var(--mint);
  box-shadow: 0 0 34px var(--mint);
}

.discovery-burst.play {
  animation: burst 620ms ease-out;
}

.hud {
  height: 100%;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(178px, 1fr) auto auto auto;
  gap: 12px;
  background: linear-gradient(180deg, rgba(16, 24, 32, 0.96), rgba(20, 25, 27, 0.92));
  border-left: 1px solid var(--line);
  overflow: auto;
}

.brand-row,
.panel-title,
.command-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.2vw, 1.9rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 0.92rem;
  color: var(--amber);
  letter-spacing: 0;
}

#chapterLabel,
.panel-title span {
  margin-top: 5px;
  font-size: 0.78rem;
  color: var(--muted);
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--amber);
  font-weight: 900;
}

.meters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.meter {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  background: rgba(242, 239, 228, 0.055);
  border-radius: 7px;
}

.meter span,
.meter strong {
  display: block;
}

.meter span {
  font-size: 0.72rem;
  color: var(--muted);
}

.meter strong {
  margin: 2px 0 6px;
  font-size: 1.05rem;
}

.meter div {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(242, 239, 228, 0.1);
}

.meter i {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--blue));
}

.meter.danger i {
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.story-panel,
.clue-panel,
.combine-panel {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.story-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

#storyText {
  font-size: 0.98rem;
  line-height: 1.56;
}

.choice-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.choice {
  min-height: 46px;
  padding: 10px;
  border-radius: 7px;
  text-align: left;
  line-height: 1.32;
}

.choice .cost {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.clue-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.clue {
  min-height: 76px;
  padding: 8px;
  border-radius: 7px;
  text-align: left;
  background: rgba(242, 239, 228, 0.055);
}

.clue.selected {
  border-color: var(--mint);
  background: rgba(115, 230, 194, 0.11);
}

.clue.locked {
  opacity: 0.46;
}

.clue b {
  display: block;
  margin-bottom: 4px;
  font-size: 0.82rem;
  color: var(--ink);
}

.clue i {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 5px;
  border-radius: 50%;
  background: rgba(244, 190, 79, 0.14);
  color: var(--amber);
  font-style: normal;
  font-weight: 800;
}

.clue svg {
  width: 25px;
  height: 25px;
  display: block;
}

.clue span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.24;
}

.selected-clues {
  min-height: 42px;
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.primary-button,
.command-row button {
  width: 100%;
  min-height: 46px;
  border-radius: 7px;
}

.primary-button {
  background: linear-gradient(135deg, rgba(244, 190, 79, 0.86), rgba(115, 230, 194, 0.76));
  color: #11191f;
  font-weight: 800;
}

.command-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 8px;
  color: #101820;
  background: var(--amber);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  animation: toast 1800ms ease forwards;
}

.ending {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 12, 15, 0.78);
  backdrop-filter: blur(8px);
}

.ending article {
  width: min(640px, 100%);
  padding: 22px;
  border-radius: 8px;
  border: 1px solid rgba(244, 190, 79, 0.44);
  background: var(--panel-strong);
}

.ending h2 {
  font-size: 1.5rem;
  color: var(--ink);
}

.ending p {
  margin: 12px 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.ending button {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 7px;
}

@keyframes burst {
  0% {
    transform: scale(0.25);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    transform: scale(8);
    opacity: 0;
  }
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  15%,
  80% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
}

@media (max-width: 860px) {
  html,
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100dvh;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(330px, 44dvh) auto;
  }

  .hud {
    height: auto;
    min-height: 56dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px;
    overflow: visible;
  }

  .hotspot {
    width: 58px;
    height: 58px;
  }

  .hotspot::after {
    display: none;
  }

  .clue-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .story-panel,
  .clue-panel,
  .combine-panel {
    padding: 10px;
  }

  #storyText {
    font-size: 0.92rem;
  }
}
