:root {
  --bg-dark: #0b0e17;
  --gold: #ffd700;
  --green: #00ff88;
  --red: #ff5c5c;
  --red-dark: #8e1c1c;
  --panel-bg: rgba(20, 22, 34, 0.85);
  --glow-gold: 0 0 12px rgba(255, 215, 0, 0.6);
  --glow-green: 0 0 12px rgba(0, 255, 136, 0.6);
  --wood-light: #7a5230;
  --wood-dark: #3a2412;
  --wall-dark: #171423;

  /* Shared "degen corkboard" language: every panel in the game is a piece of
     kraft cardboard with masking tape, sticky notes and marker handwriting. */
  --kraft-1: #a8845a;
  --kraft-2: #96714a;
  --kraft-3: #86633e;
  --kraft-ink: #38260f;
  --kraft-ink-soft: #7a6428;
  --note-1: #eed879;
  --note-2: #e6cd6b;
  --note-3: #dfdb7c;
  --note-paper: #f7f2e2;
  --tape: rgba(232, 218, 160, 0.55);
  --marker-red: #c0392b;
  --hand: "Segoe Print", "Comic Sans MS", cursive;
  --torn-top: polygon(
    0% 12px, 5% 4px, 11% 11px, 18% 3px, 25% 10px, 33% 4px, 41% 11px, 49% 4px,
    57% 10px, 65% 3px, 73% 10px, 81% 4px, 89% 11px, 95% 4px, 100% 10px,
    100% 100%, 0% 100%
  );
}

/* ===================== SHARED BOARD LANGUAGE ============================== */
.board {
  background: linear-gradient(160deg, var(--kraft-1) 0%, var(--kraft-2) 45%, var(--kraft-3) 100%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55), inset 0 0 22px rgba(60, 38, 16, 0.35);
  clip-path: var(--torn-top);
  color: var(--kraft-ink);
  position: relative;
}
/* two strips of masking tape holding the board up */
.board::before,
.board::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 54px;
  height: 20px;
  background: var(--tape);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 2;
}
.board::before {
  left: 18px;
  transform: rotate(-7deg);
}
.board::after {
  right: 18px;
  transform: rotate(6deg);
}

.board-title {
  margin: 0.15rem 0 0.4rem;
  padding: 0 0 0.2rem;
  font-family: var(--hand);
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-align: center;
  color: var(--kraft-ink);
  border-bottom: 2px dashed rgba(58, 38, 15, 0.45);
}

/* a yellow sticky note, slightly askew like the upgrade cards */
.note {
  background: var(--note-1);
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4);
  color: var(--kraft-ink);
}
.note:nth-child(even) {
  background: var(--note-2);
}
.note:nth-child(3n) {
  background: var(--note-3);
}

/* red marker circle, used for levels / counters */
.marker-badge {
  font-family: var(--hand);
  font-weight: 700;
  color: var(--marker-red);
  border: 2px solid rgba(192, 57, 43, 0.75);
  border-radius: 50% 45% 55% 48%;
  padding: 0.12rem 0.3rem;
  transform: rotate(-5deg);
  white-space: nowrap;
}

/* dashed price-tag button */
.tag-button {
  background: var(--note-paper);
  color: #4a3a1a;
  border: 2px dashed #8a6a42;
  border-radius: 3px;
  padding: 0.24rem 0.5rem;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s ease;
}
.tag-button:hover:not(:disabled) {
  background: #fffbef;
  transform: rotate(-1.5deg) scale(1.04);
}
.tag-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  color: #8a7a5a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-dark);
  color: #f5f5f5;
  font-family: "Segoe UI", system-ui, sans-serif;
  position: relative;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(180deg, rgba(11, 14, 23, 0.85), rgba(11, 14, 23, 0));
  z-index: 10;
}

/* the title is scrawled on a strip of masking tape */
.game-title {
  font-family: var(--hand);
  font-size: 1rem;
  font-weight: 700;
  color: var(--kraft-ink);
  letter-spacing: 0.1em;
  background: var(--tape);
  padding: 0.3rem 1.1rem;
  transform: rotate(-1.5deg);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.menu-button {
  background: var(--note-paper);
  color: #4a3a1a;
  border: 2px dashed #8a6a42;
  border-radius: 3px;
  padding: 0.3rem 0.8rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.45);
  transition: transform 0.1s ease, background 0.1s ease;
}

