@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #000;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
}

#game-container {
  position: relative;
  width: min(100vw, 800px, calc(100vh * 4 / 3));
  aspect-ratio: 4 / 3;
}

canvas {
  display: block;
  background: #0a0a1a;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
}

#ui-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#ui-overlay > * {
  pointer-events: auto;
}

/* Menu */
#menu-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(10, 10, 26, 0.92);
  z-index: 10;
}

#menu-screen h1 {
  font-size: 28px;
  color: #ffdd57;
  text-shadow: 0 0 20px #ffdd57, 0 0 40px #ff8800;
  margin-bottom: 10px;
  letter-spacing: 4px;
}

#menu-screen .subtitle {
  font-size: 10px;
  color: #8888cc;
  margin-bottom: 40px;
}

.controls-info {
  margin-top: 40px;
  text-align: center;
  font-size: 7px;
  line-height: 2;
  color: #6666aa;
}

button {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 14px 40px;
  background: transparent;
  color: #ffdd57;
  border: 2px solid #ffdd57;
  cursor: pointer;
  transition: all 0.2s;
  text-shadow: 0 0 10px #ffdd57;
}

button:hover {
  background: #ffdd57;
  color: #0a0a1a;
  box-shadow: 0 0 30px #ffdd57;
}

/* HUD */
#hud {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  padding: 12px 90px 12px 20px;
  display: none;
  justify-content: space-between;
  font-size: 10px;
  color: #aaa;
  text-shadow: 0 0 8px rgba(255,255,255,0.3);
}

#round-display {
  color: #ffdd57;
}

#muteBtn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 12px;
  background: transparent;
  color: #6666aa;
  border: 1px solid #6666aa;
  cursor: pointer;
  transition: all 0.2s;
  position: absolute;
  top: 8px;
  right: 8px;
}
#muteBtn:hover {
  background: #6666aa;
  color: #0a0a1a;
}

#score-display.pop {
  animation: scorePop 0.3s ease-out;
}
@keyframes scorePop {
  0% { transform: scale(1.8); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

/* Transition */
#transition-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(10, 10, 26, 0.95);
  z-index: 10;
}

#transition-screen h2 {
  font-size: 20px;
  color: #8844cc;
  text-shadow: 0 0 30px #8844cc;
  margin-bottom: 16px;
}

#transition-screen .subtitle {
  font-size: 10px;
  color: #aa66ee;
  margin-bottom: 10px;
}

.transition-hint {
  font-size: 14px;
  color: #ff4444;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.4; transform: scale(1); }
  to   { opacity: 1;   transform: scale(1.15); }
}

/* Secondary button */
.menu-secondary-btn {
  font-size: 10px;
  padding: 10px 30px;
  margin-top: 10px;
  color: #8888cc;
  border-color: #8888cc;
}
.menu-secondary-btn:hover {
  background: #8888cc;
  color: #0a0a1a;
  box-shadow: 0 0 20px #8888cc;
}
#endlessBtn {
  color: #ff8844;
  border-color: #ff8844;
}
#endlessBtn:hover {
  background: #ff8844;
  color: #0a0a1a;
  box-shadow: 0 0 20px #ff8844;
}

/* Result */
#result-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(10, 10, 26, 0.92);
  z-index: 10;
}

#result-screen h2 {
  font-size: 22px;
  margin-bottom: 20px;
}

#result-message {
  font-size: 10px;
  margin-bottom: 16px;
  color: #ccc;
}

#final-score {
  font-size: 12px;
  color: #ffdd57;
  margin-bottom: 30px;
}

#result-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

#continueBtn {
  font-size: 14px;
  padding: 14px 50px;
  color: #44ff88;
  border-color: #44ff88;
}
#continueBtn:hover {
  background: #44ff88;
  color: #0a0a1a;
  box-shadow: 0 0 30px #44ff88;
}

/* Level Select */
#level-select-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(10, 10, 26, 0.95);
  z-index: 10;
}

#level-select-screen h2 {
  font-size: 18px;
  color: #ffdd57;
  text-shadow: 0 0 20px #ffdd57;
  margin-bottom: 24px;
}

#level-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  max-width: 520px;
  width: 92%;
  margin-bottom: 20px;
  max-height: 360px;
  overflow-y: auto;
  padding: 0 4px;
}

.level-card {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 16px 10px;
  background: rgba(255,255,255,0.03);
  color: #aaa;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.level-card:hover {
  background: rgba(255,221,87,0.1);
  border-color: #ffdd57;
  color: #ffdd57;
}
.level-card.locked {
  opacity: 0.35;
  cursor: default;
  border-color: rgba(255,255,255,0.06);
}
.level-card.locked:hover {
  opacity: 0.35;
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
  color: #aaa;
}
.level-card.locked .lvl-num {
  font-size: 16px;
  color: #555;
}
.level-card .lvl-num {
  font-size: 14px;
  color: #ffdd57;
  display: block;
  margin-bottom: 4px;
}
.level-card .lvl-name {
  font-size: 7px;
  color: #888;
  display: block;
  margin-bottom: 4px;
}
.level-card .lvl-stars {
  font-size: 10px;
  color: #ffdd57;
  text-shadow: 0 0 8px #ffdd57;
}
