:root {
  --edge-x: 28px;
  --edge-y: 28px;
  --panel: rgba(5, 10, 12, 0.88);
  --panel-strong: rgba(5, 10, 12, 0.94);
  --line: rgba(235, 241, 232, 0.22);
  --text: #f3f4ed;
  --muted: rgba(243, 244, 237, 0.72);
  --warm: #e6b15f;
  --green: #91b59b;
  --red: #c76d62;
  --blue: #7fa8c9;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#game {
  width: var(--vvw, 100vw);
  height: var(--vvh, 100vh);
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: #06090a;
}

button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  background: rgba(255, 255, 255, 0.14);
}

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

#sceneCanvas,
#sceneScrim {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#sceneCanvas {
  z-index: 0;
  touch-action: none;
}

#sceneScrim {
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 46%, rgba(0, 0, 0, 0.22) 82%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 28%, transparent 58%, rgba(0, 0, 0, 0.42));
}

.hidden {
  display: none !important;
}

.meta {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--warm);
  letter-spacing: 0;
}

.top-left,
.relationship-hud,
.location-nav,
.narration-box,
.dialog-panel,
.loading-overlay,
.portrait-prompt {
  position: fixed;
  z-index: 5;
}

.top-left {
  top: var(--edge-y);
  left: var(--edge-x);
  max-width: 34vw;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.top-left h2 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
}

.top-left p {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
}

.relationship-hud {
  top: var(--edge-y);
  right: var(--edge-x);
  display: flex;
  max-width: 42vw;
  gap: 10px;
}

.bond-chip {
  display: grid;
  grid-template-columns: 42px minmax(120px, 150px);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.bond-chip img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
}

.bond-chip strong {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 15px;
}

.bond-chip span,
.bond-chip small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.meter {
  height: 5px;
  margin: 5px 0 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

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

.location-nav {
  left: 48px;
  bottom: 46px;
  max-width: 54vw;
  max-height: 28vh;
  overflow: hidden;
}

.nav-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.location-nav button {
  flex: 0 0 168px;
  height: 82px;
  padding: 12px;
  text-align: left;
  background: var(--panel);
}

.location-nav button.active {
  border-color: var(--warm);
  background: rgba(56, 47, 28, 0.9);
}

.location-nav span {
  display: block;
  overflow: hidden;
  font-size: 20px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-nav small {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.narration-box {
  right: var(--edge-x);
  bottom: 30px;
  width: min(500px, 34vw);
  max-height: 28vh;
  overflow-y: auto;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.narration-box p {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.58;
}

.narration-box ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-row,
.chip-row,
.ending-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-row span,
.chip-row span,
.ending-chips span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.07);
}

.hotspot-layer {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(10, 18, 20, 0.72);
  pointer-events: auto;
}

.hotspot span {
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background: var(--warm);
  box-shadow: 0 0 0 7px rgba(230, 177, 95, 0.2);
}

.hotspot.done span {
  background: var(--green);
}

.hotspot b {
  position: absolute;
  top: 60px;
  left: 50%;
  width: max-content;
  max-width: 168px;
  transform: translateX(-50%);
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  background: var(--panel-strong);
}

.dialog-panel {
  top: 50%;
  right: 7vw;
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr);
  width: min(980px, 82vw);
  max-height: 74vh;
  overflow: hidden;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.panel-image {
  min-height: 480px;
  background-position: center;
  background-size: cover;
}

.panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 24px;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--warm);
  font-size: 13px;
}

.panel-header button {
  padding: 7px 10px;
  font-size: 13px;
}

.dialog-panel h3 {
  margin: 0 0 12px;
  font-size: 26px;
  line-height: 1.25;
}

.dialog-panel p {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.62;
}

.dialogue-text {
  min-height: 118px;
}

.choice-list {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.choice-list button,
.primary-button,
.action-row button {
  min-height: 46px;
  padding: 12px 15px;
  text-align: left;
}

.primary-button {
  border-color: rgba(230, 177, 95, 0.66);
  background: rgba(126, 88, 35, 0.58);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chapter-cover,
.ending-screen {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  padding-left: 9vw;
  background-position: center;
  background-size: cover;
}

.chapter-copy,
.ending-copy {
  width: min(620px, 72vw);
  padding: 28px 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 10, 12, 0.82);
}

.chapter-copy h1,
.ending-copy h2 {
  margin: 0 0 14px;
  font-size: 38px;
  line-height: 1.16;
}

.chapter-copy p,
.ending-copy p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.66;
}

