/* ==========================================================================
   General Page Styling
   ========================================================================== */
* {
  box-sizing: border-box;
}

body {
  background-image: url('https://raw.githubusercontent.com/arpit456jain/Amazing-Js-Projects/master/Candy%20Crush/utils/bg.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  color: #3d3429;
  overflow-x: hidden;
}

/* ==========================================================================
   Main Game Container
   ========================================================================== */
.game-container {
  display: none; /* Shown via JS when game starts */
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
  padding: 20px;
  z-index: 1;
}

/* ==========================================================================
   Grid Styling (Strict 8x8 CSS Grid - Prevents Any Overflow or Wrap Errors)
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(8, 70px);
  grid-template-rows: repeat(8, 70px);
  width: 560px;
  height: 560px;
  box-sizing: content-box; /* Padding is added to the outside, preserving the full 560px grid */
  padding: 6px;
  background-color: rgba(40, 55, 75, 0.7);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  position: relative;
  user-select: none;
  overflow: hidden;
  transition: background-color 0.5s ease, box-shadow 0.5s ease;
}

/* ==========================================================================
   Stage-Themed Grid Backgrounds & Boss Outlines
   ========================================================================== */
.grid.stage-town {
  background-color: rgba(40, 55, 75, 0.7);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.2);
}

/* Area A: Transparent dark green */
.grid.stage-areaA {
  background-color: rgba(14, 50, 24, 0.78);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(46, 204, 113, 0.4), 0 0 16px rgba(46, 204, 113, 0.25);
}

/* Area B: Transparent light blue */
.grid.stage-areaB {
  background-color: rgba(18, 62, 100, 0.74);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(0, 210, 211, 0.4), 0 0 16px rgba(0, 210, 211, 0.25);
}

/* Area C: Transparent red */
.grid.stage-areaC {
  background-color: rgba(75, 18, 18, 0.76);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(231, 76, 60, 0.4), 0 0 16px rgba(231, 76, 60, 0.25);
}

/* Area D: Transparent purple */
.grid.stage-areaD {
  background-color: rgba(55, 18, 75, 0.76);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(155, 89, 182, 0.4), 0 0 16px rgba(155, 89, 182, 0.25);
}

/* Boss Stage: Default color at first */
.grid.stage-boss {
  background-color: rgba(40, 55, 75, 0.7);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Boss 2nd Threshold: Area A (dark green) & Area B (light blue) themed outline */
.grid.stage-boss.boss-outline-ab {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5),
              0 0 0 3px #27ae60,
              0 0 0 6px #00d2d3,
              0 0 22px rgba(0, 210, 211, 0.7) !important;
  animation: bossOutlinePulseAB 2s infinite alternate ease-in-out;
}

@keyframes bossOutlinePulseAB {
  0% {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 0 3px #27ae60, 0 0 0 6px #00d2d3, 0 0 16px rgba(39, 174, 96, 0.6);
  }
  100% {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 0 4px #00d2d3, 0 0 0 7px #2ecc71, 0 0 28px rgba(0, 210, 211, 0.9);
  }
}

/* Boss 3rd Threshold: Area C (red) & Area D (purple) themed outline */
.grid.stage-boss.boss-outline-cd {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5),
              0 0 0 3px #e74c3c,
              0 0 0 6px #8e44ad,
              0 0 25px rgba(231, 76, 60, 0.75),
              0 0 35px rgba(142, 68, 173, 0.7) !important;
  animation: bossOutlinePulseCD 1.5s infinite alternate ease-in-out;
}

@keyframes bossOutlinePulseCD {
  0% {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 0 3px #e74c3c, 0 0 0 6px #8e44ad, 0 0 20px rgba(231, 76, 60, 0.6);
  }
  100% {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 0 4px #be2edd, 0 0 0 7px #ff3838, 0 0 36px rgba(255, 56, 56, 0.95);
  }
}

