/* ============================================
   Block Blast // Neon Edition
   Cyberpunk theme matching esdesigns.org
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-dark: #0a0a1a;
  --bg-panel: #12122a;
  --text-primary: #e0e0ff;
  --text-dim: rgba(224, 224, 255, 0.5);
  --accent: #00ffff;
  --accent-dim: rgba(0, 255, 255, 0.15);
  --accent-glow: rgba(0, 255, 255, 0.4);
  --neon-pink: #ff0066;
  --neon-green: #00ff88;
  --neon-blue: #00ccff;
  --neon-purple: #bf00ff;
  --neon-orange: #ff6600;
  --neon-yellow: #ffff00;
  --board-size: min(85vw, 65vh, 600px);
}

/* ---------- Global ---------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Particle Canvas ---------- */
#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ---------- Start Menu ---------- */
#startMenu {
  text-align: center;
  padding: 15vh 20px 20px;
  animation: fadeIn 0.6s ease;
}

#startMenu h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 4em;
  font-weight: 900;
  color: var(--text-primary);
  text-shadow:
    0 0 10px var(--accent-glow),
    0 0 40px rgba(0, 255, 255, 0.2);
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0.05em;
}

#startMenu h1 .title-accent {
  color: var(--accent);
  text-shadow:
    0 0 10px var(--accent),
    0 0 30px var(--accent-glow),
    0 0 60px rgba(0, 255, 255, 0.15);
}

#startMenu .subtitle {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9em;
  color: var(--accent);
  letter-spacing: 0.3em;
  margin: 10px 0 40px;
  opacity: 0.7;
}

#startMenu button {
  display: block;
  margin: 12px auto;
  width: 220px;
}

#highScoreDisplay {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85em;
  color: var(--text-dim);
  margin-top: 30px;
  letter-spacing: 0.1em;
}

/* ---------- Buttons ---------- */
button {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 8px;
  padding: 12px 24px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85em;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.05), inset 0 0 15px rgba(0, 255, 255, 0.02);
}

button:hover {
  border-color: rgba(0, 255, 255, 0.6);
  box-shadow: 0 0 25px rgba(0, 255, 255, 0.15), inset 0 0 15px rgba(0, 255, 255, 0.05);
  text-shadow: 0 0 8px var(--accent-glow);
}

button:active {
  transform: scale(0.97);
}

/* ---------- Settings Modal ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 15, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid rgba(0, 255, 255, 0.15);
  border-radius: 12px;
  padding: 30px;
  width: 300px;
  text-align: center;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.05);
}

.modal-content h2 {
  margin-top: 0;
  font-family: 'Orbitron', sans-serif;
  color: var(--accent);
  font-size: 1.2em;
  letter-spacing: 0.1em;
}

.modal-content label {
  display: inline-block;
  margin: 15px 0 8px;
  font-weight: 600;
  font-size: 0.95em;
  color: var(--text-dim);
}

.modal-content input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(0, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
}

.modal-content input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

.modal-content input[type=range]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px var(--accent-glow);
}

.modal-content button {
  margin-top: 20px;
  width: 100%;
}

/* ---------- Game Container ---------- */
#gameContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 10px 15px;
  height: 100vh;
  overflow: hidden;
  animation: fadeIn 0.4s ease;
}

/* ---------- Scoreboard ---------- */
#scoreBoard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  margin-bottom: 12px;
  width: var(--board-size);
  font-family: 'Orbitron', sans-serif;
  position: relative;
}

.score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.score-label {
  font-size: 0.65em;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.score-value {
  font-size: 1.3em;
  font-weight: 700;
  color: var(--text-primary);
}

.combo-display {
  font-size: 1.1em;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
  animation: comboPopIn 0.3s ease;
  margin-left: 4px;
}

#scoreBoard #openSettings {
  position: absolute;
  right: 0;
  font-size: 1.1em;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1;
}

/* ---------- Game Board ---------- */
#gameBoard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  width: var(--board-size);
  height: var(--board-size);
  background: var(--bg-panel);
  padding: 6px;
  border: 1px solid rgba(0, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow:
    0 0 30px rgba(0, 255, 255, 0.03),
    inset 0 0 40px rgba(0, 0, 0, 0.3);
  position: relative;
  touch-action: none;
}

.cell {
  width: 100%;
  height: 100%;
  background: rgba(0, 255, 255, 0.03);
  border: 0.5px solid rgba(0, 255, 255, 0.05);
  border-radius: 4px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

/* ---------- Neon Block Colors ---------- */
.filled1 {
  background: var(--neon-pink);
  box-shadow: 0 0 8px rgba(255, 0, 102, 0.6), inset 0 0 4px rgba(255, 255, 255, 0.2);
}
.filled2 {
  background: var(--neon-green);
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.6), inset 0 0 4px rgba(255, 255, 255, 0.2);
}
.filled3 {
  background: var(--neon-blue);
  box-shadow: 0 0 8px rgba(0, 204, 255, 0.6), inset 0 0 4px rgba(255, 255, 255, 0.2);
}
.filled4 {
  background: var(--neon-purple);
  box-shadow: 0 0 8px rgba(191, 0, 255, 0.6), inset 0 0 4px rgba(255, 255, 255, 0.2);
}
.filled5 {
  background: var(--neon-orange);
  box-shadow: 0 0 8px rgba(255, 102, 0, 0.6), inset 0 0 4px rgba(255, 255, 255, 0.2);
}
.filled6 {
  background: var(--neon-yellow);
  box-shadow: 0 0 8px rgba(255, 255, 0, 0.5), inset 0 0 4px rgba(255, 255, 255, 0.2);
}

