/* ---- Geode ---- */
/* Stage is 2800px wide. Right panel = pixels 1400–2800.
   Geode mockup position: ~x=2130 (76%), y=1560 (65%) in 2800×2400 stage space.
   Size: ~900px in stage = ~450px logical viewport ≈ correct mockup scale. */
#geode-wrapper {
  position: absolute;
  left: 76%;
  top:  76%;
  width: 1250px;
  height: 1250px;
  margin-left: -625px;
  margin-top:  -625px;
  z-index: 10;
}

#geode-shadow {
  position: absolute;
  left: 76%;
  top: 76%;
  /* Scaled up for 1250px geode */
  transform: translate(calc(-50% + 24px), 226px);
  width: 720px;
  height: auto;
  object-fit: none;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.85;
  z-index: 9;
}

#geode-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: pointer;
  /* Static by default — wiggle fires only on tap */
  transform-origin: 50% 100%;
}

/* Inner squash wrapper — handles ONLY the tap impact, completely independent */
#geode-squash {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
}

#geode-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

#geode-break {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  background-image: url('../Geodes/Dust Geode/Dust_geode_open.png');
  background-size: 2700% 100%; /* 27 frames */
  background-position: 0 0;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
}

.hide-break {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none;
}

#geode-break.play-break {
  opacity: 1 !important;
  visibility: visible !important;
  /* 27 frames = 26 steps from 0 to 100% */
  animation: geode-shatter 0.81s steps(26) forwards;
}

@keyframes geode-shatter {
  from { background-position: 0 0; }
  to   { background-position: 100% 0; }
}

.fade-out {
  transition: opacity 2s ease-out;
  opacity: 0 !important;
}

/* One-shot damped wiggle — fires on tap, settles to rest */
@keyframes geode-wiggle {
  0%   { transform: rotate(0deg);    }
  12%  { transform: rotate(-5deg);   }
  28%  { transform: rotate( 4deg);   }
  44%  { transform: rotate(-2.5deg); }
  60%  { transform: rotate( 1.5deg); }
  74%  { transform: rotate(-0.8deg); }
  86%  { transform: rotate( 0.4deg); }
  100% { transform: rotate(0deg);    }
}

/* ---- Dust Drops & HUD ---- */
#hud-top {
  position: absolute;
  top: 40px;
  left: 40px;
  right: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
}

#energy-display, #dust-display, #level-display {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 52px;
  color: #fff;
  text-shadow: 0 4px 10px rgba(0,0,0,0.8);
}

.hud-label {
  color: #ffe566;
  font-size: 32px;
}

.hud-dust-icon {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.8));
}

/* Override .parallax-layer img rule for dust drops — they are img elements
   inside layer-1 but must NOT inherit the full-width/full-height layer rule.
   NOTE: top/left are set via inline JS styles — do NOT use !important here
   or it will override the JS coordinates and make drops disappear. */
img.dust-drop {
  position: absolute !important;
  width: 250px !important;
  height: 250px !important;
  object-fit: contain !important;
  image-rendering: auto !important;
  pointer-events: auto !important;
  cursor: pointer;
  z-index: 12;
  /* RPG loot glow: tight violet core + wide outer bloom */
  filter:
    drop-shadow(0 0 6px rgba(200, 100, 255, 0.95))
    drop-shadow(0 0 16px rgba(160, 60, 255, 0.80))
    drop-shadow(0 0 40px rgba(120, 20, 255, 0.55))
    drop-shadow(0 12px 20px rgba(0, 0, 0, 0.65)) !important;
}

img.dust-drop.opal-drop {
  filter:
    drop-shadow(0 0 6px rgba(100, 255, 255, 0.95))
    drop-shadow(0 0 16px rgba(50, 220, 255, 0.80))
    drop-shadow(0 0 40px rgba(0, 180, 200, 0.55))
    drop-shadow(0 12px 20px rgba(0, 0, 0, 0.65)) !important;
}

img.dust-drop.obsidian-drop {
  filter:
    drop-shadow(0 0 6px rgba(255, 255, 255, 0.95))
    drop-shadow(0 0 16px rgba(220, 220, 240, 0.80))
    drop-shadow(0 0 40px rgba(180, 180, 220, 0.55))
    drop-shadow(0 12px 20px rgba(0, 0, 0, 0.65)) !important;
}

@keyframes dust-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.dust-collecting {
  position: fixed; /* Attach to screen for flying to HUD */
  z-index: 9999;
  pointer-events: none;
  /* Actual animation handled via JS Web Animations API */
}

