:root {
  --green: #1DCB8A;
  --green-dark: #0F6E56;
  --bg: #0a0e14;
  --panel: #141a24;
  --text: #e8eef5;
  --muted: #7d8896;
  --gold: #f5c518;
  --danger: #e24b4a;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at 50% 25%, #ffd28a 0%, #ff9e6b 45%, #2ec5d8 100%);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  position: fixed;
  width: 100%;
  user-select: none;
}

#canvas-container { position: fixed; inset: 0; z-index: 1; }
canvas { display: block; cursor: pointer; }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center; gap: 8px;
  padding: 12px; flex-wrap: wrap;
  pointer-events: none;
}
.stat {
  background: rgba(20,26,36,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(29,203,138,0.25);
  border-radius: 12px;
  padding: 8px 16px;
  text-align: center;
  min-width: 90px;
}
.label { display: block; font-size: 10px; letter-spacing: 1px; color: var(--muted); }
.value { display: block; font-size: 20px; font-weight: 700; color: var(--green); }
#dpc.value, #lvl.value { color: var(--text); }

/* HP bar */
#hpwrap {
  position: fixed; top: 92px; left: 50%; transform: translateX(-50%);
  width: min(90%, 420px); height: 22px; z-index: 10;
  background: rgba(0,0,0,0.5); border-radius: 11px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
#hpbar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--danger), #ff7b54);
  transition: width 0.15s ease;
}
#hptext {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

/* Floating combo numbers */
#combo, #toast { position: fixed; z-index: 11; pointer-events: none; }
.float {
  position: fixed; font-weight: 800; font-size: 28px; color: var(--green);
  text-shadow: 0 2px 8px rgba(0,0,0,0.6); pointer-events: none; z-index: 12;
  animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-90px) scale(1.4); }
}
#toast {
  bottom: 90px; left: 50%; transform: translateX(-50%);
  background: rgba(20,26,36,0.95); border: 1px solid var(--green);
  padding: 10px 20px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; transition: opacity 0.3s; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* Shop */
#shop-toggle {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 10; background: var(--green); color: #062319; border: none;
  padding: 14px 28px; border-radius: 14px; font-size: 15px; font-weight: 800;
  cursor: pointer; box-shadow: 0 6px 20px rgba(29,203,138,0.4);
}
#shop-toggle:active { transform: translateX(-50%) scale(0.96); }

#shop {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  max-height: 78vh; overflow-y: auto;
  background: var(--panel); border-top: 2px solid var(--green);
  border-radius: 20px 20px 0 0; padding: 16px;
  transition: transform 0.3s ease;
}
#shop.hidden { transform: translateY(100%); }
.shop-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.shop-header h2 { font-size: 18px; }
#shop-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.shop-section h3 { font-size: 13px; color: var(--muted); margin: 14px 0 8px; }

.item {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  transition: background 0.15s;
}
.item:active { background: rgba(255,255,255,0.09); }
.item.locked { opacity: 0.45; cursor: not-allowed; }
.item-name { font-size: 15px; font-weight: 600; }
.item-name .count { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.item-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-cost { font-size: 14px; font-weight: 700; color: var(--green); white-space: nowrap; margin-left: 12px; }
.item.locked .item-cost { color: var(--muted); }

/* Loading */
#loading {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(circle at 50% 35%, #ffd28a 0%, #ff9e6b 55%, #2ec5d8 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  transition: opacity 0.5s; 
}
#loading.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 48px; height: 48px; border: 4px solid rgba(29,203,138,0.2);
  border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--muted); font-size: 14px; }

@media (max-width: 480px) {
  .stat { min-width: 70px; padding: 6px 10px; }
  .value { font-size: 16px; }
}

#sound-toggle {
  position: fixed; bottom: 20px; right: 16px; z-index: 10;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(20,26,36,0.9); border: 1px solid rgba(29,203,138,0.3);
  color: var(--text); font-size: 20px; cursor: pointer;
}
#sound-toggle:active { transform: scale(0.94); }

#credit {
  position: fixed; bottom: 4px; left: 0; right: 0; z-index: 9;
  text-align: center; font-size: 10px; color: var(--muted);
  pointer-events: auto;
}
#credit a { color: var(--muted); text-decoration: underline; }

.pumpval { color: var(--gold) !important; font-size: 16px; }
.item-cost.pump { color: var(--gold); }
.float.pumpfloat { color: var(--gold); font-size: 18px; }

#status {
  position: fixed; top: 122px; left: 50%; transform: translateX(-50%);
  z-index: 10; display: flex; gap: 16px; font-size: 13px; font-weight: 700;
  color: #7fd4ff; text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  opacity: 0; transition: opacity 0.3s; pointer-events: none; white-space: nowrap;
}

/* ===== Prestige / diamonds ===== */
.diamondval { color: #7fd4ff !important; font-size: 15px; }
.prestige-info { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.big-btn {
  width: 100%; padding: 12px; margin-bottom: 8px; border-radius: 12px;
  background: rgba(127,212,255,0.12); border: 1px solid rgba(127,212,255,0.4);
  color: #cdeeff; font-size: 14px; font-weight: 700; cursor: pointer;
}
.big-btn:active { transform: scale(0.98); }
.big-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.big-btn.danger { background: rgba(226,75,74,0.12); border-color: rgba(226,75,74,0.4); color: #ffb3b3; }

/* ===== Combo ===== */
#combo {
  position: fixed; top: 150px; left: 50%; transform: translateX(-50%);
  z-index: 10; font-size: 26px; font-weight: 800; color: var(--gold);
  text-shadow: 0 2px 10px rgba(0,0,0,0.8); opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}

/* ===== Event banner (Bull Run) ===== */
#event {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  z-index: 11; font-size: 30px; font-weight: 800; color: #1dcb8a;
  text-shadow: 0 0 20px rgba(29,203,138,0.8), 0 2px 8px rgba(0,0,0,0.9);
  opacity: 0; transition: opacity 0.4s; pointer-events: none; text-align: center;
}

/* ===== Flash overlay ===== */
#flash {
  position: fixed; inset: 0; z-index: 8; background: #fff0c0;
  opacity: 0; pointer-events: none; mix-blend-mode: screen;
}

/* ===== Float big variant ===== */
.float.big { font-size: 40px; color: var(--gold); }

/* ===== Achievement popup ===== */
.ach-pop {
  position: fixed; top: 30px; right: 16px; z-index: 30;
  background: rgba(20,26,36,0.96); border: 1px solid var(--gold);
  border-radius: 12px; padding: 12px 18px; font-size: 13px; color: var(--text);
  transform: translateX(140%); transition: transform 0.4s ease; max-width: 220px;
}
.ach-pop.show { transform: translateX(0); }
.ach-pop b { color: var(--gold); }

/* ===== Achievements button + panel ===== */
#ach-toggle {
  position: fixed; bottom: 78px; right: 16px; z-index: 10;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(20,26,36,0.9); border: 1px solid rgba(245,197,24,0.4);
  color: var(--text); font-size: 20px; cursor: pointer;
}
#ach-toggle:active { transform: scale(0.94); }
#ach-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  max-height: 70vh; overflow-y: auto;
  background: var(--panel); border-top: 2px solid var(--gold);
  border-radius: 20px 20px 0 0; padding: 16px; transition: transform 0.3s ease;
}
#ach-panel.hidden { transform: translateY(100%); }
.ach {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 6px; font-size: 14px; color: var(--muted);
}
.ach.got { color: var(--text); border-color: rgba(245,197,24,0.4); }
