:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --text: #ffffff;
  --accent: #60a5fa;
  --accent-2: #34d399;
  --banana: #f7d154;
}

* { box-sizing: border-box; }
html, body { 
  height: 100%; 
  background: #1E40FF;
}
body {
  margin: 0;
  background: #1E40FF;
  color: var(--text);
  font-family: 'Rubik', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  display: grid;
  place-items: center;
}

#game {
  width: min(96vw, 420px);
  height: calc(min(96vw, 420px) * (16/9));
  max-height: 92vh;
  background: #000;
  border-radius: 14px;
  border: 1px solid var(--banana);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5), inset 0 0 80px rgba(0,0,0,0.35);
  touch-action: none; /* prevent scroll/pinch from offsetting touch */
}

#stage { position: relative; }
#gameOver {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  background: radial-gradient(1000px 700px at 50% -120px, rgba(247,209,84,0.06), rgba(0,0,0,0.6));
  border-radius: 14px;
  pointer-events: auto; /* allow clicks on buttons */
}
#gameOver.hidden { display: none !important; }
#gameOver h2 { margin: 0 0 6px; font-size: 28px; }
#gameOver p { margin: 0; opacity: 0.9; }
#gameOver .personal-best { margin-top: 8px; font-size: 14px; opacity: 0.8; }
.leaderboard {
  margin-top: 16px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 12px;
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
}
.leaderboard h3 { margin: 0 0 8px; font-size: 16px; }
#leaderboardList {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
}
.leaderboard-item.you {
  background: rgba(247,209,84,0.2);
  border: 1px solid var(--banana);
}
.score-submit-prompt {
  margin-top: 16px;
  text-align: center;
}
.score-submit-prompt p {
  margin: 0 0 10px;
  font-size: 14px;
  opacity: 0.9;
}
.score-submit-prompt input {
  background: rgba(10,10,10,0.8);
  color: #ffffff;
  border: 2px solid var(--banana);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 180px;
  text-align: center;
  margin-bottom: 12px;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}
.score-submit-prompt input:focus {
  outline: none;
  border-color: #fff;
}
.gameOver-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  justify-content: center;
}
.gameOver-actions button {
  background: linear-gradient(135deg, var(--banana), #ffd700);
  color: #000;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  pointer-events: auto;
  position: relative;
  z-index: 10;
}

#namePrompt {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1000px 700px at 50% -120px, rgba(30,64,255,0.3), rgba(0,0,0,0.7));
  z-index: 1000;
}
#namePrompt.hidden { display: none; }
#namePrompt h2 { margin: 0 0 16px; font-size: 24px; }
#namePrompt input {
  background: rgba(10,10,10,0.8);
  color: #ffffff;
  border: 2px solid var(--banana);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 16px;
  font-family: inherit;
  width: 200px;
  text-align: center;
  margin-bottom: 12px;
}
#namePrompt input:focus {
  outline: none;
  border-color: #fff;
}
#namePrompt button {
  background: linear-gradient(135deg, var(--banana), #ffd700);
  color: #000;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
}

.stat span { opacity: 0.75; margin-right: 4px; }
.stat strong { color: #ffffff; }

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(900px 700px at 50% -120px, rgba(60,80,120,0.25), rgba(13,17,23,0.85));
  padding: 20px;
  text-align: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 160ms ease, visibility 160ms ease;
}
#overlay.show { visibility: visible; opacity: 1; }

#overlay h1 { margin: 6px 0; }
#overlay p { display: none; }

#titleBar { margin-top: 8px; margin-bottom: 6px; text-align: center; }
#titleBar h1 { 
  margin: 0; 
  font-size: 32px; 
  font-family: 'Bungee', cursive;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

#controlBar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(10, 10, 10, 0.7);
  border: 1px solid var(--banana);
  padding: 8px 12px;
  border-radius: 10px;
  backdrop-filter: blur(6px);
  margin-bottom: 10px;
  width: min(96vw, 520px);
}
#controlBar .actions { display: flex; gap: 8px; }
#controlBar .stats { display: flex; gap: 10px; align-items: center; }
#actionBtn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

/* removed old touch controls */

#ui {
  position: fixed;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 12px;
  background: rgba(20, 26, 34, 0.6);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(6px);
  padding: 8px 10px;
  border-radius: 10px;
  align-items: center;
}

.stat span { opacity: 0.7; margin-right: 4px; }
.stat strong { color: #ffffff; }

#pauseBtn {
  margin-left: 6px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
#pauseBtn:active { transform: translateY(1px); }

#game {
  width: min(96vw, 960px);
  height: calc(min(96vw, 960px) * (9/16));
  border-radius: 12px;
  background: #0b1118;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5), inset 0 0 80px rgba(0,0,0,0.4);
}

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1000px 700px at 50% -100px, rgba(44,60,80,0.25), rgba(12,15,20,0.85));
  padding: 20px;
  text-align: center;
}

#overlay.hidden { display: none; }

#overlay h1 {
  margin: 8px 0 2px;
}

#overlay p {
  margin: 0 0 16px;
  opacity: 0.8;
}

#startBtn, #restartBtn {
  background: linear-gradient(135deg, var(--accent), #5df2f5);
  color: #041016;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  margin: 0 6px;
}

#restartBtn.hidden { display: none; }

@media (max-width: 560px) {
  #titleBar { margin-top: 6px; margin-bottom: 6px; }
  #titleBar h1 { font-size: 24px; letter-spacing: 1.5px; }
  #controlBar { width: calc(100vw - 24px); gap: 10px; }
  #game { width: calc(100vw - 24px); height: 60vh; }
  .leaderboard { max-height: 150px; font-size: 11px; }
}

/* Ensure good fit in phone landscape: make canvas fill available viewport */
@media (orientation: landscape) and (max-height: 520px) {
  #titleBar { display: none; }
  #controlBar { width: calc(100vw - 24px); margin-bottom: 6px; }
  #game { width: calc(100vw - 24px); height: calc(100vh - 100px); }
  #gameOver:not(.hidden) {
    display: grid !important;
  }
  .leaderboard {
    max-height: 150px;
    font-size: 11px;
  }
}