/* Triggered on tap — container wiggles, squash div squashes */
#geode-container.wiggle {
  animation: geode-wiggle 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes geode-hit {
  0%   { transform: scale(1,    1);    }
  14%  { transform: scale(1.07, 0.94); }
  30%  { transform: scale(0.94, 1.07); }
  50%  { transform: scale(1.04, 0.97); }
  68%  { transform: scale(0.98, 1.02); }
  84%  { transform: scale(1.01, 0.99); }
  100% { transform: scale(1,    1);    }
}

/* Applied to the INNER div so pendulum is never interrupted */
#geode-squash.hit {
  animation: geode-hit 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}



/* ---- HUD ---- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  pointer-events: none;
}

#hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 36px 60px 20px;
}

#energy-display, #level-display {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-family: 'RetroMario', sans-serif;
  font-size: 26px;
  letter-spacing: 4px;
  color: rgba(255,255,180,0.7);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#energy-value {
  font-family: 'RetroMario', sans-serif;
  font-size: 88px;
  line-height: 1;
  color: #ffe566;
  text-shadow: 0 0 24px rgba(255, 220, 0, 0.6), 0 4px 0 rgba(0,0,0,0.4);
}

#level-value {
  font-family: 'RetroMario', sans-serif;
  font-size: 72px;
  line-height: 1;
  color: #8df5a8;
  text-shadow: 0 0 18px rgba(80, 220, 100, 0.5), 0 4px 0 rgba(0,0,0,0.4);
}

#lives-icons {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

/* ---- Backpack (left / equipment panel) ---- */
#inventory-btn {
  position: absolute;
  top: 88px;
  left: 88px;
  z-index: 110;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-size: 96px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.65));
  transition: transform 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

#inventory-btn:hover {
  transform: scale(1.08);
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.75)) brightness(1.08);
}

#inventory-btn:active {
  transform: scale(0.92);
}

#right-hud {
  display: flex;
  align-items: center;
}

/* ---- Equipment Panel ---- */
#equipment-panel {
  position: absolute;
  right: 20px;
  top: 140px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 100;
  pointer-events: auto;
}

.equip-slot {
  width: 240px;
  height: 240px;
  background-image: url('../Misc/Inventory/Square.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: transform 0.15s, filter 0.15s;
}

.equip-slot.occupied {
  cursor: pointer;
}

.equip-slot.occupied:hover {
  transform: scale(1.05);
  filter: brightness(1.15) drop-shadow(0 4px 8px rgba(0,0,0,0.25));
}

.equip-slot.filter-active {
  filter: brightness(1.2) drop-shadow(0 0 12px rgba(255, 220, 120, 0.85));
  transform: scale(1.04);
}

.equip-ph {
  width: 60%;
  height: 60%;
  object-fit: contain;
  opacity: 0.5;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  pointer-events: none;
}

.equip-item {
  position: absolute;
  width: 70%;
  height: 70%;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.4));
  pointer-events: none;
}

/* ---- Tap Zone ---- */
#tap-zone {
  position: absolute;
  inset: 0;
  z-index: 15;
  cursor: pointer;
}

#tap-ripple-pool {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Impact motion lines */
.impact-line {
  position: absolute;
  background: linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(255,230,80,0.8) 50%, rgba(255,200,0,0) 100%);
  border-radius: 10px;
  transform-origin: 0% 50%; /* shoot outward from left edge */
  pointer-events: none;
  box-shadow: 0 0 10px rgba(255,255,255,0.8);
}

/* ---- Swipe Hint ---- */
#swipe-hint {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  pointer-events: none;
  animation: hint-pulse 3s ease-in-out infinite;
}

#swipe-hint span {
  font-family: 'RetroMario', sans-serif;
  font-size: 36px;
  color: rgba(180, 255, 180, 0.55);
  text-shadow: 0 2px 12px rgba(0,100,20,0.4);
  writing-mode: horizontal-tb;
  display: block;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.4; transform: translateY(-50%) translateX(0); }
  50%       { opacity: 0.9; transform: translateY(-50%) translateX(-10px); }
}

/* ---- Tap Particles (DOM elements) ---- */
#particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.smash-word {
  position: absolute;
  font-size: 60px;
  font-family: 'RetroMario', sans-serif;
  font-weight: 900;
  pointer-events: none;
  animation: particle-float 0.9s ease-out forwards;
  white-space: nowrap;
}

@keyframes particle-float {
  0%   { opacity: 1;   transform: translateY(0) scale(1); }
  40%  { opacity: 1;   transform: translateY(-80px) scale(1.3); }
  100% { opacity: 0;   transform: translateY(-200px) scale(0.6); }
}

/* ---- Player Character Layers ---- */
.player-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
