@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

:root {
  --deep-ocean: #020c1b;
  --dark-sea: #0a192f;
  --sea-blue: #112240;
  --wave-teal: #64ffda;
  --soft-teal: #4fd1c5;
  --light-slate: #a8b2d1;
  --lightest-slate: #ccd6f6;
  --white: #e6f1ff;
  --grid-line: #1a2a4a;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--deep-ocean);
  color: var(--lightest-slate);
  overflow-x: hidden;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
}

.bg-animation {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(180deg, var(--deep-ocean) 0%, var(--dark-sea) 50%, var(--sea-blue) 100%);
}

.bubble {
  position: absolute;
  bottom: -100px;
  background: radial-gradient(circle, rgba(100, 255, 218, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  animation: rise 15s infinite ease-in;
  opacity: 0.6;
}

.bubble:nth-child(1) { width: 40px; height: 40px; left: 10%; animation-duration: 12s; }
.bubble:nth-child(2) { width: 20px; height: 20px; left: 20%; animation-duration: 10s; animation-delay: 2s; }
.bubble:nth-child(3) { width: 50px; height: 50px; left: 35%; animation-duration: 14s; animation-delay: 4s; }
.bubble:nth-child(4) { width: 80px; height: 80px; left: 50%; animation-duration: 18s; }
.bubble:nth-child(5) { width: 35px; height: 35px; left: 65%; animation-duration: 11s; animation-delay: 3s; }
.bubble:nth-child(6) { width: 45px; height: 45px; left: 75%; animation-duration: 16s; animation-delay: 6s; }
.bubble:nth-child(7) { width: 25px; height: 25px; left: 85%; animation-duration: 13s; animation-delay: 1s; }
.bubble:nth-child(8) { width: 60px; height: 60px; left: 90%; animation-duration: 20s; animation-delay: 5s; }

@keyframes rise {
  0% { bottom: -100px; transform: translateX(0) scale(1); opacity: 0.6; }
  50% { opacity: 0.4; }
  100% { bottom: 110vh; transform: translateX(-50px) scale(0.5); opacity: 0; }
}

.game-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  margin-bottom: 30px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--wave-teal), var(--soft-teal));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  letter-spacing: 4px;
  filter: drop-shadow(0 0 25px rgba(100, 255, 218, 0.5));
}

.main-container {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.game-container {
  display: flex;
  gap: 25px;
  align-items: flex-start;
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

#stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
  padding: 15px;
  background: var(--dark-sea);
  border: 1px solid rgba(100, 255, 218, 0.3);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(2, 12, 27, 0.5);
  gap: 8px;
}

#high-score {
  font-size: 9px;
  color: var(--soft-teal);
  font-weight: 500;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(100, 255, 218, 0.2);
  width: 100%;
  text-align: center;
}

#score, #level {
  font-size: 12px;
  color: var(--wave-teal);
  font-weight: 600;
}

.preview-container, .hold-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
  background: var(--dark-sea);
  border: 1px solid rgba(100, 255, 218, 0.3);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(2, 12, 27, 0.5);
  transition: all 0.3s ease;
}

.preview-label, .hold-label {
  color: var(--wave-teal);
  margin-bottom: 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.preview-queue {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

canvas {
  image-rendering: pixelated;
  border: 2px solid rgba(100, 255, 218, 0.4);
  border-radius: 8px;
  background: var(--deep-ocean);
  box-shadow: 0 0 30px rgba(100, 255, 218, 0.15);
}

#tetris { border-width: 3px; }
#hold { border-width: 2px; }
.preview-queue canvas { border-width: 1px; }
.preview-queue canvas:first-child { border-width: 2px; }

#controls {
  padding: 12px;
  background: var(--dark-sea);
  border: 1px solid rgba(100, 255, 218, 0.3);
  border-radius: 12px;
  font-size: 9px;
  line-height: 1.7;
  text-align: center;
  color: var(--light-slate);
  box-shadow: 0 10px 30px rgba(2, 12, 27, 0.5);
  width: 140px;
}

.control-title {
  font-size: 10px;
  margin-bottom: 8px;
  text-transform: uppercase;
  color: var(--wave-teal);
  font-weight: 600;
  letter-spacing: 2px;
}

#controls span {
  color: var(--wave-teal);
  font-weight: 600;
}

.settings-btn {
  padding: 10px 15px;
  background: var(--dark-sea);
  border: 1px solid rgba(100, 255, 218, 0.3);
  border-radius: 8px;
  color: var(--wave-teal);
  font-family: 'Poppins', sans-serif;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 140px;
}

