:root {
  color-scheme: dark;
  --ink: #f8efe2;
  --muted: #d9c7ad;
  --paper: #2b2019;
  --paper-2: #3a2b22;
  --line: rgba(255, 239, 214, 0.18);
  --gold: #f1b345;
  --green: #70c77c;
  --red: #e76659;
  --blue: #5aa7d8;
  --violet: #b483d8;
  --teal: #55b9a9;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 14% 10%, rgba(241, 179, 69, 0.24), transparent 28rem),
    linear-gradient(145deg, #1b1613 0%, #2d2019 44%, #122421 100%);
}

button {
  font: inherit;
}

.app-shell {
  width: 100%;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
}

.game {
  width: min(100%, 980px);
  min-height: min(920px, calc(100svh - 28px));
  display: grid;
  grid-template-rows: auto minmax(210px, 34svh) auto 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    rgba(35, 27, 22, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kicker {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12);
}

.icon-button.is-off {
  color: var(--muted);
  opacity: 0.65;
}

.hero-stage {
  position: relative;
  min-height: 210px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(90, 167, 216, 0.28), rgba(85, 185, 169, 0.08) 45%, rgba(65, 42, 28, 0.9) 46%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent);
  isolation: isolate;
}

.skyline {
  position: absolute;
  inset: auto 0 28%;
  height: 54px;
  opacity: 0.32;
  background:
    linear-gradient(90deg, transparent 0 5%, #2c342e 5% 12%, transparent 12% 17%, #26342f 17% 26%, transparent 26% 36%, #39412f 36% 45%, transparent 45% 54%, #243935 54% 67%, transparent 67% 73%, #3d3428 73% 87%, transparent 87% 100%);
}

.hero-stage::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 32px),
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.24));
}

.asset {
  position: absolute;
  display: block;
  width: auto;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.36));
}

.cart {
  left: 5%;
  bottom: -9%;
  width: min(52%, 340px);
  animation: idleCart 3.8s ease-in-out infinite;
}

.auntie {
  left: 19%;
  bottom: 13%;
  width: min(31%, 190px);
  animation: bob 2.7s ease-in-out infinite;
}

.leg {
  right: 19%;
  bottom: 24%;
  width: min(25%, 150px);
  transform-origin: center;
  animation: legGlow 2.3s ease-in-out infinite;
}

.customer {
  right: 1%;
  bottom: 3%;
  width: min(40%, 230px);
  animation: customerWait 3.1s ease-in-out infinite;
}

.steam {
  position: absolute;
  width: 24px;
  height: 64px;
  left: 48%;
  bottom: 36%;
  border-radius: 50%;
  border-left: 3px solid rgba(255, 245, 224, 0.68);
  filter: blur(0.3px);
  opacity: 0;
  animation: steam 2.4s ease-in-out infinite;
}

.steam-two {
  left: 55%;
  animation-delay: 0.8s;
}

.coin-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.coin {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: inset -2px -2px rgba(141, 79, 25, 0.32);
  animation: coinFly 740ms ease-out forwards;
}

.stats-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.day-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.day-meter strong {
  color: var(--ink);
  font-size: 14px;
}

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

.stat {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.stat-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.stat-value {
  color: var(--ink);
  font-weight: 800;
}

.bar {
  height: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.32);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

.bar-fill {
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color);
  transition: width 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.story-panel {
  min-height: 278px;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035)),
    var(--paper);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.09);
}

.event-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.event-meta span:last-child {
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

#eventText {
  min-height: 66px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.62;
}

.choice-list {
  display: grid;
  gap: 9px;
}

.choice {
  position: relative;
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 239, 214, 0.2);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.09);
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.choice:active {
  transform: scale(0.985);
}

.choice:hover,
.choice:focus-visible {
  border-color: rgba(241, 179, 69, 0.78);
  background: rgba(241, 179, 69, 0.13);
  outline: none;
}

.choice-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #201713;
  background: var(--gold);
  font-weight: 900;
}

.choice-title {
  display: block;
  font-weight: 900;
  line-height: 1.3;
}

.choice-detail {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.choice.is-locked {
  opacity: 0.45;
  pointer-events: none;
}

.log-strip {
  min-height: 38px;
  display: grid;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.ticker {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(92vw, 420px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(20, 15, 12, 0.94);
  box-shadow: var(--shadow);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.shake {
  animation: shake 420ms ease;
}

.flash-good {
  animation: flashGood 540ms ease;
}

.flash-bad {
  animation: flashBad 540ms ease;
}

@keyframes idleCart {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-5px) rotate(1deg);
  }
}

@keyframes legGlow {
  0%,
  100% {
    transform: rotate(-4deg) scale(1);
    filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.36)) saturate(1);
  }
  50% {
    transform: rotate(4deg) scale(1.04);
    filter: drop-shadow(0 16px 24px rgba(241, 179, 69, 0.34)) saturate(1.15);
  }
}

@keyframes customerWait {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-5px);
  }
}

@keyframes steam {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.8) rotate(0);
  }
  35% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(-42px) scale(1.14) rotate(12deg);
  }
}

@keyframes coinFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.8);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(1.15);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}

@keyframes flashGood {
  0%,
  100% {
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.09);
  }
  40% {
    box-shadow: inset 0 0 0 999px rgba(112, 199, 124, 0.12);
  }
}

@keyframes flashBad {
  0%,
  100% {
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.09);
  }
  40% {
    box-shadow: inset 0 0 0 999px rgba(231, 102, 89, 0.16);
  }
}

@media (min-width: 760px) {
  .game {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(360px, 1fr) auto;
    min-height: min(760px, calc(100svh - 48px));
    gap: 12px;
    padding: 16px;
  }

  .topbar,
  .log-strip {
    grid-column: 1 / -1;
  }

  .hero-stage {
    min-height: 440px;
  }

  .stats-panel {
    align-self: start;
  }

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

  .stats-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 24px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-left: 8px;
    padding-right: 8px;
  }

  .game {
    padding: 9px;
    gap: 8px;
  }

  .hero-stage {
    min-height: 190px;
  }

  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 18px;
  }

  #eventText {
    font-size: 14px;
  }

  .choice {
    min-height: 52px;
    padding: 9px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