.ending-notes {
  max-height: 22vh;
  overflow-y: auto;
  margin-top: 18px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.loading-overlay {
  top: 50%;
  left: 50%;
  z-index: 20;
  padding: 14px 18px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.portrait-prompt {
  display: none;
}

@media (max-width: 900px), (max-height: 520px) {
  :root {
    --edge-x: 12px;
    --edge-y: 12px;
  }

  .top-left {
    max-width: 34vw;
    padding: 10px 11px;
  }

  .top-left h2 {
    font-size: 18px;
  }

  .top-left p,
  .narration-box p {
    font-size: 13px;
  }

  .relationship-hud {
    max-width: 48vw;
    gap: 6px;
  }

  .bond-chip {
    grid-template-columns: 32px minmax(86px, 105px);
    min-height: 44px;
    padding: 5px 6px;
  }

  .bond-chip img {
    width: 32px;
    height: 32px;
  }

  .bond-chip strong {
    font-size: 12px;
  }

  .bond-chip small {
    display: none;
  }

  .location-nav {
    left: 12px;
    bottom: 12px;
    max-width: 50vw;
  }

  .location-nav button {
    flex-basis: 124px;
    height: 58px;
    padding: 8px;
  }

  .location-nav span {
    font-size: 15px;
  }

  .narration-box {
    right: 12px;
    bottom: 12px;
    width: 40vw;
    max-height: 30vh;
    padding: 10px 11px;
  }

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

  .hotspot span {
    inset: 12px;
  }

  .hotspot b {
    top: 45px;
    max-width: 116px;
    font-size: 11px;
  }

  .dialog-panel {
    right: 3vw;
    grid-template-columns: 180px minmax(260px, 1fr);
    width: 78vw;
    max-height: 82vh;
  }

  .panel-image {
    min-height: 280px;
  }

  .panel-body {
    padding: 14px;
  }

  .dialog-panel h3 {
    font-size: 20px;
  }

  .dialog-panel p {
    font-size: 14px;
  }

  .choice-list button,
  .primary-button,
  .action-row button {
    min-height: 38px;
    padding: 9px 10px;
  }

  .chapter-cover,
  .ending-screen {
    padding-left: 5vw;
  }

  .chapter-copy,
  .ending-copy {
    width: min(560px, 78vw);
    padding: 18px 20px;
  }

  .chapter-copy h1,
  .ending-copy h2 {
    font-size: 28px;
  }
}

@media (orientation: portrait) and (max-width: 620px) {
  .portrait-prompt {
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 30;
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-strong);
  }

  .relationship-hud {
    top: 92px;
    right: 12px;
    flex-direction: column;
  }

  .top-left {
    top: 92px;
    max-width: 48vw;
  }

  .dialog-panel {
    inset: auto 10px 10px 10px;
    grid-template-columns: 1fr;
    width: auto;
    max-height: 62vh;
    transform: none;
  }

  .panel-image {
    min-height: 150px;
  }

  .narration-box {
    width: 46vw;
  }
}

:root {
  --if-panel-bg: rgba(5, 10, 12, 0.88);
  --if-panel-border: rgba(255, 255, 255, 0.18);
  --if-panel-radius: 8px;
  --if-panel-pad-x: 22px;
  --if-panel-pad-y: 20px;
  --if-gap-xs: 6px;
  --if-gap-sm: 10px;
  --if-gap-md: 14px;
  --if-corner-x: 28px;
  --if-corner-y: 26px;
  --if-bottom-x: 48px;
  --if-bottom-y: 48px;
  --if-meta-font: 13px;
  --if-body-font: 17px;
  --if-body-line: 1.55;
  --if-panel-title-font: 28px;
  --if-ending-title-font: 36px;
  --if-top-left-w: 420px;
  --if-hud-max-w: 560px;
  --if-hud-chip-h: 56px;
  --if-hud-avatar: 42px;
  --if-narration-w: 500px;
  --if-narration-max-h: 28vh;
  --if-hub-w: min(760px, 56vw);
  --if-hub-max-h: 28vh;
  --if-hub-button-w: 138px;
  --if-hub-button-h: 82px;
  --if-hub-label-font: 22px;
  --if-hotspot-hit: 52px;
  --if-hotspot-dot: 18px;
  --if-hotspot-label-w: 168px;
  --if-hotspot-label-font: 15px;
  --if-dialog-w: min(960px, calc(100vw - 96px));
  --if-dialog-max-h: 74vh;
  --if-closeup-h: 360px;
  --if-choice-h: 58px;
  --if-choice-font: 17px;
  --if-result-w: 720px;
  --if-action-button-h: 48px;
  --if-close-button: 44px;
  --if-settlement-w: 760px;
  --if-settlement-pad: 32px;
  --if-loading-title-font: 24px;
}

#game {
  position: relative;
}

