:root {
  color-scheme: dark;
  --bg: #050606;
  --panel: rgba(13, 14, 13, 0.88);
  --panel-strong: rgba(20, 20, 18, 0.94);
  --line: rgba(186, 134, 69, 0.45);
  --line-soft: rgba(186, 134, 69, 0.22);
  --text: #e0d4c4;
  --muted: #9e9182;
  --dim: #675e55;
  --amber: #d5953e;
  --amber-bright: #f2b454;
  --danger: #d75547;
  --blue: #5b9bd5;
  --green: #8faf7a;
  --shadow: rgba(0, 0, 0, 0.72);
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --text-scale: 1;
  --status-dock-height: 96px;
  font-family:
    "Noto Sans KR",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
}

body[data-contrast="high"] {
  --panel: rgba(8, 9, 8, 0.96);
  --panel-strong: rgba(12, 12, 11, 0.985);
  --line: rgba(242, 180, 84, 0.7);
  --line-soft: rgba(242, 180, 84, 0.34);
  --text: #f2e8da;
  --muted: #ccbda8;
  --dim: #8b7f72;
  --shadow: rgba(0, 0, 0, 0.84);
}

button {
  font: inherit;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.58)),
    #050606;
}

.scene {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
}

.scene::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";
  background:
    linear-gradient(180deg, rgba(5, 6, 6, 0.14) 0%, rgba(5, 6, 6, 0.48) 58%, #050606 100%),
    url("./assets/illustrations/busan-port-arrival.png") center / cover no-repeat;
  filter: saturate(0.82) contrast(1.08) brightness(0.72);
  transform: scale(1.02);
}

.scene::after {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mix-blend-mode: screen;
  opacity: 0.18;
}

body[data-contrast="high"] .scene::before {
  filter: saturate(0.8) contrast(1.16) brightness(0.64);
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 0;
  padding: calc(12px + var(--safe-area-top)) 14px 0;
}

.place-block {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  max-width: min(68vw, 260px);
  padding: 12px 14px;
  border: 1px solid rgba(186, 134, 69, 0.4);
  border-radius: 10px;
  background: rgba(8, 9, 9, 0.74);
  backdrop-filter: blur(10px);
}

.pin-mark {
  position: relative;
  width: 18px;
  height: 24px;
  flex: 0 0 auto;
  border: 2px solid var(--muted);
  border-radius: 14px 14px 14px 4px;
  transform: rotate(-45deg);
}

.pin-mark::after {
  position: absolute;
  inset: 4px;
  content: "";
  border-radius: 50%;
  background: var(--muted);
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin: 2px 0 0;
  color: #ead7bd;
  font-size: calc(20px * var(--text-scale));
  font-weight: 760;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 13, 12, 0.78);
  color: var(--amber-bright);
  cursor: pointer;
}

.save-pill {
  border: 1px solid rgba(186, 134, 69, 0.24);
  border-radius: 999px;
  padding: 7px 10px;
  color: #cfbea8;
  background: rgba(12, 13, 12, 0.64);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-strip {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  width: calc(min(100vw, 480px) - 24px);
  min-height: var(--status-dock-height);
  margin: 0 auto;
  padding-bottom: calc(8px + var(--safe-area-bottom));
  overflow: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: rgba(4, 5, 5, 0.92);
  backdrop-filter: blur(14px);
  box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.42);
  transform: translateX(-50%);
}

.status-meter {
  min-width: 0;
  padding: 8px 7px 9px;
  border-right: 1px solid rgba(186, 134, 69, 0.14);
}

.status-meter:last-child {
  border-right: 0;
}

.status-name {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-meter strong {
  display: block;
  margin-top: 1px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.1;
}

.meter-track {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.meter-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--amber);
}

.status-meter[data-tone="danger"] .meter-track span {
  background: var(--danger);
}

.status-meter[data-tone="info"] .meter-track span {
  background: var(--blue);
}

