* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  background: #0a0a0f;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  color: #00ffc8;
  user-select: none;
  -webkit-user-select: none;
}
#gameContainer {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
canvas {
  display: block;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}
#hud {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 10;
}
#title {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  font-size: 14px; font-weight: bold; color: #00ffc8;
  text-shadow: 0 0 10px #00ffc8, 0 0 20px #00ffc888;
  letter-spacing: 3px; white-space: nowrap;
}
#depth {
  position: absolute; top: 32px; left: 12px;
  font-size: 14px; color: #aaffcc;
  text-shadow: 0 0 5px #00ffc866;
}
#score {
  position: absolute; top: 50px; left: 12px;
  font-size: 14px; font-weight: bold; color: #ffd700;
  text-shadow: 0 0 8px #ffd70088;
}
#pickaxeDisplay {
  position: absolute; top: 68px; left: 12px;
  font-size: 11px; color: #88ccff;
}
#inventory {
  position: absolute; top: 90px; left: 8px;
  font-size: 11px; line-height: 1.6; color: #ccc;
  background: rgba(0,0,0,0.55); padding: 6px 10px;
  border: 1px solid #00ffc833; border-radius: 4px;
  max-height: 40vh; overflow-y: auto;
}
.inv-row { display: flex; align-items: center; gap: 5px; }
.inv-icon { width: 10px; height: 10px; display: inline-block; border-radius: 2px; flex-shrink: 0; }
/* Health + Stamina bars */
#barsContainer {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px;
  width: min(340px, 85vw);
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.35) 100%);
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}
.bar-row-hud {
  display: flex; align-items: center; gap: 8px;
}
.bar-icon-hud {
  font-size: 14px; width: 18px; flex-shrink: 0; text-align: center;
  filter: drop-shadow(0 0 3px currentColor);
}
.sta-icon { color: #4488ff; }
.hp-icon { color: #22cc44; }
.bar-label-hud {
  font-size: 9px; font-weight: bold; text-transform: uppercase;
  letter-spacing: 1.5px; width: 28px; flex-shrink: 0;
}
.sta-lbl { color: #4488ff; }
.hp-lbl { color: #22cc44; }
#staminaBarOuter, #healthBarOuter {
  flex: 1; height: 14px;
  background: #0a0a12;
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}
#staminaBarInner {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #1a3faa, #3377ee, #55aaff);
  transition: width 0.15s ease;
}
#healthBarInner {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #cc2222, #ee6622, #44dd44);
  transition: width 0.2s ease;
}
/* Glass shine highlight */
.bar-shine {
  position: absolute; top: 1px; left: 4px; right: 4px; height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, transparent 100%);
  border-radius: 4px; pointer-events: none;
}
/* Tick marks at 25/50/75% */
.bar-ticks {
  position: absolute; inset: 0; display: flex; pointer-events: none;
}
.bar-ticks span {
  flex: 1;
  border-right: 1px solid rgba(255,255,255,0.08);
}
.bar-ticks span:last-child { border-right: none; }
/* Fixed-width value labels so both bars are identical length */
#energyLabel, #healthText {
  width: 70px; flex-shrink: 0; text-align: right;
  font-size: 9px; color: #aaa; letter-spacing: 0.5px;
}
/* Shimmer sweep — on outer bars to avoid GPU compositing issue with nested overflow+border-radius */
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
#staminaBarOuter::after, #healthBarOuter::after {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 30%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  animation: shimmer 4s ease-in-out infinite;
  pointer-events: none; z-index: 3;
}
#healthBarOuter::after { animation-delay: 2s; }
/* Pulse — on outer bars, safe opacity animation (no filter on fill) */
@keyframes barPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.88; }
}
/* barPulse removed — caused GPU compositing issues on desktop */
/* LOW energy overlay */
#lowEnergyText {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 8px; color: #ffaa00; font-weight: bold;
  display: none; z-index: 2;
}
@keyframes flicker { 0%,100%{opacity:1} 50%{opacity:0.2} }
.lowEnergyFlicker { animation: flicker 0.4s infinite; display: flex !important; }
#energyLabel {
  font-size: 10px; font-weight: bold; color: #88bbff; flex-shrink: 0;
  min-width: 52px; text-align: right;
  text-shadow: 0 0 4px rgba(68,136,255,0.3);
}
#healthText {
  font-size: 10px; font-weight: bold; color: #66ee88; flex-shrink: 0;
  min-width: 52px; text-align: right;
  text-shadow: 0 0 4px rgba(34,204,68,0.3);
}
/* Wallet section */
#walletSection {
  position: absolute; top: 30px; right: 12px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  pointer-events: auto;
}
#connectWalletBtn {
  background: rgba(0,255,200,0.1); border: 1px solid #00ffc855;
  color: #00ffc8; font-family: 'Courier New', monospace; font-size: 10px;
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  pointer-events: auto;
}
#connectWalletBtn:hover { background: rgba(0,255,200,0.25); }
#walletInfo { display: none; flex-direction: column; align-items: flex-end; gap: 3px; }
#walletAddr { font-size: 9px; color: #88ccaa; }
#redeemBtn {
  background: rgba(255,215,0,0.1); border: 1px solid #ffd70055;
  color: #ffd700; font-family: 'Courier New', monospace; font-size: 10px;
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  pointer-events: auto;
}
#redeemBtn:hover { background: rgba(255,215,0,0.25); }
/* Event banner */
#eventBanner {
  position: absolute; top: 34px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); border: 1px solid #ffd700;
  color: #ffd700; font-size: 16px; font-weight: bold;
  padding: 8px 24px; border-radius: 6px;
  letter-spacing: 2px; white-space: nowrap;
  transition: opacity 0.5s;
  opacity: 0; pointer-events: none;
  text-shadow: 0 0 12px #ffd700;
}
/* Mission flash */
#missionFlash {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 28px; font-weight: bold; color: #ffd700;
  text-shadow: 0 0 20px #ffd700, 0 0 40px #ffd70066;
  letter-spacing: 4px;
  opacity: 0; transition: opacity 0.3s;
  pointer-events: none;
}
/* Missions Button */
#missionsBtn {
  position: absolute; bottom: 115px; right: 8px;
  background: rgba(0,0,0,0.75); border: 1px solid #00ffc8;
  color: #00ffc8; font-family: monospace; font-size: 10px;
  font-weight: bold; letter-spacing: 2px; padding: 6px 12px;
  border-radius: 6px; cursor: pointer;
  transition: background 0.2s; z-index: 80; display: none;
}
#missionsBtn:hover { background: rgba(0,255,200,0.15); }

