:root {
  color-scheme: dark;
  --paper: #d7c5a1;
  --ink: #efe5d0;
  --rust: #a34a32;
  --shadow: rgba(0, 0, 0, 0.72);
  --panel: rgba(19, 18, 15, 0.78);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 18%, rgba(140, 121, 85, 0.34), transparent 36%),
    linear-gradient(145deg, #151512 0%, #070807 58%, #11100e 100%);
  font-family: "Microsoft YaHei", "Noto Serif SC", serif;
}

#shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: auto;
}

#hud {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.hud-card,
#hint,
#debugPanel {
  border: 1px solid rgba(215, 197, 161, 0.22);
  background: rgba(19, 18, 15, 0.54);
  box-shadow: 0 18px 40px var(--shadow);
  backdrop-filter: blur(8px);
}

.hud-card {
  min-width: 108px;
  padding: 9px 12px;
}

.hud-card.wide {
  min-width: 260px;
}

.hud-card strong {
  display: block;
  color: var(--paper);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.hud-card span {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

#hint {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 10px 14px;
  color: rgba(239, 229, 208, 0.88);
  pointer-events: none;
}

#hint .debug-hotkeys {
  display: block;
  margin-top: 4px;
  color: rgba(239, 229, 208, 0.72);
  font-size: 13px;
}

#hint .camera-hotkey {
  display: block;
  margin-top: 4px;
  color: rgba(239, 229, 208, 0.82);
  font-size: 13px;
}

#debugPanel {
  position: absolute;
  right: 18px;
  top: 18px;
  max-width: 360px;
  max-height: calc(100vh - 36px);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow: auto;
  scrollbar-width: thin;
}

.gm-map-overlay {
  position: absolute;
  left: 18px;
  top: 96px;
  width: min(760px, calc(100vw - 430px));
  max-height: calc(100vh - 142px);
  padding: 12px;
  border: 1px solid rgba(215, 197, 161, 0.24);
  background: rgba(12, 11, 9, 0.78);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 11;
  overflow: auto;
}

.gm-map-overlay[hidden] {
  display: none;
}

.gm-map-overlay__header,
.gm-map-overlay__layers,
.gm-map-overlay__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.gm-map-overlay__header {
  justify-content: space-between;
  margin-bottom: 8px;
}

.gm-map-overlay__header strong {
  color: var(--paper);
  letter-spacing: 0.08em;
}

.gm-map-overlay__floors {
  display: flex;
  gap: 6px;
}

.gm-map-overlay button {
  padding: 4px 9px;
  color: rgba(239, 229, 208, 0.9);
  border: 1px solid rgba(215, 197, 161, 0.28);
  background: rgba(30, 27, 21, 0.78);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.gm-map-overlay button.active {
  color: #17120c;
  background: var(--paper);
}

.gm-map-overlay__layers {
  margin-bottom: 8px;
  color: rgba(239, 229, 208, 0.78);
  font-size: 12px;
}

.gm-map-overlay__preview {
  margin-bottom: 8px;
  color: rgba(255, 223, 127, 0.9);
  font-size: 12px;
}

.gm-map-overlay__layer {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

.gm-map-overlay__warning {
  margin: 0 0 8px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 223, 127, 0.28);
  color: rgba(255, 223, 127, 0.92);
  background: rgba(58, 36, 18, 0.38);
  font-size: 12px;
}

.gm-map-overlay__warning[hidden] {
  display: none;
}

.gm-map-overlay__stage {
  width: 100%;
  border: 1px solid rgba(215, 197, 161, 0.18);
  background: #15120e;
}

.gm-map-overlay__canvas {
  display: block;
  width: 100%;
  height: auto;
}

.gm-map-overlay__meta {
  justify-content: space-between;
  margin-top: 8px;
  color: rgba(239, 229, 208, 0.66);
  font-size: 11px;
}

@media (max-width: 980px) {
  .gm-map-overlay {
    left: 12px;
    right: 12px;
    top: 96px;
    width: auto;
    max-height: 44vh;
  }
}

.copy-log {
  position: absolute;
  right: 18px;
  bottom: 18px;
  padding: 8px 14px;
  color: #1d1710;
  border: 0;
  background: var(--paper);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  z-index: 12;
}

#pauseBadge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 18px 32px;
  color: var(--paper);
  border: 1px solid rgba(215, 197, 161, 0.4);
  background: rgba(7, 7, 6, 0.78);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.82);
  font-size: 28px;
  letter-spacing: 0.18em;
  pointer-events: none;
}