.menu-button:hover {
  background: #fffbef;
  transform: rotate(-1.5deg) scale(1.05);
}

/* stat panels are small cork boards with the numbers on sticky notes */
.hud-panel {
  position: fixed;
  top: 4.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.7rem 0.5rem 0.55rem;
  z-index: 5;
  width: 152px;
  background: linear-gradient(160deg, var(--kraft-1) 0%, var(--kraft-2) 45%, var(--kraft-3) 100%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55), inset 0 0 22px rgba(60, 38, 16, 0.35);
  clip-path: var(--torn-top);
  color: var(--kraft-ink);
}

.hud-panel::before,
.hud-panel::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 44px;
  height: 18px;
  background: var(--tape);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.hud-panel::before {
  left: 12px;
  transform: rotate(-7deg);
}

.hud-panel::after {
  right: 12px;
  transform: rotate(6deg);
}

.hud-panel--left {
  left: 1rem;
}

.hud-panel--right {
  right: 1rem;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
  background: var(--note-1);
  padding: 0.22rem 0.4rem;
  box-shadow: 2px 3px 4px rgba(40, 24, 8, 0.35);
  transform: rotate(-0.7deg);
}

.hud-stat:nth-child(even) {
  background: var(--note-2);
  transform: rotate(0.8deg);
}

.hud-stat:nth-child(3n) {
  background: var(--note-3);
}

.hud-stat-label {
  font-family: var(--hand);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--kraft-ink-soft);
}

.hud-stat-value {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.92rem;
  color: #1f4d2b;
}

/* progress toward the next rank: marker ink filling a hand-drawn bar */
.hud-progress {
  width: 100%;
  height: 9px;
  background: rgba(60, 38, 16, 0.3);
  border: 2px solid rgba(58, 38, 15, 0.5);
  border-radius: 6px 4px 7px 5px;
  overflow: hidden;
}

.hud-progress-bar {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(45deg, #c0392b 0 6px, #e05a3a 6px 12px);
  transition: width 0.4s ease;
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.scene3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.generators-panel {
  position: fixed;
  left: 0.9rem;
  bottom: 0.9rem;
  z-index: 10;
  width: 262px;
  background: linear-gradient(160deg, #a8845a 0%, #96714a 45%, #86633e 100%);
  padding: 0.65rem 0.55rem 0.5rem;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.55),
    inset 0 0 22px rgba(60, 38, 16, 0.35);
  clip-path: polygon(
    0% 12px, 5% 4px, 11% 11px, 18% 3px, 25% 10px, 33% 4px, 41% 11px, 49% 4px,
    57% 10px, 65% 3px, 73% 10px, 81% 4px, 89% 11px, 95% 4px, 100% 10px,
    100% 100%, 0% 100%
  );
}

.generators-panel::before,
.generators-panel::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 54px;
  height: 20px;
  background: rgba(232, 218, 160, 0.55);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 2;
}

.generators-panel::before {
  left: 18px;
  transform: rotate(-7deg);
}

.generators-panel::after {
  right: 18px;
  transform: rotate(6deg);
}

.generators-panel h2 {
  margin: 0.15rem 0 0.35rem;
  padding: 0 0 0.2rem;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-align: center;
  color: #38260f;
  border-bottom: 2px dashed rgba(58, 38, 15, 0.45);
}

#generatorsList {
  list-style: none;
  margin: 0;
  padding: 0.1rem 0.1rem 0.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 29vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #6e4f30 #96714a;
}

#generatorsList::-webkit-scrollbar {
  width: 9px;
}

#generatorsList::-webkit-scrollbar-track {
  background: rgba(60, 38, 16, 0.25);
}

#generatorsList::-webkit-scrollbar-thumb {
  background: #6e4f30;
  border: 2px solid #96714a;
}

.generator-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.38rem;
  background: #eed879;
  padding: 0.28rem 0.35rem;
  font-size: 0.78rem;
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4);
  transition: transform 0.12s ease;
}

.generator-item:nth-child(odd) {
  transform: rotate(-0.9deg);
}