.illustration-band {
  position: relative;
  height: clamp(320px, 46svh, 470px);
  border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
}

.rain-lines {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      105deg,
      rgba(198, 217, 224, 0.13) 0 1px,
      transparent 1px 14px
    );
  mask-image: linear-gradient(180deg, transparent, #000 20%, #000 75%, transparent);
  opacity: 0.45;
}

.content-stack {
  display: grid;
  gap: 10px;
  width: min(100%, 760px);
  margin: 12px auto 0;
  padding: 0 12px calc(var(--status-dock-height) + 28px + var(--safe-area-bottom));
}

.title-scene {
  display: flex;
  align-items: flex-end;
}

.title-shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 24px 12px calc(20px + var(--safe-area-bottom));
}

.title-panel {
  display: grid;
  gap: 14px;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 18px;
  background: linear-gradient(180deg, rgba(12, 13, 12, 0.78), rgba(9, 10, 9, 0.94));
  box-shadow: 0 24px 60px var(--shadow);
  backdrop-filter: blur(10px);
}

.title-mark {
  margin: 2px 0 0;
  color: #f0ddc2;
  font-size: calc(clamp(48px, 14vw, 76px) * var(--text-scale));
  line-height: 0.96;
}

.title-copy {
  margin: 0;
  color: #d3c5b3;
  font-size: calc(17px * var(--text-scale));
  line-height: 1.65;
}

.title-actions,
.sheet-actions {
  display: grid;
  gap: 10px;
}

.hero-button,
.sheet-action,
.toggle-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 14, 13, 0.86);
  color: var(--text);
}

.hero-button,
.sheet-action {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  min-height: 60px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
}

.hero-button span,
.sheet-action {
  font-size: calc(15px * var(--text-scale));
}

.hero-button span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--amber-bright);
  font-weight: 800;
}

.hero-button strong,
.sheet-action {
  font-weight: 760;
}

.hero-button.primary,
.sheet-action.primary {
  border-color: rgba(242, 180, 84, 0.84);
  box-shadow: 0 0 0 2px rgba(242, 180, 84, 0.08), 0 10px 28px rgba(213, 149, 62, 0.18);
}

.hero-button:hover,
.hero-button:focus-visible,
.sheet-action:hover,
.sheet-action:focus-visible,
.toggle-row:hover,
.toggle-row:focus-visible,
.segment-group button:hover,
.segment-group button:focus-visible {
  outline: none;
  border-color: var(--amber-bright);
  box-shadow: 0 0 0 2px rgba(242, 180, 84, 0.12);
}

.sheet-action {
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
  min-height: 54px;
  font-size: calc(16px * var(--text-scale));
}

.sheet-action.danger {
  border-color: rgba(215, 85, 71, 0.58);
  color: #f0beb8;
}

.summary-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(186, 134, 69, 0.24);
  border-radius: 8px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.035);
}

.summary-card.is-empty {
  border-style: dashed;
  opacity: 0.92;
}

.summary-card strong {
  color: #ead8c0;
  font-size: calc(18px * var(--text-scale));
  line-height: 1.3;
}