#chatMenuBtn {
  position: static;
  background: rgba(0,0,0,0.75); border: 1px solid #00ff88;
  color: #00ff88; font-family: monospace; font-size: 10px;
  font-weight: bold; letter-spacing: 2px; padding: 6px 12px;
  border-radius: 6px; cursor: pointer;
  transition: background 0.2s; z-index: 80;
}
#chatMenuBtn:hover { background: rgba(0,255,136,0.15); }

/* Missions Overlay */
#missionsOverlay {
  display: none; position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
  align-items: center; justify-content: center;
  z-index: 90; pointer-events: auto;
}
#missionsOverlay.open { display: flex; }
#missionsBox {
  background: #0a0a1a; border: 1px solid #00ffc8;
  border-radius: 10px; padding: 24px 32px; min-width: 300px;
  max-width: 400px; text-align: center;
}
#missionTitle {
  color: #00ffc8; font-weight: bold; font-size: 14px;
  margin-bottom: 16px; letter-spacing: 3px;
}
.mission-item {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; color: #aaa; font-size: 11px;
  text-align: left;
}
.mission-item.done { color: #ffd700; }
.mission-check { width: 14px; height: 14px; border: 1px solid #555; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }
.mission-item.done .mission-check { border-color: #ffd700; background: #ffd700; color: #000; }
#closeMissionsBtn {
  margin-top: 16px; background: transparent; border: 1px solid #00ffc8;
  color: #00ffc8; font-family: monospace; font-size: 11px;
  padding: 6px 20px; border-radius: 6px; cursor: pointer;
  letter-spacing: 2px;
}
#closeMissionsBtn:hover { background: rgba(0,255,200,0.1); }
/* ===== PICKAXE FORGE OVERLAY ===== */
#upgradeOverlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.88);
  display: none; align-items: center; justify-content: center;
  z-index: 200; font-family: 'Courier New', monospace;
  pointer-events: auto;
}
#upgradeBox {
  background: #07070f;
  border: 2px solid #00ffc8;
  border-radius: 14px;
  width: 92%; max-width: 440px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 0 50px #00ffc820, inset 0 0 30px #00ffc808;
  overflow: hidden;
}
.upgrade-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #1a3a30;
  color: #00ffc8; font-size: 14px; font-weight: bold; letter-spacing: 4px;
  text-shadow: 0 0 12px #00ffc855;
  flex-shrink: 0;
}
.upgrade-header button {
  background: #2a0000; border: 1px solid #aa2222;
  color: #ff4444; font-family: monospace; font-size: 18px;
  width: 32px; height: 32px; border-radius: 6px;
  cursor: pointer; line-height: 1; padding: 0;
  transition: all 0.15s;
  text-shadow: 0 0 8px #ff444488;
}
.upgrade-header button:hover { background: #440000; border-color: #ff4444; color: #ff6666; }
.upgrade-balance-bar {
  background: #0d1a15; border-bottom: 1px solid #1a3a30;
  padding: 10px 18px; font-size: 12px; letter-spacing: 1px;
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.ub-label { color: #555; }
#upgradeGEMBalance { color: #00ffc8; font-weight: bold; font-size: 14px; }
.ub-unit { color: #00ffc888; }
.upgrade-tiers-list {
  overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin; scrollbar-color: #1a3a30 transparent;
}
.upgrade-tiers-list::-webkit-scrollbar { width: 4px; }
.upgrade-tiers-list::-webkit-scrollbar-track { background: transparent; }
.upgrade-tiers-list::-webkit-scrollbar-thumb { background: #1a3a30; border-radius: 2px; }
/* Tier cards */
.upgrade-tier-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 12px; border-radius: 8px; border: 1px solid #1a1a2a;
  transition: all 0.15s; background: #0a0a18;
}
.upgrade-tier-card.upgrade-current {
  border-color: #00ffc8; background: #081a14;
  box-shadow: 0 0 18px #00ffc820, inset 0 0 12px #00ffc808;
}
.upgrade-tier-card.upgrade-owned { border-color: #1a3a28; background: #080f0a; }
.upgrade-tier-card.upgrade-owned .ut-name { color: #ccddcc; }
.upgrade-tier-card.upgrade-owned .ut-desc { color: #aabbaa; }
.upgrade-tier-card.upgrade-affordable {
  border-color: #225533; background: #081208;
  box-shadow: 0 0 12px #00ff4420;
}
.upgrade-tier-card.upgrade-affordable:hover {
  border-color: #33aa66; background: #0a1a0a;
  box-shadow: 0 0 20px #00ff4430; transform: translateX(2px);
}
.upgrade-tier-card.upgrade-locked { border-color: #2a2540; background: #0a0915; }
.upgrade-tier-card.upgrade-locked .ut-desc { color: #aaa; }
.upgrade-tier-card.upgrade-locked .utstat { opacity: 0.7; }
.ut-icon { font-size: 24px; min-width: 32px; text-align: center; }
.ut-body { flex: 1; min-width: 0; }
.ut-name { font-size: 11px; font-weight: bold; letter-spacing: 3px; margin-bottom: 2px; }
.ut-desc { font-size: 9px; color: #999; margin-bottom: 5px; line-height: 1.4; }
.ut-stats { display: flex; flex-wrap: wrap; gap: 5px; }
.utstat {
  font-size: 8px; padding: 2px 6px; border-radius: 3px;
  letter-spacing: 0.5px; font-weight: bold;
}
.utstat.speed { background: #1a1500; color: #ffd700; }
.utstat.power { background: #1a0a00; color: #ff7744; }
.utstat.regen { background: #001a10; color: #44ff88; }
.utstat.stamina { background: #001010; color: #00ffc8; }
.ut-action { min-width: 80px; text-align: right; flex-shrink: 0; }
.ut-badge { font-size: 9px; letter-spacing: 2px; padding: 5px 8px; border-radius: 4px; }
.ut-equipped { background: #0a2a1a; color: #00ffc8; border: 1px solid #00ffc844; }
.ut-owned { background: #111; color: #7a9a88; border: 1px solid #2a4a38; }
.ut-cost {
  font-size: 10px; font-weight: bold; letter-spacing: 1px;
  padding: 6px 8px; border-radius: 4px;
}
.ut-cost-ok { background: #0a1a08; color: #44ff88; border: 1px solid #1a4a22; }
.ut-cost-no { background: #0a0a0a; color: #444; border: 1px solid #1a1a1a; }
.forge-section-divider {
  margin: 6px 0 4px; padding: 8px 10px;
  border-top: 1px solid #2a4a38; border-bottom: 1px solid #2a4a38;
  color: #aaffcc; font-size: 10px; letter-spacing: 4px;
  text-align: center; font-weight: bold;
  text-shadow: 0 0 8px #00ffc855;
}
/* Legacy */
.upgrade-tier { display: none; }
#upgradeClose { /* handled inside .upgrade-header button */ }
/* Ore breakdown in redeem modal */
.redeem-breakdown {
  background: rgba(0,0,0,0.4);
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px;
  max-height: 160px;
  overflow-y: auto;
}
.redeem-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 11px;
  border-bottom: 1px solid #222;
}
.redeem-row:last-child { border-bottom: none; }
.redeem-ore-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.redeem-ore-name { color: #ccc; flex: 1; }
.redeem-ore-count { color: #888; width: 35px; text-align: right; }
.redeem-ore-rate { color: #666; width: 45px; text-align: right; }
.redeem-ore-val { color: #ffd700; width: 70px; text-align: right; font-weight: bold; }

/* Redeem modal */
#redeemModal {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.9);
  display: none; align-items: center; justify-content: center;
  z-index: 100; pointer-events: auto;
}
#redeemBox {
  border: 1px solid #ffd700; border-radius: 8px;
  padding: 24px 32px; max-width: 460px; width: 90%; text-align: center;
  background: #0a0a0a;
}
#redeemBox h2 { color: #ffd700; font-size: 18px; margin-bottom: 12px; letter-spacing: 2px; }
#redeemBox p { color: #aaa; font-size: 12px; line-height: 1.6; margin-bottom: 8px; }
#redeemClose {
  margin-top: 16px;
  background: transparent; border: 1px solid #ffd700;
  color: #ffd700; font-family: 'Courier New', monospace; font-size: 12px;
  padding: 6px 20px; border-radius: 4px; cursor: pointer;
}
/* Start screen */
#startScreen {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: #06060e;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 100; overflow: hidden;
}
#startScreen .gem-cluster {
  display: flex; gap: 10px; margin-bottom: 18px; align-items: center; justify-content: center;
}
#startScreen .gem-cluster span { font-size: clamp(22px, 5vw, 32px); filter: drop-shadow(0 0 8px #00ffc8); animation: gemFloat 3s ease-in-out infinite; }
#startScreen .gem-cluster span:nth-child(1) { animation-delay: 0s; font-size: clamp(24px, 5vw, 30px); }
#startScreen .gem-cluster span:nth-child(2) { animation-delay: 0.4s; font-size: clamp(28px, 6vw, 38px); filter: drop-shadow(0 0 10px #bf5fff); }
#startScreen .gem-cluster span:nth-child(3) { animation-delay: 0.8s; font-size: clamp(24px, 5vw, 30px); filter: drop-shadow(0 0 8px #44aaff); }
@keyframes gemFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-7px)} }
#startScreen h1 {
  font-size: clamp(28px, 7vw, 54px);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1.1;
  margin-bottom: 6px;
  text-align: center;
  background: linear-gradient(135deg, #00ffc8, #bf5fff, #44aaff, #00ffc8);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: startShimmer 4s ease infinite;
  filter: drop-shadow(0 0 18px #00ffc866);
}
@keyframes startShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
#startScreen .start-tagline {
  font-size: clamp(9px, 2vw, 12px);
  letter-spacing: 5px;
  color: #d08fff;
  margin-bottom: 16px;
  text-transform: uppercase;
  filter: drop-shadow(0 0 8px #bf5fffaa);
}
#startScreen .subtitle {
  font-size: clamp(11px, 2vw, 14px); color: #aaddbb; margin-bottom: 7px; text-align: center; padding: 0 20px; letter-spacing: 1px;
}
#startScreen .subtitle.controls { color: #99bbdd; }
#startScreen .prompt {
  font-size: clamp(12px, 2.5vw, 16px);
  color: #06060e;
  background: linear-gradient(135deg, #00ffc8, #44aaff);
  margin-top: 20px;
  padding: 12px 30px;
  border-radius: 4px;
  letter-spacing: 3px;
  font-weight: bold;
  cursor: pointer;
  animation: startPulse 2.5s ease-in-out infinite;
}
@keyframes startPulse {
  0%,100% { box-shadow: 0 0 20px #00ffc855, 0 0 40px #00ffc822; }
  50% { box-shadow: 0 0 32px #00ffc888, 0 0 60px #00ffc844; }
}
#startBest { font-size: 13px; color: #ffd700; margin-top: 10px; filter: drop-shadow(0 0 6px #ffd70066); }
#startCanvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1;
}
/* Death overlay */
#deathOverlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(180,0,0,0.25);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; z-index: 100; pointer-events: auto;
}
#deathOverlay h2 { font-size: 36px; color: #ff4444; text-shadow: 0 0 20px #ff0000; margin-bottom: 10px; }
#deathOverlay .death-score { color: #ffd700; font-size: 18px; margin-bottom: 4px; }
#deathOverlay .death-best { color: #ffaa88; font-size: 14px; margin-bottom: 4px; }
#deathOverlay .death-new { color: #00ffc8; font-size: 16px; font-weight: bold; margin-bottom: 10px; text-shadow: 0 0 10px #00ffc8; display: none; }
#deathOverlay .death-hint { color: #888; font-size: 12px; margin-top: 10px; }
#deathOverlay .death-penalty { color: #ffaa88; font-size: 11px; }
#deathClaimBtn {
  margin-top: 14px;
  background: rgba(255,215,0,0.15); border: 1px solid #ffd700;
  color: #ffd700; font-family: 'Courier New', monospace; font-size: 13px;
  padding: 8px 20px; border-radius: 4px; cursor: pointer;
  display: none;
}
#deathRestartBtn {
  margin-top: 10px;
  background: rgba(0,255,200,0.1); border: 1px solid #00ffc8;
  color: #00ffc8; font-family: 'Courier New', monospace; font-size: 13px;
  padding: 8px 20px; border-radius: 4px; cursor: pointer;
}
/* Ore rush tint */
#oreRushOverlay {
  position: absolute; inset: 0;
  background: rgba(255,200,0,0.07);
  pointer-events: none; z-index: 12;
  display: none;
}
/* Rare flash */
#rareFlash {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 15;
  background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, transparent 70%);
  opacity: 0; transition: opacity 0.1s;
}
/* Mobile controls — bottom-left to avoid overlapping HUD buttons on the right */
#mobileControls {
  display: none;
  position: absolute; bottom: 82px; left: 10px;
  z-index: 20; pointer-events: auto;
}
.mBtn {
  width: 48px; height: 48px; background: rgba(0,255,200,0.15);
  border: 1px solid #00ffc855; border-radius: 8px;
  color: #00ffc8; font-size: 20px; display: flex;
  align-items: center; justify-content: center;
  pointer-events: auto; touch-action: none;
}
.mBtn:active { background: rgba(0,255,200,0.4); }
#mobileGrid {
  display: grid;
  grid-template-columns: 48px 48px 48px;
  grid-template-rows: 48px 48px 48px;
  gap: 4px;
}
@media (pointer: coarse) {
  #mobileControls { display: block; }
}
/* ===== COLLAPSIBLE GAME MENU ===== */
#menuBtnRow {
  display: none; flex-direction: row; gap: 5px; width: 100%;
}
#menuBtn, #potBtn {
  flex: 1; background: rgba(0,0,0,0.85); border: 1px solid #00ffc8;
  color: #00ffc8; font-family: 'Courier New', monospace; font-size: 8px;
  font-weight: bold; letter-spacing: 1px; padding: 5px 4px;
  border-radius: 4px; cursor: pointer; text-align: center;
  transition: all 0.2s; pointer-events: auto;
}
#potBtn { border-color: #ff2200; color: #ff6644; }
#menuBtn:hover, #menuBtn.active { background: rgba(0,255,200,0.15); }
#potBtn:hover { background: rgba(255,34,0,0.15); }
/* Menu panel — hidden by default, opens as fixed overlay to avoid bleeding through HUD elements */
#menuPanel {
  display: none; flex-direction: column; gap: 4px;
  pointer-events: auto;
  background: rgba(6,6,18,0.98);
  border: 1px solid rgba(0,255,200,0.2);
  border-radius: 8px; padding: 8px;
  box-shadow: 0 0 24px rgba(0,0,0,0.8);
}
#menuPanel.open {
  display: flex;
  position: fixed; top: 28px; right: 8px;
  width: 160px; max-height: 75vh; overflow-y: auto;
  z-index: 200;
  animation: menuSlideUp 0.15s ease;
}
@keyframes menuSlideUp {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
/* Override absolute positioning for buttons living inside panel */
#menuPanel #missionsBtn,
#menuPanel #earningsBtn,
#menuPanel #achieveBtn,
#menuPanel #forgeBtn,
#menuPanel #statsBtn,
#menuPanel #chatMenuBtn,
#menuPanel #griffCoinflipMenuBtn,
#menuPanel #griffWheelMenuBtn,
#menuPanel #approveMenuBtn,
#menuPanel #bugReportMenuBtn {
  position: static !important;
  bottom: auto !important; right: auto !important;
  width: 100%; text-align: left;
}
/* Force buttons visible when panel is open (overrides engine.js display:none) */
#menuPanel.open #missionsBtn,
#menuPanel.open #earningsBtn,
#menuPanel.open #achieveBtn,
#menuPanel.open #forgeBtn,
#menuPanel.open #statsBtn,
#menuPanel.open #chatMenuBtn,
#menuPanel.open #griffCoinflipMenuBtn,
#menuPanel.open #griffWheelMenuBtn {
  display: block !important;
}

/* Minigame menu buttons — full styling matching the other HUD buttons */
#griffCoinflipMenuBtn,
#griffWheelMenuBtn {
  position: absolute;
  background: rgba(0,0,0,0.75);
  font-family: monospace; font-size: 10px;
  font-weight: bold; letter-spacing: 2px; padding: 6px 12px;
  border-radius: 6px; cursor: pointer;
  transition: background 0.2s; z-index: 80; display: none;
  pointer-events: auto;
}
#griffCoinflipMenuBtn { border: 1px solid #ffd700; color: #ffd700; }
#griffWheelMenuBtn    { border: 1px solid #bf5fff; color: #bf5fff; }
#approveMenuBtn {
  background: rgba(0,0,0,0.75); border: 1px solid #00ccff;
  color: #00ccff; font-family: monospace; font-size: 10px;
  font-weight: bold; letter-spacing: 2px; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; transition: background 0.2s;
}
#bugReportMenuBtn {
  background: rgba(0,0,0,0.75); border: 1px solid #ff6633;
  color: #ff6633; font-family: monospace; font-size: 10px;
  font-weight: bold; letter-spacing: 2px; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; transition: background 0.2s;
}
#griffCoinflipMenuBtn:hover { background: rgba(255,215,0,0.15); }
#griffWheelMenuBtn:hover    { background: rgba(191,95,255,0.15); }
#approveMenuBtn:hover       { background: rgba(0,204,255,0.15); }
#bugReportMenuBtn:hover     { background: rgba(255,102,51,0.15); }
/* Minimap hint */
/* ===== EARNINGS MENU ===== */
#earningsBtn {
  position: absolute; bottom: 158px; right: 8px;
  background: rgba(0,0,0,0.75); border: 1px solid #ffd700;
  color: #ffd700; font-family: monospace; font-size: 10px;
  font-weight: bold; letter-spacing: 2px; padding: 6px 12px;
  border-radius: 6px; cursor: pointer;
  transition: background 0.2s; z-index: 80; display: none;
  pointer-events: auto;
}
#earningsBtn:hover { background: rgba(255,215,0,0.15); }
#earningsOverlay {
  display: none; position: absolute; inset: 0;
  background: rgba(0,0,0,0.82);
  align-items: center; justify-content: center;
  z-index: 95; pointer-events: auto;
}
#earningsOverlay.open { display: flex; }
#earningsBox {
  background: #0a0a1a; border: 1px solid #ffd700;
  border-radius: 10px; padding: 24px 28px; min-width: 320px;
  max-width: 90vw; font-family: monospace; color: #ffd700;
  box-shadow: 0 0 30px rgba(255,215,0,0.3);
  pointer-events: auto;
}
#earningsTitle {
  font-size: 16px; font-weight: bold; letter-spacing: 3px;
  text-align: center; margin-bottom: 18px;
  text-shadow: 0 0 10px #ffd700;
}
.earnings-row {
  display: flex; justify-content: space-between;
  border-bottom: 1px solid #222; padding: 7px 0; font-size: 12px;
}
.earnings-label { color: #aaa; }
.earnings-value { color: #ffd700; font-weight: bold; }
#earningsTotal {
  margin-top: 14px; font-size: 18px; text-align: center;
  color: #00ffc8; font-weight: bold;
  text-shadow: 0 0 10px #00ffc8;
}
#cashoutBtn {
  margin-top: 18px; width: 100%;
  background: linear-gradient(135deg, rgba(255,215,0,0.2), rgba(0,255,200,0.1));
  border: 1px solid #ffd700; color: #ffd700;
  font-family: monospace; font-size: 13px; font-weight: bold;
  letter-spacing: 2px; padding: 10px; border-radius: 6px;
  cursor: pointer; transition: all 0.2s; pointer-events: auto;
}
#cashoutBtn:hover { background: rgba(255,215,0,0.3); box-shadow: 0 0 15px rgba(255,215,0,0.4); }
#cashoutBtn:disabled { opacity: 0.4; cursor: not-allowed; }
#cashoutStatus {
  margin-top: 8px; font-size: 10px; text-align: center;
  color: #00ffc8; min-height: 14px;
}
#closeEarningsBtn {
  margin-top: 12px; width: 100%;
  background: transparent; border: 1px solid #444;
  color: #666; font-family: monospace; font-size: 11px;
  padding: 6px; border-radius: 4px; cursor: pointer;
  pointer-events: auto;
}
#closeEarningsBtn:hover { border-color: #888; color: #aaa; }
.ore-breakdown { max-height: 180px; overflow-y: auto; margin-bottom: 6px; }
.ore-breakdown::-webkit-scrollbar { width: 4px; }
.ore-breakdown::-webkit-scrollbar-thumb { background: #333; }

/* Auth Modal */
#authModal {
  display:none; position:fixed; inset:0;
  background:rgba(0,0,0,0.92);
  align-items:center; justify-content:center;
  z-index:999999; padding:1rem;
}
#authModal.show { display:flex; }
#authModalBox {
  background:#0a0005; border:1px solid #00ffc833;
  border-radius:16px; padding:32px 28px;
  width:100%; max-width:340px;
  font-family:'Courier New',monospace;
  box-shadow:0 0 60px rgba(0,255,200,0.08);
  position:relative;
}
#authCloseBtn {
  position:absolute; top:12px; right:16px;
  background:none; border:none; color:#444; font-size:18px; cursor:pointer;
}
#authCloseBtn:hover { color:#fff; }
#authLogo {
  text-align:center; font-size:28px; margin-bottom:4px;
}
#authTitle {
  text-align:center; font-size:14px; font-weight:bold;
  color:#00ffc8; letter-spacing:4px; margin-bottom:20px;
}
.auth-subtitle {
  text-align:center; font-size:11px; color:#888;
  letter-spacing:1px; margin-bottom:16px;
}
#authEmailInput {
  width:100%; background:#111; border:1px solid #222;
  border-radius:8px; color:#fff; font-family:'Courier New',monospace;
  font-size:13px; padding:12px 14px; outline:none;
  margin-bottom:12px; transition:border-color 0.2s;
}
#authEmailInput:focus { border-color:#00ffc8; }
#authEmailBtn, #authVerifyBtn {
  width:100%; background:#00ffc8; border:none;
  border-radius:8px; color:#000; font-family:'Courier New',monospace;
  font-size:12px; font-weight:bold; letter-spacing:2px;
  padding:12px; cursor:pointer; transition:opacity 0.2s;
}
#authEmailBtn:hover, #authVerifyBtn:hover { opacity:0.85; }
#authDivider {
  text-align:center; margin:16px 0; position:relative;
}
#authDivider::before {
  content:''; position:absolute; top:50%; left:0; right:0;
  height:1px; background:#222;
}
#authDivider span {
  position:relative; background:#0a0005;
  padding:0 12px; color:#444; font-size:10px; letter-spacing:2px;
}
.auth-social-btn {
  width:100%; background:#111; border:1px solid #222;
  border-radius:8px; color:#ccc; font-family:'Courier New',monospace;
  font-size:11px; padding:11px 14px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:10px;
  margin-bottom:8px; transition:border-color 0.2s, background 0.2s;
}
.auth-social-btn:hover { border-color:#444; background:#1a1a1a; }
#authCodeEmail {
  text-align:center; color:#00ffc8; font-size:12px;
  margin-bottom:18px; word-break:break-all;
}
#authCodeInputs {
  display:flex; gap:8px; justify-content:center; margin-bottom:16px;
}
.auth-code-digit {
  width:40px; height:48px; text-align:center;
  background:#111; border:1px solid #222; border-radius:8px;
  color:#fff; font-family:'Courier New',monospace; font-size:20px;
  outline:none; transition:border-color 0.2s;
}
.auth-code-digit:focus { border-color:#00ffc8; }
#authResend, #authBackLink {
  text-align:center; font-size:10px; color:#555; margin-top:12px;
}
#authResend a, #authBackLink a {
  color:#00ffc8; text-decoration:none;
}
#authResend a:hover, #authBackLink a:hover { text-decoration:underline; }
#authError {
  display:none; text-align:center; color:#ff4444;
  font-size:10px; margin-top:14px;
}
#authLoading {
  display:none; justify-content:center; margin-top:14px;
}
.auth-spinner {
  width:20px; height:20px; border:2px solid #222;
  border-top-color:#00ffc8; border-radius:50%;
  animation:authSpin 0.6s linear infinite;
}
@keyframes authSpin { to { transform:rotate(360deg); } }