.generator-item:nth-child(even) {
  transform: rotate(0.8deg);
  background: #e6cd6b;
}

.generator-item:nth-child(3n) {
  background: #dfdb7c;
}

.generator-item:hover {
  transform: rotate(0deg) scale(1.02);
}

.generator-icon {
  width: 30px;
  height: 30px;
  display: block;
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid rgba(58, 42, 20, 0.4);
  padding: 1px;
  image-rendering: pixelated;
  box-sizing: border-box;
}

.generator-info {
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
  min-width: 0;
}

.generator-name {
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-weight: 700;
  font-size: 0.7rem;
  color: #33270f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.generator-rate {
  font-family: monospace;
  font-size: 0.58rem;
  color: #7a6428;
}

.generator-owned {
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-weight: 700;
  font-size: 0.6rem;
  color: #c0392b;
  border: 2px solid rgba(192, 57, 43, 0.75);
  border-radius: 50% 45% 55% 48%;
  padding: 0.12rem 0.24rem;
  transform: rotate(-5deg);
  white-space: nowrap;
}

.generator-buy {
  background: #f7f2e2;
  color: #4a3a1a;
  border: 2px dashed #8a6a42;
  border-radius: 3px;
  padding: 0.22rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: monospace;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(58, 38, 15, 0.5);
}

.generator-buy:hover:not(:disabled) {
  background: #fffbe8;
}

.generator-buy:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.generator-buy:disabled {
  background: #ded5be;
  color: #9a8d70;
  border-color: #b3a488;
  box-shadow: none;
  cursor: not-allowed;
}

.toast-container {
  position: fixed;
  top: 3.6rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 100;
}

/* toasts are sticky notes slapped onto the screen */
.toast {
  background: var(--note-1);
  color: var(--kraft-ink);
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.55rem 0.9rem;
  box-shadow: 3px 4px 8px rgba(20, 12, 4, 0.55);
  transform: rotate(-1.2deg);
  animation: fade-in 0.3s ease;
  max-width: min(420px, 88vw);
  text-align: center;
}

.toast:nth-child(even) {
  background: var(--note-2);
  transform: rotate(1deg);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.click-popup {
  position: fixed;
  pointer-events: none;
  z-index: 20;
  font-family: monospace;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--green);
  text-shadow: var(--glow-green);
  animation: float-up 0.85s ease-out forwards;
}

@keyframes float-up {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-64px);
  }
}

.prestige-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 10, 0.72);
}

.prestige-modal {
  width: min(480px, 92vw);
  background: linear-gradient(160deg, #a8845a 0%, #96714a 45%, #86633e 100%);
  padding: 1.1rem 1rem 1rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7), inset 0 0 26px rgba(60, 38, 16, 0.35);
  clip-path: polygon(
    0% 12px, 6% 4px, 13% 11px, 21% 3px, 29% 10px, 38% 4px, 47% 11px, 56% 4px,
    65% 10px, 74% 3px, 83% 10px, 92% 4px, 100% 11px, 100% 100%, 0% 100%
  );
  text-align: center;
}

.prestige-modal h3 {
  margin: 0.2rem 0 0.2rem;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  color: #38260f;
}

.prestige-modal p {
  margin: 0 0 0.8rem;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: 0.8rem;
  color: #4a3418;
}

.prestige-cards {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.prestige-card {
  flex: 1 1 120px;
  max-width: 150px;
  background: #eed879;
  border: none;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
  box-shadow: 3px 4px 7px rgba(40, 24, 8, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: transform 0.12s ease;
}

.prestige-card:nth-child(odd) {
  transform: rotate(-1.4deg);
}

.prestige-card:nth-child(even) {
  transform: rotate(1.2deg);
  background: #e6cd6b;
}

.prestige-card:hover {
  transform: rotate(0deg) scale(1.06);
}

.prestige-card-name {
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-weight: 700;
  font-size: 0.85rem;
  color: #33270f;
}

.prestige-card-desc {
  font-family: monospace;
  font-size: 0.66rem;
  color: #6a5a2a;
}

/* ---- SETUP shop (prestige, premium look) ---- */
.shop-toggle {
  margin-top: 0.35rem;
  width: 100%;
}

.shop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 12, 0.74);
}