.summary-card p,
.summary-card small {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.summary-card p {
  font-size: calc(14px * var(--text-scale));
}

.summary-card small {
  font-size: calc(12px * var(--text-scale));
}

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

.summary-stat {
  min-width: 0;
  border: 1px solid rgba(186, 134, 69, 0.16);
  border-radius: 7px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.summary-stat span,
.summary-stat strong {
  display: block;
}

.summary-stat span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-stat strong {
  margin-top: 4px;
  color: #f0dfc7;
  font-size: calc(16px * var(--text-scale));
}

.story-panel,
.knowledge-dock {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px var(--shadow);
  backdrop-filter: blur(8px);
}

.clue-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.clue-strip span,
.sensory-row span {
  border: 1px solid rgba(213, 149, 62, 0.28);
  border-radius: 999px;
  padding: 4px 8px;
  color: #d7c3a6;
  background: rgba(213, 149, 62, 0.08);
  font-size: 12px;
}

.unlock-strip {
  margin-top: 10px;
  padding: 10px;
  border-left: 2px solid var(--green);
  background: rgba(85, 122, 74, 0.12);
}

.unlock-strip p {
  margin-bottom: 5px;
  color: #cfe0c1;
}

.story-signals {
  margin-top: 14px;
}

.story-panel {
  max-height: min(29svh, 250px);
  min-height: 190px;
  overflow-y: auto;
  padding: 18px 17px;
}

.story-heading,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 3px 0 0;
  color: #e9d7c0;
  font-size: calc(clamp(24px, 6vw, 34px) * var(--text-scale));
  line-height: 1.18;
  letter-spacing: 0;
}

.event-index {
  flex: 0 0 auto;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
}

.story-copy {
  margin-top: 22px;
}

.story-copy p {
  margin-bottom: 17px;
  color: #d8cbbb;
  font-size: calc(clamp(17px, 4.35vw, 21px) * var(--text-scale));
  line-height: 1.72;
  letter-spacing: 0;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.threat-line {
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--amber-bright);
  font-size: calc(17px * var(--text-scale));
  line-height: 1.55;
  word-break: keep-all;
}

.sensory-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.failure-panel {
  border-color: rgba(215, 85, 71, 0.58);
}

.failure-panel h2 {
  color: #f0a49a;
}

.choice-list {
  position: sticky;
  bottom: calc(var(--status-dock-height) + 10px + var(--safe-area-bottom));
  z-index: 3;
  display: grid;
  gap: 9px;
}

.choice-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  min-height: 62px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  background: rgba(14, 15, 14, 0.9);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

.choice-button:hover,
.choice-button:focus-visible {
  outline: none;
  border-color: var(--amber-bright);
  box-shadow: 0 0 0 2px rgba(242, 180, 84, 0.16), 0 0 28px rgba(213, 149, 62, 0.18);
}

.choice-button.is-disabled,
.choice-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  border-color: var(--line-soft);
  box-shadow: none;
}

.choice-button span:last-child {
  min-width: 0;
  font-size: calc(clamp(17px, 4.4vw, 21px) * var(--text-scale));
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.choice-no {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  color: var(--amber-bright);
  font-weight: 800;
}

.primary-choice {
  border-color: rgba(242, 180, 84, 0.85);
}

.knowledge-dock {
  overflow: hidden;
}

.knowledge-tabs {
  display: grid;
  grid-auto-columns: minmax(74px, 1fr);
  grid-auto-flow: column;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-soft);
}

