/* ==========================================================================
   Quantum Sweeper v5.0 - Stylesheet & Humorous Animations
   Built on Google Chrome Labs game architecture + Sudoku RPG HUD
   ========================================================================== */

:root {
  --bg-core: #020617;
  --bg-panel: rgba(15, 23, 42, 0.88);
  --grid-line: rgba(56, 189, 248, 0.18);
  --accent-primary: #38bdf8;
  --accent-secondary: #a855f7;
  --accent-warn: #f59e0b;
  --accent-danger: #ef4444;
  --accent-success: #4ade80;
  --tile-unrevealed: linear-gradient(145deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.96));
  --tile-revealed: rgba(2, 6, 23, 0.72);
  --tile-border: rgba(56, 189, 248, 0.28);
  --text-color: #e2e8f0;
  --font-mono: 'JetBrains Mono', monospace;
}

body {
  background-color: var(--bg-core);
  color: var(--text-color);
  overflow-x: hidden;
}

/* WebGL Background Canvas */
#quantum-webgl-bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  pointer-events: none;
}

.scanlines {
  position: fixed;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.14) 50%,
    rgba(0, 0, 0, 0.14)
  );
  background-size: 100% 4px;
  z-index: 998;
  pointer-events: none;
  opacity: 0.25;
}

/* Floating Navigation & Lang Switcher (Sudoku parity) */
.smart-lang-switcher {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  opacity: 0.75;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.smart-lang-switcher:hover {
  opacity: 1;
  transform: scale(1.05);
}
.lang-pill {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
  padding: 8px 16px;
  border-radius: 50px;
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}
.lang-pill:hover {
  background: var(--accent-primary);
  color: #020617;
}

.back-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #e2e8f0;
  padding: 10px 18px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.25s ease;
  backdrop-filter: blur(8px);
}
.back-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.25);
}

/* HUD & Panels */
.hud-panel,
.control-panel,
.scoreboard-panel,
.mascot-panel {
  background: var(--bg-panel);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--tile-border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55), 0 0 20px rgba(56, 189, 248, 0.08);
}

/* Board Container */
.quantum-stage-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  overflow-x: auto;
  padding: 6px;
}

.quantum-board {
  display: grid;
  gap: 4px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.82);
  border: 2px solid var(--accent-primary);
  border-radius: 14px;
  box-shadow: 0 0 35px rgba(56, 189, 248, 0.18), inset 0 0 25px rgba(168, 85, 247, 0.12);
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  perspective: 900px;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.quantum-board.board-shake {
  animation: screenEarthquake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Individual Cell */
.p-cell {
  aspect-ratio: 1;
  min-width: 26px;
  min-height: 26px;
  background: var(--tile-unrevealed);
  border: 1px solid var(--tile-border);
  border-radius: 7px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(0.78rem, 1.8vw, 1.15rem);
  cursor: pointer;
  user-select: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color 0.15s ease,
              background 0.2s ease,
              box-shadow 0.15s ease;
}

/* Zero-G Holo Dot inside unrevealed tile */
.p-cell:not(.revealed):not(.flagged):not(.questioned)::after {
  content: '';
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.32);
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.45);
  transition: transform 0.2s ease, background 0.2s ease;
}

.p-cell:not(.revealed):hover {
  transform: translateY(-2px) scale(1.06);
  border-color: var(--accent-primary);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.45);
  z-index: 4;
}

.p-cell:not(.revealed):hover::after {
  transform: scale(1.7);
  background: var(--accent-primary);
}

.p-cell.selected-cursor {
  outline: 2px solid var(--accent-warn);
  outline-offset: 1px;
  z-index: 5;
}

/* Revealed Tile with Wave Flip Animation */
.p-cell.revealed {
  background: var(--tile-revealed);
  border-color: rgba(30, 41, 59, 0.65);
  cursor: default;
  animation: quantumWaveReveal 0.38s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: var(--ripple-delay, 0ms);
}

.p-cell.revealed.chord-ready:hover {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.12);
  cursor: pointer;
}