.shop-modal {
  width: min(470px, 94vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.6rem 0.6rem;
  background: linear-gradient(160deg, var(--kraft-1) 0%, var(--kraft-2) 45%, var(--kraft-3) 100%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65), inset 0 0 26px rgba(60, 38, 16, 0.35);
  clip-path: var(--torn-top);
  color: var(--kraft-ink);
  position: relative;
}

.shop-modal::before,
.shop-modal::after {
  content: "";
  position: absolute;
  top: -2px;
  width: 62px;
  height: 22px;
  background: var(--tape);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.shop-modal::before { left: 26px; transform: rotate(-6deg); }
.shop-modal::after { right: 26px; transform: rotate(5deg); }

.shop-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.1rem 0.3rem 0.25rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--kraft-ink);
  border-bottom: 2px dashed rgba(58, 38, 15, 0.45);
}

.shop-x {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--marker-red);
  font-family: var(--hand);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transform: rotate(4deg);
}

.shop-hint {
  margin: 0;
  padding: 0.4rem 0.35rem 0.5rem;
  font-family: var(--hand);
  font-size: 0.68rem;
  line-height: 1.35;
  color: #4a3a1a;
}

.shop-list {
  list-style: none;
  margin: 0;
  padding: 0.1rem 0.15rem 0.3rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: #6e4f30 var(--kraft-2);
}

.shop-list::-webkit-scrollbar { width: 9px; }
.shop-list::-webkit-scrollbar-track { background: rgba(60, 38, 16, 0.25); }
.shop-list::-webkit-scrollbar-thumb { background: #6e4f30; border: 2px solid var(--kraft-2); }

/* every upgrade is a sticky note pinned to the board */
.shop-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  background: var(--note-1);
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4);
  transform: rotate(-0.8deg);
  transition: transform 0.12s ease;
}

.shop-item:nth-child(even) { background: var(--note-2); transform: rotate(0.7deg); }
.shop-item:nth-child(3n) { background: var(--note-3); }
.shop-item:hover { transform: rotate(0deg) scale(1.015); }

.shop-icon { font-size: 1.35rem; width: 2rem; text-align: center; }

.shop-info { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }

.shop-name {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--kraft-ink);
}

.shop-desc { font-family: monospace; font-size: 0.62rem; color: var(--kraft-ink-soft); }

.shop-level {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.62rem;
  color: var(--marker-red);
  border: 2px solid rgba(192, 57, 43, 0.75);
  border-radius: 50% 45% 55% 48%;
  padding: 0.12rem 0.28rem;
  transform: rotate(-5deg);
  white-space: nowrap;
}

.shop-buy {
  background: var(--note-paper);
  color: #4a3a1a;
  border: 2px dashed #8a6a42;
  border-radius: 3px;
  padding: 0.26rem 0.5rem;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.7rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s ease, background 0.1s ease;
}