.grid.screen-shake {
  animation: gridShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes gridShake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.grid div {
  height: 70px;
  width: 70px;
  box-sizing: border-box;
  background-size: cover;
  background-position: center;
  border-radius: 8px;
  cursor: grab;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.grid div:active {
  cursor: grabbing;
}

.grid div:hover {
  transform: scale(1.05);
  z-index: 5;
}

/* Selected candy highlight (for Click-to-Swap) */
.grid div.selected-candy {
  box-shadow: 0 0 0 3px #00f0ff, 0 0 18px rgba(0, 240, 255, 0.9) !important;
  transform: scale(1.08) !important;
  z-index: 10 !important;
  animation: selectedPulse 0.7s infinite alternate ease-in-out;
}

@keyframes selectedPulse {
  0% { transform: scale(1.05); filter: brightness(1.1); }
  100% { transform: scale(1.12); filter: brightness(1.3); }
}

/* ==========================================================================
   Monster Candy Shine & Visual Effects (5 Turns Limit)
   ========================================================================== */
.monster-candy {
  position: relative;
  border-radius: 8px !important;
  box-shadow: 0 0 14px 4px rgba(255, 215, 0, 0.95), inset 0 0 8px rgba(255, 255, 255, 0.85);
  border: 2px solid #ffd700;
  animation: monsterPulse 1.4s infinite alternate ease-in-out;
  overflow: visible !important;
}

@keyframes monsterPulse {
  0% {
    box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.8), inset 0 0 6px rgba(255, 255, 255, 0.7);
    filter: brightness(1.1);
  }
  100% {
    box-shadow: 0 0 22px 7px rgba(255, 140, 0, 1), inset 0 0 14px rgba(255, 255, 255, 1);
    filter: brightness(1.35);
  }
}

/* Shining sheen light sweep effect */
.monster-candy::before {
  content: '';
  position: absolute;
  top: -60%;
  left: -60%;
  width: 220%;
  height: 220%;
  background: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.75) 50%,
    rgba(255, 255, 255, 0) 70%
  );
  transform: rotate(25deg);
  animation: shineSweep 2.2s infinite linear;
  pointer-events: none;
  z-index: 2;
}

@keyframes shineSweep {
  0% { transform: translateX(-120%) rotate(25deg); }
  100% { transform: translateX(120%) rotate(25deg); }
}

/* Monster turns countdown badge */
.monster-candy::after {
  content: '👾 ' attr(data-turns);
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(20, 20, 25, 0.9);
  color: #ffd700;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid #ffd700;
  pointer-events: none;
  z-index: 3;
  line-height: 1.2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Critical warning (1 turn left!) */
.monster-candy.critical {
  border-color: #ff2222 !important;
  animation: monsterCritical 0.45s infinite alternate ease-in-out !important;
}

.monster-candy.critical::after {
  background: rgba(180, 0, 0, 0.95);
  color: #ffffff;
  border-color: #ff4444;
  content: '💥 ' attr(data-turns);
  animation: criticalBadgePulse 0.45s infinite alternate ease-in-out;
}

@keyframes monsterCritical {
  0% {
    box-shadow: 0 0 12px 4px rgba(255, 30, 30, 0.85);
    filter: brightness(1.2);
  }
  100% {
    box-shadow: 0 0 28px 9px rgba(255, 0, 0, 1);
    filter: brightness(1.55);
  }
}

@keyframes criticalBadgePulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.15); }
}

/* Explosion animation for tiles destroyed by monster self-explosion */
.exploding-tile {
  animation: explodeTileAnim 0.4s forwards ease-out !important;
  z-index: 10;
}

@keyframes explodeTileAnim {
  0% {
    transform: scale(1);
    filter: brightness(2.5) drop-shadow(0 0 12px #ff4500);
    opacity: 1;
  }
  50% {
    transform: scale(1.25);
    background-color: #ff3300 !important;
    opacity: 0.9;
  }
  100% {
    transform: scale(0.1);
    opacity: 0;
  }
}

/* ==========================================================================
   Special Hazard Candies: Frozen & Shadow
   ========================================================================== */
/* Frozen Candy (Area B) */
.grid div.frozen-candy {
  position: relative;
  border: 3px solid #00d2d3 !important;
  box-shadow: 0 0 14px rgba(0, 210, 211, 0.9), inset 0 0 10px rgba(255, 255, 255, 0.9) !important;
  cursor: not-allowed !important;
  filter: contrast(1.15) brightness(1.1);
}

.grid div.frozen-candy::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(220, 245, 255, 0.45);
  border-radius: 6px;
  pointer-events: none;
  z-index: 2;
}