/* Wallet Modal (WalletConnect) */
#walletModal {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.88);
  align-items: center; justify-content: center;
  z-index: 999999; pointer-events: auto; padding: 1rem;
}
#walletModal.show { display: flex; }
#walletModalBox {
  background: #0d0d1a; border: 1px solid #00ffc844;
  border-radius: 16px; padding: 1.5rem;
  width: 100%; max-width: 360px;
  max-height: 90vh; overflow-y: auto;
  font-family: 'Courier New', monospace;
  box-shadow: 0 0 40px rgba(0,255,200,0.15);
}
#walletModalHeader {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem;
}
#walletModalHeader span {
  font-size: 13px; font-weight: bold; color: #00ffc8; letter-spacing: 2px;
}
#walletModalHeader button {
  background: none; border: none; color: #555; font-size: 18px; cursor: pointer;
  line-height: 1;
}
#walletModalHeader button:hover { color: #fff; }
#wcModalError {
  background: rgba(255,80,80,0.1); border: 1px solid rgba(255,80,80,0.3);
  border-radius: 8px; padding: 0.75rem; margin-bottom: 1rem;
  color: #ff6666; font-size: 10px; text-align: center;
}
.wc-wallet-opt {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; padding: 0.875rem; margin-bottom: 0.5rem;
  background: #0a0a14; border: 1px solid #1e1e2e; border-radius: 10px;
  color: #fff; font-family: 'Courier New', monospace; cursor: pointer;
  transition: border-color 0.2s;
}
.wc-wallet-opt:hover { border-color: #00ffc8; }
.wc-wallet-opt img { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; }
.wc-wallet-opt-name { font-size: 12px; font-weight: bold; color: #00ffc8; text-align: left; }
.wc-wallet-opt-desc { font-size: 9px; color: #555; text-align: left; margin-top: 2px; }
.wc-divider {
  text-align: center; color: #333; font-size: 9px; margin: 0.875rem 0;
  letter-spacing: 2px;
}
#wcLoading {
  text-align: center; padding: 0.875rem; color: #666; font-size: 11px;
}
#wcQrContainer { margin-bottom: 0.875rem; }
#wcQrWrap {
  display: flex; justify-content: center;
  background: white; border-radius: 10px; padding: 12px;
}
#wcMobileLinks { margin-bottom: 0.5rem; }
#wcMobileGrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  margin-bottom: 0.625rem;
}
.wc-mobile-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.375rem;
  padding: 0.875rem 0.5rem;
  background: #0a0a14; border: 1px solid #1e1e2e; border-radius: 10px;
  color: #aaa; font-family: 'Courier New', monospace; font-size: 10px;
  cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.wc-mobile-btn:hover { border-color: #00ffc8; color: #00ffc8; }
.wc-mobile-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.wc-mobile-btn img { width: 30px; height: 30px; border-radius: 7px; }
#wcCopyBtn {
  width: 100%; padding: 0.75rem;
  background: linear-gradient(135deg, rgba(0,255,200,0.2), rgba(0,180,140,0.1));
  border: 1px solid #00ffc866; border-radius: 10px;
  color: #00ffc8; font-family: 'Courier New', monospace; font-size: 11px;
  font-weight: bold; letter-spacing: 1px; cursor: pointer;
  transition: background 0.2s;
}
#wcCopyBtn:hover { background: linear-gradient(135deg, rgba(0,255,200,0.3), rgba(0,180,140,0.2)); }


