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

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; user-select: none; touch-action: none; }
body { background: #0f172a; display: flex; justify-content: center; align-items: center; min-height: 100vh; overflow: hidden; }

#game-container { 
  position: relative; 
  width: 100%; 
  max-width: 100%; /* Fully flexible for mobile */
  height: 100vh; 
  max-height: 100vh; 
  background: #70c5ce; 
  overflow: hidden; 
  box-shadow: 0 0 30px rgba(0,0,0,0.5); 
}

/* Widescreen enhancement for PC / Tablets */
@media (min-width: 768px) {
  #game-container {
    height: 85vh;
    max-height: 900px;
    max-width: 1200px; /* Big wide screen experience */
    border-radius: 20px;
    border: 6px solid #1e293b;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  }
}

canvas { display: block; width: 100%; height: 100%; }

#ui-layer { 
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
  pointer-events: none; display: flex; flex-direction: column; 
}

.top-bar { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 30px; pointer-events: auto; }

.score-display, .high-score-display { 
  background: rgba(15, 23, 42, 0.7); color: white; padding: 10px 20px; 
  border-radius: 25px; font-weight: 700; display: flex; align-items: center; gap: 10px; font-size: 1.4rem; 
  backdrop-filter: blur(5px); box-shadow: 0 4px 15px rgba(0,0,0,0.4); border: 2px solid rgba(255,255,255,0.1);
}
.score-display i { color: #34d399; }
.high-score-display i { color: #fbbf24; }

.action-btn { 
  background: #3b82f6; color: white; border: 2px solid rgba(255,255,255,0.2); width: 50px; height: 50px; 
  border-radius: 50%; cursor: pointer; font-size: 1.4rem; display: flex; 
  justify-content: center; align-items: center; box-shadow: 0 4px 15px rgba(0,0,0,0.4); 
  transition: all 0.15s ease;
}
.action-btn:hover { background: #2563eb; transform: scale(1.05); }
.action-btn:active { transform: scale(0.9); }

.overlay { 
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; 
  background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(6px); 
  display: flex; justify-content: center; align-items: center; 
  pointer-events: auto; z-index: 10; 
}

.modal { 
  background: #1e293b; color: white; padding: 40px 5%; max-width: 380px; width: 85%;
  border-radius: 20px; text-align: center; border: 3px solid #334155; 
  box-shadow: 0 20px 50px rgba(0,0,0,0.9);
  transform: translateY(0); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: popIn 0.4s ease-out;
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.8) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Shake effect for crashes */
@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.shake { animation: shake 0.4s; }

.modal h2 { font-size: 2.5rem; color: #f8fafc; margin-bottom: 15px; }
#gameOverMenu h2 { color: #ef4444; text-shadow: 0 0 20px rgba(239, 68, 68, 0.6); }

.modal p { font-size: 1.2rem; margin-bottom: 25px; color: #cbd5e1; }
.modal .highlight-score { color: #fbbf24; font-size: 1.8rem; font-weight: bold; background: rgba(0,0,0,0.2); padding: 5px 15px; border-radius: 10px;}
.modal .main-icon { font-size: 5rem; color: #fbbf24; margin-bottom: 20px; filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5)); animation: float 3s ease-in-out infinite; }

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

.modal button { 
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; 
  padding: 18px; font-size: 1.3rem; font-weight: bold; border: none; border-radius: 15px; cursor: pointer; 
  color: white; transition: all 0.2s; background: linear-gradient(145deg, #10b981, #059669); 
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}
.modal button:hover { background: linear-gradient(145deg, #34d399, #10b981); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(16, 185, 129, 0.6); }
.modal button:active { transform: translateY(2px); box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3); }
