:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --panel-3: #2a2b3d;
  --line: #34364c;
  --accent: #6842ff;
  --accent-2: #8a6cff;
  --text: #fff;
  --muted: #aaadbe;
  --orange: #ff9f1c;
  --pink: #ff4f8b;
  --lime: #7ee26b;
  --gold: #ffd23f;
  --sky: #4cc9f0;
  --red: #ff5a5f;
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  padding: 10px 12px 12px;
  overflow-x: hidden;
}
button {
  font: inherit;
}
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.shell {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.logo em {
  font-style: normal;
  background: linear-gradient(180deg, #ffe066, var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-cup {
  width: 28px;
  height: 32px;
  border-radius: 4px 4px 10px 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0 18%, transparent 18%),
    linear-gradient(180deg, #ffb347, #ff6f3c);
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.35),
    0 4px 10px rgba(255, 111, 60, 0.45);
  position: relative;
  clip-path: polygon(0 0, 100% 0, 86% 100%, 14% 100%);
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 3px 0 rgba(0, 0, 0, 0.35);
  font-weight: 800;
}
.chip span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chip strong {
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.chip small {
  color: var(--muted);
  font-size: 12px;
}
.chip-cash strong {
  color: var(--lime);
}
.chip-best strong {
  color: var(--gold);
}
.chip.bump {
  animation: bump 0.35s ease;
}
.rep-bar {
  display: block;
  width: 70px;
  height: 10px;
  border-radius: 99px;
  background: #0d0e1a;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
.rep-bar b {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff9f1c, #ffd23f 60%, #7ee26b);
  background-size: 70px 100%;
  transition: width 0.6s ease;
}

/* ---------- Stage ---------- */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, 1fr);
  gap: 12px;
  align-items: start;
}
.scene-col {
  min-width: 0;
}
.scene {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #7dd3fc;
  box-shadow:
    0 0 0 3px #2a2b3d,
    0 12px 28px rgba(0, 0, 0, 0.45);
}
.scene canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 440;
}
.scene.shake {
  animation: shake 0.35s ease;
}
.forecast {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  background: rgba(15, 16, 32, 0.72);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.wx-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
}
.wx-icon svg {
  width: 32px;
  height: 32px;
}
.wx-text {
  display: grid;
  line-height: 1.05;
}
.wx-text small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.wx-text strong {
  font-size: 15px;
  font-weight: 900;
}
.live-chips {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}
.live-chip {
  display: grid;
  line-height: 1.05;
  padding: 5px 12px;
  border-radius: 14px;
  background: rgba(15, 16, 32, 0.72);
  text-align: center;
}
.live-chip small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.live-chip strong {
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.live-chip-cash strong {
  color: var(--lime);
}
.clock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.clock i {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: rgba(15, 16, 32, 0.55);
  overflow: hidden;
}
.clock b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd23f, #ff9f1c);
}
.run-controls {
  position: absolute;
  right: 10px;
  top: 62px;
  display: flex;
  gap: 6px;
}

