/* Design System Tokens */
:root {
  --color-bg: #0a0a0f;
  --color-surface: #1a1a2e;
  --color-text: #ffffff;
  --color-muted: #6b7280;
  --color-primary: #00f5d4;
  --color-secondary: #9b5de5;
  --color-accent: #f72585;
  --color-error: #ff006e;
  --color-success: #00f5d4;
  
  /* Tetromino colors */
  --tetris-i: #00f5d4;
  --tetris-j: #3a86ff;
  --tetris-l: #ff9500;
  --tetris-o: #fee440;
  --tetris-s: #00bb7c;
  --tetris-t: #9b5de5;
  --tetris-z: #f72585;
  
  /* Typography */
  --font-heading: 'Press Start 2P', cursive;
  --font-body: 'Space Mono', monospace;
  
  /* Text sizes */
  --text-xs: 0.625rem;
  --text-sm: 0.75rem;
  --text-base: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  
  /* Effects */
  --glow-primary: 0 0 20px rgba(0, 245, 212, 0.5);
  --glow-secondary: 0 0 20px rgba(155, 93, 229, 0.5);
  --glow-accent: 0 0 20px rgba(247, 37, 133, 0.5);
}

footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid rgba(155, 93, 229, 0.2);
  background: linear-gradient(to top, rgba(10, 10, 15, 0.95), transparent);
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-text {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

.footer-text strong {
  color: var(--primary);
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--secondary);
  text-decoration: none;
  transition: all 0.2s ease;
}

.footer-link:hover {
  color: var(--primary);
  text-shadow: 0 0 8px var(--primary);
}

.github-icon {
  opacity: 0.8;
}

.footer-link:hover .github-icon {
  opacity: 1;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

/* Utility Classes */
.neon-text {
  text-shadow: var(--glow-primary);
}

.neon-text-secondary {
  text-shadow: var(--glow-secondary);
}

.neon-text-accent {
  text-shadow: var(--glow-accent);
}

.pixel-text {
  font-family: var(--font-heading);
  letter-spacing: 1px;
}

/* Game Container */
.game-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: var(--color-bg);
  background-image: 
    radial-gradient(ellipse at 20% 80%, rgba(155, 93, 229, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 245, 212, 0.1) 0%, transparent 50%);
}

.game-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-4);
}

.game-main {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
}

.game-canvas-wrapper {
  position: relative;
  background: var(--color-surface);
  border: 4px solid var(--color-primary);
  box-shadow: var(--glow-primary), inset 0 0 60px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

#gameCanvas {
  display: block;
}

/* Game Stats Panel */
.game-stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 180px;
}

.stat-box {
  background: var(--color-surface);
  border: 2px solid var(--color-secondary);
  padding: var(--space-4);
  border-radius: 4px;
  box-shadow: var(--glow-secondary);
}

.stat-label {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--color-primary);
  text-shadow: var(--glow-primary);
}

/* Next Piece Preview */
.preview-box {
  background: var(--color-surface);
  border: 2px solid var(--color-secondary);
  padding: var(--space-4);
  border-radius: 4px;
  box-shadow: var(--glow-secondary);
}

.preview-label {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  text-align: center;
}

#previewCanvas {
  display: block;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
}

/* Controls Info */
.controls-box {
  background: var(--color-surface);
  border: 2px solid var(--color-muted);
  padding: var(--space-4);
  border-radius: 4px;
  font-size: var(--text-sm);
}

.controls-title {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
}

.control-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  color: var(--color-muted);
}

.control-key {
  color: var(--color-primary);
  font-weight: 700;
}