.grid div.frozen-candy:not(.monster-candy)::after {
  content: '❄️';
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 13px;
  background: rgba(15, 30, 45, 0.85);
  padding: 1px 4px;
  border-radius: 6px;
  border: 1px solid #00d2d3;
  pointer-events: none;
  z-index: 3;
}

/* Monster Candy that has also been frozen (doubled timer) */
.grid div.monster-candy.frozen-candy {
  border: 3px solid #00d2d3 !important;
  box-shadow: 0 0 16px 4px rgba(0, 210, 211, 0.95), inset 0 0 12px rgba(255, 255, 255, 0.9) !important;
}

.grid div.monster-candy.frozen-candy::after {
  content: '❄️👾 ' attr(data-turns);
  background: rgba(10, 25, 40, 0.95);
  color: #74b9ff;
  border-color: #00d2d3;
}

/* Shadow Candy (Area D - Instant Defeat Hazard) */
.grid div.shadow-candy {
  position: relative;
  border-radius: 8px !important;
  border: 2px solid #8e44ad !important;
  box-shadow: 0 0 16px 5px rgba(142, 68, 173, 0.95), inset 0 0 10px rgba(0, 0, 0, 0.9);
  animation: shadowAuraPulse 1.2s infinite alternate ease-in-out;
  overflow: visible !important;
  z-index: 4;
}

@keyframes shadowAuraPulse {
  0% {
    box-shadow: 0 0 12px 3px rgba(108, 52, 131, 0.8), inset 0 0 8px rgba(0, 0, 0, 0.8);
    filter: brightness(0.9) contrast(1.2);
  }
  100% {
    box-shadow: 0 0 24px 8px rgba(155, 89, 182, 1), inset 0 0 15px rgba(0, 0, 0, 0.95);
    filter: brightness(0.7) contrast(1.4);
  }
}

.grid div.shadow-candy::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(142, 68, 173, 0.4) 0%, rgba(20, 5, 30, 0.7) 100%);
  border-radius: 6px;
  pointer-events: none;
  z-index: 2;
}

.grid div.shadow-candy::after {
  content: '💀 ' attr(data-shadow-time) 's';
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(20, 5, 30, 0.95);
  color: #e056fd;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid #be2edd;
  pointer-events: none;
  z-index: 3;
  line-height: 1.2;
}

.grid div.shadow-candy.critical-shadow {
  border-color: #ff0055 !important;
  animation: shadowCriticalPulse 0.4s infinite alternate ease-in-out !important;
}

.grid div.shadow-candy.critical-shadow::after {
  background: rgba(180, 0, 50, 0.95);
  color: #ffffff;
  border-color: #ff0055;
  content: '⚠️ ' attr(data-shadow-time) 's';
  animation: criticalBadgePulse 0.4s infinite alternate ease-in-out;
}

@keyframes shadowCriticalPulse {
  0% { box-shadow: 0 0 15px 5px rgba(255, 0, 85, 0.9); }
  100% { box-shadow: 0 0 30px 10px rgba(255, 0, 0, 1); }
}

/* Contagion Spread Flash (Area A) */
.contagion-spread {
  animation: contagionFlash 0.5s ease-out !important;
}

@keyframes contagionFlash {
  0% { transform: scale(1.18); box-shadow: 0 0 20px #2ecc71; filter: brightness(1.6); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(0,0,0,0); }
}

/* Frost Freeze Flash (Area B) */
.frost-flash {
  animation: frostFlashAnim 0.5s ease-out !important;
}

@keyframes frostFlashAnim {
  0% { transform: scale(1.15); box-shadow: 0 0 22px #00d2d3; filter: brightness(1.8); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(0,0,0,0); }
}

/* ==========================================================================
   Scoreboard & Stage HUD Styling
   ========================================================================== */
.scoreBoard {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(240, 248, 255, 0.88));
  border-radius: 20px;
  width: 280px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  gap: 14px;
}

/* Adventure Stage Info */
.stage-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  border-bottom: 2px dashed #e2dcd5;
  padding-bottom: 12px;
}