.start-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 38%, rgba(116, 101, 72, 0.2), transparent 34%),
    linear-gradient(180deg, rgba(5, 6, 5, 0.76), rgba(4, 4, 3, 0.94));
  backdrop-filter: blur(4px);
  z-index: 20;
}

.start-screen[hidden] {
  display: none;
}

.start-card {
  width: min(620px, calc(100vw - 42px));
  padding: 36px 38px;
  border: 1px solid rgba(215, 197, 161, 0.32);
  background:
    linear-gradient(145deg, rgba(28, 25, 20, 0.9), rgba(9, 9, 8, 0.94)),
    repeating-linear-gradient(90deg, rgba(215, 197, 161, 0.04) 0 1px, transparent 1px 16px);
  box-shadow: 0 34px 120px rgba(0, 0, 0, 0.86);
  text-align: center;
}

.start-eyebrow {
  margin: 0 0 10px;
  color: rgba(215, 197, 161, 0.78);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.start-card h1 {
  margin: 0;
  color: var(--paper);
  font-size: clamp(34px, 7vw, 64px);
  letter-spacing: 0.08em;
}

.start-copy {
  margin: 22px auto 0;
  max-width: 460px;
  color: rgba(239, 229, 208, 0.86);
  font-size: 16px;
  line-height: 1.9;
}

#startGame {
  margin-top: 28px;
  padding: 12px 30px;
  color: #17120c;
  border: 0;
  background: var(--paper);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
}

#startGame:hover,
#startGame:focus-visible {
  background: #eadbb9;
  outline: 2px solid rgba(215, 197, 161, 0.38);
  outline-offset: 4px;
}

.start-hint {
  margin: 16px 0 0;
  color: rgba(239, 229, 208, 0.58);
  font-size: 13px;
}

#ambientText {
  position: absolute;
  left: 50%;
  top: 88px;
  transform: translateX(-50%);
  max-width: min(680px, calc(100vw - 48px));
  padding: 10px 14px;
  color: rgba(247, 238, 220, 0.96);
  border: 1px solid rgba(215, 197, 161, 0.26);
  background: rgba(12, 11, 10, 0.38);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
  text-align: center;
  font-size: 15px;
  line-height: 1.7;
  pointer-events: none;
  white-space: pre-wrap;
  opacity: 0.96;
}

#monologueText {
  position: absolute;
  left: 50%;
  bottom: 168px;
  transform: translateX(-50%);
  max-width: min(620px, calc(100vw - 56px));
  padding: 10px 16px;
  color: rgba(248, 240, 225, 0.94);
  border: 1px solid rgba(215, 197, 161, 0.18);
  background: rgba(10, 10, 9, 0.26);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
  text-align: center;
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  pointer-events: none;
  opacity: 0.94;
}

#textBox {
  position: absolute;
  left: 50%;
  bottom: 42px;
  width: min(760px, calc(100vw - 36px));
  max-height: 54vh;
  transform: translateX(-50%);
  padding: 20px 22px;
  border: 1px solid rgba(215, 197, 161, 0.34);
  background: rgba(12, 11, 10, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
}

#textBox h2 {
  margin: 0 0 12px;
  color: var(--paper);
  font-size: 20px;
  letter-spacing: 0.04em;
}

#textBody {
  max-height: 34vh;
  overflow: auto;
  color: rgba(248, 237, 215, 0.94);
  font-size: 16px;
  line-height: 1.8;
  white-space: pre-wrap;
}

#textInputRow {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

#textInputRow[hidden] {
  display: none;
}

#textInputLabel,
#textInputMeta {
  color: rgba(236, 222, 196, 0.82);
  font-size: 13px;
}

#textInputField {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 10px 12px;
  color: rgba(248, 237, 215, 0.96);
  border: 1px solid rgba(215, 197, 161, 0.24);
  background: rgba(22, 20, 18, 0.92);
  outline: none;
  font: inherit;
  line-height: 1.7;
}

#textInputField:focus {
  border-color: rgba(215, 197, 161, 0.52);
  box-shadow: 0 0 0 1px rgba(215, 197, 161, 0.2);
}

#submitTextInput,
#closeText {
  margin-top: 14px;
  padding: 8px 14px;
  color: #1d1710;
  border: 0;
  background: var(--paper);
  cursor: pointer;
  font-weight: 700;
}

#submitTextInput {
  margin-top: 0;
  justify-self: start;
}

#closeText:disabled {
  opacity: 0.56;
  cursor: default;
}

@media (max-width: 760px) {
  #hud {
    flex-direction: column;
  }

  #ambientText {
    top: 132px;
  }

  #monologueText {
    bottom: 184px;
  }

  #hint {
    right: 18px;
  }
}
