/* CSS variables for neon colors and general theme */
:root {
  --bg-color: #080710;
  --panel-bg: rgba(18, 16, 35, 0.6);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-glow: rgba(0, 240, 255, 0.15);
  
  --text-main: #f0f0f5;
  --text-muted: #8a88a0;
  --color-gold: #ffd700;
  
  /* Neon Tetromino Colors */
  --neon-cyan: #00f0ff;
  --neon-blue: #0033ff;
  --neon-orange: #ff5e00;
  --neon-yellow: #ffe600;
  --neon-green: #39ff14;
  --neon-purple: #b026ff;
  --neon-pink: #ff007f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Background decorative neon orbs */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
}

.circle-1 {
  width: 400px;
  height: 400px;
  background-color: var(--neon-purple);
  top: 10%;
  left: 15%;
  animation: float-slow 15s ease-in-out infinite alternate;
}

.circle-2 {
  width: 450px;
  height: 450px;
  background-color: var(--neon-cyan);
  bottom: 10%;
  right: 15%;
  animation: float-slow 18s ease-in-out infinite alternate-reverse;
}

@keyframes float-slow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 30px) scale(1.1); }
}

/* Container & Header */
.app-container {
  width: 100%;
  max-width: 950px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.game-header {
  text-align: center;
  margin-bottom: 5px;
}

.logo {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 2.8rem;
  letter-spacing: 4px;
  color: var(--text-main);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.glow-text {
  color: var(--neon-pink);
  text-shadow: 
    0 0 5px var(--neon-pink),
    0 0 15px var(--neon-pink),
    0 0 30px var(--neon-pink);
  animation: neon-flicker 3s infinite alternate;
}

.subtitle {
  font-size: 0.85rem;
  letter-spacing: 5px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: -2px;
}

@keyframes neon-flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
    text-shadow: 
      0 0 5px var(--neon-pink),
      0 0 15px var(--neon-pink),
      0 0 30px var(--neon-pink);
  }
  20%, 24%, 55% {
    text-shadow: none;
    color: rgba(255, 0, 127, 0.5);
  }
}

/* Layout Grid */
.game-layout {
  display: grid;
  grid-template-columns: 200px 320px 200px;
  gap: 20px;
  justify-content: center;
  align-items: start;
  width: 100%;
}

/* Glassmorphism Panels */
.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 18px;
  box-shadow: 
    0 8px 32px 0 rgba(0, 0, 0, 0.3),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-panel:hover {
  border-color: rgba(0, 240, 255, 0.25);
  box-shadow: 
    0 8px 32px 0 rgba(0, 0, 0, 0.4),
    0 0 15px var(--panel-glow),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

.glass-panel h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 12px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

/* Sidebars styling */
.sidebar-left, .sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 15px;
  height: 100%;
}

.preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.next-previews {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.secondary-preview {
  opacity: 0.6;
  transform: scale(0.9);
  margin-top: -5px;
}

/* Keyboard Controls Guide */
.controls-list {
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.key {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-weight: bold;
  color: var(--text-main);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

/* Center Board area */
.game-board-container {
  display: flex;
  justify-content: center;
}

.board-wrapper {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  background: #000;
}

#game-canvas {
  display: block;
  background: radial-gradient(circle at center, #110e26 0%, #05040a 100%);
}

/* Screen shake effect */
.shake-animation {
  animation: shake 0.25s cubic-bezier(.36,.07,.19,.97) both;
}

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

/* Score & Stats panel */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.3);
}

.text-gold {
  color: var(--color-gold);
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

/* Screen Overlays (Start, Pause, Game Over) */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 6, 18, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 10;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

.overlay-content {
  text-align: center;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.overlay h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 3px;
}

.overlay p {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 200px;
  line-height: 1.4;
}

.pulse-text {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; text-shadow: 0 0 5px var(--neon-cyan); }
  50% { opacity: 1; text-shadow: 0 0 20px var(--neon-cyan); }
}

.glitch-text {
  color: var(--neon-pink);
  text-shadow: 
    -2px 0 var(--neon-cyan),
    2px 0 var(--neon-purple);
  animation: glitch 1.5s infinite linear alternate-reverse;
}

@keyframes glitch {
  0% { text-shadow: -2px 0 var(--neon-cyan), 2px 0 var(--neon-purple); }
  50% { text-shadow: 2px -1px var(--neon-cyan), -1px 2px var(--neon-purple); }
  100% { text-shadow: -1px 2px var(--neon-cyan), 2px -2px var(--neon-purple); }
}

.final-score-text {
  font-size: 1.1rem;
  font-family: 'Orbitron', sans-serif;
  color: var(--text-main) !important;
  margin-top: 5px;
}

.final-score-text span {
  color: var(--color-gold);
  font-weight: bold;
}

/* Neon buttons styling */
.neon-btn {
  background: transparent;
  border: 2px solid var(--neon-pink);
  color: var(--neon-pink);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 10px 24px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.2);
  transition: all 0.2s ease;
  outline: none;
}

