: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 .collision-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-command-bar {
  position: absolute;
  right: 18px;
  bottom: 64px;
  display: grid;
  grid-template-columns: auto minmax(180px, 280px) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(215, 197, 161, 0.24);
  background: rgba(12, 11, 9, 0.82);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 13;
}

.gm-command-bar[hidden] {
  display: none;
}

.gm-command-bar__label {
  color: rgba(239, 229, 208, 0.72);
  font-size: 12px;
  white-space: nowrap;
}

.gm-command-bar__input {
  min-width: 0;
  padding: 7px 9px;
  color: rgba(248, 237, 215, 0.96);
  border: 1px solid rgba(215, 197, 161, 0.28);
  background: rgba(22, 20, 18, 0.92);
  outline: none;
  font: inherit;
  font-size: 13px;
}

.gm-command-bar__input:focus {
  border-color: rgba(215, 197, 161, 0.66);
  box-shadow: 0 0 0 2px rgba(215, 197, 161, 0.14);
}

.gm-command-bar__button {
  padding: 7px 11px;
  color: #1d1710;
  border: 0;
  background: var(--paper);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.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%);
  display: flex;
  min-width: min(300px, calc(100vw - 48px));
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 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);
  backdrop-filter: blur(8px);
  z-index: 18;
}

#pauseBadge[hidden] {
  display: none;
}

#pauseTitle {
  font-size: 28px;
  letter-spacing: 0.18em;
}

#restartGameButton {
  width: 100%;
  padding: 11px 20px;
  color: #17120c;
  border: 0;
  background: var(--paper);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
}

#restartGameButton:hover,
#restartGameButton:focus-visible {
  background: #eadbb9;
  outline: 2px solid rgba(215, 197, 161, 0.5);
  outline-offset: 3px;
}

#pauseResumeHint {
  color: rgba(239, 229, 208, 0.62);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.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;
}

.professor-opening-overlay {
  position: absolute;
  inset: 0;
  z-index: 24;
  pointer-events: auto;
  background: #000;
  opacity: 1;
  transition: opacity 0.8s ease, background 1.8s ease, backdrop-filter 1.8s ease;
}

.professor-opening-overlay.is-blurred {
  background: rgba(4, 4, 3, 0.42);
  backdrop-filter: blur(9px) brightness(0.48);
}

.professor-opening-overlay.is-releasing {
  opacity: 0;
  pointer-events: none;
  background: transparent;
  backdrop-filter: blur(0) brightness(1);
}

.professor-opening-overlay[hidden] {
  display: none;
}

.language-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  z-index: 30;
}

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

.language-panel {
  display: grid;
  gap: 30px;
  justify-items: center;
}

.language-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 240px));
  gap: 28px;
  align-items: center;
  justify-content: center;
}

.author-contact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: rgba(239, 229, 208, 0.72);
  font-size: 14px;
}

.author-contact__button,
.author-contact__email {
  color: inherit;
  text-decoration: none;
}

.author-contact__button {
  padding: 9px 14px;
  border: 1px solid rgba(215, 197, 161, 0.38);
  background: rgba(215, 197, 161, 0.06);
  color: var(--paper);
  letter-spacing: 0.04em;
}

.author-contact__email {
  border-bottom: 1px solid rgba(215, 197, 161, 0.32);
}

.author-contact__button:hover,
.author-contact__button:focus-visible,
.author-contact__email:hover,
.author-contact__email:focus-visible {
  color: #fff4d8;
  border-color: rgba(215, 197, 161, 0.72);
  outline: none;
}

.language-option {
  min-height: 72px;
  border: 1px solid rgba(215, 197, 161, 0.62);
  background: rgba(215, 197, 161, 0.08);
  color: var(--paper);
  font: inherit;
  font-size: 24px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.language-option:hover,
.language-option:focus-visible {
  background: rgba(215, 197, 161, 0.2);
  outline: 2px solid rgba(215, 197, 161, 0.56);
  outline-offset: 4px;
}

@media (max-width: 620px) {
  .language-options {
    grid-template-columns: 1fr;
    width: min(320px, calc(100vw - 48px));
  }

  .author-contact {
    flex-direction: column;
    gap: 12px;
  }
}

#broadcastText,
#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;
}

#broadcastText {
  z-index: 26;
  min-width: min(520px, calc(100vw - 48px));
  border-color: rgba(238, 210, 145, 0.5);
  background: rgba(18, 15, 10, 0.82);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.62);
  color: rgba(255, 240, 201, 0.98);
  font-weight: 700;
  letter-spacing: 0.03em;
}

#ambientText {
  z-index: 12;
}

#broadcastText:not([hidden]) ~ #ambientText {
  top: 154px;
}

#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.5);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.interaction-item-portrait {
  position: absolute;
  right: max(80px, calc(50% - 585px));
  bottom: max(206px, calc(min(41vh, 360px) + 10px));
  width: clamp(180px, 21vw, 320px);
  height: clamp(180px, 27vh, 330px);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  z-index: 20;
}

.interaction-item-portrait[hidden] {
  display: none;
}

.interaction-item-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.npc-dialogue-portrait {
  position: absolute;
  right: max(-320px, calc(50% - 985px));
  bottom: 100px;
  width: clamp(840px, 62vw, 1120px);
  height: clamp(840px, 92vh, 1120px);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  z-index: 21;
}

.npc-dialogue-portrait[hidden] {
  display: none;
}

.npc-dialogue-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 760px) {
  .interaction-item-portrait {
    right: 74px;
    bottom: max(170px, calc(min(36vh, 300px) + 10px));
    width: clamp(120px, 32vw, 190px);
    height: clamp(120px, 22vh, 190px);
    padding: 0;
  }

  .npc-dialogue-portrait {
    right: -326px;
    bottom: 100px;
    width: clamp(520px, 116vw, 780px);
    height: clamp(520px, 96vh, 780px);
    padding: 0;
  }
}

#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;
  }

  #broadcastText,
  #ambientText {
    top: 132px;
  }

  #broadcastText:not([hidden]) ~ #ambientText {
    top: 198px;
  }

  #monologueText {
    bottom: 184px;
  }

  #hint {
    right: 18px;
  }
}
