@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@400;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0e2a;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(
      -35deg,
      transparent,
      transparent 40px,
      rgba(100, 120, 255, 0.015) 40px,
      rgba(100, 120, 255, 0.015) 42px
    ),
    radial-gradient(ellipse at 20% 50%, rgba(60, 80, 200, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(100, 60, 200, 0.1) 0%, transparent 60%),
    linear-gradient(180deg, #080c24 0%, #0d1235 50%, #0a0e2a 100%);
  z-index: -1;
  transition: background 2s ease-in-out, opacity 1.5s ease-in-out;
}

#game-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transform: scale(var(--game-scale, 1));
  transform-origin: center center;
}

/* Side panels */
.side-panel {
  width: 110px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-box {
  background: rgba(10, 15, 50, 0.85);
  border: 1.5px solid rgba(120, 140, 255, 0.25);
  border-radius: 10px;
  padding: 10px;
  backdrop-filter: blur(4px);
}

.panel-box .label {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: rgba(180, 195, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
}

.mini-grid {
  width: 80px;
  height: 64px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.mini-grid canvas {
  image-rendering: pixelated;
}

.stat-box {
  text-align: center;
}

.stat-box .value {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 12px rgba(150, 170, 255, 0.4);
}

/* Main board */
#board-container {
  position: relative;
  background: rgba(5, 8, 30, 0.95);
  border: 2px solid rgba(100, 130, 255, 0.3);
  border-radius: 12px;
  padding: 4px;
  box-shadow:
    0 0 40px rgba(80, 100, 255, 0.12),
    inset 0 0 60px rgba(20, 30, 80, 0.5);
}

#board-container canvas {
  display: block;
  border-radius: 8px;
}

/* Score display */
#score-area {
  text-align: center;
  margin-bottom: 12px;
}

#new-best {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #ffd54f;
  text-shadow: 0 0 10px rgba(255, 213, 79, 0.5);
  letter-spacing: 3px;
  visibility: hidden;
}

#new-best.visible { visibility: visible; }

#score-display {
  font-family: 'Orbitron', sans-serif;
  font-size: 36px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px rgba(200, 210, 255, 0.3);
  line-height: 1.1;
}

#best-score {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: rgba(150, 180, 255, 0.5);
}

/* Next pieces */
.next-pieces {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Overlay */
#overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 30, 0.88);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  z-index: 10;
  backdrop-filter: blur(6px);
}

#overlay.hidden { display: none; }

#overlay h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #7c8dff, #c490ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#overlay .sub {
  font-size: 15px;
  color: rgba(180, 195, 255, 0.6);
  margin-bottom: 24px;
}

#overlay button {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, rgba(100, 120, 255, 0.25), rgba(140, 100, 255, 0.25));
  color: #c0ccff;
  border: 1.5px solid rgba(120, 140, 255, 0.4);
  border-radius: 8px;
  padding: 12px 32px;
  cursor: pointer;
  transition: all 0.2s;
}

#overlay button:hover {
  background: linear-gradient(135deg, rgba(100, 120, 255, 0.4), rgba(140, 100, 255, 0.4));
  border-color: rgba(150, 170, 255, 0.6);
  transform: scale(1.04);
}

#game-over-score {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #ffd54f;
  margin-bottom: 16px;
}

/* Control buttons container (right panel) */
#control-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

#pause-btn, #sfx-btn, #music-btn {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  background: rgba(100, 120, 255, 0.15);
  border: 1.5px solid rgba(120, 140, 255, 0.3);
  color: rgba(180, 195, 255, 0.7);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#pause-btn:hover, #sfx-btn:hover, #music-btn:hover {
  background: rgba(100, 120, 255, 0.3);
}

#sfx-btn.muted, #music-btn.muted {
  opacity: 0.4;
}

/* Controls hint */
#controls-hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(150, 170, 255, 0.35);
  letter-spacing: 1px;
  white-space: nowrap;
  pointer-events: none;
}

/* Line clear flash */
@keyframes lineFlash {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* Mobile touch controls */
#touch-controls {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 20px 20px;
  justify-content: space-between;
  z-index: 20;
}

.touch-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(100, 120, 255, 0.12);
  border: 1.5px solid rgba(120, 140, 255, 0.25);
  color: rgba(180, 195, 255, 0.6);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.touch-btn:active {
  background: rgba(100, 120, 255, 0.3);
}

.touch-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

@media (max-width: 600px) {
  #touch-controls { display: flex; }
  #controls-hint { display: none; }
}
