/* ═══════════════════════════════════════════
   ATMOSPHERE & EFFECTS
   ═══════════════════════════════════════════ */

/* ─── Starfield background ─── */
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: star-twinkle var(--dur, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes star-twinkle {
  0%, 100% { opacity: var(--min-o, 0.1); transform: scale(1); }
  50% { opacity: var(--max-o, 0.7); transform: scale(1.3); }
}

/* ─── Shooting / falling stars ─── */
.shooting-star {
  position: absolute;
  width: var(--trail, 80px);
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.7), rgba(255,255,255,0));
  border-radius: 1px;
  opacity: 0;
  transform: rotate(var(--angle, -30deg));
  animation: shooting-star var(--speed, 1.2s) linear forwards;
  animation-delay: var(--delay, 0s);
  pointer-events: none;
  filter: drop-shadow(0 0 3px rgba(200, 180, 255, 0.6));
}

@keyframes shooting-star {
  0%   { opacity: 0; transform: rotate(var(--angle, -30deg)) translateX(0); }
  10%  { opacity: 1; }
  70%  { opacity: 0.6; }
  100% { opacity: 0; transform: rotate(var(--angle, -30deg)) translateX(var(--dist, 300px)); }
}

/* Vignette — deeper at edges, above stars */
.screen--game::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 35%, rgba(6, 6, 18, var(--depth-vignette, 0.4)) 100%);
  transition: background 1.5s ease;
}

/* Grid ambient aura — animated pulsing glow */
.grid-wrap::before {
  content: '';
  position: absolute;
  inset: -30px;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 70%, rgba(99, 102, 241, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
  animation: aura-breathe 6s ease-in-out infinite;
}

.grid-wrap::after {
  content: '';
  position: absolute;
  inset: -50px;
  border-radius: 30px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(168, 85, 247, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: -2;
  animation: aura-breathe 8s ease-in-out infinite reverse;
}

@keyframes aura-breathe {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

/* Entity glow effects on cells */
.cell[data-glow="accent"] {
  box-shadow: 0 0 8px var(--c-accent-glow);
}

.cell[data-glow="gold"] {
  box-shadow: 0 0 8px var(--c-gold-glow);
}

.cell[data-glow="danger"] {
  box-shadow: 0 0 8px var(--c-danger-glow);
}

/* Float animation for NPCs, bosses */
.cell--float {
  animation: entity-float 3s ease-in-out infinite;
}

@keyframes entity-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Flash effects */
.cell--flash-red {
  animation: flash-red 0.3s ease-out;
}

.cell--flash-gold {
  animation: flash-gold 0.4s ease-out;
}

.cell--flash-heal {
  animation: flash-heal 0.4s ease-out;
}

@keyframes flash-red {
  0% { background: var(--c-danger); box-shadow: 0 0 15px var(--c-danger-glow); }
  100% { background: var(--c-floor); box-shadow: none; }
}

@keyframes flash-gold {
  0% { background: rgba(251, 191, 36, 0.4); box-shadow: 0 0 15px var(--c-gold-glow); }
  100% { background: var(--c-floor); box-shadow: none; }
}

@keyframes flash-heal {
  0% { background: rgba(52, 211, 153, 0.4); box-shadow: 0 0 15px rgba(52, 211, 153, 0.4); }
  100% { background: var(--c-floor); box-shadow: none; }
}

/* Dust particles — burst from cells on interaction */
.dust-particle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(200, 190, 220, 0.7);
  pointer-events: none;
  z-index: 5;
  top: 50%;
  left: 50%;
  box-shadow: 0 0 4px rgba(180, 170, 200, 0.4);
  animation: dust-float 600ms ease-out var(--delay, 0ms) forwards;
}

@keyframes dust-float {
  0% { opacity: 0.7; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx, 10px), var(--dy, -10px)) scale(0.3); }
}

/* Gold particles — full screen burst on gold pickup */
.gold-particle {
  position: fixed;
  width: var(--size, 10px);
  height: var(--size, 10px);
  border-radius: 50%;
  background: var(--c-gold);
  pointer-events: none;
  z-index: 300;
  top: 50%;
  left: 50%;
  box-shadow: 0 0 10px var(--c-gold-glow), 0 0 22px rgba(251, 191, 36, 0.45);
  animation: gold-float 1100ms cubic-bezier(0.2, 0.9, 0.3, 1) var(--delay, 0ms) forwards;
}

@keyframes gold-float {
  0%   { opacity: 1; transform: translate(0, 0) scale(1) rotate(0); }
  30%  { opacity: 1; transform: translate(calc(var(--dx, 0px) * 0.4), calc(var(--dy, -40px) * 0.3)) scale(1.25) rotate(90deg); }
  100% { opacity: 0; transform: translate(var(--dx, 0px), var(--dy, -40px)) scale(0.25) rotate(360deg); }
}