/* Number Colors (1-8) */
.p-cell[data-num="1"] { color: #38bdf8; text-shadow: 0 0 8px rgba(56, 189, 248, 0.55); }
.p-cell[data-num="2"] { color: #4ade80; text-shadow: 0 0 8px rgba(74, 222, 128, 0.55); }
.p-cell[data-num="3"] { color: #f43f5e; text-shadow: 0 0 8px rgba(244, 63, 94, 0.6); }
.p-cell[data-num="4"] { color: #a855f7; text-shadow: 0 0 8px rgba(168, 85, 247, 0.65); }
.p-cell[data-num="5"] { color: #f59e0b; text-shadow: 0 0 8px rgba(245, 158, 11, 0.65); }
.p-cell[data-num="6"] { color: #14b8a6; text-shadow: 0 0 8px rgba(20, 184, 166, 0.65); }
.p-cell[data-num="7"] { color: #ec4899; text-shadow: 0 0 8px rgba(236, 72, 153, 0.7); }
.p-cell[data-num="8"] { color: #f8fafc; text-shadow: 0 0 12px #ef4444; }

/* Flagged, Questioned, Shielded & Black Hole States */
.p-cell.flagged {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(15, 23, 42, 0.95));
  border-color: #f59e0b;
  box-shadow: inset 0 0 10px rgba(245, 158, 11, 0.35);
  animation: flagBounceIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.p-cell.defused-shield {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.28), rgba(15, 23, 42, 0.95)) !important;
  border-color: #4ade80 !important;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.45);
}

.p-cell.questioned {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(15, 23, 42, 0.95));
  border-color: #a855f7;
  color: #d8b4fe;
}

.p-cell.scanned-safe:not(.revealed) {
  border-color: #4ade80;
  box-shadow: inset 0 0 10px rgba(74, 222, 128, 0.45);
}

.p-cell.mine-revealed {
  background: radial-gradient(circle, #450a0a 0%, #090d16 80%);
  border-color: #ef4444;
  animation: blackHoleVortex 1.4s infinite linear;
}

.p-cell.mine-exploded {
  background: radial-gradient(circle, #ef4444 0%, #7f1d1d 60%, #020617 100%) !important;
  border-color: #fef08a !important;
  box-shadow: 0 0 25px #ef4444;
  z-index: 10;
  animation: supernovaPulse 0.6s infinite alternate;
}

.p-cell.chord-error-flash {
  animation: wrongShake 0.4s ease;
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.28) !important;
}

/* ==========================================================================
   B.O.M.B.I.E. Interactive Mascot Styles & Facial Expressions
   ========================================================================== */

.mascot-stage {
  display: flex;
  align-items: center;
  gap: 14px;
}

.bombie-avatar {
  width: 82px;
  height: 82px;
  flex-shrink: 0;
  position: relative;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 35%, rgba(56, 189, 248, 0.2), rgba(2, 6, 23, 0.95));
  border: 2px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.25);
  transition: all 0.3s ease;
}

.bombie-svg {
  width: 68px;
  height: 68px;
  overflow: visible;
}

/* Mascot Mood Animations */
.bombie-avatar[data-mood="normal"] .bombie-head {
  animation: botFloat 2.8s ease-in-out infinite;
}

.bombie-avatar[data-mood="panic"] {
  border-color: #f59e0b;
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.55);
  animation: botChatter 0.14s infinite;
}
.bombie-avatar[data-mood="panic"] .bombie-sweat {
  opacity: 1 !important;
  animation: sweatDrop 0.65s infinite;
}
.bombie-avatar[data-mood="panic"] .bombie-eye {
  transform: scale(1.25);
  transform-origin: center;
}

.bombie-avatar[data-mood="cool"] {
  border-color: #4ade80;
  box-shadow: 0 0 24px rgba(74, 222, 128, 0.55);
}
.bombie-avatar[data-mood="cool"] .bombie-shades {
  transform: translateY(0) !important;
  opacity: 1 !important;
}

.bombie-avatar[data-mood="charred"] {
  border-color: #ef4444;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.35), #090d16);
}
.bombie-avatar[data-mood="charred"] .bombie-soot {
  opacity: 0.9 !important;
}

.bombie-avatar[data-mood="bored"] .bombie-tea {
  opacity: 1 !important;
}

.bombie-shades {
  transform: translateY(-30px);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
.bombie-sweat,
.bombie-soot,
.bombie-tea {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.bombie-bubble {
  position: relative;
  background: rgba(2, 6, 23, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 12px;
  padding: 10px 13px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.4;
  color: #e0f2fe;
  min-height: 62px;
  display: flex;
  align-items: center;
  flex: 1;
}

.speech-pop {
  animation: bubblePop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Comic-Book Floating Popups, Cartoon Particles & Gadget Actors
   ========================================================================== */

#comic-fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2500;
  overflow: hidden;
}

.comic-pop {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, -6deg));
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.15rem;
  padding: 6px 14px;
  border-radius: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  animation: comicFloatUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.comic-pop--cascade {
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  color: #020617;
  border: 2px solid #fff;
}
.comic-pop--chord {
  background: linear-gradient(135deg, #4ade80, #10b981);
  color: #020617;
  border: 2px solid #fff;
}
.comic-pop--flag {
  background: #f59e0b;
  color: #020617;
  border: 2px solid #fef08a;
}
.comic-pop--shield {
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  border: 2px solid #fde047;
}
.comic-pop--explosion {
  background: #ef4444;
  color: #fff;
  font-size: 1.45rem;
  border: 3px solid #fde047;
}
.comic-pop--gadget {
  background: #0f172a;
  color: #38bdf8;
  border: 2px solid #38bdf8;
}

.cartoon-particle {
  position: absolute;
  font-size: 1.35rem;
  transform: translate(-50%, -50%);
  animation: particleBurst 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.gadget-actor {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 2.3rem;
  animation: gadgetFlyIn 1.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.drone-beam {
  position: absolute;
  top: 75%;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 64px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.55) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulseBeam 0.3s infinite alternate;
}

/* Tactical Gadget Buttons */
.gadget-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 9px;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  transition: all 0.2s ease;
}
.gadget-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.14);
  transform: translateX(3px);
}
.gadget-btn.active-gadget {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.35);
}
.gadget-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Wire Cutting Minigame Buttons */
.wire-choice-btn {
  position: relative;
  padding: 14px 18px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-weight: 800;
  text-transform: uppercase;
  border: 2px solid rgba(255, 255, 255, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.wire-choice-btn:hover {
  transform: scale(1.04);
}
.wire-red { background: linear-gradient(90deg, #991b1b, #ef4444, #991b1b); color: #fff; }
.wire-blue { background: linear-gradient(90deg, #1e40af, #3b82f6, #1e40af); color: #fff; }
.wire-yellow { background: linear-gradient(90deg, #92400e, #f59e0b, #92400e); color: #020617; }

/* Scoreboard Badges (Sudoku parity) */
.scoreboard-table { font-family: var(--font-mono); font-size: 0.85rem; }
.rank-badge {
  display: inline-flex;
  width: 24px;
  height: 24px;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background: #334155;
  color: #fff;
  font-size: 0.75rem;
}
.rank-1 { background: #f59e0b; color: #000; font-weight: 800; }
.rank-2 { background: #94a3b8; color: #000; font-weight: 800; }
.rank-3 { background: #b45309; color: #fff; font-weight: 800; }

/* Keyframe Animations */
@keyframes quantumWaveReveal {
  0% {
    opacity: 0.2;
    transform: rotateX(85deg) scale(0.75);
    background: rgba(56, 189, 248, 0.45);
  }
  60% {
    transform: rotateX(-12deg) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: rotateX(0deg) scale(1);
  }
}

@keyframes flagBounceIn {
  0% { transform: scale(0.4) rotate(-25deg); }
  70% { transform: scale(1.18) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes blackHoleVortex {
  0% { transform: rotate(0deg) scale(0.95); }
  50% { transform: rotate(180deg) scale(1.06); }
  100% { transform: rotate(360deg) scale(0.95); }
}

@keyframes supernovaPulse {
  0% { transform: scale(0.96); box-shadow: 0 0 12px #ef4444; }
  100% { transform: scale(1.1); box-shadow: 0 0 28px #fde047; }
}

@keyframes screenEarthquake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-8px, -5px) rotate(-1.5deg); }
  30% { transform: translate(8px, 4px) rotate(1.5deg); }
  45% { transform: translate(-6px, 6px) rotate(-1deg); }
  60% { transform: translate(6px, -4px) rotate(1deg); }
  75% { transform: translate(-4px, 2px) rotate(-0.5deg); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes botFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-3px); }
}

@keyframes botChatter {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2px, 1px); }
}

@keyframes sweatDrop {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(10px); opacity: 0; }
}

@keyframes bubblePop {
  0% { transform: scale(0.92); opacity: 0.5; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes comicFloatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.4) rotate(var(--rot, -6deg));
  }
  22% {
    opacity: 1;
    transform: translate(-50%, -65%) scale(1.15) rotate(var(--rot, -6deg));
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -125%) scale(1) rotate(var(--rot, -6deg));
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -155%) scale(0.85) rotate(var(--rot, -6deg));
  }
}

@keyframes particleBurst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.25) rotate(var(--spin));
  }
}

@keyframes gadgetFlyIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -180%) scale(0.4) rotate(-25deg);
  }
  35% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.25) rotate(8deg);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.95) rotate(-8deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -90%) scale(0.5) rotate(0deg);
  }
}

@keyframes pulseBeam {
  0% { transform: translateX(-50%) scale(0.85); opacity: 0.4; }
  100% { transform: translateX(-50%) scale(1.25); opacity: 0.85; }
}

@media (max-width: 768px) {
  .quantum-board {
    gap: 3px;
    padding: 6px;
  }
  .p-cell {
    min-width: 22px;
    min-height: 22px;
    border-radius: 5px;
  }
  .back-btn {
    bottom: 10px;
    left: 10px;
    padding: 8px 12px;
    font-size: 0.72rem;
  }
  .smart-lang-switcher {
    top: auto;
    right: 12px;
    bottom: 12px;
    opacity: 0.95;
  }
}

