/* ═══════════════════════════════════════════════
   BabyKeyPlay Ultra — Styles
   ═══════════════════════════════════════════════ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --text-primary: #f0f0ff;
  --text-secondary: #8888aa;
  --accent-cyan: #0ff;
  --accent-magenta: #f0f;
  --accent-yellow: #ff0;
  --accent-green: #0f6;
  --neon-glow: 0 0 10px var(--accent-cyan), 0 0 40px var(--accent-cyan), 0 0 80px rgba(0, 255, 255, 0.3);
  --panel-bg: rgba(10, 10, 26, 0.95);
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  color-scheme: dark;
}

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

/* ── Canvas Layers ── */

#gpu-canvas,
#trail-canvas,
#ui-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#gpu-canvas  { z-index: 1; }
#trail-canvas { z-index: 2; }
#ui-canvas   { z-index: 3; }

/* ── FPS Counter ── */

.fps-counter {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 100;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  display: none;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.fps-counter.visible {
  display: flex;
}

.gpu-badge {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  color: #000;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.5px;
}

/* ── Welcome Overlay ── */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(0, 255, 255, 0.08) 0%, var(--bg-primary) 70%);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.welcome-shell {
  width: 100%;
  max-width: 640px;
  padding: 2rem 1.5rem env(safe-area-inset-bottom, 1rem);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
}

.logo-glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 255, 255, 0.15) 0%, transparent 70%);
  filter: blur(60px);
  pointer-events: none;
  animation: logo-pulse 4s ease-in-out infinite;
}

@keyframes logo-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
  position: relative;
}

.title-baby {
  background: linear-gradient(135deg, #fff 0%, #cce8ff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-key {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-green) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.5));
}

.title-play {
  background: linear-gradient(135deg, var(--accent-magenta) 0%, var(--accent-yellow) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 0, 255, 0.4));
}

.hero-tagline {
  font-size: clamp(1rem, 3vw, 1.35rem);
  color: var(--text-secondary);
  max-width: 480px;
}

.hero-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: 520px;
}

.feature-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: nowrap;
  transition: var(--transition);
}

.feature-chip:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 255, 255, 0.08);
}

.chip-icon {
  font-size: 1rem;
}

/* ── Start Button ── */

.start-btn {
  position: relative;
  padding: 1rem 2.5rem;
  font-size: 1.25rem;
  font-weight: 800;
  font-family: inherit;
  color: #000;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.3s;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.4), 0 4px 20px rgba(0, 0, 0, 0.4);
}

.start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 50px rgba(0, 255, 255, 0.6), 0 4px 30px rgba(0, 0, 0, 0.4);
}

.start-btn:active {
  transform: scale(0.97);
}

.start-btn-glow {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta), var(--accent-yellow), var(--accent-cyan));
  background-size: 300% 300%;
  animation: glow-rotate 3s linear infinite;
  opacity: 0.6;
  z-index: -1;
  filter: blur(8px);
}

@keyframes glow-rotate {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.start-btn-text {
  position: relative;
  z-index: 1;
}

/* ── Mode Buttons ── */

.hero-modes {
  display: flex;
  gap: 0.5rem;
}

.mode-btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.mode-btn.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(0, 255, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.mode-btn:hover:not(.active) {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text-primary);
}

/* ── Multiplayer Setup ── */

.multi-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
}

.multi-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.multi-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.multi-btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  color: #000;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s;
}

.multi-btn:hover { transform: scale(1.04); }
.multi-btn:active { transform: scale(0.96); }

.multi-divider {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.join-row {
  display: flex;
  gap: 0.5rem;
}

.room-code-input {
  width: 120px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  color: var(--accent-cyan);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: var(--radius);
  outline: none;
  transition: var(--transition);
}

.room-code-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.multi-status {
  font-size: 0.8rem;
  color: var(--accent-green);
  min-height: 1.2em;
}

/* ── Theme Previews ── */

.theme-preview-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.theme-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.6rem;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.theme-preview.active {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}

.theme-preview:hover:not(.active) {
  border-color: rgba(255, 255, 255, 0.2);
}

.theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

/* ── Install Prompt ── */

.install-prompt {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 255, 255, 0.06);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: var(--radius);
}

.install-prompt p {
  flex: 1;
  font-size: 0.85rem;
}

.install-btn {
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  color: #000;
  background: var(--accent-cyan);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s;
}

.install-btn:hover { transform: scale(1.04); }

.parent-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.parent-hint kbd {
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ── Multiplayer HUD ── */

.multiplayer-hud {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  gap: 1.5rem;
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

/* ── Combo Display ── */

.combo-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
}

.combo-display.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#combo-number {
  font-size: clamp(4rem, 15vw, 10rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 40px rgba(0, 255, 255, 0.6));
  line-height: 1;
}

.combo-label {
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 800;
  color: var(--accent-yellow);
  text-shadow: 0 0 20px rgba(255, 255, 0, 0.5);
  letter-spacing: 0.15em;
}

/* ── Parent Panel ── */

.parent-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: 90%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--panel-bg);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: 0 0 60px rgba(0, 255, 255, 0.15), 0 20px 60px rgba(0, 0, 0, 0.6);
}

.parent-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  text-align: center;
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  cursor: pointer;
}

.panel-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.panel-row select {
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.panel-actions button {
  flex: 1;
  padding: 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.panel-actions button:first-child {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.panel-actions button:last-child {
  color: #000;
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* ── Ad Container ── */

.ad-container {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: 100%;
  max-width: 728px;
  min-height: 50px;
  text-align: center;
}

/* ── Animations ── */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-hero > * {
  animation: fade-in 0.6s ease-out backwards;
}

.welcome-hero > *:nth-child(1) { animation-delay: 0.1s; }
.welcome-hero > *:nth-child(2) { animation-delay: 0.2s; }
.welcome-hero > *:nth-child(3) { animation-delay: 0.3s; }
.welcome-hero > *:nth-child(4) { animation-delay: 0.4s; }
.welcome-hero > *:nth-child(5) { animation-delay: 0.5s; }
.welcome-hero > *:nth-child(6) { animation-delay: 0.6s; }
.welcome-hero > *:nth-child(7) { animation-delay: 0.7s; }

/* ── Responsive ── */

@media (max-width: 480px) {
  .welcome-shell { padding: 1.25rem 1rem; }
  .start-btn { padding: 0.85rem 2rem; font-size: 1.1rem; }
  .hero-features { gap: 0.35rem; }
  .feature-chip { font-size: 0.72rem; padding: 0.28rem 0.6rem; }
  .theme-swatch { width: 26px; height: 26px; }
  .multiplayer-hud { gap: 0.75rem; font-size: 0.7rem; padding: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
