/* Black Hole Game - Mobile-First CSS */

/* CSS Variables */
:root {
  --primary: #1a1a2e;
  --primary-light: #4a4a6e;
  --accent: #00a8ff;
  --accent-hover: #0097e6;
  --danger: #e84118;
  --success: #4cd137;
  --warning: #fbc531;
  --bg: #0f0f1a;
  --bg-light: #1e1e2e;
  --text: #f5f6fa;
  --text-muted: #7f8fa6;
  --border: #2f3640;
  
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  overflow: hidden;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Setup Screen */
#setup-screen {
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary) 100%);
  padding: 20px;
}

.game-header {
  text-align: center;
  padding: 20px 0;
}

.game-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, #9c88ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.setup-container {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}

.setup-section {
  margin-bottom: 24px;
}

.setup-section h2 {
  font-size: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

/* Choice Buttons */
.mode-choices,
.difficulty-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-light);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.choice-btn:hover,
.choice-btn:active {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.choice-btn.active {
  background: rgba(0, 168, 255, 0.15);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 168, 255, 0.2);
}

.choice-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  border-radius: var(--radius-sm);
}

.choice-label {
  font-weight: 600;
  font-size: 1.1rem;
  display: block;
}

.choice-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* Toggle Switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  border-radius: 28px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
}

.toggle-label {
  font-size: 1rem;
  color: var(--text);
}

/* Power-up Info */
.powerup-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.powerup-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.powerup-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* Controls Info */
.controls-info ul {
  list-style: none;
  background: var(--bg-light);
  border-radius: var(--radius-md);
  padding: 16px;
}

.controls-info li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.controls-info li:last-child {
  border-bottom: none;
}

/* Start Button */
.start-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, #9c88ff 100%);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
  margin-bottom: 12px;
}

.start-btn:hover,
.start-btn:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.back-link {
  display: block;
  text-align: center;
  color: var(--text-muted);
  text-decoration: none;
  padding: 12px;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--text);
}

/* Game Screen */
#game-screen {
  background: var(--bg);
  position: relative;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
  z-index: 0;
}

/* HUD */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

.hud > div {
  pointer-events: auto;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-display,
.timer-display {
  background: rgba(26, 26, 46, 0.9);
  backdrop-filter: blur(10px);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.score-display .label,
.timer-display .label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-display .value,
.timer-display .value {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.timer-display .value {
  color: var(--warning);
}

/* Power-up Indicator */
.powerup-indicator {
  background: rgba(0, 168, 255, 0.9);
  backdrop-filter: blur(10px);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.powerup-indicator.hidden {
  display: none;
}

#powerup-icon {
  font-size: 1.2rem;
}

#powerup-timer {
  font-weight: 700;
  font-size: 1.1rem;
}

/* Pause Button */
.pause-btn {
  width: 44px;
  height: 44px;
  background: rgba(26, 26, 46, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pause-btn:hover {
  background: var(--primary-light);
}

/* Minimap */
.minimap {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 120px;
  height: 120px;
  background: rgba(26, 26, 46, 0.9);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  z-index: 10;
}

#minimap-canvas {
  width: 100%;
  height: 100%;
}

/* Modal */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-light);
  padding: 32px;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 320px;
  width: 90%;
  border: 1px solid var(--border);
}

.modal-content h2 {
  font-size: 1.8rem;
  margin-bottom: 24px;
  color: var(--text);
}

.modal-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.modal-btn:hover {
  background: var(--accent-hover);
}

.modal-btn.secondary {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-muted);
}

.modal-btn.secondary:hover {
  border-color: var(--text);
  color: var(--text);
}

/* Game Over Screen */
#gameover-screen {
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary) 100%);
  padding: 20px;
  align-items: center;
  justify-content: center;
}

.gameover-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

#gameover-title {
  font-size: 2.2rem;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--accent) 0%, #9c88ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-item {
  background: var(--bg-light);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.death-reason {
  background: rgba(232, 65, 24, 0.2);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

.death-reason p {
  color: var(--danger);
  font-weight: 600;
}

.death-reason.hidden {
  display: none;
}

/* Responsive Adjustments */
@media (min-width: 768px) {
  .game-header h1 {
    font-size: 3.5rem;
  }
  
  .mode-choices,
  .difficulty-choices {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .choice-btn {
    flex: 1;
    min-width: 200px;
  }
  
  .powerup-info {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-height: 600px) {
  .game-header {
    padding: 10px 0;
  }
  
  .game-header h1 {
    font-size: 2rem;
  }
  
  .setup-section {
    margin-bottom: 16px;
  }
  
  .choice-btn {
    padding: 12px;
  }
}

/* Score Popups */
#popup-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.score-popup {
  position: absolute;
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
  text-shadow: 0 0 8px rgba(0, 168, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  white-space: nowrap;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Prevent pull-to-refresh on mobile */
html, body {
  overscroll-behavior: none;
}