.neon-btn:hover {
  background: var(--neon-pink);
  color: #000;
  box-shadow: 
    0 0 15px var(--neon-pink),
    0 0 30px rgba(255, 0, 127, 0.4);
  transform: translateY(-2px);
}

.neon-btn:active {
  transform: translateY(0);
}

/* Footer / Audio buttons */
.game-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 5px;
}

.audio-controls {
  display: flex;
  gap: 15px;
}

.audio-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 15px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  transition: all 0.2s ease;
}

.audio-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.audio-btn.muted {
  color: #ff3366;
  border-color: rgba(255, 51, 102, 0.3);
  background: rgba(255, 51, 102, 0.05);
}

.audio-btn svg {
  width: 16px;
  height: 16px;
}

/* Mobile Touch Controls - hidden by default */
.touch-controls {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin-top: 15px;
}

.touch-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.touch-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border-radius: 12px;
  height: 52px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: background 0.1s, transform 0.05s;
  touch-action: manipulation;
  outline: none;
}

.touch-btn:active {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
  transform: translateY(2px);
}

.action-btn {
  background: rgba(255, 0, 127, 0.08);
  border-color: rgba(255, 0, 127, 0.2);
  color: var(--neon-pink);
}
.action-btn:active {
  background: rgba(255, 0, 127, 0.25);
  border-color: var(--neon-pink);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.4);
}

.utility-btn {
  background: rgba(255, 215, 0, 0.05);
  border-color: rgba(255, 215, 0, 0.15);
  color: var(--color-gold);
}
.utility-btn:active {
  background: rgba(255, 215, 0, 0.2);
  border-color: var(--color-gold);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.hard-drop-btn {
  flex: 1.5;
  background: rgba(57, 255, 20, 0.08);
  border-color: rgba(57, 255, 20, 0.2);
  color: var(--neon-green);
}
.hard-drop-btn:active {
  background: rgba(57, 255, 20, 0.25);
  border-color: var(--neon-green);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.4);
}

/* Responsiveness Queries */

/* Tablet & Smaller Screens */
@media (max-width: 768px) {
  .app-container {
    padding: 10px;
    gap: 10px;
  }
  
  .logo {
    font-size: 2.2rem;
  }
  
  .game-layout {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 
      "board board"
      "left right";
    gap: 12px;
    max-width: 320px;
  }
  
  .sidebar-left {
    grid-area: left;
  }
  
  .sidebar-right {
    grid-area: right;
  }
  
  .game-board-container {
    grid-area: board;
  }
  
  .controls-guide-panel {
    display: none; /* Hide on mobile/tablet */
  }
  
  .preview-box {
    padding: 5px;
  }
  
  .next-previews {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
  }
  
  .secondary-preview {
    margin-top: 0;
  }
  
  /* Show touch controls on smaller screens */
  .touch-controls {
    display: flex;
  }
}

/* Detect touch device */
@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
  .controls-guide-panel {
    display: none;
  }
}

/* Very Small Mobile Screens */
@media (max-width: 360px) {
  .game-layout {
    max-width: 300px;
    gap: 8px;
  }
  
  .board-wrapper {
    max-width: 280px;
  }
  
  #game-canvas {
    width: 280px;
    height: 560px; /* Scaling down canvas layout slightly */
  }
  
  .glass-panel {
    padding: 10px;
    border-radius: 10px;
  }
  
  .glass-panel h2 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    padding-bottom: 5px;
  }
  
  .stat-value {
    font-size: 1.1rem;
  }
}
