:root {
  color-scheme: dark;
  --ink: #e9eee8;
  --muted: #8e9d99;
  --panel: rgba(18, 28, 30, .9);
  --panel-2: rgba(24, 37, 39, .88);
  --line: rgba(174, 204, 193, .16);
  --gold: #e4c276;
  --teal: #6bc9b0;
  --danger: #df776f;
  --shadow: 0 26px 80px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #0b1113; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 70% 15%, rgba(80, 112, 91, .18), transparent 35%),
    linear-gradient(140deg, #111b1e 0%, #0a1012 58%, #131714 100%);
}

button { font: inherit; }

.weather {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .45;
  background-image:
    linear-gradient(110deg, transparent 0 48%, rgba(255,255,255,.025) 49% 50%, transparent 51%),
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 190px 190px, 100% 7px;
}

.app { min-height: 100vh; position: relative; }

.topbar {
  min-height: 94px;
  display: grid;
  grid-template-columns: 1fr minmax(220px, 360px) auto;
  align-items: center;
  gap: 28px;
  padding: 18px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 16, 18, .9);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font: 800 26px/1.1 Georgia, "Noto Serif TC", serif;
}

h1 small {
  margin-left: 12px;
  color: var(--muted);
  font: 500 14px/1.2 "Noto Sans TC", sans-serif;
}

.map-progress { align-self: center; }
.map-progress > span { display: block; margin-bottom: 8px; text-align: right; color: var(--muted); font-size: 12px; }
.progress-track { height: 4px; overflow: hidden; background: rgba(255,255,255,.08); border-radius: 99px; }
.progress-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .35s ease; }

