/* ===== CARTOON THEME - RITMO BRASILEIRO ===== */
/* "Cartoon Rhythm Party" — Fun & Bold */

/* ===== CSS VARIABLES ===== */
:root {
  /* Background & Surface — purple music vibe */
  --background: #7B1FA2;
  --surface: #F5E6D0;
  --surface-container: #EDE0CC;
  --surface-container-low: #F0E3CF;
  --surface-container-lowest: #F5E6D0;
  --surface-container-high: #E8DAC4;
  --surface-container-highest: #E2D4BE;

  /* Primary — orange energy */
  --primary: #FF5722;
  --primary-container: #FF7043;
  --primary-dim: #E64A19;
  --on-primary: #fff;

  /* Secondary — deep purple accent */
  --secondary: #9C27B0;
  --secondary-container: #AB47BC;
  --secondary-dim: #7B1FA2;
  --on-secondary: #fff;

  /* Tertiary — golden highlight */
  --tertiary: #FFC107;
  --tertiary-container: #FFD54F;
  --on-tertiary: #5D4037;

  /* On-Surface & Outlines */
  --on-background: #F5E6D0;
  --on-surface: #4E342E;
  --on-surface-variant: #6D4C41;
  --outline: #8D6E63;
  --outline-variant: #A1887F;

  /* Status */
  --error: #D32F2F;
  --success: #388E3C;
  --warning: #FFA000;

  /* Lane colors — cartoon bold */
  --lane-0: #E91E63;
  --lane-1: #2196F3;
  --lane-2: #4CAF50;
  --lane-3: #FFC107;

  /* Cartoon shadows instead of glow */
  --glow-primary: 0 4px 0 #BF360C, 0 8px 24px rgba(255,87,34,0.2);
  --glow-secondary: 0 4px 0 #6A1B9A, 0 8px 24px rgba(156,39,176,0.2);
  --glow-tertiary: 0 4px 0 #FF8F00, 0 8px 24px rgba(255,193,7,0.2);

  /* Glass → Cartoon solid */
  --glass-bg: #F5E6D0;
  --glass-border: #8D6E63;
  --glass-blur: 0px;

  /* Fonts */
  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radius */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--background);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border-bottom: 3px solid var(--outline);
  height: 52px;
  position: relative;
  z-index: 100;
  box-shadow: 0 4px 0 #5D4037;
}

.btn-back {
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.9rem;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.btn-back:hover {
  background: rgba(255, 87, 34, 0.12);
}

.game-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  text-shadow: 2px 2px 0 #BF360C;
  letter-spacing: 0.5px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: var(--space-sm);
}

.score-box {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--surface-container-high);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 3px solid var(--outline);
  box-shadow: 0 3px 0 #5D4037;
}

.score-box.best {
  border-color: var(--tertiary);
  box-shadow: 0 3px 0 #FF8F00;
}

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

.score-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--on-surface);
}

.neon-text {
  color: var(--primary);
  text-shadow: 1px 1px 0 #BF360C;
}

/* ===== GAME CONTAINER ===== */
.game-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  height: calc(100vh - 52px);
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ===== HUD ===== */
.hud-top {
  position: absolute;
  top: var(--space-sm);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  z-index: 10;
  pointer-events: none;
}

.combo-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  border: 3px solid var(--outline);
  box-shadow: 0 4px 0 #5D4037;
}

.combo-count {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.8rem;
  color: var(--primary);
  text-shadow: 2px 2px 0 #BF360C;
}

.combo-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--on-surface-variant);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.combo-mult {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--secondary);
  text-shadow: 2px 2px 0 #6A1B9A;
}

.progress-bar-container {
  width: 200px;
  height: 6px;
  background: var(--outline-variant);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid var(--outline);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--tertiary));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* ===== TIMING FEEDBACK ===== */
.timing-feedback {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.5rem;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.25);
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.1s;
}

.timing-feedback.show {
  opacity: 1;
  animation: feedbackPop 0.4s ease-out forwards;
}

@keyframes feedbackPop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}

.timing-perfect { color: var(--tertiary); }
.timing-good { color: var(--success); }
.timing-miss { color: var(--error); }

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.glass-overlay {
  background: rgba(93, 64, 55, 0.65);
}

.glass-modal {
  background: var(--surface);
  border: 3px solid var(--outline);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 6px 0 #5D4037, 0 12px 32px rgba(93,64,55,0.25);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
  display: block;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  color: var(--primary);
  text-shadow: 2px 2px 0 #BF360C;
  margin-bottom: var(--space-sm);
}

