:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --text: #fff;
  --muted: #aaadbe;
  --gold: #ffc21a;
  --green: #3ddc84;
  --danger: #ff4d6d;
  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: 8px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
}
button:focus-visible {
  outline: 3px solid #ffd84d;
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.im-shell {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  gap: 8px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, transparent 44%, #8b5a2b 44%, #8b5a2b 56%, transparent 56%),
    radial-gradient(ellipse 60% 26% at 32% 30%, #e8eefc 0 60%, transparent 62%),
    linear-gradient(160deg, #ffcf4a, #ff8a1f);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 3px 8px rgba(255, 138, 31, 0.35);
}
.chips {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 0.9rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip-k {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chip-cash {
  background: linear-gradient(180deg, #2c2a1a, #211f16);
  border-color: rgba(255, 194, 26, 0.35);
  font-size: 1.05rem;
  min-width: 108px;
}
.chip-cash strong {
  color: #ffe07a;
}
.chip-cash.bump {
  animation: bump 0.28s ease;
}
.chip-mine strong {
  color: #b9a6ff;
}
.coin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b8, #ffc21a 45%, #d98a00);
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.18),
    0 0 0 2px rgba(255, 194, 26, 0.25);
}
@keyframes bump {
  40% {
    transform: scale(1.08);
  }
}

/* ---------- pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 16px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
  background: #2a2b3d;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 3px 0 rgba(0, 0, 0, 0.35);
  transition:
    transform 0.08s ease,
    filter 0.15s ease;
  touch-action: manipulation;
}
.pill:active {
  transform: translateY(2px) scale(0.98);
}
.pill-primary {
  background: linear-gradient(180deg, #7d5cff, #6842ff 55%, #5530e8);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    0 4px 0 #3b1fb0,
    0 8px 18px rgba(104, 66, 255, 0.35);
}
.pill-secondary {
  background: #2a2b3d;
}
.pill-big {
  min-height: 52px;
  padding: 10px 34px;
  font-size: 1.15rem;
}
.pill[disabled],
.pill.is-locked {
  filter: grayscale(0.7) brightness(0.8);
}
.pill-prestige {
  flex-direction: column;
  gap: 3px;
  min-height: 40px;
  padding: 5px 14px;
  font-size: 0.85rem;
  background: linear-gradient(180deg, #34355a, #2a2b3d);
}
.pill-prestige.ready {
  background: linear-gradient(180deg, #ffd85c, #ff9f1a);
  color: #3a2200;
  animation: glow 1.6s ease-in-out infinite;
}
.pp-bar {
  display: block;
  width: 72px;
  height: 5px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.pp-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffd85c, #ff9f1a);
}
.pill-prestige.ready .pp-bar i {
  background: #3a2200;
}
@keyframes glow {
  50% {
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.4),
      0 0 0 4px rgba(255, 200, 60, 0.3),
      0 6px 18px rgba(255, 170, 40, 0.5);
  }
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  height: 510px;
  border-radius: 22px;
  overflow: hidden;
  background: #3a2a22;
  box-shadow:
    0 0 0 1px var(--line),
    0 18px 40px rgba(0, 0, 0, 0.45);
}
#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.mine-scroll {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.mine-inner {
  position: relative;
  width: 100%;
}

/* in-scene controls */
.tap-zone {
  position: absolute;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.tap-zone:focus-visible {
  outline: 3px solid #ffd84d;
  outline-offset: -3px;
}
.tap-zone:active {
  background: rgba(255, 255, 255, 0.06);
}
.ctrl {
  position: absolute;
  display: flex;
  gap: 6px;
  align-items: center;
}
.up-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 40px;
  min-width: 96px;
  padding: 3px 12px 3px 34px;
  border: 0;
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  background: linear-gradient(180deg, #33344c, #26273a);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 3px 0 rgba(0, 0, 0, 0.4);
  line-height: 1.05;
  text-align: left;
  touch-action: manipulation;
}
.up-btn::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border-radius: 7px;
  background: #4b4c66;
  clip-path: polygon(50% 8%, 94% 56%, 66% 56%, 66% 92%, 34% 92%, 34% 56%, 6% 56%);
}
.up-btn.can::before {
  background: linear-gradient(180deg, #7bffb0, #1fc86a);
}
.up-btn.can {
  background: linear-gradient(180deg, #2f4a3c, #213428);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 3px 0 rgba(0, 0, 0, 0.4),
    0 0 0 2px rgba(61, 220, 132, 0.4);
}
.up-btn:active {
  transform: translateY(2px);
}
.up-btn b {
  font-size: 0.8rem;
  font-weight: 900;
}
.up-btn small {
  font-size: 0.72rem;
  font-weight: 800;
  color: #ffe07a;
  white-space: nowrap;
}
.mgr-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring, #6842ff) calc(var(--p, 1) * 1turn), #2a2b3d 0);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
}
.mgr-btn .face {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: block;
  background: #1a1b28;
  overflow: hidden;
}
.mgr-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}
.mgr-btn .tag {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 900;
  white-space: nowrap;
  background: #6842ff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.mgr-btn.hire {
  background: linear-gradient(180deg, #3a3b55, #2a2b3d);
  border: 2px dashed rgba(255, 255, 255, 0.28);
}
.mgr-btn.hire.can {
  border-color: #3ddc84;
}
.mgr-btn.hire .plus {
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  color: var(--muted);
}
.mgr-btn.hire.can .plus {
  color: #3ddc84;
}
.mgr-btn.hire .tag {
  background: #2a2b3d;
  color: #ffe07a;
}
.mgr-btn.ready {
  --ring: #3ddc84;
  animation: pulse 1.4s ease-in-out infinite;
}
.mgr-btn.ready .tag {
  background: #1fc86a;
  color: #07210f;
}
.mgr-btn.active {
  --ring: #ffc21a;
}
.mgr-btn.active .tag {
  background: #ffc21a;
  color: #3a2200;
}
.mgr-btn.cool .tag {
  background: #2a2b3d;
  color: var(--muted);
}
@keyframes pulse {
  50% {
    box-shadow:
      0 3px 0 rgba(0, 0, 0, 0.4),
      0 0 0 5px rgba(61, 220, 132, 0.25);
  }
}
.unlock-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  min-height: 52px;
  max-width: calc(100% - 24px);
  padding: 8px 20px 8px 50px;
  border-radius: 18px;
  border: 0;
  cursor: pointer;
  font-weight: 900;
  line-height: 1.1;
  text-align: left;
  background: linear-gradient(180deg, #3a3b55, #2a2b3d);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 4px 0 rgba(0, 0, 0, 0.45);
  touch-action: manipulation;
}
.unlock-btn::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 24px;
  height: 26px;
  margin-top: -13px;
  background:
    radial-gradient(circle at 50% 66%, #3a2200 0 3px, transparent 4px),
    linear-gradient(180deg, transparent 42%, #ffc21a 42%);
  border-radius: 5px;
  box-shadow: inset 0 0 0 0 transparent;
}
.unlock-btn::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 16px;
  height: 14px;
  margin-top: -15px;
  border: 3px solid #ffc21a;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
}
.unlock-btn small {
  display: block;
  color: #ffe07a;
  font-size: 0.85rem;
}
.unlock-btn.can {
  background: linear-gradient(180deg, #7d5cff, #6842ff 55%, #5530e8);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    0 4px 0 #3b1fb0,
    0 8px 18px rgba(104, 66, 255, 0.4);
}
.shake {
  animation: shake 0.32s ease;
}
.unlock-btn.shake {
  animation: shake-c 0.32s ease;
}
@keyframes shake {
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}
@keyframes shake-c {
  25% {
    transform: translateX(calc(-50% - 5px));
  }
  50% {
    transform: translateX(calc(-50% + 5px));
  }
  75% {
    transform: translateX(calc(-50% - 3px));
  }
}
.bottleneck {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
  background: rgba(15, 16, 32, 0.82);
  border: 1px solid rgba(255, 194, 26, 0.45);
  color: #ffe07a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(10, 10, 24, 0.62);
  backdrop-filter: blur(3px);
  z-index: 5;
}
.overlay[hidden] {
  display: none;
}
.card {
  position: relative;
  width: min(380px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 22px 20px 20px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #25263a, #1a1b28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: card-in 0.28s cubic-bezier(0.2, 1.3, 0.4, 1);
}
@keyframes card-in {
  from {
    transform: scale(0.86);
    opacity: 0;
  }
}
.card h2 {
  margin: 4px 0 6px;
  font-size: 1.5rem;
  font-weight: 900;
}
.card p {
  margin: 6px 0 12px;
  color: #d9dbea;
  font-weight: 700;
  line-height: 1.35;
}
.card .muted,
.muted {
  color: var(--muted);
  font-size: 0.85rem;
}
.card-start h2 {
  font-size: 2.3rem;
  background: linear-gradient(180deg, #fff6c9, #ffc21a 60%, #ff8a1f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #7a3b00);
}
.start-art {
  position: relative;
  height: 74px;
  margin: 0 auto 4px;
  width: 170px;
}
.sa-ore {
  position: absolute;
  bottom: 4px;
  width: 44px;
  height: 38px;
  border-radius: 40% 46% 38% 50%;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.45),
    inset 0 -5px 0 rgba(0, 0, 0, 0.2),
    0 6px 12px rgba(0, 0, 0, 0.35);
}
.sa-1 {
  left: 8px;
  background: linear-gradient(160deg, #ffb27a, #e8641f);
}
.sa-2 {
  left: 62px;
  bottom: 14px;
  width: 50px;
  height: 46px;
  background: linear-gradient(160deg, #fff0a0, #ffb800);
  animation: float 2.2s ease-in-out infinite;
}
.sa-3 {
  right: 8px;
  background: linear-gradient(160deg, #b8fbff, #16b8e6);
  clip-path: polygon(50% 0, 100% 38%, 80% 100%, 20% 100%, 0 38%);
  border-radius: 0;
}
.sa-pick {
  position: absolute;
  left: 50%;
  top: -4px;
  width: 64px;
  height: 64px;
  margin-left: -8px;
  background:
    linear-gradient(135deg, transparent 45%, #9a6231 45%, #b8773c 55%, transparent 55%),
    radial-gradient(ellipse 70% 22% at 30% 26%, #eef3ff 0 58%, transparent 61%);
  transform: rotate(-12deg);
  animation: swing 1.4s ease-in-out infinite;
  transform-origin: 80% 80%;
}
@keyframes float {
  50% {
    transform: translateY(-6px);
  }
}
@keyframes swing {
  50% {
    transform: rotate(-38deg);
  }
}
.coins-art {
  width: 76px;
  height: 56px;
  margin: 0 auto;
  background:
    radial-gradient(circle at 30% 60%, #fff6b8 0 4px, transparent 5px),
    radial-gradient(ellipse 22px 20px at 26px 34px, #ffc21a 0 96%, transparent 100%),
    radial-gradient(ellipse 22px 20px at 50px 34px, #ffb000 0 96%, transparent 100%),
    radial-gradient(ellipse 22px 20px at 38px 22px, #ffd84d 0 96%, transparent 100%);
  filter: drop-shadow(0 4px 0 #a45f00);
  animation: float 2s ease-in-out infinite;
}
.big-number {
  font-size: 2rem;
  font-weight: 900;
  color: #ffe07a !important;
  margin: 4px 0 6px !important;
  text-shadow: 0 3px 0 #7a4b00;
}
.close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: #2a2b3d;
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
}
.sheet h2 {
  font-size: 1.25rem;
  padding: 0 34px;
}
.sheet-level {
  margin: 0 0 10px !important;
  color: #b9a6ff !important;
  font-weight: 900 !important;
}
.stats {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  text-align: left;
}
.stats div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 800;
  font-size: 0.9rem;
}
.stats dt {
  color: var(--muted);
}
.stats dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stats dd b {
  color: #7bffb0;
}
.amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.amt {
  min-height: 40px;
  border-radius: 12px;
  border: 0;
  background: #2a2b3d;
  font-weight: 900;
  cursor: pointer;
}
.amt[aria-pressed="true"] {
  background: #6842ff;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.sheet .pill-big {
  width: 100%;
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}
.sheet .pill-big small {
  font-size: 0.85rem;
  color: #ffe07a;
}
.progress {
  height: 12px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin: 4px 0 6px;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffd85c, #ff9f1a);
  border-radius: 99px;
}
.row-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.help {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}
kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font: inherit;
  font-size: 0.75rem;
  text-align: center;
}

@media (max-width: 600px) {
  body {
    padding: 6px;
  }
  .brand {
    font-size: 1.05rem;
  }
  .brand-icon {
    width: 26px;
    height: 26px;
  }
  .chip {
    padding: 3px 9px;
    font-size: 0.82rem;
    min-height: 32px;
  }
  .chip-cash {
    min-width: 0;
    font-size: 0.95rem;
  }
  .pill-prestige {
    margin-left: auto;
  }
  .chips {
    order: 3;
    flex-basis: 100%;
  }
  .stage {
    height: 560px;
    border-radius: 18px;
  }
  .up-btn {
    min-width: 88px;
    padding-right: 8px;
  }
  .help {
    font-size: 0.74rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