/* ---------- Inventory strip ---------- */
.stock {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.stock li {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 9px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.stock svg {
  flex: none;
  width: 26px;
  height: 26px;
}
.stock .qty {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}
.stock strong {
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.stock small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.stock small.warn {
  color: var(--orange);
}
.stock li.pop {
  animation: bump 0.35s ease;
}

/* ---------- Panel ---------- */
.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 24px rgba(0, 0, 0, 0.35);
}
.panel.busy .pane,
.panel.busy .tabs {
  opacity: 0.45;
  pointer-events: none;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: #11121f;
}
.tab {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}
.tab[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 3px 0 #4526c4;
}
.pane {
  padding: 10px 2px 4px;
  min-height: 246px;
}
.pane-note {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.shop-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) repeat(3, minmax(0, 62px));
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}
.shop-row + .shop-row {
  border-top: 1px solid #25263a;
}
.shop-row svg {
  width: 28px;
  height: 28px;
}
.shop-name {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}
.shop-name strong {
  font-size: 14px;
  font-weight: 900;
}
.shop-name small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.buy {
  display: grid;
  min-width: 0;
  min-height: 44px;
  padding: 3px 2px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #34365a, #2a2b3d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 3px 0 #181929;
  color: #fff;
  line-height: 1.05;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.buy b {
  font-size: 13px;
  font-weight: 900;
}
.buy span {
  color: var(--lime);
  font-size: 11px;
  font-weight: 800;
}
.buy:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 1px 0 #181929;
}
.buy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.buy:disabled span {
  color: var(--muted);
}
.buy.pop {
  animation: bump 0.3s ease;
}

.recipe-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}
.recipe-row svg {
  width: 28px;
  height: 28px;
}
.recipe-row .shop-name small {
  white-space: normal;
}
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: #11121f;
}
.stepper button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #7b5cff, var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 #4526c4;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.stepper button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #4526c4;
}
.stepper button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.stepper output {
  min-width: 52px;
  text-align: center;
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.recipe-row.price output {
  color: var(--lime);
}
.tip {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(104, 66, 255, 0.14);
  color: #d9d2ff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}
.tip b {
  color: #fff;
}

.upgrade {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.upgrade + .upgrade {
  border-top: 1px solid #25263a;
}
.upgrade svg {
  width: 38px;
  height: 38px;
}
.upgrade .pill {
  min-width: 86px;
}
.upgrade.owned .pill {
  background: rgba(126, 226, 107, 0.16);
  color: var(--lime);
  box-shadow: none;
}
.upgrade.locked svg {
  filter: grayscale(1) opacity(0.5);
}

.panel-foot {
  margin-top: auto;
  padding-top: 8px;
}
.makes {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}
.makes strong {
  color: #fff;
  font-size: 15px;
}
.makes.warn strong {
  color: var(--orange);
}

/* ---------- Pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 4px 0 #17182a;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.08s ease,
    filter 0.15s ease;
}
.pill:hover:not(:disabled) {
  filter: brightness(1.1);
}
.pill:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 1px 0 #17182a;
}
.pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pill-primary {
  background: linear-gradient(180deg, #8466ff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #4526c4,
    0 8px 18px rgba(104, 66, 255, 0.4);
}
.pill-primary:active:not(:disabled) {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 1px 0 #4526c4;
}
.pill-big {
  width: 100%;
  min-height: 54px;
  font-size: 19px;
}
.pill-sm {
  min-height: 40px;
  padding: 6px 14px;
  font-size: 13px;
}
.pill-dark {
  background: rgba(15, 16, 32, 0.78);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}
.pill-dark[aria-pressed="true"] {
  background: var(--accent);
}
.pill-gold {
  background: linear-gradient(180deg, #ffe066, #ffb703);
  color: #3a2300;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 4px 0 #c47f00;
}

.help {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
kbd {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--panel-3);
  color: #fff;
  font: inherit;
  font-size: 11px;
}

/* ---------- Overlay cards ---------- */
.overlay {
  position: absolute;
  inset: -10px -12px auto;
  min-height: calc(100% + 22px);
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 12px;
  background: rgba(8, 9, 20, 0.72);
  backdrop-filter: blur(4px);
}
.overlay[hidden] {
  display: none;
}
.card {
  position: relative;
  width: min(520px, 100%);
  padding: 22px 22px 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, #25264a, var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 3px #2d2e4a,
    0 24px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: card-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.card h2 {
  margin: 4px 0 4px;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.05;
}
.card .lead {
  margin: 0 auto 14px;
  max-width: 400px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}
.card .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.card .actions .pill {
  min-width: 150px;
}
.title-art {
  display: block;
  width: 220px;
  max-width: 70%;
  margin: -4px auto 4px;
}
.big-title {
  font-size: 36px !important;
  background: linear-gradient(180deg, #fff 30%, #ffd9a8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.big-title em {
  font-style: normal;
  background: linear-gradient(180deg, #ffe066, #ff8a1c);
  -webkit-background-clip: text;
  background-clip: text;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}
.stat {
  display: grid;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.25);
}
.stat small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat strong {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.good {
  color: var(--lime);
}
.bad {
  color: var(--red);
}
.gold {
  color: var(--gold);
}
.big-profit {
  display: block;
  margin: 2px 0 2px;
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}
.breakdown {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.breakdown li {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.breakdown li b {
  color: #fff;
}
.breakdown li.warn b {
  color: var(--orange);
}
.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.chart {
  padding: 8px 8px 4px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.25);
  text-align: left;
}
.chart small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
}
.new-best {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, #ffb703);
  color: #3a2300;
  font-size: 13px;
  font-weight: 900;
  animation: bump 0.6s ease 0.3s both;
}
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: fall 1.8s ease-in forwards;
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}
@keyframes card-in {
  from {
    transform: scale(0.85) translateY(12px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes fall {
  to {
    transform: translateY(560px) rotate(540deg);
    opacity: 0.6;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
  }
  .pane {
    min-height: 0;
  }
  .logo {
    font-size: 18px;
  }
  .hud {
    justify-content: center;
  }
}
@media (max-width: 420px) {
  body {
    padding: 8px;
  }
  .overlay {
    inset: -8px -8px auto;
    min-height: calc(100% + 16px);
  }
  .chips {
    justify-content: center;
    gap: 5px;
  }
  .chip {
    padding: 4px 9px;
    gap: 5px;
  }
  .chip strong {
    font-size: 14px;
  }
  .rep-bar {
    width: 48px;
  }
  .stock {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shop-row {
    grid-template-columns: 26px minmax(0, 1fr) repeat(3, minmax(0, 56px));
    gap: 4px;
  }
  .card {
    padding: 18px 14px;
  }
  .card h2 {
    font-size: 24px;
  }
  .big-title {
    font-size: 30px !important;
  }
  .stat strong {
    font-size: 17px;
  }
  .charts {
    grid-template-columns: 1fr;
  }
  .forecast {
    top: 6px;
    left: 6px;
    padding: 3px 10px 3px 4px;
  }
  .wx-text strong {
    font-size: 13px;
  }
  .live-chip {
    padding: 3px 8px;
  }
  .live-chip strong {
    font-size: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .confetti {
    display: none;
  }
}