/* === MISSION SYSTEM v2 === */

/* Mission cards */
.mission-card {
  background: rgba(20,20,30,0.9);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid #333;
  transition: all 0.3s ease;
}

.mission-card:hover {
  background: rgba(30,30,45,0.95);
}

.mission-done {
  opacity: 0.7;
  background: rgba(20,30,20,0.9) !important;
  border-color: #4ade8044 !important;
}

.mission-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.mission-tier-badge {
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.mission-check-badge {
  color: #4ade80;
  font-size: 14px;
  font-weight: bold;
}

.mission-card-desc {
  color: #ddd;
  font-size: 11px;
  margin-bottom: 6px;
}

.mission-done .mission-card-desc {
  text-decoration: line-through;
  color: #888;
}

.mission-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-bottom: 6px;
  overflow: hidden;
}

.mission-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease-out;
  box-shadow: 0 0 6px currentColor;
}

.mission-done .mission-progress-fill {
  opacity: 0.5;
}

.mission-card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
}

/* Streak banner */
.mission-streak {
  text-align: center;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, rgba(255,136,0,0.15), rgba(255,200,0,0.15));
  border: 1px solid #ff880044;
  border-radius: 6px;
  color: #ffaa00;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
}

/* Refresh countdown */
.mission-refresh {
  text-align: center;
  color: #555;
  font-size: 9px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}


