* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Trebuchet MS', sans-serif;
  background: linear-gradient(135deg, #E0F7FF 0%, #B3E5FC 100%);
  color: white;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  -ms-touch-action: none;
  touch-action: none;
}

.screen {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

.screen.active { display: flex; }
.screen.overlay { background: rgba(0, 0, 0, 0.9); z-index: 100; }
.hidden { display: none !important; }

/* MENU */
#mainMenu {
  background: linear-gradient(135deg, #1E3A8A, #3B82F6);
  flex-direction: column;
}

.menu-content {
  text-align: center;
  max-width: 600px;
  width: 100%;
  padding: 20px;
  max-height: 95vh;
  overflow-y: auto;
}

.game-title {
  font-size: clamp(2rem, 8vw, 5rem);
  font-weight: 900;
  margin-bottom: 20px;
  text-shadow: 0 0 20px #87CEEB;
  color: #FFFFFF;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 30px 0;
}

.btn {
  padding: 18px 40px;
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  font-weight: bold;
  text-transform: uppercase;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: linear-gradient(135deg, #06B6D4, #0891B2);
  color: white;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.btn-tertiary {
  background: linear-gradient(135deg, #64748B, #475569);
  color: white;
}

.btn-reward {
  background: linear-gradient(135deg, #f093fb, #f5576c);
  color: white;
  animation: pulse 1.5s infinite;
}

.btn:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.controls-info {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  padding: 20px;
  margin: 20px 0;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.controls-info h3 {
  color: #87CEEB;
  margin-bottom: 10px;
}

.control-row {
  margin: 8px 0;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
}

.best-score {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: bold;
  color: #87CEEB;
  margin-top: 20px;
}

/* GAME SCREEN */
#gameScreen {
  background: linear-gradient(to bottom, #E0F7FF, #B3E5FC);
  flex-direction: column;
  padding: 0;
}

.game-hud {
  position: absolute;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(30, 58, 138, 0.6), transparent);
  z-index: 10;
  pointer-events: none;
}

.game-hud button {
  pointer-events: all;
}

.hud-left { display: flex; gap: 20px; align-items: flex-start; }

.score-display, .distance-display {
  display: flex;
  flex-direction: column;
}

.score-display .value, .distance-display .value {
  font-size: clamp(1.4rem, 4vw, 2.5rem);
  font-weight: 900;
  color: #FFFFFF;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  line-height: 1;
}

.score-display span:first-child,
.distance-display span:first-child {
  font-size: clamp(0.65rem, 1.5vw, 0.9rem);
  opacity: 0.8;
}

.hud-right { display: flex; gap: 10px; align-items: flex-start; }

.icon-btn {
  width: clamp(36px, 6vw, 50px);
  height: clamp(36px, 6vw, 50px);
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* CANVAS — fills the full screen */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* MOBILE CONTROLS */
.mobile-controls {
  display: none;
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
}

@media (max-width: 768px), (pointer: coarse) {
  .mobile-controls { display: flex; }
}

.mobile-btn {
  padding: clamp(12px, 3vw, 20px) clamp(24px, 6vw, 40px);
  border: none;
  border-radius: 15px;
  background: rgba(59, 130, 246, 0.8);
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: bold;
  color: white;
  border: 3px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mobile-btn:active {
  transform: scale(0.95);
  background: rgba(59, 130, 246, 1);
}

/* PAUSE / GAMEOVER */
.pause-content, .gameover-content {
  text-align: center;
  width: 90%;
  max-width: 500px;
  padding: clamp(20px, 4vw, 40px);
  background: rgba(30, 58, 138, 0.95);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-height: 95vh;
  overflow-y: auto;
}

.pause-content {
  border: 3px solid #3B82F6;
}

.gameover-content {
  border: 3px solid #FF6B6B;
}

.screen-title {
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  margin-bottom: 20px;
}

.pause-stats, .final-stats {
  display: flex;
  gap: 20px;
  margin: 20px 0;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-item, .stat-box {
  flex: 1;
  min-width: 120px;
}

.stat-value {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 900;
  color: #87CEEB;
  display: block;
}

.stat-value.big {
  font-size: clamp(2rem, 5vw, 3rem);
  color: #3B82F6;
}

.new-record {
  background: linear-gradient(135deg, #3B82F6, #06B6D4);
  padding: 15px;
  border-radius: 12px;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: bold;
  margin-bottom: 20px;
  animation: pulse 1s infinite;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.5);
}
/* Low-height iframe adaptation (e.g. 800x450) */
@media (max-height: 500px) {
  .game-title { font-size: clamp(1.2rem, 5vw, 2rem); margin-bottom: 8px; }
  .menu-content > p { display: none; }
  .controls-info { padding: 10px; margin: 8px 0; }
  .controls-info h3 { margin-bottom: 4px; }
  .control-row { margin: 3px 0; font-size: 0.85rem; }
  .menu-buttons { margin: 10px 0; gap: 8px; }
  .btn { padding: 10px 24px; }
  .best-score { margin-top: 8px; font-size: 1rem; }
  .screen-title { font-size: clamp(1.2rem, 4vw, 2rem); margin-bottom: 10px; }
  .pause-stats, .final-stats { margin: 10px 0; gap: 10px; }
  .stat-value { font-size: clamp(1.2rem, 3vw, 1.8rem); }
  .stat-value.big { font-size: clamp(1.4rem, 3.5vw, 2rem); }
  .new-record { padding: 8px; margin-bottom: 10px; font-size: clamp(0.8rem, 2vw, 1rem); }
  .pause-content, .gameover-content { padding: 15px; }
}