.knowledge-tabs button {
  min-height: 48px;
  border: 0;
  border-right: 1px solid rgba(186, 134, 69, 0.16);
  background: rgba(11, 12, 11, 0.72);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.knowledge-tabs button.is-active {
  color: var(--amber-bright);
  background: rgba(213, 149, 62, 0.12);
}

.knowledge-panel {
  padding: 13px 14px 15px;
}

.panel-heading strong {
  flex: 0 0 auto;
  color: #c7baa9;
  font-size: 13px;
  font-weight: 700;
}

.panel-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: calc(14px * var(--text-scale));
  line-height: 1.55;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.insight-card {
  min-width: 0;
  border: 1px solid rgba(186, 134, 69, 0.22);
  border-radius: 7px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.insight-card span,
.identity-card span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-card strong,
.identity-card strong {
  display: block;
  margin-top: 4px;
  color: #ead7bd;
  font-size: 15px;
  line-height: 1.25;
}

.route-map {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.route-node {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  padding: 7px 8px;
  opacity: 0.45;
  background: rgba(255, 255, 255, 0.025);
}

.route-node.is-discovered {
  border-color: rgba(91, 155, 213, 0.46);
  opacity: 1;
  background: rgba(91, 155, 213, 0.08);
}

.route-node span,
.person-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  color: var(--amber-bright);
  font-weight: 800;
}

.route-node strong {
  min-width: 0;
  color: #e0d2bd;
  font-size: 14px;
  line-height: 1.25;
}

.route-node small {
  color: var(--muted);
  font-size: 12px;
}

.person-card,
.identity-card {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid rgba(143, 175, 122, 0.34);
  border-radius: 8px;
  padding: 11px;
  background: rgba(143, 175, 122, 0.08);
}

.person-card {
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
}

.person-card strong {
  display: block;
  color: #dfe8d3;
  font-size: calc(16px * var(--text-scale));
}

.person-card p,
.identity-card small {
  display: block;
  margin: 4px 0 0;
  color: #b9c7ad;
  font-size: 13px;
  line-height: 1.45;
}

.memory-fragments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.memory-fragments span {
  border: 1px solid rgba(215, 85, 71, 0.3);
  border-radius: 999px;
  padding: 5px 9px;
  color: #e6c3bd;
  background: rgba(215, 85, 71, 0.08);
  font-size: 12px;
}

.clue-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.clue-list li {
  border-top: 1px solid rgba(186, 134, 69, 0.16);
  padding-top: 9px;
}

.clue-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.clue-list span,
.clue-list small {
  display: block;
}

.clue-list span {
  min-width: 0;
  color: #e0d2bd;
  font-size: calc(15px * var(--text-scale));
  font-weight: 760;
}

.clue-list em {
  flex: 0 0 auto;
  border: 1px solid rgba(186, 134, 69, 0.24);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--amber);
  font-size: 11px;
  font-style: normal;
}

.clue-list small {
  margin-top: 3px;
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
  line-height: 1.45;
}

.overlay-layer {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  align-items: end;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.62);
}

.sheet {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(100%, 480px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 16px 14px calc(18px + var(--safe-area-bottom));
  background: var(--panel-strong);
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.4);
}

.sheet-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sheet-title {
  margin: 4px 0 0;
  color: #ead7bd;
  font-size: calc(24px * var(--text-scale));
  line-height: 1.2;
}

.settings-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid rgba(186, 134, 69, 0.16);
  padding-top: 14px;
}

.settings-label {
  margin: 0;
  color: #dcc9b0;
  font-size: calc(14px * var(--text-scale));
  font-weight: 700;
}

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

.segment-group button {
  min-height: 46px;
  border: 1px solid rgba(186, 134, 69, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: calc(15px * var(--text-scale));
  cursor: pointer;
}

.segment-group button.is-active {
  border-color: rgba(242, 180, 84, 0.82);
  color: var(--amber-bright);
  background: rgba(213, 149, 62, 0.12);
}

.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
}

.toggle-copy strong,
.toggle-copy small {
  display: block;
}

.toggle-copy strong {
  color: #ead7bd;
  font-size: calc(15px * var(--text-scale));
}

.toggle-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: calc(12px * var(--text-scale));
  line-height: 1.45;
}

.toggle-button {
  min-width: 58px;
  border: 1px solid rgba(186, 134, 69, 0.24);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.toggle-button.is-on {
  border-color: rgba(143, 175, 122, 0.5);
  color: #dfe8d3;
  background: rgba(143, 175, 122, 0.12);
}

@media (min-width: 820px) {
  body {
    background:
      radial-gradient(circle at 50% 0%, rgba(69, 90, 91, 0.18), transparent 34%),
      #020303;
  }

  .scene {
    width: min(480px, 100%);
    margin: 0 auto;
    border-right: 1px solid rgba(186, 134, 69, 0.16);
    border-left: 1px solid rgba(186, 134, 69, 0.16);
  }

  .scene::before,
  .scene::after {
    width: min(480px, 100%);
    margin: 0 auto;
  }

  .content-stack {
    width: 100%;
  }
}

@media (max-width: 370px) {
  .status-meter {
    padding-inline: 5px;
  }

  .status-name {
    font-size: 10px;
  }

  .status-meter strong {
    font-size: 15px;
  }
}