/* === ACHIEVEMENT CELEBRATION POPUP === */
#achieveCelebrate {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10003;
  font-family: 'Courier New', monospace;
}
#achieveCelebrate.show {
  display: flex;
  animation: achOverlayIn 0.4s ease-out;
}
#achieveCelebrate.closing {
  animation: achOverlayOut 0.35s ease-in forwards;
}
#achCelebrateBox {
  background: rgba(10,10,20,0.97);
  border: 2px solid #ffd700;
  border-radius: 12px;
  padding: 32px 40px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  position: relative;
  overflow: visible;
  animation: achCardAppear 0.5s ease-out;
}
#achCelebrateParticles {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  overflow: visible;
}
#achCelebrateIcon {
  font-size: 52px;
  margin-bottom: 12px;
  display: block;
}
#achCelebrateName {
  font-size: 18px;
  font-weight: bold;
  color: #ffd700;
  letter-spacing: 3px;
  margin-bottom: 8px;
  text-transform: uppercase;
}
#achCelebrateDesc {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 12px;
  line-height: 1.6;
}
#achCelebrateReward {
  font-size: 16px;
  font-weight: bold;
  color: #00ffc8;
  letter-spacing: 2px;
}
.sparkle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: sparkleFly var(--dur, 1s) var(--delay, 0s) ease-out forwards;
}
@keyframes sparkleFly {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx,0),var(--ty,0)) scale(0); opacity: 0; }
}
@keyframes achOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes achOverlayOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes achCardAppear {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Mission celebration popup — reuses celebrate-overlay/card from achievements */
#missionCelebrate {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  font-family: monospace;
}

