:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --panel: #161514;
  --panel-strong: #211c18;
  --line: #3a342e;
  --text: #ece7dc;
  --muted: #aa9d8c;
  --dim: #74695f;
  --amber: #c99652;
  --cyan: #8aa6a0;
  --sage: #9fb489;
  --red: #b9564f;
  --blue: #7d91c5;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(58, 35, 31, 0.16), rgba(11, 11, 13, 0.96) 36%),
    #0b0b0d;
  color: var(--text);
  transition: background 260ms ease, color 260ms ease;
}

body[data-alert="warn"] {
  --line: #4a3a29;
  --amber: #dfaa50;
  --shadow: rgba(10, 3, 0, 0.48);
  background:
    linear-gradient(180deg, rgba(96, 55, 18, 0.22), rgba(16, 12, 8, 0.98) 42%),
    #100c08;
}

body[data-alert="danger"] {
  --line: #5a302b;
  --amber: #f1ae56;
  --red: #df665a;
  --shadow: rgba(22, 0, 0, 0.58);
  background:
    linear-gradient(180deg, rgba(118, 22, 18, 0.24), rgba(15, 6, 6, 0.98) 40%),
    #100606;
}

body[data-alert="danger"] .timer-panel,
body[data-alert="danger"] .visual-panel,
body[data-alert="danger"] .actions-panel {
  box-shadow: 0 0 0 1px rgba(185, 86, 79, 0.16), 0 18px 48px var(--shadow);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(22, 21, 20, 0.9);
  box-shadow: 0 18px 48px var(--shadow);
  backdrop-filter: blur(14px);
}

.brand-mark {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #101317;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.18;
}

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

.top-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 14px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 120px));
  overflow: auto;
  border: 1px solid var(--line);
  background: rgba(18, 15, 13, 0.98);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.62);
  padding: 12px;
  display: grid;
  gap: 12px;
}

.top-menu-panel[hidden] {
  display: none;
}

.top-menu-section {
  border-top: 1px solid rgba(58, 52, 46, 0.78);
  padding-top: 12px;
}