/* Leaderboard Sidebar */
.leaderboard-sidebar {
  width: 280px;
  background: var(--color-surface);
  border-left: 3px solid var(--color-secondary);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.leaderboard-title {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  color: var(--color-secondary);
  text-shadow: var(--glow-secondary);
  text-align: center;
  margin-bottom: var(--space-6);
  text-transform: uppercase;
}

.leaderboard-list {
  flex: 1;
  overflow-y: auto;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.leaderboard-item:nth-child(1) {
  border-left-color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

.leaderboard-item:nth-child(2) {
  border-left-color: #c0c0c0;
  background: rgba(192, 192, 192, 0.1);
}

.leaderboard-item:nth-child(3) {
  border-left-color: #cd7f32;
  background: rgba(205, 127, 50, 0.1);
}

.rank {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  color: var(--color-primary);
  min-width: 24px;
}

.player-info {
  flex: 1;
  overflow: hidden;
}

.player-name {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-score {
  font-size: var(--text-sm);
  color: var(--color-primary);
  text-shadow: var(--glow-primary);
}

.player-level {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* Game Over Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.modal-content {
  background: var(--color-surface);
  border: 4px solid var(--color-accent);
  box-shadow: var(--glow-accent);
  padding: var(--space-8);
  border-radius: 8px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

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

.modal-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--color-accent);
  text-shadow: var(--glow-accent);
  margin-bottom: var(--space-6);
}

.modal-score-label {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

.modal-score-value {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--color-primary);
  text-shadow: var(--glow-primary);
  margin-bottom: var(--space-6);
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.modal-stat {
  text-align: center;
}

.modal-stat-label {
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-1);
}

.modal-stat-value {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  color: var(--color-secondary);
}

.name-input-group {
  margin-bottom: var(--space-6);
}

.name-label {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--color-muted);
  display: block;
  margin-bottom: var(--space-2);
}

.name-input {
  width: 100%;
  padding: var(--space-3);
  font-family: var(--font-heading);
  font-size: var(--text-base);
  background: var(--color-bg);
  border: 2px solid var(--color-primary);
  color: var(--color-text);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  border-radius: 4px;
  outline: none;
  transition: box-shadow 0.2s ease;
}

.name-input:focus {
  box-shadow: var(--glow-primary);
}

.name-input::placeholder {
  color: var(--color-muted);
  text-transform: none;
  letter-spacing: normal;
}

.modal-buttons {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
}

.btn {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  padding: var(--space-3) var(--space-6);
  border: 2px solid;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s ease;
  outline: none;
}

.btn:focus {
  transform: scale(1.05);
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-bg);
}

.btn-primary:hover {
  box-shadow: var(--glow-primary);
  transform: scale(1.05);
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

.btn-secondary:hover {
  background: var(--color-secondary);
  color: var(--color-bg);
  box-shadow: var(--glow-secondary);
}

/* Pause Overlay */
.pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

.pause-text {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--color-secondary);
  text-shadow: var(--glow-secondary);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Mobile Controls */
.mobile-controls {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-4);
  background: rgba(26, 26, 46, 0.95);
  border-top: 2px solid var(--color-secondary);
  z-index: 50;
}

.mobile-controls-row {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}

.mobile-btn {
  width: 60px;
  height: 60px;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  color: var(--color-primary);
  font-size: var(--text-xl);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.1s ease;
}

.mobile-btn:active {
  background: var(--color-primary);
  color: var(--color-bg);
  transform: scale(0.95);
}

.mobile-btn-wide {
  width: 100px;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-surface);
  border: 2px solid var(--color-success);
  padding: var(--space-3) var(--space-6);
  border-radius: 4px;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--color-success);
  box-shadow: var(--glow-primary);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Scrollbar */
.leaderboard-list::-webkit-scrollbar {
  width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

.leaderboard-list::-webkit-scrollbar-thumb {
  background: var(--color-secondary);
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 1024px) {
  .game-wrapper {
    flex-direction: column;
  }
  
  .leaderboard-sidebar {
    width: 100%;
    border-left: none;
    border-top: 3px solid var(--color-secondary);
    max-height: 200px;
  }
  
  .leaderboard-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .leaderboard-item {
    flex: 1 1 150px;
    min-width: 150px;
  }
}

@media (max-width: 768px) {
  .game-main {
    flex-direction: column;
    align-items: center;
  }
  
  .game-stats {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: auto;
  }
  
  .stat-box, .preview-box, .controls-box {
    min-width: 100px;
  }
  
  .controls-box {
    display: none;
  }
  
  .mobile-controls {
    display: block;
  }
  
  .game-container {
    padding-bottom: 180px;
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-8);
  color: var(--color-muted);
}

.empty-state-text {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
}

/* Loading State */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-8);
}

.loading-dots {
  display: flex;
  gap: var(--space-2);
}

.loading-dot {
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  animation: loadingPulse 1s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}