.modal-subtitle {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--on-surface-variant);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.overlay-score {
  margin-bottom: var(--space-md);
}

.neon-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.5rem;
  color: var(--primary);
  text-shadow: 3px 3px 0 #BF360C;
}

/* ===== BUTTONS ===== */
.btn {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1rem;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-block;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: #BF360C;
  box-shadow: 0 4px 0 #BF360C;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #BF360C;
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #BF360C;
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
  border: 3px solid #1a9e4a;
  box-shadow: 0 4px 0 #1a9e4a;
}

.btn-whatsapp:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #1a9e4a;
}

.btn-whatsapp:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1a9e4a;
}

/* ===== GENRE SELECTION MODAL ===== */
.genre-select-modal {
  max-width: 560px;
  width: 95%;
  max-height: 85vh;
  overflow-y: auto;
}

.difficulty-selector {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.diff-btn {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.85rem;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  border: 3px solid var(--outline);
  background: var(--surface-container);
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 3px 0 #5D4037;
}

.diff-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.diff-btn.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: #BF360C;
  box-shadow: 0 3px 0 #BF360C;
}

.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
}

.genre-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 3px solid var(--outline);
  background: var(--surface-container);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 0 #5D4037;
}

.genre-card:hover {
  border-color: var(--primary);
  background: var(--surface-container-high);
  transform: translateY(-4px);
  box-shadow: 0 8px 0 #5D4037;
}

.genre-card:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5D4037;
}

.genre-emoji {
  font-size: 2.2rem;
}

.genre-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--primary);
  text-shadow: 1px 1px 0 #BF360C;
}

.genre-bpm {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--secondary);
}

.genre-desc {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--on-surface-variant);
}

/* ===== MOBILE CONTROLS ===== */
.mobile-controls {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  z-index: 30;
  gap: 2px;
}

.lane-btn {
  flex: 1;
  border: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border-top: 3px solid rgba(0,0,0,0.15);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.lane-btn.lane-0 { background: rgba(233, 30, 99, 0.5); }
.lane-btn.lane-1 { background: rgba(33, 150, 243, 0.5); }
.lane-btn.lane-2 { background: rgba(76, 175, 80, 0.5); }
.lane-btn.lane-3 { background: rgba(255, 193, 7, 0.5); }

.lane-btn:active, .lane-btn.pressed {
  filter: brightness(1.4);
}

.lane-btn.lane-0:active, .lane-btn.lane-0.pressed { background: rgba(233, 30, 99, 0.75); }
.lane-btn.lane-1:active, .lane-btn.lane-1.pressed { background: rgba(33, 150, 243, 0.75); }
.lane-btn.lane-2:active, .lane-btn.lane-2.pressed { background: rgba(76, 175, 80, 0.75); }
.lane-btn.lane-3:active, .lane-btn.lane-3.pressed { background: rgba(255, 193, 7, 0.75); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .game-title {
    font-size: 1.2rem;
  }

  .topbar {
    padding: var(--space-xs) var(--space-sm);
    height: 44px;
  }

  .game-container {
    height: calc(100vh - 44px - 100px);
  }

  .mobile-controls {
    display: flex;
  }

  .genre-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-sm);
  }

  .genre-card {
    padding: var(--space-sm);
  }

  .genre-emoji {
    font-size: 1.6rem;
  }

  .genre-name {
    font-size: 1.1rem;
  }

  .glass-modal {
    padding: var(--space-lg);
  }

  .combo-count {
    font-size: 1.4rem;
  }
}

@media (max-width: 400px) {
  .btn-back { font-size: 0.8rem; }
  .game-title { font-size: 1rem; }
  .score-value { font-size: 1rem; }

  .genre-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mobile-controls {
    height: 80px;
  }

  .game-container {
    height: calc(100vh - 44px - 80px);
  }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { height: 36px; }
  .game-title { font-size: 1rem; }
  .game-container { height: calc(100vh - 36px - 70px); }
  .mobile-controls { height: 70px; }
  .glass-modal { padding: var(--space-md); }
  .modal-icon { font-size: 2rem; margin-bottom: 4px; }
  .modal-title { font-size: 1.4rem; }
  .genre-select-modal { max-height: 90vh; }
}

/* Desktop key indicators */
@media (min-width: 769px) {
  .mobile-controls {
    display: none !important;
  }
}
