/* =============================================
   LA ABEJITA LISCA — Estilos Globales
   Paleta: amarillo pastel, verde menta, rosado, lavanda, cielo
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

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

:root {
  --yellow:   #FFE566;
  --yellow-d: #FFB800;
  --yellow-dk:#D4900A;
  --green:    #A8E6CF;
  --green-d:  #5DBE99;
  --pink:     #FFB3C6;
  --pink-d:   #FF6B9D;
  --lavender: #DEB0F5;
  --lavender-d:#A855D8;
  --sky:      #B3D9FF;
  --sky-d:    #5BAAFF;
  --white:    #FFFDF7;
  --text:     #4A3728;
  --heart:    #FF4E6A;
  --shadow:   rgba(74,55,40,0.15);
  --r-btn:    24px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(180deg, #B3E0FF 0%, #E8F9FF 40%, #FEFFF0 100%);
  user-select: none;
  touch-action: none;
}

/* ===== CANVAS ===== */
#gameCanvas {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ===== OVERLAY SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  overflow-y: auto; /* Permite scroll en pantallas pequeñas o laptops */
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* Centrado vertical fluido (evita que se corte la parte superior en laptops) */
.screen::before,
.screen::after {
  content: '';
  flex: 1 0 auto;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ===== MENU SCREEN ===== */
#screen-menu {
  background: linear-gradient(180deg, rgba(179,217,255,0.92) 0%, rgba(255,249,230,0.96) 100%);
  backdrop-filter: blur(4px);
}

.menu-logo {
  animation: float 3s ease-in-out infinite;
  margin-bottom: 8px;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

.game-title {
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 900;
  color: var(--text);
  text-align: center;
  line-height: 1.1;
  text-shadow: 3px 3px 0 rgba(255,200,0,0.4);
  letter-spacing: -0.5px;
}

.game-subtitle {
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  font-weight: 600;
  color: #7A6050;
  margin-bottom: 28px;
  text-align: center;
}

/* Name input */
.name-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 300px;
}

.name-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #7A6050;
  letter-spacing: 0.5px;
}

.name-input {
  width: 100%;
  padding: 12px 20px;
  border: 3px solid var(--yellow-d);
  border-radius: 50px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(255,255,255,0.9);
  outline: none;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(255,184,0,0.15);
}

.name-input:focus {
  border-color: var(--pink-d);
  box-shadow: 0 0 0 4px rgba(255,107,157,0.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 40px;
  border: none;
  border-radius: var(--r-btn);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15), 0 6px 20px rgba(0,0,0,0.12);
  position: relative;
  min-width: 200px;
  letter-spacing: 0.3px;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1);
}

.btn-start {
  background: linear-gradient(135deg, #FFE566, #FFB800);
  color: #4A3728;
}

.btn-start:hover { filter: brightness(1.05); transform: translateY(-2px); }

.btn-restart {
  background: linear-gradient(135deg, #FFB3C6, #FF6B9D);
  color: #fff;
}

.btn-next {
  background: linear-gradient(135deg, #A8E6CF, #5DBE99);
  color: #fff;
}

/* ===== BABY MODE TOGGLE ===== */
.baby-mode-section {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  width: 100%;
  max-width: 300px;
}

.mode-btn {
  flex: 1;
  padding: 10px 8px;
  border: 2.5px solid rgba(255,184,0,0.3);
  border-radius: 50px;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(0.8rem, 3.2vw, 1rem);
  font-weight: 700;
  cursor: pointer;
  background: rgba(255,255,255,0.6);
  color: #7A6050;
  transition: all 0.2s ease;
}

.mode-btn--active {
  background: linear-gradient(135deg, #FFE566, #FFB800);
  border-color: #D4900A;
  color: #4A3728;
  box-shadow: 0 3px 0 rgba(0,0,0,0.12);
}

.mode-btn:active { transform: scale(0.96); }

.mode-description {
  font-size: 0.8rem;
  font-weight: 600;
  color: #7A6050;
  text-align: center;
  margin-bottom: 14px;
  min-height: 18px;
  transition: all 0.2s;
}

/* Instructions */

.instructions {
  margin-top: 20px;
  background: rgba(255,255,255,0.7);
  border-radius: 20px;
  padding: 14px 20px;
  max-width: 320px;
  width: 100%;
  border: 2px solid rgba(255,184,0,0.2);
}

.instructions p {
  font-size: 0.88rem;
  font-weight: 600;
  color: #7A6050;
  text-align: center;
  line-height: 1.6;
}

.inst-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.95rem;
  color: var(--text);
}

.inst-icon {
  font-size: 1.4rem;
}

/* ===== HUD (in-game UI) ===== */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(179,217,255,0.85) 0%, transparent 100%);
}

#hud.hidden { display: none; }

.hud-lives {
  display: flex;
  gap: 6px;
  align-items: center;
}

.heart {
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  transition: transform 0.3s, filter 0.3s;
  filter: drop-shadow(0 2px 4px rgba(255,78,106,0.4));
}

.heart.lost {
  opacity: 0.3;
  filter: grayscale(1);
}

.heart.pulse {
  animation: heartPulse 0.5s ease;
}

@keyframes heartPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.hud-score {
  font-size: clamp(1.2rem, 5vw, 1.6rem);
  font-weight: 900;
  color: var(--text);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
  letter-spacing: -0.5px;
}

.hud-level {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hud-level-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #7A6050;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-level-num {
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 900;
  color: var(--lavender-d);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
}

/* Action buttons (Mute & Home) */
#btn-mute, #btn-home {
  position: fixed;
  bottom: 20px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(8px);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: transform 0.15s;
  pointer-events: all;
}

