:root {
  color-scheme: light;
  --paper: #f6f1e7;
  --paper-deep: #ece2d1;
  --ink: #25221d;
  --muted: #756d61;
  --line: #cfc2ae;
  --accent: #9b4f2c;
  --accent-dark: #65331f;
  --leaf: #526b4b;
  --card: #fffaf0;
  --shadow: rgba(65, 48, 31, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.72), transparent 28rem),
    linear-gradient(135deg, var(--paper), var(--paper-deep));
  font-family: Georgia, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 500;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 0.9;
}

h2 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
}

.hamster-status {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) repeat(2, minmax(150px, 1fr)) repeat(2, minmax(100px, 0.7fr));
  gap: 12px;
  align-items: stretch;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 18px 40px var(--shadow);
}

.hamster-identity,
.status-meter,
.status-fact {
  min-width: 0;
  border-right: 1px dotted var(--line);
  padding: 4px 12px 4px 0;
}

.hamster-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hamster-portrait {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border: 1px solid var(--line);
  border-radius: 10px;
  object-fit: cover;
  background: var(--paper);
  box-shadow: 0 4px 12px rgba(65, 48, 31, 0.12);
}

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

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.meter-track {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-deep);
}

.meter-fill {
  width: 0;
  height: 100%;
  background: var(--leaf);
  transition: width 180ms ease;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.scene-card,
.state-card,
.control-card,
.log-card,
.quest-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: 0 18px 40px var(--shadow);
}

.scene-card {
  min-width: 0;
  padding: 18px;
}

.scene-card.is-travelling {
  animation: scene-travel 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.scene-heading,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.location-picker {
  min-width: 0;
}

.select-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

.location-select {
  max-width: 100%;
  appearance: none;
  border: 0;
  outline: 0;
  padding: 0 34px 1px 0;
  color: var(--ink);
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  cursor: pointer;
}

.location-select:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.location-select:disabled {
  cursor: wait;
  opacity: 0.6;
}

.select-arrow {
  position: absolute;
  right: 6px;
  color: var(--accent-dark);
  pointer-events: none;
}

.status-pill {
  min-width: 88px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--accent-dark);
  background: var(--paper);
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  text-align: center;
}

.scene-art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: var(--paper-deep);
}

.scene-stage {
  position: relative;
  margin: 18px 0;
}

.scene-hotspots,
.scene-hotspot {
  position: absolute;
}

.scene-hotspots {
  inset: 0;
  pointer-events: none;
}

.scene-hotspot {
  padding: 0;
  border: 2px dashed transparent;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.scene-hotspot:hover:not(:disabled),
.scene-hotspot:focus-visible {
  border-color: rgba(155, 79, 44, 0.55);
  background: rgba(255, 248, 233, 0.18);
}

.scene-hotspot:disabled {
  cursor: wait;
}

.hotspot-prompt {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 8px;
  min-width: 11rem;
  max-width: 70%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 12px 28px var(--shadow);
  transform: translate(-8px, 8px);
}

.hotspot-prompt[hidden] {
  display: none;
}

.hotspot-prompt-text {
  margin: 0;
  font-size: 1.05rem;
}

.hotspot-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hotspot-confirm {
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--accent-dark);
  background: rgba(155, 79, 44, 0.1);
  cursor: pointer;
}

.location-description {
  max-width: 66ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.state-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

.coins {
  font-size: 2rem;
}

.inventory-list,
.fact-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.inventory-list li,
.fact-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dotted var(--line);
  padding-bottom: 6px;
  color: var(--muted);
}

.control-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.location-nav,
.action-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-bar {
  flex-direction: row;
  flex-wrap: wrap;
}

.location-button,
.action-button,
.ghost-button,
.text-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.location-button,
.action-button {
  padding: 10px 12px;
  text-align: left;
}

.location-button[aria-current="true"],
.action-button:hover:not(:disabled),
.location-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: rgba(155, 79, 44, 0.08);
}

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

.ghost-button,
.text-button {
  padding: 7px 10px;
  color: var(--muted);
}

.log-card {
  grid-column: 1 / -1;
  padding: 18px;
}

.result-log {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding-left: 22px;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
}

.result-log li {
  padding-left: 4px;
}

.log-muted {
  color: var(--muted);
}

.log-good {
  color: var(--leaf);
}

.log-accent {
  color: var(--accent-dark);
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: stretch;
}

.scene-stack {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.choice-card,
.inventory-card,
.ledger-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 18px 40px var(--shadow);
}

.choice-card {
  min-width: 0;
  overflow: hidden;
  padding: 18px;
}

.choice-heading,
.log-heading,
.quest-heading,
.inventory-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.log-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.menu-breadcrumb {
  color: var(--accent-dark);
  font-size: 1.15rem;
}

.menu-breadcrumb span {
  color: var(--muted);
}

.back-button {
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--accent-dark);
  background: rgba(155, 79, 44, 0.09);
  cursor: pointer;
}

.back-button:hover:not(:disabled) {
  background: rgba(155, 79, 44, 0.15);
}

.back-button:disabled {
  cursor: wait;
  opacity: 0.45;
}

