:root {
  --bg: #101311;
  --panel: #f5f0df;
  --panel-2: #e7dfc8;
  --ink: #26251e;
  --muted: #67604d;
  --line: #827a61;
  --accent: #7a4d2b;
  --accent-2: #2f6f65;
  --red: #b9473f;
  --yellow: #c59a2d;
  --green: #4e8a45;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.18)),
    var(--bg);
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1160px, calc(100vw - 24px));
  height: min(820px, calc(100svh - 24px));
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  border: 3px solid #2d3028;
  background: #cfc5a7;
  box-shadow: 0 22px 60px var(--shadow);
}

.top-bar,
.story-panel,
.hud-panel,
.scene-panel {
  border: 2px solid var(--line);
  background: var(--panel);
}

.top-bar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.25rem, 2.8vw, 2.15rem);
}

h2 {
  font-size: clamp(1.45rem, 3.4vw, 2.55rem);
}

.progress-card {
  flex: 0 0 auto;
  min-width: 170px;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  background: var(--panel-2);
  text-align: right;
}

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

.progress-card strong {
  font-size: 1.05rem;
}

.play-area {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 12px;
}

.scene-panel {
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  background: #ddd3b6;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #9da17d;
}

.hud-panel {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.meter {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px solid rgba(38, 37, 30, 0.28);
  background: rgba(255, 255, 255, 0.34);
}

.meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
}

.meter-head strong {
  font-size: 1.15rem;
}

.meter-track {
  height: 18px;
  overflow: hidden;
  border: 2px solid #322e24;
  background: #b7ad91;
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: var(--red);
  transform-origin: left center;
  transition: width 420ms ease, background-color 280ms ease, filter 220ms ease;
}

.meter.is-drop {
  animation: meterShake 260ms ease;
}

.meter.is-gain .meter-fill {
  animation: meterBloom 520ms ease;
}

.story-panel {
  min-height: 170px;
  display: grid;
  grid-template-rows: auto minmax(48px, 1fr) auto;
  gap: 10px;
  padding: 14px;
}

.slot-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.narration {
  margin: 0;
  max-width: 68ch;
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  line-height: 1.45;
}

.choices {
  min-height: 46px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.choice-button,
.primary-action {
  min-height: 44px;
  border: 2px solid #302d25;
  background: #e6b95f;
  color: #201e18;
  padding: 9px 14px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #302d25;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.choice-button:hover,
.primary-action:hover,
.choice-button:focus-visible,
.primary-action:focus-visible {
  background: #f0c96f;
  outline: 3px solid rgba(47, 111, 101, 0.5);
  outline-offset: 2px;
}

.choice-button:active,
.primary-action:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #302d25;
}

.choice-button[disabled] {
  cursor: wait;
  opacity: 0.62;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(16, 19, 17, 0.76);
  z-index: 10;
}

.overlay.is-visible {
  display: grid;
}

.overlay-card {
  width: min(720px, 100%);
  max-height: min(760px, calc(100svh - 36px));
  overflow: auto;
  padding: 22px;
  border: 3px solid #302d25;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.overlay-body,
.overlay-card p {
  line-height: 1.48;
}

.overlay-card h2 + .overlay-body {
  margin-top: 14px;
}

.primary-action {
  margin-top: 12px;
}

.comparison-grid {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.comparison-row {
  display: grid;
  grid-template-columns: 170px 1fr 1fr;
  gap: 10px;
  align-items: center;
}

.comparison-label {
  color: var(--muted);
}

.comparison-bar {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
  align-items: center;
}

.comparison-track {
  height: 18px;
  border: 2px solid #302d25;
  background: #b7ad91;
}

.comparison-fill {
  height: 100%;
  background: var(--green);
}

.callouts,
.credits-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.callout,
.credit-item {
  padding: 10px;
  border: 2px solid rgba(38, 37, 30, 0.28);
  background: rgba(255, 255, 255, 0.42);
}

.flash-note {
  color: var(--accent-2);
  font-weight: 700;
}

body.day-current {
  --bg: #161a17;
  --panel: #e1decf;
  --panel-2: #cbc6ae;
  --line: #777566;
  --accent: #596052;
}

body.day-improved {
  --bg: #1c2117;
  --panel: #f4e8c7;
  --panel-2: #e5d29d;
  --line: #8b6e3f;
  --accent: #7a4d2b;
}

@keyframes meterShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  55% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

@keyframes meterBloom {
  0% { filter: brightness(1); }
  35% { filter: brightness(1.55) saturate(1.2); }
  100% { filter: brightness(1); }
}

@media (max-width: 820px) {
  body {
    place-items: stretch;
  }

  .game-shell {
    width: 100vw;
    height: 100svh;
    min-height: 0;
    border: 0;
    padding: 8px;
    gap: 8px;
  }

  .top-bar {
    min-height: 70px;
    padding: 9px;
  }

  .progress-card {
    min-width: 128px;
    padding: 8px;
  }

  .play-area {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .scene-panel {
    padding: 7px;
  }

  .hud-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding: 7px;
  }

  .meter {
    padding: 7px;
  }

  .meter-head {
    display: grid;
    gap: 2px;
    font-size: 0.72rem;
  }

  .meter-track {
    height: 14px;
  }

  .story-panel {
    min-height: 156px;
    padding: 10px;
    gap: 7px;
  }

  .narration {
    font-size: 0.98rem;
  }

  .choice-button,
  .primary-action {
    min-height: 40px;
    padding: 8px 10px;
  }

  .comparison-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1.08rem;
  }

  .eyebrow,
  .slot-label,
  .progress-card span {
    font-size: 0.68rem;
  }

  .progress-card strong {
    font-size: 0.84rem;
  }

  .hud-panel {
    grid-template-columns: 1fr;
  }

  .meter {
    grid-template-columns: 130px 1fr;
    align-items: center;
  }

  .meter-head strong {
    font-size: 0.96rem;
  }

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

  .choices {
    gap: 7px;
  }
}