.shop-buy:hover:not(:disabled) { background: #fffbef; transform: rotate(-1.5deg) scale(1.05); }
.shop-buy:disabled { opacity: 0.5; cursor: not-allowed; color: #8a7a5a; }

.rug-flash {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: rgba(255, 30, 30, 0.4);
  animation: flash-fade 0.65s ease-out forwards;
}

@keyframes flash-fade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ===================== COMBO METER ========================================= */
/* a torn strip of note paper with the streak scribbled on it */
.combo-meter {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translate(-50%, 14px) rotate(-1.5deg);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.7rem;
  font-family: var(--hand);
  font-weight: 700;
  background: var(--note-1);
  box-shadow: 3px 4px 8px rgba(20, 12, 4, 0.55);
  color: var(--kraft-ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.combo-meter.show {
  opacity: 1;
  transform: translate(-50%, 0) rotate(-1.5deg);
}
.combo-label {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--kraft-ink-soft);
}
.combo-x {
  font-size: 1.05rem;
  color: var(--marker-red);
}
.combo-bar {
  width: 88px;
  height: 7px;
  border: 2px solid rgba(58, 38, 15, 0.5);
  border-radius: 5px 3px 6px 4px;
  background: rgba(60, 38, 16, 0.22);
  overflow: hidden;
}
.combo-fill {
  height: 100%;
  width: 0;
  background: var(--combo-heat, var(--marker-red));
  transition: width 0.1s linear;
}
.combo-meter--max {
  animation: combo-throb 0.45s ease-in-out infinite;
}
@keyframes combo-throb {
  0%, 100% { transform: translate(-50%, 0) rotate(-1.5deg) scale(1); }
  50% { transform: translate(-50%, 0) rotate(-1.5deg) scale(1.07); }
}

/* ===================== CRIT + GOLDEN FEEDBACK ============================== */
.click-popup--crit {
  font-family: var(--hand);
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px #ff3b3b, 0 0 22px #ffb020, 0 2px 3px rgba(0, 0, 0, 0.85);
  animation: crit-pop 1.3s ease-out forwards;
}
@keyframes crit-pop {
  0% { transform: translateY(0) scale(0.6) rotate(-6deg); opacity: 0; }
  18% { transform: translateY(-14px) scale(1.35) rotate(3deg); opacity: 1; }
  35% { transform: translateY(-22px) scale(1) rotate(-2deg); }
  100% { transform: translateY(-70px) scale(1); opacity: 0; }
}
.crit-flash,
.golden-flash {
  position: fixed;
  inset: 0;
  z-index: 48;
  pointer-events: none;
}
.crit-flash {
  background: radial-gradient(circle at 50% 62%, rgba(255, 170, 40, 0.42), transparent 62%);
  animation: flash-fade 0.5s ease-out forwards;
}
.golden-flash {
  background: radial-gradient(circle at 50% 45%, rgba(255, 215, 0, 0.55), transparent 70%);
  animation: flash-fade 0.8s ease-out forwards;
}

/* ===================== GOLDEN BUFF BANNER ================================== */
/* a strip of masking tape stuck across the top of the screen */
.buff-banner {
  position: fixed;
  top: 3.6rem;
  left: 50%;
  transform: translate(-50%, -12px) rotate(-1deg);
  z-index: 46;
  padding: 0.4rem 1.2rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: #3a2a00;
  background: linear-gradient(95deg, #ffd76a, #ffb43c);
  box-shadow: 0 3px 10px rgba(20, 12, 4, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.buff-banner.show {
  opacity: 1;
  transform: translate(-50%, 0) rotate(-1deg);
  animation: buff-glow 1.1s ease-in-out infinite;
}
@keyframes buff-glow {
  0%, 100% { box-shadow: 0 3px 10px rgba(20, 12, 4, 0.6); }
  50% { box-shadow: 0 3px 22px rgba(255, 200, 60, 0.75); }
}

/* GOLDEN RUSH: louder than a normal buff, because coins are raining */
.buff-banner--rush {
  color: #2a1200;
  background: linear-gradient(95deg, #ffe066, #ff8a1b, #ffe066);
  background-size: 200% 100%;
  border: 2px solid #fff3b0;
  animation: rush-sweep 0.9s linear infinite, rush-pop 0.5s ease-in-out infinite !important;
}

@keyframes rush-sweep {
  to { background-position: -200% 0; }
}

@keyframes rush-pop {
  0%, 100% { transform: translate(-50%, 0) rotate(-1deg) scale(1); }
  50% { transform: translate(-50%, 0) rotate(-1deg) scale(1.05); }
}

/* ===================== ACHIEVEMENTS ======================================== */
.ach-modal {
  width: min(580px, 94vw);
}
.ach-grid {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0.2rem 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #6e4f30 var(--kraft-2);
}
/* each achievement is a little polaroid pinned to the board */
.ach-cell {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0 0.45rem;
  padding: 0.4rem 0.5rem;
  background: var(--note-paper);
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4);
  transform: rotate(-0.8deg);
  transition: transform 0.12s ease;
}
.ach-cell:nth-child(even) { transform: rotate(0.9deg); }
.ach-cell:nth-child(3n) { transform: rotate(-1.4deg); }
.ach-cell:hover { transform: rotate(0deg) scale(1.03); }
/* earned ones get a red marker tick, so the grid reads at a glance */
.ach-cell {
  position: relative;
}
.ach-cell:not(.ach-cell--locked)::after {
  content: "✓";
  position: absolute;
  top: -6px;
  right: -4px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--marker-red);
  transform: rotate(9deg);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.ach-icon {
  grid-row: 1 / 3;
  align-self: center;
  font-size: 1.5rem;
}
.ach-name {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.74rem;
  color: var(--kraft-ink);
}
.ach-desc {
  font-family: monospace;
  font-size: 0.6rem;
  line-height: 1.25;
  color: var(--kraft-ink-soft);
}
/* locked ones look like faded blank paper */
.ach-cell--locked {
  background: #cfc6ae;
  opacity: 0.75;
}
.ach-cell--locked .ach-icon {
  filter: grayscale(1) brightness(0.75);
}
.ach-cell--locked .ach-name {
  color: #6d6250;
}
.toast--achievement {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--note-paper);
  border-left: 6px solid var(--marker-red);
  color: var(--kraft-ink);
  text-align: left;
}
.toast-ach-icon {
  font-size: 1.6rem;
}

/* ===================== SHOP: legendary + locked ============================ */
/* legendary upgrades get a gold marker frame and a hand-drawn tag */
.shop-item--legendary {
  border-left: 6px solid #c9a227;
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4), inset 0 0 0 2px rgba(201, 162, 39, 0.35);
}
.shop-tag {
  font-family: var(--hand);
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  font-style: normal;
  padding: 0.05rem 0.32rem;
  background: #c9a227;
  color: #2e2200;
  vertical-align: middle;
  transform: rotate(-3deg);
  display: inline-block;
}
.shop-item--locked {
  background: #cfc6ae;
  opacity: 0.8;
}
.shop-item--locked .shop-icon {
  filter: grayscale(1);
}

/* ===================== OFFLINE WELCOME BACK =============================== */
.offline-away {
  margin: 0 0 0.5rem;
  font-family: var(--hand);
  font-size: 0.82rem;
  color: #4a3a1a;
}
.offline-amount {
  font-family: monospace;
  font-weight: 900;
  font-size: 2rem;
  text-align: center;
  color: #1f4d2b;
  margin: 0.4rem 0 0.8rem;
  text-shadow: 1px 2px 0 rgba(255, 255, 255, 0.35);
}

/* ===================== DUMP-IT confirmation =============================== */
/* same board as everything else, but taped shut with hazard tape */
.dump-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(80, 8, 8, 0.5), rgba(4, 3, 8, 0.86));
}
.dump-overlay.show {
  display: flex;
  animation: dump-in 0.18s ease-out;
}
.dump-modal {
  width: min(430px, 92vw);
  padding: 0.8rem 0.7rem 0.7rem;
  background: linear-gradient(160deg, var(--kraft-1) 0%, var(--kraft-2) 45%, var(--kraft-3) 100%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.7), inset 0 0 26px rgba(60, 38, 16, 0.35);
  clip-path: var(--torn-top);
  color: var(--kraft-ink);
  position: relative;
  animation: dump-shake 0.5s ease-out 0.05s;
}
/* hazard tape instead of plain masking tape */
.dump-modal::before,
.dump-modal::after {
  content: "";
  position: absolute;
  top: -2px;
  width: 74px;
  height: 20px;
  background: repeating-linear-gradient(45deg, #e0b400 0 8px, #2a2200 8px 16px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.dump-modal::before { left: 22px; transform: rotate(-6deg); }
.dump-modal::after { right: 22px; transform: rotate(5deg); }

.dump-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.1rem 0.3rem 0.3rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--marker-red);
  border-bottom: 2px dashed rgba(192, 57, 43, 0.5);
}
.dump-head .dump-siren {
  font-size: 1.1rem;
  animation: dump-pulse 0.9s ease-in-out infinite;
}
.dump-body {
  padding: 0.7rem 0.4rem 0.4rem;
}
.dump-warn {
  font-family: var(--hand);
  color: var(--marker-red);
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 0.7rem;
  transform: rotate(-1deg);
}
.dump-stats {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.dump-stat {
  flex: 1;
  padding: 0.5rem;
  text-align: center;
  background: var(--note-1);
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4);
  transform: rotate(-1deg);
}
.dump-stat:last-child {
  background: var(--note-2);
  transform: rotate(1.2deg);
}
.dump-stat .dump-stat-label {
  display: block;
  font-family: var(--hand);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--kraft-ink-soft);
  margin-bottom: 0.2rem;
}
.dump-stat .dump-stat-val {
  display: block;
  font-family: monospace;
  font-size: 1.05rem;
  font-weight: 700;
}
.dump-stat.lose .dump-stat-val { color: var(--marker-red); }
.dump-stat.gain .dump-stat-val { color: #1f4d2b; }
.dump-fine {
  font-family: monospace;
  font-size: 0.64rem;
  color: #5c4a24;
  margin: 0 0 0.2rem;
  line-height: 1.4;
}
.dump-actions {
  display: flex;
  gap: 0.6rem;
  padding: 0.5rem 0.4rem 0.2rem;
}
.dump-btn {
  flex: 1;
  padding: 0.55rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: 2px dashed #8a6a42;
  border-radius: 3px;
  background: var(--note-paper);
  color: #4a3a1a;
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4);
  transition: transform 0.1s ease, background 0.1s ease;
}
.dump-btn:hover { transform: rotate(-1.5deg) scale(1.04); }
.dump-btn.confirm {
  background: var(--marker-red);
  border: 2px dashed #6d1a12;
  color: #fff5f0;
}
.dump-btn.confirm:hover { background: #d4483a; }
@keyframes dump-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dump-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes dump-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@media (prefers-reduced-motion: reduce) {
  .click-popup,
  .toast,
  .rug-flash,
  .dump-overlay.show,
  .dump-modal,
  .dump-head .dump-siren {
    animation: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.5rem 1rem;
  }
  .hud-panel {
    top: 3.4rem;
    padding: 0.5rem 0.6rem;
    min-width: 0;
    gap: 0.3rem;
    font-size: 0.85rem;
  }
  .hud-panel--left {
    left: 0.5rem;
  }
  .hud-panel--right {
    right: 0.5rem;
  }
  .hud-stat-value {
    font-size: 0.85rem;
  }
  .generators-panel {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    width: auto;
  }
  #generatorsList {
    max-height: 26vh;
  }
}

/* ===================== HELP BIRD ("la palomita") ========================== */
/* A little dove perched in the corner. Click it and it explains the game. */
.help-bird {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 40;
  width: 92px;
  height: 92px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
  animation: bird-bob 3.2s ease-in-out infinite;
}

.help-bird:hover {
  animation: bird-excited 0.5s ease-in-out infinite;
}

.help-bird svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* the bird tilts its head every few seconds so it reads as alive */
.help-bird .bird-head {
  transform-origin: 46px 34px;
  animation: bird-tilt 4.5s ease-in-out infinite;
}

/* speech bubble on a scrap of note paper */
.help-bubble {
  position: absolute;
  right: 78px;
  top: 8px;
  padding: 0.28rem 0.5rem;
  background: var(--note-paper);
  color: var(--kraft-ink);
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.66rem;
  white-space: nowrap;
  box-shadow: 2px 3px 5px rgba(20, 12, 4, 0.5);
  transform: rotate(-3deg);
  pointer-events: none;
}

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

@keyframes bird-excited {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

@keyframes bird-tilt {
  0%, 70%, 100% { transform: rotate(0deg); }
  78% { transform: rotate(-11deg); }
  88% { transform: rotate(7deg); }
}

/* ===================== TUTORIAL BOARD ===================================== */
.help-modal {
  width: min(560px, 94vw);
  max-height: 86vh;
}

.help-steps {
  list-style: none;
  margin: 0;
  padding: 0.3rem 0.2rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #6e4f30 var(--kraft-2);
}

.help-steps::-webkit-scrollbar { width: 9px; }
.help-steps::-webkit-scrollbar-track { background: rgba(60, 38, 16, 0.25); }
.help-steps::-webkit-scrollbar-thumb { background: #6e4f30; border: 2px solid var(--kraft-2); }

/* each step is a sticky note with a marker-circled number */
.help-step {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.55rem;
  background: var(--note-1);
  box-shadow: 2px 3px 5px rgba(40, 24, 8, 0.4);
  transform: rotate(-0.7deg);
  transition: transform 0.12s ease;
}

.help-step:nth-child(even) { background: var(--note-2); transform: rotate(0.8deg); }
.help-step:nth-child(3n) { background: var(--note-3); }
.help-step:hover { transform: rotate(0deg) scale(1.015); }

.help-step-num {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--marker-red);
  border: 2px solid rgba(192, 57, 43, 0.75);
  border-radius: 50% 45% 55% 48%;
  width: 1.9rem;
  height: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-6deg);
  flex: none;
}

.help-step-body { min-width: 0; }

.help-step-title {
  display: block;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--kraft-ink);
}