.cell.filled1, .cell.filled2, .cell.filled3,
.cell.filled4, .cell.filled5, .cell.filled6 {
  border-radius: 5px;
  border-color: transparent;
}

/* ---------- Preview (Ghost Placement) ---------- */
.cell.preview {
  animation: previewPulse 1s ease-in-out infinite;
}

.cell.preview.preview-1 { background: rgba(255, 0, 102, 0.3); box-shadow: 0 0 6px rgba(255, 0, 102, 0.3); }
.cell.preview.preview-2 { background: rgba(0, 255, 136, 0.3); box-shadow: 0 0 6px rgba(0, 255, 136, 0.3); }
.cell.preview.preview-3 { background: rgba(0, 204, 255, 0.3); box-shadow: 0 0 6px rgba(0, 204, 255, 0.3); }
.cell.preview.preview-4 { background: rgba(191, 0, 255, 0.3); box-shadow: 0 0 6px rgba(191, 0, 255, 0.3); }
.cell.preview.preview-5 { background: rgba(255, 102, 0, 0.3); box-shadow: 0 0 6px rgba(255, 102, 0, 0.3); }
.cell.preview.preview-6 { background: rgba(255, 255, 0, 0.25); box-shadow: 0 0 6px rgba(255, 255, 0, 0.3); }

.cell.preview.invalid {
  background: rgba(255, 0, 0, 0.35) !important;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.4) !important;
  animation: none;
}

/* ---------- Piece Tray ---------- */
#pieceTray {
  display: flex;
  justify-content: center;
  margin: 15px 0;
  gap: 10px;
  touch-action: none;
}

.piece {
  position: relative;
  width: 85px;
  height: 85px;
  border: 1.5px dashed rgba(0, 255, 255, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(0, 255, 255, 0.02);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.piece:hover {
  border-color: rgba(0, 255, 255, 0.3);
  background: rgba(0, 255, 255, 0.04);
}

.piece.selected {
  border: 2px solid var(--accent);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.2), inset 0 0 10px rgba(0, 255, 255, 0.05);
  animation: selectedPulse 1.5s ease-in-out infinite;
}

/* Mini blocks in piece tray — sizes set dynamically by JS for proper fit */
.mini-block {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 3px;
}

.mini1 { background: var(--neon-pink); box-shadow: 0 0 5px rgba(255, 0, 102, 0.5); }
.mini2 { background: var(--neon-green); box-shadow: 0 0 5px rgba(0, 255, 136, 0.5); }
.mini3 { background: var(--neon-blue); box-shadow: 0 0 5px rgba(0, 204, 255, 0.5); }
.mini4 { background: var(--neon-purple); box-shadow: 0 0 5px rgba(191, 0, 255, 0.5); }
.mini5 { background: var(--neon-orange); box-shadow: 0 0 5px rgba(255, 102, 0, 0.5); }
.mini6 { background: var(--neon-yellow); box-shadow: 0 0 5px rgba(255, 255, 0, 0.4); }

/* ---------- Game Over Overlay ---------- */
#gameOver {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 10, 26, 0.96);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 16px;
  text-align: center;
  padding: 40px 35px;
  z-index: 10;
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.08);
  animation: fadeIn 0.4s ease;
  min-width: 280px;
}

#gameOver h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 2em;
  margin: 0 0 15px;
  color: var(--accent);
  text-shadow: 0 0 15px var(--accent-glow), 0 0 40px rgba(0, 255, 255, 0.15);
  letter-spacing: 0.1em;
}

#gameOver p {
  font-size: 1.1em;
  margin: 8px 0;
  color: var(--text-primary);
}

#gameOver #restartButton {
  margin-top: 20px;
  padding: 12px 30px;
}

/* ---------- Score Popup Container ---------- */
#scorePopupContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.score-popup {
  position: absolute;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.4em;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
  animation: scoreFloat 1s ease-out forwards;
  pointer-events: none;
}

/* ---------- Drag Ghost ---------- */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 60;
  opacity: 0.85;
}

.drag-ghost .mini-block {
  position: absolute;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop-in {
  0% { transform: scale(0); box-shadow: 0 0 20px currentColor; }
  80% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.cell.placed {
  animation: pop-in 0.25s ease;
}

@keyframes flash {
  0%, 100% { background-color: inherit; box-shadow: inherit; }
  50% {
    background-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow), 0 0 30px rgba(0, 255, 255, 0.2);
  }
}

.cell.clearing {
  animation: flash 0.4s ease;
}

@keyframes previewPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

@keyframes selectedPulse {
  0%, 100% {
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2), inset 0 0 10px rgba(0, 255, 255, 0.05);
    border-color: rgba(0, 255, 255, 0.8);
  }
  50% {
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.35), inset 0 0 15px rgba(0, 255, 255, 0.08);
    border-color: rgba(0, 255, 255, 1);
  }
}

@keyframes comboPopIn {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes scoreFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  50% { opacity: 0.9; transform: translateY(-30px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(calc(var(--shake-intensity, 3px) * -1)); }
  50% { transform: translateX(var(--shake-intensity, 3px)); }
  75% { transform: translateX(calc(var(--shake-intensity, 3px) * -0.5)); }
}

#gameBoard.shaking {
  animation: screenShake 0.08s linear 3;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  #startMenu h1 {
    font-size: 3em;
  }

  .piece {
    width: 70px;
    height: 70px;
  }

  /* mini-block sizes are set dynamically by JS */

  #scoreBoard {
    gap: 15px;
  }

  .score-value {
    font-size: 1.1em;
  }
}
