* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.6s ease;
  background: #f8d84f;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UI
   ═══════════════════════════════════════════════════════════════════════════════ */
.ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SCREEN TRANSITIONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 216, 79, 0.95);
  backdrop-filter: blur(15px);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  pointer-events: all;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MENU
   ═══════════════════════════════════════════════════════════════════════════════ */
.menu-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 2rem;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  backdrop-filter: blur(25px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  width: min(90vw, 400px);
  transform: translateY(0);
  animation: menuFloat 3s ease-in-out infinite alternate;
}

@keyframes menuFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════════════ */
.title {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 800;
  color: #fff;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 1.5rem;
}

.tap-instruction {
  position: absolute;
  bottom: clamp(2rem, 8vw, 4rem);
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.9rem, 3.5vw, 1.1rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 1);
  pointer-events: none;
  animation: tapPulse 2s ease-in-out infinite;
  opacity: 0;
  transition: opacity 0.5s ease;
}

@keyframes tapPulse {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.7; }
  50% { transform: translateX(-50%) scale(1.05); opacity: 1; }
}

.game-playing .tap-instruction {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2.5rem;
  margin: 0.75rem 0;
  background: linear-gradient(135deg, #fff 0%, #f8f8f8 100%);
  color: #333;
  border: none;
  border-radius: 50px;
  font-family: inherit;
  font-size: clamp(0.9rem, 3.5vw, 1.1rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 8px 25px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  min-width: clamp(160px, 45vw, 200px);
  pointer-events: all;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s;
}

.btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 12px 35px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.btn:hover::before {
  left: 100%;
}

.btn:active {
  transform: translateY(-1px) scale(0.98);
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SCORE BOX
   ═══════════════════════════════════════════════════════════════════════════════ */
.score {
  position: absolute;
  top: clamp(1rem, 4vw, 2rem);
  right: clamp(1rem, 4vw, 2rem);
  text-align: right;
  pointer-events: none;
  z-index: 1001;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transform: translateY(0);
  animation: scoreFloat 2s ease-in-out infinite alternate;
}

@keyframes scoreFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-5px); }
}

.score-main {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  color: #fff;
  line-height: 1;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-best {
  font-size: clamp(0.8rem, 3vw, 1rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}


/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE OPTIMIZATIONS
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .menu-container {
    padding: 2rem 1.5rem;
    border-radius: 20px;
  }

  .score {
    padding: 0.75rem 1rem;
    border-radius: 16px;
  }

  .btn {
    padding: 0.75rem 2rem;
    margin: 0.5rem 0;
  }
}

@media (max-width: 320px) {
  .menu-container {
    padding: 1.5rem 1rem;
  }

  .btn {
    padding: 0.6rem 1.5rem;
    min-width: 140px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY & PERFORMANCE
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .score-main,
  .title {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .menu-container,
  .score,
  .tap-instruction {
    animation: none;
  }
}

.btn:focus {
  outline: 3px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   GAME STATE STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */
.game-playing .score {
  opacity: 1;
  transform: translateY(0);
}

.game-menu .score,
.game-over .score {
  opacity: 0.6;
  transform: translateY(-10px);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════════════════════════════════════ */
.loading {
  pointer-events: none;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TRANSITIONS FOR COLORS CHANGE
   ═══════════════════════════════════════════════════════════════════════════════ */
.screen,
body {
  transition: background-color 0.6s ease;
}