.stage-badge {
  background: linear-gradient(135deg, #ff7b00, #ffae19);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 12px;
  border-radius: 12px;
  margin-bottom: 4px;
  box-shadow: 0 2px 6px rgba(255, 123, 0, 0.35);
}

.stage-title {
  margin: 4px 0 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: #3b2e2a;
}

/* Thresholds & Progress Bar */
.threshold-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #6d6155;
  font-weight: 600;
}

.progress-bar-bg {
  width: 100%;
  height: 12px;
  background-color: #e0dad3;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff7b00 0%, #ffc837 50%, #4cd137 100%);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.threshold-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #e74c3c;
  z-index: 2;
}

.threshold-marker.t1-marker {
  left: 33.33%; /* Updated dynamically in JS */
  background-color: #e74c3c;
}

.threshold-marker.t2-marker {
  left: 60%; /* Updated dynamically in JS */
  background-color: #f39c12;
  box-shadow: 0 0 4px #f39c12;
}

.threshold-marker.t3-marker {
  left: 75%; /* Updated dynamically in JS */
  background-color: #9b59b6;
  box-shadow: 0 0 4px #9b59b6;
}

/* Monster Threat HUD */
.monster-hud {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 8px;
  background: rgba(255, 235, 235, 0.85);
  border: 1px solid #ffccd2;
  border-radius: 10px;
  padding: 8px 10px;
  gap: 6px;
}

.threat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}

.threat-label {
  color: #632222;
}

.strikes-display {
  font-size: 14px;
  letter-spacing: 2px;
}

.defused-count {
  color: #27ae60;
  font-weight: 700;
}

/* Score Section */
.score-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.score-section h3 {
  font-family: 'Montserrat', sans-serif;
  text-transform: uppercase;
  margin: 0;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #8c7d6b;
}

.score-section h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 38px;
  margin: 4px 0 0 0;
  color: #2d3436;
  font-weight: 800;
}

/* Timer Display */
.timer-display {
  font-size: 18px;
  font-weight: 700;
  color: #d63031;
  min-height: 22px;
}

/* Controls Section in Scoreboard */
.controls-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  width: 100%;
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.map-btn {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(108, 92, 231, 0.35);
}

.exit-btn {
  background: linear-gradient(135deg, #ff7675, #d63031);
  color: white;
  box-shadow: 0 4px 10px rgba(214, 48, 49, 0.35);
}

.action-btn:hover {
  transform: translateY(-2px);
}

/* ==========================================================================
   Mode Selection Screen
   ========================================================================== */
#modeSelection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  background: radial-gradient(circle at center, rgba(30, 40, 55, 0.85) 0%, rgba(15, 20, 30, 0.95) 100%);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

#modeSelection h2 {
  font-size: 28px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 28px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.mode-options {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 340px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  text-align: left;
}

.mode-btn:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45);
}

.btn-icon {
  font-size: 32px;
}

.btn-content {
  display: flex;
  flex-direction: column;
}

.btn-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
}

.btn-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 3px;
}

.adventure-btn {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.timed-btn {
  background: linear-gradient(135deg, #0984e3, #74b9ff);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Adventure Stage Selection Map Screen
   ========================================================================== */
.stage-select-overlay {
  display: none; /* Shown via JS */
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, rgba(20, 25, 40, 0.92) 0%, rgba(10, 15, 25, 0.98) 100%);
  z-index: 60;
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 24px;
}

.stage-select-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  width: 100%;
  max-width: 820px;
  padding: 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.3);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stage-select-header {
  text-align: center;
  border-bottom: 2px dashed #e2dcd5;
  padding-bottom: 16px;
}

.stage-select-header h2 {
  font-size: 28px;
  font-weight: 800;
  color: #2d3436;
  margin: 0 0 6px 0;
}

.stage-select-header p {
  font-size: 13px;
  color: #636e72;
  margin: 0 0 14px 0;
}

.map-progress-summary {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.progress-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 14px;
  background: #edf2f7;
  color: #4a5568;
}

.badge-locked {
  background: #ffe3e3;
  color: #c53030;
  border: 1px solid #feb2b2;
}

.badge-unlocked {
  background: #feebc8;
  color: #c05621;
  border: 1px solid #fbd38d;
  animation: criticalBadgePulse 1s infinite alternate;
}

/* Stage Grid Cards */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .stage-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .stage-grid {
    grid-template-columns: 1fr;
  }
}