.help-step-text {
  display: block;
  font-family: monospace;
  font-size: 0.63rem;
  line-height: 1.35;
  color: var(--kraft-ink-soft);
}

.help-step-text b {
  color: #7a3a12;
}

/* the bird signs off at the bottom */
.help-sign {
  margin: 0.2rem 0.3rem 0;
  padding-top: 0.4rem;
  border-top: 2px dashed rgba(58, 38, 15, 0.4);
  font-family: var(--hand);
  font-size: 0.68rem;
  text-align: right;
  color: #5c4a24;
  transform: rotate(-0.8deg);
}

@media (max-width: 640px) {
  .help-bird {
    width: 68px;
    height: 68px;
    right: 0.6rem;
    bottom: 30vh;
  }
  .help-bubble { display: none; }
}

/* ===================== TITLE SCREEN ======================================= */
/* Shown over everything until START is pressed. It is also the user gesture
   that unlocks WebAudio, so music/SFX can begin the moment the game starts. */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(60, 44, 20, 0.55), transparent 62%),
    var(--bg-dark);
}

.start-screen--gone {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.start-card {
  width: min(430px, 90vw);
  padding: 1.6rem 1.2rem 1.2rem;
  text-align: center;
  background: linear-gradient(160deg, var(--kraft-1) 0%, var(--kraft-2) 45%, var(--kraft-3) 100%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.75), inset 0 0 30px rgba(60, 38, 16, 0.4);
  clip-path: var(--torn-top);
  color: var(--kraft-ink);
  position: relative;
  animation: start-in 0.5s ease-out;
}

.start-card::before,
.start-card::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 78px;
  height: 24px;
  background: var(--tape);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.start-card::before { left: 24px; transform: rotate(-6deg); }
.start-card::after { right: 24px; transform: rotate(5deg); }

.start-kicker {
  margin: 0.2rem 0 0;
  font-family: var(--hand);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--kraft-ink-soft);
}