#btn-mute { right: 16px; }
#btn-home { left: 16px; }

#btn-home.hidden { display: none; }

#btn-mute:active, #btn-home:active { transform: scale(0.9); }

/* Lane guides (subtle) */
.lane-guide {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.25);
  pointer-events: none;
  z-index: 1;
}

#lane-left  { left: 33.33%; }
#lane-right { left: 66.66%; }

/* Touch zones (invisible, for UX) */
.touch-zone {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 8;
  display: none;
}
#touch-left  { left: 0; }
#touch-right { right: 0; }

/* ===== GAME OVER SCREEN ===== */
#screen-gameover {
  background: linear-gradient(180deg, rgba(255,179,198,0.93) 0%, rgba(255,229,102,0.96) 100%);
  backdrop-filter: blur(6px);
}

.gameover-bee {
  animation: dance 0.6s ease-in-out infinite alternate;
  margin-bottom: 8px;
}

@keyframes dance {
  0%   { transform: rotate(-15deg) scale(1); }
  100% { transform: rotate(15deg) scale(1.05); }
}

.gameover-title {
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  font-weight: 900;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
}

.gameover-score {
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 700;
  color: #7A6050;
  text-align: center;
  margin-bottom: 4px;
}

.gameover-best {
  font-size: clamp(0.85rem, 3.2vw, 1.1rem);
  font-weight: 600;
  color: var(--pink-d);
  text-align: center;
  margin-bottom: 24px;
}

/* ===== TUTORIAL SCREEN ===== */
#screen-tutorial {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50; /* Above everything */
}
.tutorial-content {
  background: #FFFDF7;
  padding: 30px 20px;
  border-radius: 24px;
  text-align: center;
  width: 100%;
  max-width: 340px;
  border: 4px solid var(--yellow-d);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.tutorial-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 20px;
}
.tutorial-hands {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}
.tut-hand {
  flex: 1;
  background: rgba(179,217,255,0.4);
  padding: 16px 8px;
  border-radius: 16px;
  border: 2px solid rgba(179,217,255,0.8);
}
.tut-icon {
  font-size: 2.8rem;
  display: block;
  margin-bottom: 8px;
}
.animated-tap {
  animation: tapAnim 1s infinite alternate ease-in-out;
}
@keyframes tapAnim {
  0% { transform: scale(1) translateY(0); }
  100% { transform: scale(0.9) translateY(8px); }
}
.tut-hand p {
  font-size: 0.9rem;
  font-weight: 800;
  color: #5BAAFF;
  line-height: 1.3;
}

/* ===== LEVEL UP SCREEN ===== */
#screen-levelup {
  background: linear-gradient(180deg, rgba(168,230,207,0.93) 0%, rgba(179,217,255,0.96) 100%);
  backdrop-filter: blur(6px);
}

.levelup-title {
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 900;
  color: var(--text);
  text-align: center;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0%   { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.levelup-subtitle {
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 700;
  color: #4A8060;
  text-align: center;
  margin-bottom: 24px;
  animation: popIn 0.5s 0.1s both cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.levelup-stars {
  font-size: 2.5rem;
  letter-spacing: 8px;
  animation: popIn 0.5s 0.2s both cubic-bezier(0.175, 0.885, 0.32, 1.275);
  margin-bottom: 20px;
}

/* ===== FLOWER COUNTER BAR ===== */
#flower-bar-container {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 5;
  padding: 6px 16px 10px;
  background: linear-gradient(to top, rgba(255,249,230,0.85) 0%, transparent 100%);
  pointer-events: none;
}

#flower-bar-container.hidden { display: none; }

.flower-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #7A6050;
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.flower-bar-track {
  height: 10px;
  background: rgba(255,255,255,0.6);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255,184,0,0.3);
}

.flower-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFB3C6, #FFB800, #A8E6CF);
  border-radius: 10px;
  transition: width 0.3s ease;
  width: 0%;
  position: relative;
}

.flower-bar-fill::after {
  content: '🌸';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
}

/* ===== SCORE POPUP (canvas overlaid by absolute div) ===== */
.score-popup {
  position: fixed;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  pointer-events: none;
  z-index: 15;
  animation: scoreFloat 0.9s ease-out forwards;
  white-space: nowrap;
}

@keyframes scoreFloat {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-70px) scale(0.7); opacity: 0; }
}

/* ===== LOADING SCREEN ===== */
#screen-loading {
  background: linear-gradient(180deg, #B3D9FF 0%, #FFF9E6 100%);
  z-index: 100;
}

.loading-bee {
  animation: loadFloat 1.5s ease-in-out infinite;
  font-size: 5rem;
}

@keyframes loadFloat {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-20px) rotate(5deg); }
}

.loading-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: #7A6050;
  margin-top: 16px;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ===== RESPONSIVE ===== */
@media (max-height: 600px) {
  .game-title { font-size: 1.8rem; }
  .btn { padding: 12px 30px; font-size: 1rem; }
}

@media (prefers-color-scheme: dark) {
  /* Keep bright pastel in dark mode for kids */
  html, body {
    background: linear-gradient(180deg, #B3E0FF 0%, #E8F9FF 40%, #FEFFF0 100%);
  }
}