.top-actions { display: flex; gap: 8px; }
.text-button, .secondary-button, .primary-button, .action-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255,255,255,.035);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.text-button { padding: 9px 12px; border-radius: 6px; font-size: 13px; }
.text-button:hover, .secondary-button:hover, .action-button:not(:disabled):hover { border-color: rgba(107,201,176,.55); background: rgba(107,201,176,.08); }
.text-button.danger { color: #e8aaa4; }

.error { margin: 14px 30px 0; padding: 14px 16px; border: 1px solid rgba(223,119,111,.45); background: rgba(113,35,31,.28); color: #ffc4bf; }

.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 20px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 28px 44px;
}

.route-panel, .stage {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.route-panel {
  position: sticky;
  top: 20px;
  height: calc(100vh - 138px);
  min-height: 600px;
  overflow: auto;
}

.route-panel > header { padding: 22px; border-bottom: 1px solid var(--line); }
.route-panel h2 { margin-bottom: 8px; font: 700 22px/1.15 Georgia, "Noto Serif TC", serif; }
.route-panel header > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.scene-list { list-style: none; margin: 0; padding: 8px; }
.scene-list li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
}
.scene-list li > span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font: 700 10px/1 monospace;
}
.scene-list small, .scene-list strong { display: block; }
.scene-list small { margin-bottom: 3px; color: #6f817d; font-size: 9px; letter-spacing: .1em; }
.scene-list strong { font-size: 12px; font-weight: 600; }
.scene-list .current { color: var(--ink); border-color: rgba(228,194,118,.38); background: rgba(228,194,118,.07); }
.scene-list .current > span { color: #101615; background: var(--gold); border-color: var(--gold); }
.scene-list .complete { color: #b6cbc4; }
.scene-list .complete > span { color: #07120f; background: var(--teal); border-color: var(--teal); }
.scene-list .locked { opacity: .45; }

.stage { min-height: calc(100vh - 138px); padding: clamp(22px, 3vw, 48px); }

.scene-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.scene-heading h2 { margin-bottom: 8px; font: 700 clamp(28px, 3vw, 44px)/1.12 Georgia, "Noto Serif TC", serif; }
.location { margin: 0; color: var(--muted); }
.status {
  flex: none;
  padding: 7px 10px;
  border: 1px solid rgba(228,194,118,.3);
  color: var(--gold);
  font-size: 11px;
  letter-spacing: .08em;
}
.status.complete { border-color: rgba(107,201,176,.38); color: var(--teal); }
.situation {
  margin: 24px 0;
  padding: 15px 18px;
  border-left: 3px solid var(--gold);
  background: rgba(228,194,118,.055);
  color: #cbd3ce;
  line-height: 1.75;
}

.transcript { display: grid; gap: 10px; }
.transcript article {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 1fr;
  gap: 18px;
  padding: 15px 17px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.025);
}
.transcript strong { color: var(--gold); font-size: 13px; }
.transcript p { margin: 0; color: #e3e8e4; line-height: 1.8; }

.action-panel { margin-top: 32px; padding-top: 25px; border-top: 1px solid var(--line); }
.action-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; }
.action-heading h3 { margin-bottom: 0; font: 700 22px/1.2 Georgia, "Noto Serif TC", serif; }
.action-heading > span { color: var(--muted); font-size: 12px; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.action-button {
  min-height: 86px;
  padding: 15px 16px;
  text-align: left;
  border-radius: 6px;
}
.action-button:not(:disabled):hover { transform: translateY(-2px); }
.action-button strong, .action-button span { display: block; }
.action-button strong { margin-bottom: 7px; color: var(--ink); line-height: 1.55; }
.action-button span { color: var(--muted); font-size: 12px; line-height: 1.55; }
.action-button:disabled { cursor: default; opacity: .5; }
.action-button.done { border-color: rgba(107,201,176,.35); }
.action-button.done strong::before { content: "✓ "; color: var(--teal); }
.response {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(107,201,176,.25);
  background: rgba(107,201,176,.055);
}
.response p { margin: 0 0 8px; line-height: 1.7; }
.response p:last-child { margin-bottom: 0; }
.response strong { color: var(--teal); }

.scene-footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.secondary-button, .primary-button { min-height: 42px; padding: 9px 15px; border-radius: 5px; }
.primary-button { border-color: rgba(228,194,118,.7); background: var(--gold); color: #17170f; font-weight: 800; }
.primary-button:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .35; }
.outcome { color: #a9b8b3; font-size: 12px; line-height: 1.6; }

.ledger {
  position: fixed;
  z-index: 20;
  inset: 0 0 0 auto;
  width: min(470px, 100%);
  overflow: auto;
  padding: 26px;
  border-left: 1px solid var(--line);
  background: rgba(10, 16, 18, .98);
  box-shadow: -30px 0 90px rgba(0,0,0,.5);
}
.ledger > header { display: flex; justify-content: space-between; align-items: start; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.ledger h2 { margin-bottom: 0; font: 700 28px/1.2 Georgia, "Noto Serif TC", serif; }
.ledger section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.ledger h3 { color: var(--gold); font-size: 14px; }
.ledger li, .ledger p, .ledger dd { color: #b8c4c0; font-size: 13px; line-height: 1.75; }
.ledger dl { display: grid; grid-template-columns: minmax(150px, 1fr) 1fr; gap: 8px 14px; }
.ledger dt { color: #7d918b; font: 11px/1.55 monospace; }
.ledger dd { margin: 0; overflow-wrap: anywhere; }

.loading {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background: #0b1113;
}
.loading[hidden] { display: none; }
.loading span { width: 36px; height: 36px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
.loading p { margin: 15px 0 0; color: var(--muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .map-progress { grid-column: 1 / -1; grid-row: 2; }
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .route-panel { position: static; height: auto; min-height: 0; }
  .scene-list { display: grid; grid-template-columns: repeat(4, 1fr); }
  .scene-list li { grid-template-columns: 1fr; }
  .scene-list li div { display: none; }
  .stage { min-height: 0; }
}

@media (max-width: 620px) {
  .topbar { padding: 16px; gap: 14px; }
  .top-actions { grid-column: 1 / -1; }
  h1 small { display: block; margin: 6px 0 0; }
  .stage { padding: 20px 16px; }
  .actions { grid-template-columns: 1fr; }
  .transcript article { grid-template-columns: 1fr; gap: 6px; }
  .scene-footer { grid-template-columns: 1fr; }
  .primary-button, .secondary-button { width: 100%; }
}