.action-progress {
  margin-top: 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 13px 14px 14px;
  color: var(--paper);
  background: #29251f;
  box-shadow:
    0 10px 24px rgba(65, 48, 31, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.action-progress[hidden] {
  display: none;
}

.action-progress-copy {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.action-progress-kicker,
.action-progress-copy strong {
  display: block;
}

.action-progress-kicker {
  margin-bottom: 3px;
  color: #cbbda8;
  font-family: "Courier New", monospace;
  font-size: 0.64rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.action-progress-copy strong {
  color: #fff8e9;
  font-size: 1.05rem;
}

.action-timer {
  color: #fff8e9;
  font-family: "Courier New", monospace;
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1;
}

.action-progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 233, 0.28);
  border-radius: 999px;
  background: rgba(255, 248, 233, 0.1);
}

.action-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #d99a62;
  transition: width 90ms linear;
}

.menu-stage {
  min-height: 154px;
  margin-top: 14px;
}

.menu-view {
  display: grid;
  gap: 9px;
}

.menu-view[data-motion="forward"] {
  animation: menu-forward 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.menu-view[data-motion="back"] {
  animation: menu-back 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.menu-view[data-motion="travel"] {
  animation: menu-travel 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.choice-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  width: 100%;
  border: 1px solid rgba(207, 194, 174, 0.85);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.25);
  text-align: left;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.choice-button:hover:not(:disabled) {
  transform: translateX(3px);
  border-color: var(--accent);
  background: rgba(155, 79, 44, 0.07);
}

.choice-button:focus-visible,
.back-button:focus-visible,
.ghost-button:focus-visible,
.text-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.choice-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--paper-deep);
  font-size: 1.15rem;
}

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

.choice-title,
.choice-hint {
  display: block;
}

.choice-title {
  margin-bottom: 2px;
  font-size: 1rem;
}

.choice-hint {
  overflow: hidden;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-arrow {
  color: var(--muted);
  font-family: "Courier New", monospace;
}

.play-layout > .quest-card {
  display: flex;
  grid-column: auto;
  flex-direction: column;
  min-width: 0;
  min-height: 100%;
  padding: 18px;
}

.quest-heading,
.log-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.quest-heading h2,
.log-heading h2,
.inventory-heading h2 {
  font-size: 1.35rem;
}

.quest-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.4;
}

.quest-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.quest-list li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(207, 194, 174, 0.85);
  border-radius: 7px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.22);
}

.quest-list li[data-status="current"] {
  border-color: var(--accent);
  background: rgba(155, 79, 44, 0.08);
}

.quest-list li[data-status="done"] {
  border-color: var(--leaf);
}

.quest-list li[data-status="later"] {
  opacity: 0.52;
}

.quest-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--paper-deep);
  font-size: 1.05rem;
}

.quest-list li[data-status="done"] .quest-mark {
  color: var(--leaf);
}

.quest-title,
.quest-where {
  display: block;
}

.quest-title {
  margin-bottom: 2px;
  font-size: 1rem;
  font-weight: 500;
}

.quest-where {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 0.73rem;
  line-height: 1.35;
}

.result-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  max-height: 720px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 0 4px 0 0;
  list-style: none;
}

.result-log li {
  border-left: 2px solid var(--line);
  border-radius: 0 6px 6px 0;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.25);
  animation: log-enter 180ms ease-out;
}

.result-log li.log-good {
  border-left-color: var(--leaf);
}

.result-log li.log-accent {
  border-left-color: var(--accent);
}

.log-visual,
.log-result,
.log-direction {
  display: block;
}

.log-visual {
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
}

.log-result {
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.4;
}

.log-direction {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.4;
}

.empty-log {
  margin: 18px 0 0;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
}

.log-card-horizontal {
  margin-top: 16px;
  padding: 14px 18px 16px;
}

.log-card-horizontal h2 {
  font-size: 1.1rem;
}

.log-card-horizontal .result-log {
  display: flex;
  flex: none;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 12px 0 0;
  padding: 0 0 8px;
}

.log-card-horizontal .result-log li {
  flex: 0 0 240px;
  width: 240px;
}

.log-card-horizontal .empty-log {
  margin-top: 10px;
}

.log-card-horizontal .log-visual {
  font-size: 0.98rem;
}

.log-card-horizontal .log-direction {
  font-size: 0.76rem;
}

.inventory-card {
  margin-top: 16px;
  padding: 18px;
}

.ledger-card {
  margin-top: 16px;
  padding: 0 0 16px;
}

.ledger-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.ledger-tab {
  flex: 1 1 0;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 12px 10px;
  color: var(--muted);
  background: transparent;
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.ledger-tab[aria-selected="true"] {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.ledger-tab:hover {
  color: var(--ink);
}

.ledger-panel {
  padding: 16px 18px 0;
}

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

.inventory-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.purse {
  text-align: right;
}

.purse .label,
.purse strong {
  display: block;
}

.purse strong {
  font-size: 1.25rem;
  font-weight: 500;
}

.inventory-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  min-height: 0;
  margin-top: 14px;
}

.inventory-list li {
  align-items: center;
  border: 1px solid rgba(207, 194, 174, 0.8);
  border-radius: 6px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.22);
}

.shelf-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.shelf-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  border: 1px solid rgba(207, 194, 174, 0.8);
  border-radius: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.22);
}

.shelf-note {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 0.73rem;
}

.ledger-panel .result-log {
  flex: none;
  max-height: 280px;
}

@keyframes menu-forward {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes menu-back {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes menu-travel {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes log-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scene-travel {
  from { opacity: 0.35; transform: translateY(7px) scale(0.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .menu-view,
  .result-log li,
  .scene-card,
  .choice-button,
  .action-progress-bar,
  .meter-fill {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 900px) {
  .hamster-status,
  .play-layout {
    grid-template-columns: 1fr;
  }

  .hamster-identity,
  .status-meter,
  .status-fact {
    border-right: 0;
    border-bottom: 1px dotted var(--line);
    padding: 0 0 10px;
  }

  .status-fact:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .play-layout > .quest-card {
    min-height: 0;
  }

  .log-card-horizontal .result-log {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding-top: 20px;
  }

  .choice-button {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    padding: 9px;
  }

  .choice-icon {
    width: 32px;
    height: 32px;
  }

  .choice-hint {
    white-space: normal;
  }
}