.settings-btn:hover {
  background: rgba(100, 255, 218, 0.1);
  border-color: var(--wave-teal);
}

.settings-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(2, 12, 27, 0.95);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

.settings-modal {
  background: var(--dark-sea);
  border: 2px solid rgba(100, 255, 218, 0.4);
  border-radius: 16px;
  padding: 30px;
  max-width: 800px;
  width: 95%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(100, 255, 218, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.settings-overlay.active .settings-modal {
  transform: scale(1);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(100, 255, 218, 0.2);
}

.settings-title {
  font-size: 18px;
  text-transform: uppercase;
  color: var(--wave-teal);
  font-weight: 700;
  letter-spacing: 3px;
}

.close-settings {
  background: none;
  border: none;
  color: var(--light-slate);
  font-size: 28px;
  cursor: pointer;
  transition: color 0.3s ease;
  line-height: 1;
}

.close-settings:hover { color: var(--wave-teal); }

.settings-section {
  margin-bottom: 25px;
}

.settings-section h4 {
  color: var(--lightest-slate);
  font-size: 12px;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.setting-item label {
  color: var(--light-slate);
  font-size: 10px;
  text-transform: uppercase;
}

.setting-item input {
  background: var(--sea-blue);
  border: 1px solid rgba(100, 255, 218, 0.2);
  border-radius: 6px;
  padding: 10px;
  color: var(--wave-teal);
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  text-align: center;
  width: 100%;
  outline: none;
  transition: all 0.3s ease;
}

.setting-item input:focus {
  border-color: var(--wave-teal);
  box-shadow: 0 0 10px rgba(100, 255, 218, 0.2);
}

.key-bindings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.key-binding {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--sea-blue);
  border-radius: 8px;
  border: 1px solid rgba(100, 255, 218, 0.1);
}

.key-binding span {
  color: var(--light-slate);
  font-size: 11px;
}

.key-input {
  background: var(--dark-sea);
  border: 1px solid rgba(100, 255, 218, 0.2);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--wave-teal);
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  text-align: center;
  min-width: 60px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.key-input:focus {
  border-color: var(--wave-teal);
  box-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
  outline: none;
}

.key-input.recording {
  background: rgba(100, 255, 218, 0.1);
  border-color: var(--wave-teal);
  animation: pulse-border 1s infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 5px rgba(100, 255, 218, 0.3); }
  50% { box-shadow: 0 0 15px rgba(100, 255, 218, 0.6); }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 25px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  cursor: pointer;
  border: none;
  font-family: 'Poppins', sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary {
  background: var(--wave-teal);
  color: var(--deep-ocean);
}

.btn-primary:hover {
  background: var(--soft-teal);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(100, 255, 218, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--wave-teal);
  border: 1px solid var(--wave-teal);
}

.btn-secondary:hover {
  background: rgba(100, 255, 218, 0.1);
  transform: translateY(-2px);
}

.settings-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid rgba(100, 255, 218, 0.2);
}

.settings-info {
  font-size: 9px;
  color: var(--light-slate);
  text-align: center;
  margin-top: 10px;
  opacity: 0.7;
}

#pauseOverlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(2, 12, 27, 0.9);
  z-index: 1500;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
}

.pause-content { text-align: center; }

.pause-text {
  font-size: 48px;
  color: var(--wave-teal);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 8px;
  text-shadow: 0 0 30px rgba(100, 255, 218, 0.5), 0 0 60px rgba(100, 255, 218, 0.3);
  animation: pulse-glow 2s ease-in-out infinite;
}

.pause-hint {
  margin-top: 20px;
  font-size: 14px;
  color: var(--light-slate);
  letter-spacing: 2px;
}

@keyframes pulse-glow {
  0%, 100% { 
    text-shadow: 0 0 30px rgba(100, 255, 218, 0.5), 0 0 60px rgba(100, 255, 218, 0.3);
    transform: scale(1);
  }
  50% { 
    text-shadow: 0 0 50px rgba(100, 255, 218, 0.8), 0 0 100px rgba(100, 255, 218, 0.5);
    transform: scale(1.02);
  }
}

@media (max-width: 900px) {
  .game-container { flex-direction: column; align-items: center; }
  .left-panel, .right-panel { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .preview-queue { flex-direction: row; }
  .key-bindings-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .bubble { display: none; }
}

@media (max-width: 480px) {
  .game-title { font-size: 1.8rem; }
  .settings-modal { padding: 20px; }
  .settings-grid { grid-template-columns: 1fr; }
  .pause-text { font-size: 32px; letter-spacing: 4px; }
}