.stage-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: all 0.22s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.stage-card-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.stage-card-title {
  font-size: 16px;
  font-weight: 800;
  color: #2d3436;
  margin: 0 0 2px 0;
}

.stage-card-subtitle {
  font-size: 11px;
  color: #718096;
  margin: 0 0 8px 0;
}

.stage-card-goal {
  font-size: 11px;
  font-weight: 700;
  color: #4a5568;
  background: #edf2f7;
  padding: 2px 8px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.stage-status-btn {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: none;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* Available Stage Card */
.stage-card.available {
  border-color: #a29bfe;
  cursor: pointer;
}

.stage-card.available:hover {
  transform: translateY(-4px);
  border-color: #6c5ce7;
  box-shadow: 0 10px 22px rgba(108, 92, 231, 0.25);
}

.stage-card.available .stage-status-btn {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #ffffff;
}

/* Cleared Stage Card */
.stage-card.cleared {
  background: #f7fafc;
  border-color: #9ae6b4;
  opacity: 0.9;
}

.stage-card.cleared .stage-status-btn {
  background: #c6f6d5;
  color: #22543d;
  cursor: default;
}

/* Locked Stage Card */
.stage-card.locked {
  background: #edf2f7;
  border-color: #cbd5e0;
  opacity: 0.65;
}

.stage-card.locked .stage-status-btn {
  background: #e2e8f0;
  color: #718096;
  cursor: not-allowed;
}

/* Boss Stage Card */
.stage-card.boss-card {
  grid-column: span 1;
}

@media (min-width: 769px) {
  .stage-card.boss-card {
    grid-column: 3;
    grid-row: 2;
  }
}

.stage-card.boss-card.unlocked {
  border: 2px solid #ff4757;
  background: linear-gradient(135deg, #fff5f5, #ffffff);
  animation: bossPulseGlow 1.4s infinite alternate ease-in-out;
  cursor: pointer;
}

@keyframes bossPulseGlow {
  0% { box-shadow: 0 0 10px rgba(255, 71, 87, 0.4); border-color: #ff4757; }
  100% { box-shadow: 0 0 24px rgba(255, 71, 87, 0.9); border-color: #ff6b81; transform: scale(1.02); }
}

.stage-card.boss-card.unlocked .stage-status-btn {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: #ffffff;
  font-weight: 800;
}

.stage-select-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
}

.text-btn {
  background: transparent;
  color: #e55039;
  font-size: 12px;
  width: auto;
  padding: 6px 12px;
  border: 1px dashed #e55039;
  border-radius: 8px;
}

.text-btn:hover {
  background: #fff0ed;
}

/* ==========================================================================
   Toast Notification Banner
   ========================================================================== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(30, 39, 46, 0.95);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Modal Dialog (Victory / Defeat)
   ========================================================================== */
.modal-overlay {
  display: none; /* Shown via JS */
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 15, 25, 0.82);
  backdrop-filter: blur(8px);
  z-index: 80;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 32px 28px;
  width: 380px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.modal-card h2 {
  font-size: 24px;
  font-weight: 800;
  color: #2d3436;
  margin: 0 0 8px 0;
}

.modal-card p {
  font-size: 13px;
  color: #636e72;
  margin: 0 0 18px 0;
  line-height: 1.4;
}

.modal-stats {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #2d3436;
}

.stat-row {
  display: flex;
  justify-content: space-between;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.35);
}

.secondary-btn {
  background: #dfe6e9;
  color: #2d3436;
}

.modal-btn:hover {
  transform: translateY(-2px);
}