.top-menu-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.top-menu-title {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.menu-button {
  min-height: 40px;
  border: 1px solid #3a342e;
  background: #151210;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
  font-size: 0.88rem;
}

.menu-button:hover,
.menu-button:focus-visible {
  border-color: var(--amber);
  outline: none;
}

.menu-button.active {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(201, 150, 82, 0.1);
}

.menu-button.danger {
  color: #e7a29b;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #121519;
  color: var(--text);
  font-size: 1.25rem;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.icon-button.active {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(201, 150, 82, 0.1);
}

.icon-button.danger:hover,
.icon-button.danger:focus-visible {
  border-color: var(--red);
  color: #ffd8d3;
}

.game-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.left-pane,
.center-pane,
.right-pane {
  min-width: 0;
}

.left-pane,
.right-pane,
.center-pane {
  display: grid;
  gap: 12px;
}

.timer-panel,
.stats-panel,
.inventory-panel,
.echo-panel,
.visual-panel,
.story-panel,
.actions-panel,
.log-panel {
  border: 1px solid var(--line);
  background: rgba(22, 21, 20, 0.94);
  box-shadow: 0 16px 38px var(--shadow);
}

.archive-panel {
  display: none;
}

.timer-panel {
  min-height: 128px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.timer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.timer-label,
.panel-title,
.item-meta,
.echo-meta,
.log-time {
  color: var(--muted);
  font-size: 0.82rem;
}

.timer-value {
  font-size: 2.55rem;
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.loop-value {
  color: var(--cyan);
  font-size: 0.95rem;
}

.heat-panel {
  display: grid;
  gap: 5px;
  margin-top: 4px;
}

.heat-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.heat-head strong {
  color: var(--amber);
}

.heat-cells {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
}

.heat-cell {
  height: 7px;
  border: 1px solid #332d28;
  background: #0f0e0d;
}

.heat-cell.on.calm {
  background: var(--sage);
}

.heat-cell.on.warn {
  background: var(--amber);
}

.heat-cell.on.danger {
  background: var(--red);
}

.heat-note {
  color: var(--dim);
  font-size: 0.76rem;
}

.text-button {
  min-height: 28px;
  border: 1px solid #3a414b;
  background: #111418;
  color: var(--cyan);
  padding: 0 9px;
  font-size: 0.82rem;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.stats-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: 3.7rem minmax(0, 1fr) 1.6rem;
  gap: 10px;
  align-items: center;
}

.stat-name {
  color: var(--text);
  font-size: 0.9rem;
}

.stat-track {
  height: 10px;
  background: #0f1216;
  border: 1px solid #2e343c;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  width: 50%;
  background: var(--sage);
}

.stat-fill.warn {
  background: var(--amber);
}

.stat-fill.danger {
  background: var(--red);
}

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

.stat-cell {
  height: 12px;
  border: 1px solid #39322c;
  background: #100f0e;
}

.stat-cell.spent {
  background: rgba(159, 180, 137, 0.45);
}

.stat-cell.warn {
  background: rgba(201, 150, 82, 0.55);
}

.stat-cell.danger {
  background: rgba(185, 86, 79, 0.62);
}

.stat-cell.current {
  border-color: #eee0c8;
  box-shadow: 0 0 0 1px rgba(238, 224, 200, 0.28);
}

.stat-value {
  color: var(--amber);
  text-align: right;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.archive-panel {
  display: none;
}

.inventory-panel,
.echo-panel {
  display: none;
  padding: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.panel-heading h3 {
  margin: 0;
  font-size: 0.98rem;
}

.inventory-list,
.archive-list {
  display: grid;
  gap: 8px;
}

.inventory-group {
  border-top: 1px solid rgba(58, 52, 46, 0.75);
  padding-top: 10px;
  margin-top: 10px;
}

.inventory-group:first-of-type {
  margin-top: 0;
}

.inventory-title {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.inventory-group.omen .inventory-title {
  color: var(--amber);
}

.inventory-item,
.archive-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(52, 58, 67, 0.72);
}

.inventory-item.omen {
  color: #f0d2a6;
}

.inventory-item:first-child,
.archive-item:first-child {
  border-top: 0;
}

.item-name,
.archive-name {
  overflow-wrap: anywhere;
}

.empty-line {
  color: var(--dim);
  font-size: 0.9rem;
}

.echo-card {
  display: grid;
  gap: 8px;
}

.relic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.relic-chip {
  border: 1px solid rgba(216, 170, 99, 0.5);
  color: var(--amber);
  background: rgba(216, 170, 99, 0.08);
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  font-size: 0.78rem;
}

.echo-name {
  color: var(--amber);
  font-weight: 700;
}

.echo-text {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.visual-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  min-height: 116px;
}

.scene-art {
  display: none;
  min-height: 166px;
  overflow: hidden;
  background: #101317;
  border: 1px solid #2d333b;
}

.scene-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.map-grid {
  min-height: 92px;
  display: block;
}

.route-strip {
  min-height: 92px;
  display: grid;
  align-items: stretch;
  gap: 10px;
}

.route-strip.choosing {
  grid-template-columns: minmax(320px, 1.2fr) 28px minmax(220px, 0.8fr);
}

.route-strip.solo {
  grid-template-columns: 1fr;
}

.route-node {
  border: 1px solid #303741;
  background: #12161b;
  padding: 10px 12px;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 5px;
}

.route-node.current {
  border-color: var(--amber);
  background: #221d16;
  align-content: start;
}

.route-node.fork.open {
  border-color: rgba(122, 184, 189, 0.72);
  background: #132027;
}

.route-node.fork.pending {
  opacity: 0.62;
}

.route-kicker,
.route-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.route-name {
  color: var(--text);
  font-weight: 800;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.route-node.current .route-name {
  color: var(--amber);
  font-size: 1.16rem;
}

.route-story {
  color: #ddd8cf;
  line-height: 1.48;
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.route-arrow {
  display: grid;
  place-items: center;
  color: var(--cyan);
  font-size: 1.35rem;
}

.route-forks {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(0, 1fr);
  gap: 8px;
}

.where-card,
.known-paths {
  border: 1px solid #303741;
  background: #12161b;
  padding: 12px;
}

.where-card {
  display: grid;
  gap: 7px;
}

.where-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.where-card strong {
  color: var(--amber);
  font-size: 1.08rem;
}

.where-card p {
  margin: 0;
  color: #d8d1c6;
  line-height: 1.55;
}

.known-paths {
  display: grid;
  gap: 8px;
}

.path-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.path-chip {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #3a414b;
  background: #0f1216;
  color: var(--text);
  padding: 0 9px;
  font-size: 0.84rem;
}

.path-chip.muted {
  color: var(--dim);
}

.room-node {
  position: relative;
  min-height: 62px;
  border: 1px solid #303741;
  background: #12161b;
  color: var(--text);
  padding: 10px;
  text-align: left;
  display: grid;
  gap: 4px;
  align-content: center;
}

.room-node:hover,
.room-node:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.room-node.current {
  border-color: var(--amber);
  background: #221d16;
}

.room-node:disabled {
  cursor: default;
}

.room-node.locked {
  color: var(--dim);
  background: #111316;
}

.room-node.done::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 8px;
  width: 8px;
  height: 8px;
  background: var(--sage);
}

.room-name {
  font-weight: 700;
}

.room-status {
  color: var(--muted);
  font-size: 0.76rem;
}

.story-panel {
  display: none;
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(216, 170, 99, 0.7);
  color: var(--amber);
  background: rgba(216, 170, 99, 0.08);
  font-size: 0.82rem;
  margin-bottom: 12px;
}

#sceneTitle {
  margin: 0 0 10px;
  font-size: 1.28rem;
  line-height: 1.3;
}

#storyText {
  margin: 0;
  color: #ddd8cf;
  line-height: 1.75;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.actions-panel {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.action-button {
  min-height: 58px;
  border: 1px solid #3b352f;
  background: #171412;
  color: var(--text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  text-align: left;
}

.action-button:hover,
.action-button:focus-visible {
  border-color: var(--amber);
  outline: none;
  background: #211b17;
}

.action-button.primary {
  border-color: var(--cyan);
}

.action-button.primary .action-cost {
  border-color: rgba(122, 184, 189, 0.7);
  color: var(--cyan);
}

.action-button.danger {
  border-color: rgba(199, 107, 99, 0.72);
}

.action-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.action-label {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.action-detail {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.action-cost {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid #3a414b;
  color: var(--amber);
  background: #111418;
  white-space: nowrap;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.action-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.action-heat {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.action-heat.warn {
  color: var(--amber);
}

.action-heat.danger {
  color: #e48d84;
}

.action-heat.cool {
  color: var(--cyan);
}

.action-button:disabled {
  opacity: 0.48;
}

.log-panel {
  padding: 14px;
  min-height: 360px;
  max-height: 58vh;
  overflow: auto;
}

.log-panel h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-list.compact {
  margin-top: 12px;
}

.result-card {
  border: 1px solid rgba(122, 184, 189, 0.5);
  background: rgba(122, 184, 189, 0.07);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.result-title {
  color: var(--cyan);
  font-weight: 700;
}

.result-card p {
  margin: 0;
  line-height: 1.55;
}

.outcome-row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  border-top: 1px solid rgba(122, 184, 189, 0.24);
  padding-top: 8px;
}

.outcome-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.outcome-row strong {
  font-size: 0.9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.log-entry {
  padding-top: 10px;
  border-top: 1px solid rgba(52, 58, 67, 0.72);
}

.log-entry:first-child {
  border-top: 0;
  padding-top: 0;
}

.log-text {
  margin: 3px 0 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.ending-panel {
  border-color: var(--amber);
}

.ending-score {
  color: var(--amber);
  font-size: 1.1rem;
  font-weight: 700;
}

.end-note {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  margin-top: 8px;
  border: 1px solid var(--line);
  background: #111418;
  color: var(--text);
  padding: 10px;
}

.end-note:focus {
  outline: 1px solid var(--cyan);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid var(--cyan);
  background: #11161a;
  color: var(--text);
  box-shadow: 0 18px 48px var(--shadow);
  z-index: 20;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 7, 10, 0.74);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  background: #171412;
  color: var(--text);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.55);
}

.modal-heading {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #171412;
}

.modal-heading h2 {
  margin: 0;
  font-size: 1.16rem;
}

.lore-content {
  padding: 16px;
}

.lore-content p {
  margin: 0 0 16px;
  line-height: 1.7;
  color: #ddd8cf;
}

.lore-content dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.lore-content dl > div {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(52, 58, 67, 0.72);
}

.lore-content dt {
  color: var(--amber);
  font-weight: 800;
}

.lore-content dd {
  margin: 0;
  color: #cfc8bd;
  line-height: 1.6;
}

.settlement-panel {
  width: min(760px, 100%);
}

.settlement-content {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.settlement-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  border: 1px solid rgba(216, 170, 99, 0.62);
  background: rgba(216, 170, 99, 0.08);
  padding: 14px;
}

.settlement-grade {
  color: var(--amber);
  font-weight: 800;
  margin-bottom: 6px;
}

.settlement-hero h3 {
  margin: 0;
  font-size: 1.25rem;
}

.settlement-score {
  color: var(--cyan);
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.settlement-body {
  margin: 0;
  line-height: 1.7;
  color: #ddd8cf;
  white-space: pre-line;
}

.settlement-grid {
  display: grid;
  gap: 8px;
}

.settlement-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(52, 58, 67, 0.72);
}

.settlement-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.settlement-row strong {
  font-weight: 600;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.settlement-row.trace strong {
  color: var(--amber);
}

.settlement-actions {
  display: grid;
  gap: 10px;
}

.feedback-panel {
  width: min(560px, 100%);
}

.feedback-content {
  padding: 16px;
}

.feedback-card {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(138, 166, 160, 0.58);
  background: linear-gradient(180deg, rgba(138, 166, 160, 0.08), rgba(22, 20, 17, 0.94));
  padding: 16px;
}

.feedback-card.fail {
  border-color: rgba(185, 86, 79, 0.7);
  background: linear-gradient(180deg, rgba(185, 86, 79, 0.12), rgba(22, 14, 13, 0.96));
}

.feedback-kicker {
  color: var(--muted);
  font-size: 0.8rem;
}

.feedback-card h3 {
  margin: 0;
  color: var(--amber);
  font-size: 1.25rem;
}

.feedback-card p {
  margin: 0;
  line-height: 1.7;
  color: #e5dacb;
}

.feedback-grid {
  display: grid;
  gap: 8px;
  border-top: 1px solid rgba(58, 52, 46, 0.76);
  padding-top: 10px;
}

.feedback-grid div {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr);
  gap: 10px;
}

.feedback-grid span {
  color: var(--muted);
  font-size: 0.82rem;
}

.feedback-grid strong {
  color: var(--text);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.feedback-note {
  border-left: 2px solid var(--amber);
  padding-left: 10px;
  color: #d4c5b4;
}

.archive-modal-panel {
  width: min(720px, 100%);
}

.archive-modal-content {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.archive-modal-section {
  display: grid;
  gap: 10px;
}

.archive-note {
  color: #ddd8cf;
  line-height: 1.6;
}

.archive-detail-grid {
  display: grid;
  gap: 8px;
}

.archive-detail-card {
  border: 1px solid #343a43;
  background: #12161b;
  padding: 10px;
  display: grid;
  gap: 5px;
}

.archive-detail-card strong {
  color: var(--amber);
}

.archive-detail-card span {
  color: var(--muted);
  line-height: 1.5;
}

.archive-history-list {
  display: grid;
  gap: 8px;
}

.archive-history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(52, 58, 67, 0.72);
  padding-top: 10px;
}

.archive-history-item div {
  display: grid;
  gap: 3px;
}

.archive-history-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.archive-history-item b {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .right-pane {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.55fr);
  }

  .log-panel {
    max-height: 340px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  h1 {
    font-size: 1.2rem;
  }

  .game-layout,
  .right-pane {
    grid-template-columns: 1fr;
  }

  .left-pane {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }

  .timer-panel,
  .stats-panel,
  .inventory-panel,
  .echo-panel {
    min-height: 0;
  }

  .timer-panel {
    padding: 14px;
    gap: 6px;
  }

  .timer-value {
    font-size: 2.15rem;
  }

  .stats-panel {
    padding: 12px;
    gap: 9px;
  }

  .inventory-panel,
  .echo-panel {
    padding: 12px;
  }

  .inventory-panel {
    max-height: 190px;
    overflow: auto;
  }

  .inventory-group {
    padding-top: 7px;
    margin-top: 7px;
  }

  .inventory-item,
  .archive-item {
    padding: 6px 0;
  }

  .visual-panel {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .scene-art {
    display: none;
  }

  .map-grid {
    min-height: 96px;
  }

  .route-strip {
    min-height: 96px;
    padding-bottom: 4px;
  }

  .route-strip.choosing,
  .route-strip.solo {
    grid-template-columns: minmax(260px, 1fr);
  }

  .route-arrow {
    display: none;
  }

  .route-forks {
    grid-template-columns: 1fr;
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .left-pane {
    grid-template-columns: 1fr 1.25fr;
  }

  .echo-panel {
    display: none;
  }

  .inventory-panel {
    grid-column: 1 / -1;
    padding: 10px;
  }

  .inventory-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .brand-mark {
    display: none;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .timer-panel {
    min-height: 104px;
    padding: 14px;
  }

  .timer-value {
    font-size: 2rem;
  }

  .stats-panel {
    padding: 10px;
    gap: 9px;
  }

  .stat-row {
    grid-template-columns: 3rem minmax(0, 1fr) 2rem;
    gap: 7px;
  }

  .stat-name,
  .stat-value {
    font-size: 0.78rem;
  }

  .stat-cell {
    height: 8px;
  }

  .map-grid {
    min-height: 104px;
  }

  .route-strip {
    min-height: 104px;
    gap: 7px;
  }

  .route-strip.choosing,
  .route-strip.solo {
    grid-template-columns: 1fr;
  }

  .route-node {
    padding: 9px;
    gap: 5px;
  }

  .route-forks {
    min-width: 0;
    gap: 7px;
  }

  .route-name {
    font-size: 0.95rem;
  }

  .route-node.current .route-name {
    font-size: 1.08rem;
  }

  .route-story {
    line-height: 1.5;
    font-size: 0.92rem;
  }

  .route-meta,
  .route-kicker {
    font-size: 0.72rem;
  }

  .where-card,
  .known-paths {
    padding: 9px;
  }

  .where-card {
    gap: 5px;
  }

  .where-card p {
    line-height: 1.45;
    font-size: 0.88rem;
  }

  .path-chip {
    min-height: 26px;
    font-size: 0.78rem;
  }

  .visual-panel,
  .story-panel,
  .actions-panel {
    padding: 10px;
  }

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

  #sceneTitle {
    font-size: 1.1rem;
  }

  #storyText {
    line-height: 1.62;
  }

  .phase-pill {
    margin-bottom: 8px;
  }

  .action-button {
    grid-template-columns: 1fr;
    min-height: 58px;
    padding: 10px;
  }

  .action-cost {
    justify-self: start;
  }

  .action-side {
    justify-items: start;
  }
}