.start-title {
  margin: 0.1rem 0 0.5rem;
  font-family: var(--hand);
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--marker-red);
  text-shadow: 2px 3px 0 rgba(255, 245, 220, 0.5), 0 6px 10px rgba(0, 0, 0, 0.3);
  transform: rotate(-1.6deg);
}

.start-sub {
  margin: 0 0 1.1rem;
  font-family: monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  color: #4a3a1a;
}

/* the START button echoes the big red PUMP dome */
.start-button {
  display: inline-block;
  padding: 0.75rem 2.6rem;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  color: #fff5f0;
  background: linear-gradient(180deg, #e8453a 0%, #c0392b 60%, #96271c 100%);
  border: 3px solid #6d1a12;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 6px 0 #6d1a12, 0 12px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
  animation: start-pulse 1.8s ease-in-out infinite;
}

.start-button:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 8px 0 #6d1a12, 0 16px 26px rgba(0, 0, 0, 0.55);
}

.start-button:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #6d1a12, 0 4px 10px rgba(0, 0, 0, 0.5);
  animation: none;
}

.start-note {
  display: inline-block;
  margin: 1.1rem 0 0.2rem;
  padding: 0.25rem 0.7rem;
  font-family: monospace;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: #43351a;
  background: var(--tape);
  transform: rotate(-1deg);
}

@keyframes start-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes start-pulse {
  0%, 100% { box-shadow: 0 6px 0 #6d1a12, 0 12px 20px rgba(0, 0, 0, 0.5); }
  50% { box-shadow: 0 6px 0 #6d1a12, 0 12px 30px rgba(224, 69, 58, 0.55); }
}

@media (prefers-reduced-motion: reduce) {
  .start-card,
  .start-button {
    animation: none;
  }
}