#missionCelebrate.show {
  display: flex;
  animation: achOverlayIn 0.4s ease-out;
}

#missionCelebrate.closing {
  animation: achOverlayOut 0.35s ease-in forwards;
}

#missionCelebCard {
  background: rgba(10,10,20,0.95);
  border: 2px solid #fbbf24;
  border-radius: 12px;
  padding: 28px 36px;
  text-align: center;
  max-width: 320px;
  animation: achCardAppear 0.5s ease-out;
}

/* ============================================================
   PvP Gem Steal — UI styles
   ============================================================ */

/* Steal button — pulsing danger glow */
#pvpStealBtn {
  animation: pvp-btn-pulse 1.2s ease-in-out infinite;
}

@keyframes pvp-btn-pulse {
  0%, 100% { box-shadow: 0 0 16px rgba(255, 0, 0, 0.4); }
  50%       { box-shadow: 0 0 28px rgba(255, 0, 0, 0.75), 0 0 8px rgba(255,80,80,0.5); }
}

/* Victim shake animation */
@keyframes pvp-shake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-8px) rotate(-1deg); }
  30%  { transform: translateX(8px)  rotate(1deg); }
  45%  { transform: translateX(-6px) rotate(-0.5deg); }
  60%  { transform: translateX(6px)  rotate(0.5deg); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

.pvp-shake {
  animation: pvp-shake 0.5s ease-in-out;
}
