/* ============================================
   Asteroid Miner — Game Styles
   ============================================ */

/* --- Game Layout --- */
.game-page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 0 16px;
}

.game-container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-bottom: 48px;
  position: relative;
}

/* --- Starfield Background Canvas --- */
#starfield-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* --- HUD --- */
.hud {
  display: flex;
  gap: 24px;
  justify-content: center;
  width: 100%;
  z-index: 10;
  padding: 12px 0;
}

.hud__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  min-width: 90px;
}

.hud__label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.hud__value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  transition: color 0.15s, text-shadow 0.15s;
}

.hud__value--flash {
  color: var(--color-accent-yellow);
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.6);
}

/* --- Asteroid Zone --- */
.asteroid-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 280px;
  height: 280px;
  z-index: 10;
  flex-shrink: 0;
}

.asteroid {
  position: relative;
  width: 160px;
  height: 160px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.asteroid__body {
  width: 100%;
  height: 100%;
  border-radius: 44% 56% 52% 48% / 48% 44% 56% 52%;
  background:
    radial-gradient(circle at 35% 30%, #5a5a6e, #2a2a3a 40%, #1a1a28 80%);
  box-shadow:
    inset -8px -6px 20px rgba(0, 0, 0, 0.6),
    inset 6px 6px 16px rgba(100, 100, 140, 0.15),
    0 0 40px rgba(168, 85, 247, 0.15);
  transition: transform 0.08s ease-out, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.asteroid:active .asteroid__body {
  transform: scale(0.94);
}

.asteroid--shake .asteroid__body {
  animation: asteroidShake 0.12s ease-out;
}

@keyframes asteroidShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-3px, 1px) rotate(-1deg); }
  50% { transform: translate(2px, -2px) rotate(1deg); }
  75% { transform: translate(-1px, 2px) rotate(-0.5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* Craters */
.asteroid__crater {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.12));
  box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.asteroid__crater--1 {
  width: 28px;
  height: 28px;
  top: 22%;
  left: 55%;
}

.asteroid__crater--2 {
  width: 18px;
  height: 18px;
  top: 55%;
  left: 25%;
}

.asteroid__crater--3 {
  width: 14px;
  height: 14px;
  top: 68%;
  left: 60%;
}

.asteroid__crater--4 {
  width: 22px;
  height: 22px;
  top: 15%;
  left: 18%;
}

/* Glow surrounding asteroid — reacts to depth */
.asteroid__glow {
  position: absolute;
  inset: -30px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.12), transparent 70%);
  pointer-events: none;
  transition: opacity 0.4s;
  animation: glowPulse 4s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}

/* --- Mineral Burst Particles (spawned by JS) --- */
.mineral-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 20;
  animation: particleFly 0.7s ease-out forwards;
}

@keyframes particleFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.3);
  }
}

/* Float text showing credits earned per click */
.float-text {
  position: absolute;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 25;
  animation: floatUp 0.8s ease-out forwards;
  text-shadow: 0 0 8px currentColor;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-50px) scale(0.7);
  }
}

/* --- Upgrade Panel --- */
.upgrades-panel {
  width: 100%;
  z-index: 10;
  padding: 0 8px;
}

.upgrades-panel__title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.upgrades-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

/* Individual upgrade card */
.upgrade-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.upgrade-card:hover:not(.upgrade-card--locked) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.1);
}

.upgrade-card:active:not(.upgrade-card--locked) {
  transform: scale(0.97);
}

.upgrade-card--locked {
  opacity: 0.35;
  cursor: not-allowed;
}

.upgrade-card--flash {
  animation: upgradeFlash 0.3s ease-out;
}

@keyframes upgradeFlash {
  0% { box-shadow: 0 0 0 rgba(250, 204, 21, 0); }
  50% { box-shadow: 0 0 24px rgba(250, 204, 21, 0.3); }
  100% { box-shadow: 0 0 0 rgba(250, 204, 21, 0); }
}

.upgrade-card__icon {
  font-size: 1.6rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168, 85, 247, 0.1);
  border-radius: 10px;
  flex-shrink: 0;
}

.upgrade-card__info {
  flex: 1;
  min-width: 0;
}

.upgrade-card__name {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  margin-bottom: 2px;
}

.upgrade-card__desc {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.upgrade-card__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.upgrade-card__cost {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-accent-yellow);
  letter-spacing: 0.04em;
}

.upgrade-card__count {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--color-text-muted);
  letter-spacing: 0.06em;
}

/* --- Toast Notifications --- */
.toast-area {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  background: rgba(20, 20, 40, 0.92);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-accent-purple);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
  white-space: nowrap;
}

@keyframes toastIn {
  0% { opacity: 0; transform: translateX(40px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  0% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(40px); }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .asteroid-zone {
    width: 220px;
    height: 220px;
  }

  .asteroid {
    width: 130px;
    height: 130px;
  }

  .hud {
    gap: 12px;
  }

  .hud__item {
    padding: 6px 14px;
    min-width: 70px;
  }

  .hud__value {
    font-size: 0.95rem;
  }

  .upgrades-list {
    grid-template-columns: 1fr;
  }

  .toast-area {
    right: 12px;
    bottom: 12px;
  }
}