.force-landscape #game {
  position: fixed;
  top: calc(var(--vvh, 100vh) / 2);
  left: calc(var(--vvw, 100vw) / 2);
  width: var(--vvh, 100vh);
  height: var(--vvw, 100vw);
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center;
}

.force-landscape #sceneCanvas,
.force-landscape #sceneScrim,
.force-landscape .chapter-cover,
.force-landscape .ending-screen,
.force-landscape .top-left,
.force-landscape .relationship-hud,
.force-landscape .hotspot-layer,
.force-landscape .location-nav,
.force-landscape .narration-box,
.force-landscape .dialog-panel,
.force-landscape .loading-overlay {
  position: fixed;
}

.force-landscape .portrait-prompt {
  display: none !important;
}

.top-left {
  top: var(--if-corner-y);
  left: var(--if-corner-x);
  width: var(--if-top-left-w);
  max-width: 34vw;
  padding: var(--if-panel-pad-y) var(--if-panel-pad-x);
  border-color: var(--if-panel-border);
  border-radius: var(--if-panel-radius);
  background: var(--if-panel-bg);
}

.top-left h2 {
  font-size: var(--if-panel-title-font);
}

.top-left p {
  font-size: var(--if-body-font);
  line-height: var(--if-body-line);
}

.relationship-hud {
  top: var(--if-corner-y);
  right: var(--if-corner-x);
  max-width: var(--if-hud-max-w);
  gap: var(--if-gap-sm);
}

.bond-chip {
  grid-template-columns: var(--if-hud-avatar) minmax(120px, 150px);
  min-height: var(--if-hud-chip-h);
  border-color: var(--if-panel-border);
  border-radius: var(--if-panel-radius);
  background: var(--if-panel-bg);
}

.bond-chip img {
  width: var(--if-hud-avatar);
  height: var(--if-hud-avatar);
}

.location-nav {
  left: var(--if-bottom-x);
  bottom: var(--if-bottom-y);
  width: var(--if-hub-w);
  max-width: calc(100vw - var(--if-narration-w) - 112px);
  max-height: var(--if-hub-max-h);
}

.location-nav button {
  flex: 0 0 var(--if-hub-button-w);
  width: var(--if-hub-button-w);
  height: var(--if-hub-button-h);
}

.location-nav span {
  font-size: var(--if-hub-label-font);
}

.narration-box {
  right: var(--if-corner-x);
  bottom: 32px;
  width: var(--if-narration-w);
  max-height: var(--if-narration-max-h);
  padding: var(--if-panel-pad-y) var(--if-panel-pad-x);
  border-color: var(--if-panel-border);
  border-radius: var(--if-panel-radius);
  background: var(--if-panel-bg);
  -webkit-overflow-scrolling: touch;
}

.narration-box p {
  font-size: var(--if-body-font);
  line-height: var(--if-body-line);
}

.hotspot {
  width: var(--if-hotspot-hit);
  height: var(--if-hotspot-hit);
}

.hotspot span {
  inset: calc((var(--if-hotspot-hit) - var(--if-hotspot-dot)) / 2);
}

.hotspot b {
  top: calc(var(--if-hotspot-hit) + 8px);
  max-width: var(--if-hotspot-label-w);
  font-size: var(--if-hotspot-label-font);
}

