/* Modern Glassmorphism & Cyber-Neon Aesthetics for Click the Target */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&family=Plus+Jakarta+Sans:wght@500;700;800&display=swap');

:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --glass-bg: rgba(15, 23, 42, 0.75);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-glow: rgba(56, 189, 248, 0.15);
  
  --color-accent: #38bdf8;       /* Neon Cyan */
  --color-accent-glow: #0284c7;
  --color-purple: #c084fc;       /* Electric Purple */
  --color-gold: #fbbf24;         /* Golden Yellow */
  --color-red: #f43f5e;          /* Ruby Red */
  --color-green: #34d399;        /* Emerald Green */
  --color-ice: #38bdf8;          /* Frost Blue */
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Plus Jakarta Sans', sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-neon: 0 0 25px rgba(56, 189, 248, 0.35);
  --shadow-glass: 0 20px 40px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-main);
  touch-action: none;
}

/* Background animated gradient glow */
body::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 30% 20%, rgba(56, 189, 248, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 70% 80%, rgba(192, 132, 252, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0.05) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
  animation: bgPulse 20s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.1) rotate(5deg); }
}

/* Main Container */
#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* Header HUD */
#hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 900px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glass);
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.hud-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.hud-value.highlight {
  color: var(--color-accent);
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* Combo Streak Container */
.combo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}

.combo-badge {
  background: linear-gradient(135deg, var(--color-purple), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
  font-size: 1.6rem;
  transform: scale(1);
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-badge.bounce {
  transform: scale(1.25);
}

.combo-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  margin-top: 4px;
  overflow: hidden;
}

.combo-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-purple));
  border-radius: var(--radius-full);
  transition: width 0.1s linear;
}

/* Top Right Controls */
.top-controls {
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  border-color: var(--color-accent);
}

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

/* Canvas Canvas */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  background: transparent;
}

/* Overlays / Modals */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass), var(--shadow-neon);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: min(90%, 540px);
  text-align: center;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.game-title {
  font-family: var(--font-heading);
  font-size: 2.75rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ffffff 0%, var(--color-accent) 60%, var(--color-purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 28px;
}

/* Mode Selection Cards */
.mode-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.mode-card {
  flex: 1;
  padding: 16px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mode-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-3px);
}

.mode-card.selected {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--color-accent);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
}

.mode-icon {
  font-size: 1.75rem;
}

.mode-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.mode-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Main Action Buttons */
.btn-primary {
  width: 100%;
  padding: 16px 28px;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 800;
  color: #090d16;
  background: linear-gradient(135deg, var(--color-accent), #0284c7);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(56, 189, 248, 0.6);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  width: 100%;
  padding: 14px 24px;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 12px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Stats Breakdown Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  text-align: left;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

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

.stat-val {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-accent);
}

/* Settings Form Controls */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-info {
  text-align: left;
}

.setting-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Custom Toggle Switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-switch:checked {
  background: var(--color-accent);
}

.toggle-switch::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  background: white;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Countdown Overlay */
#countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  pointer-events: none;
}

#countdown-text {
  font-family: var(--font-heading);
  font-size: 8rem;
  font-weight: 900;
  color: var(--color-accent);
  text-shadow: 0 0 40px rgba(56, 189, 248, 0.8);
  transform: scale(0.5);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#countdown-text.pop {
  transform: scale(1.2);
  opacity: 1;
}

/* Target Guide Legend */
.target-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
  text-align: left;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Target Dot Colors in Legend */
.dot-standard { background: var(--color-accent); box-shadow: 0 0 8px var(--color-accent); }
.dot-speedster { background: var(--color-purple); box-shadow: 0 0 8px var(--color-purple); }
.dot-golden { background: var(--color-gold); box-shadow: 0 0 8px var(--color-gold); }
.dot-bomb { background: var(--color-red); box-shadow: 0 0 8px var(--color-red); }
.dot-freeze { background: #60a5fa; box-shadow: 0 0 8px #60a5fa; }
.dot-multiplier { background: #e879f9; box-shadow: 0 0 8px #e879f9; }

/* Mobile Adaptations */
@media (max-width: 640px) {
  #hud {
    padding: 10px 14px;
    top: 10px;
  }

  .hud-value {
    font-size: 1.2rem;
  }

  .hud-label {
    font-size: 0.65rem;
  }

  .modal-card {
    padding: 24px 20px;
  }

  .game-title {
    font-size: 2rem;
  }

  .mode-selector {
    flex-direction: column;
  }

  .target-legend {
    grid-template-columns: 1fr;
  }
}