/* Gold burst central flash — bright shock ring behind the particle fan */
.gold-burst-flash {
  position: fixed;
  top: 50%;
  left: 50%;
  pointer-events: none;
  z-index: 299;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.85) 0%, rgba(251, 191, 36, 0.3) 35%, transparent 70%);
  animation: gold-flash 520ms ease-out forwards;
}

@keyframes gold-flash {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.25); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.6); }
}

/* Chest pulse — persistent breathing glow on unopened chests */
.cell--chest {
  animation: chest-pulse 2.4s ease-in-out infinite;
}

@keyframes chest-pulse {
  0%, 100% {
    box-shadow: 0 0 4px rgba(251, 191, 36, 0.25), inset 0 0 3px rgba(251, 191, 36, 0.1);
  }
  50% {
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.55), inset 0 0 8px rgba(251, 191, 36, 0.25);
  }
}

/* COMBO! text — big golden text on synergy activation */
.combo-text {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--c-gold);
  text-shadow: 0 0 20px var(--c-gold-glow), 0 0 40px rgba(251, 191, 36, 0.3);
  letter-spacing: 6px;
  pointer-events: none;
  z-index: 300;
  animation: combo-pop 1s ease-out forwards;
}

@keyframes combo-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.2); }
  30% { transform: translateX(-50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1) translateY(-30px); }
}

/* Heal pulse — green flash on entire screen */
.hud--heal-pulse {
  animation: heal-pulse 0.6s ease-out;
}

@keyframes heal-pulse {
  0% { box-shadow: inset 0 0 40px rgba(52, 211, 153, 0.5), inset 0 0 80px rgba(52, 211, 153, 0.2); }
  40% { box-shadow: inset 0 0 60px rgba(52, 211, 153, 0.7), inset 0 0 120px rgba(52, 211, 153, 0.3); }
  100% { box-shadow: none; }
}

/* Heal vignette flash — green pulse on heal */
.vignette-flash--heal {
  animation: vignette-heal 0.5s ease-out;
}

@keyframes vignette-heal {
  0% { box-shadow: inset 0 0 80px rgba(52, 211, 153, 0.5); }
  100% { box-shadow: none; }
}

/* Gold vignette flash — level clear */
.vignette-flash--gold {
  animation: vignette-gold 0.6s ease-out;
}

@keyframes vignette-gold {
  0% { box-shadow: inset 0 0 60px rgba(251, 191, 36, 0.5); }
  100% { box-shadow: none; }
}

/* Title screen shimmer */
.screen--title h1 {
  animation: title-shimmer 4s ease-in-out infinite;
}

@keyframes title-shimmer {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.3)); }
  50% { filter: drop-shadow(0 0 40px rgba(168, 85, 247, 0.5)) drop-shadow(0 0 60px rgba(251, 191, 36, 0.15)); }
}

/* ─── Intro overlay (combat / level) ─── */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 18, 0.88);
  animation: intro-fade-in 0.5s ease-out;
  cursor: pointer;
  padding: 32px;
}

.intro-overlay[hidden] { display: none; }

.intro-overlay__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 380px;
  padding: 28px 28px 20px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6), 0 0 80px rgba(168, 85, 247, 0.08);
  animation: intro-card-in 0.5s ease-out;
}

.intro-overlay__icon {
  font-size: 2.5rem;
  opacity: 0.6;
  filter: drop-shadow(0 0 12px currentColor);
}

.intro-overlay__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--c-text-bright);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.intro-overlay__divider {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-accent), transparent);
}

.intro-overlay__text {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--c-text);
  text-align: center;
  line-height: 1.7;
  font-style: italic;
}

.intro-overlay__objective {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--c-gold);
  text-align: center;
  line-height: 1.4;
  opacity: 0.8;
  letter-spacing: 0.3px;
}

.intro-overlay__hint {
  font-size: 0.7rem;
  color: var(--c-text-dim);
  letter-spacing: 1px;
  animation: hint-blink 2s ease-in-out infinite;
}

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

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

/* Smooth step transition on player cell */
.cell--player {
  transition: all 0.12s ease-out;
}

.cell__under {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  pointer-events: none;
}

/* Secret wall proximity hint — subtle shimmer */
.cell--secret-hint {
  animation: secret-shimmer 1.5s ease-out;
}

@keyframes secret-shimmer {
  0% { box-shadow: inset 0 0 6px rgba(168, 85, 247, 0.5); border-color: rgba(168, 85, 247, 0.3); }
  30% { box-shadow: inset 0 0 10px rgba(168, 85, 247, 0.3); border-color: rgba(168, 85, 247, 0.2); }
  100% { box-shadow: inset 0 1px 2px rgba(0,0,0,0.5); border-color: var(--c-wall-edge); }
}