.dialog-panel {
  right: 6vw;
  grid-template-columns: 320px minmax(420px, 1fr);
  width: var(--if-dialog-w);
  max-height: var(--if-dialog-max-h);
}

.panel-image {
  min-height: var(--if-closeup-h);
}

.dialog-panel h3 {
  font-size: var(--if-panel-title-font);
}

.dialog-panel p {
  font-size: var(--if-body-font);
  line-height: var(--if-body-line);
}

.choice-list button,
.primary-button,
.action-row button {
  min-height: var(--if-choice-h);
  font-size: var(--if-choice-font);
}

.chapter-copy,
.ending-copy {
  width: var(--if-settlement-w);
  max-width: calc(100vw - 96px);
  padding: var(--if-settlement-pad);
}

.chapter-copy h1,
.ending-copy h2 {
  font-size: var(--if-ending-title-font);
}

.loading-overlay {
  font-size: var(--if-loading-title-font);
}

.mobile-portrait .portrait-prompt {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
  border: 0;
  border-radius: 0;
  background: rgba(5, 8, 10, 0.96);
}

.mobile-portrait .portrait-prompt strong {
  font-size: 22px;
}

.mobile-portrait .portrait-prompt span {
  color: var(--muted);
  font-size: 14px;
}

.mobile-portrait .portrait-prompt button {
  min-width: 148px;
  min-height: 40px;
  margin: 0 auto;
  border-color: rgba(230, 177, 95, 0.66);
  background: rgba(126, 88, 35, 0.58);
}

@media (max-width: 899px), (max-height: 520px) {
  :root {
    --if-panel-pad-x: 12px;
    --if-panel-pad-y: 10px;
    --if-gap-xs: 4px;
    --if-gap-sm: 8px;
    --if-gap-md: 10px;
    --if-corner-x: 14px;
    --if-corner-y: 12px;
    --if-bottom-x: 14px;
    --if-bottom-y: 14px;
    --if-meta-font: 11px;
    --if-body-font: 13px;
    --if-body-line: 1.45;
    --if-panel-title-font: 18px;
    --if-ending-title-font: 24px;
    --if-top-left-w: 190px;
    --if-hud-max-w: 360px;
    --if-hud-chip-h: 38px;
    --if-hud-avatar: 28px;
    --if-narration-w: 260px;
    --if-narration-max-h: 30vh;
    --if-hub-w: 360px;
    --if-hub-max-h: 26vh;
    --if-hub-button-w: 96px;
    --if-hub-button-h: 48px;
    --if-hub-label-font: 13px;
    --if-hotspot-hit: 40px;
    --if-hotspot-dot: 14px;
    --if-hotspot-label-w: 112px;
    --if-hotspot-label-font: 11px;
    --if-dialog-w: min(520px, calc(100vw - 28px));
    --if-dialog-max-h: 76vh;
    --if-closeup-h: 180px;
    --if-choice-h: 44px;
    --if-choice-font: 13px;
    --if-result-w: min(440px, calc(100vw - 28px));
    --if-action-button-h: 40px;
    --if-close-button: 36px;
    --if-settlement-w: min(520px, calc(100vw - 28px));
    --if-settlement-pad: 18px;
    --if-loading-title-font: 18px;
  }

  .top-left {
    max-width: var(--if-top-left-w);
  }

  .relationship-hud {
    max-width: var(--if-hud-max-w);
  }

  .bond-chip {
    grid-template-columns: var(--if-hud-avatar) 92px;
    padding: 5px 6px;
  }

  .bond-chip strong {
    font-size: 12px;
  }

  .bond-chip small {
    display: none;
  }

  .location-nav {
    width: var(--if-hub-w);
    max-width: calc(100vw - var(--if-narration-w) - 42px);
  }

  .narration-box {
    width: var(--if-narration-w);
  }

  .dialog-panel {
    right: 14px;
    grid-template-columns: 180px minmax(260px, 1fr);
    width: var(--if-dialog-w);
  }

  .panel-body {
    padding: 14px;
  }

  .chapter-cover,
  .ending-screen {
    padding-left: 5vw;
  }
}
