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

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

body {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  background: #1a1410;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  font-family: 'Press Start 2P', monospace;
  image-rendering: pixelated;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ===== START SCREEN ===== */
#start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 5, 0, 0.85);
  pointer-events: auto;
  gap: 20px;
}

.start-title {
  font-size: 28px;
  color: #ffe8c8;
  text-shadow: 3px 3px 0 #000, 4px 4px 0 rgba(200,100,50,0.3);
  text-align: center;
  line-height: 1.4;
}

.start-rules {
  text-align: center;
  line-height: 2.2;
}
.start-rules p {
  font-size: 8px;
  color: #ffe8c8;
  text-shadow: 1px 1px 0 #000;
}
.start-rules .dim { color: rgba(255,232,200,0.5); }

.start-controls {
  text-align: center;
  line-height: 2;
  border: 1px solid rgba(255,232,200,0.15);
  padding: 10px 16px;
  border-radius: 4px;
}
.start-controls p {
  font-size: 7px;
  color: rgba(255,232,200,0.6);
  text-shadow: 1px 1px 0 #000;
}

#start-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  background: rgba(255,232,200,0.1);
  border: 2px solid rgba(255,232,200,0.3);
  color: #ffe8c8;
  padding: 14px 36px;
  cursor: pointer;
  border-radius: 3px;
  margin-top: 12px;
  pointer-events: auto;
  transition: background 0.15s, border-color 0.15s;
}
#start-btn:hover { background: rgba(255,232,200,0.2); border-color: rgba(255,232,200,0.5); }

.start-links {
  margin-top: 10px;
  pointer-events: auto;
}

.start-credits {
  font-size: 6px;
  color: rgba(255,232,200,0.35);
  text-align: center;
  line-height: 2;
  margin-top: 12px;
}
.start-credits .accent { color: rgba(255,180,100,0.6); }
.start-credits .small { font-size: 5px; }

/* ===== HUD ===== */
#score {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 12px;
  color: #ffe8c8;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
}

#points {
  position: absolute;
  top: 30px;
  left: 12px;
  font-size: 9px;
  color: #ffb870;
  text-shadow: 2px 2px 0 #000;
}

#combo-container {
  position: absolute;
  top: 48px;
  left: 12px;
  font-size: 8px;
  color: #ff9a76;
  text-shadow: 2px 2px 0 #000;
  transition: transform 0.1s ease-out;
}
#combo-container.hidden { display: none; }
#combo-container.pop { transform: scale(1.4); }

#combo-splash {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 20px;
  color: #ffe8c8;
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
#combo-splash.show {
  animation: combo-splash-in 0.6s ease-out forwards;
}
@keyframes combo-splash-in {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(-5deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.3) rotate(2deg); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1.0) rotate(-1deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.0) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(0.8); opacity: 0; }
}

#biome-name {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #ffe8c8;
  text-shadow: 3px 3px 0 #000;
  opacity: 0;
  pointer-events: none;
}
#biome-name.show { animation: biome-fade 2.5s ease-out forwards; }
@keyframes biome-fade {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  15% { opacity: 1; transform: translate(-50%, -50%); }
  70% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

#momentum-label {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  color: rgba(255,232,200,0.5);
  text-shadow: 1px 1px 0 #000;
  transition: opacity 0.3s;
}
#momentum-label.hidden { opacity: 0; }

/* Charge bar */
#charge-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 6px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,232,200,0.2);
  opacity: 0;
  transition: opacity 0.15s;
}
#charge-bar.visible { opacity: 1; }
#charge-fill {
  height: 100%;
  width: 0%;
  background: #ffe8c8;
  transition: width 0.05s linear;
}
#charge-fill.full { background: #ff9a76; }

#speed-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(
    0deg, transparent 0px, transparent 8px,
    rgba(255,255,255,0.03) 8px, rgba(255,255,255,0.03) 10px
  );
  transition: opacity 0.3s;
}

.hidden { display: none !important; }

/* ===== GAME OVER ===== */
#game-over {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 5, 0, 0.8);
  pointer-events: auto;
  gap: 8px;
}

.go-title {
  font-size: 20px;
  color: #ff6b6b;
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 8px;
}

#go-height {
  font-size: 11px;
  color: #ffe8c8;
  text-shadow: 2px 2px 0 #000;
}

#go-points {
  font-size: 14px;
  color: #ffb870;
  text-shadow: 2px 2px 0 #000;
}

#go-combo {
  font-size: 8px;
  color: #ff9a76;
  text-shadow: 2px 2px 0 #000;
}

#go-best {
  font-size: 10px;
  color: #ff22ff;
  text-shadow: 2px 2px 0 #000;
  animation: pulse 0.8s ease-in-out infinite;
}

/* Name input */
#name-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  pointer-events: auto;
}

#name-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  background: rgba(255,232,200,0.08);
  border: 1px solid rgba(255,232,200,0.25);
  color: #ffe8c8;
  padding: 6px 8px;
  width: 120px;
  outline: none;
  border-radius: 2px;
  text-transform: uppercase;
}
#name-input::placeholder { color: rgba(255,232,200,0.25); }
#name-input:focus { border-color: rgba(255,180,100,0.5); }

#submit-score {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  background: rgba(255,180,100,0.2);
  border: 1px solid rgba(255,180,100,0.4);
  color: #ffb870;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 2px;
}
#submit-score:hover { background: rgba(255,180,100,0.3); }
#submit-score:disabled { opacity: 0.4; cursor: default; }

#submit-status {
  font-size: 7px;
  color: #b8e0d2;
  text-shadow: 1px 1px 0 #000;
  margin-top: 4px;
}

/* Interactive zone — no accidental restart */
#go-interactive {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  pointer-events: auto;
  width: 100%;
  max-width: 280px;
}

#go-leaderboard {
  margin-top: 6px;
  text-align: center;
  border: 1px solid rgba(255,232,200,0.12);
  padding: 8px 14px;
  border-radius: 4px;
  min-width: 180px;
}

.lb-title {
  font-size: 7px;
  color: rgba(255,232,200,0.5);
  margin-bottom: 6px;
}

#lb-list {
  font-size: 7px;
  color: rgba(255,232,200,0.7);
  text-shadow: 1px 1px 0 #000;
  line-height: 2;
  text-align: left;
}
#lb-list .you { color: #ffb870; }
#lb-list .lb-sep { color: rgba(255,232,200,0.25); font-size: 6px; margin: 3px 0; }
#lb-list .lb-you { font-size: 7px; margin-top: 2px; }
#lb-list .lb-gap { color: rgba(255,232,200,0.35); font-size: 6px; }

#restart-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: rgba(255,232,200,0.1);
  border: 2px solid rgba(255,232,200,0.3);
  color: #ffe8c8;
  padding: 12px 28px;
  cursor: pointer;
  border-radius: 3px;
  margin-top: 12px;
  pointer-events: auto;
  transition: background 0.15s, border-color 0.15s;
}
#restart-btn:hover { background: rgba(255,232,200,0.2); border-color: rgba(255,232,200,0.5); }

.go-links {
  margin-top: 8px;
}
.portal-link {
  font-size: 6px;
  color: #44ddff;
  text-decoration: none;
  text-shadow: 1px 1px 0 #000;
  pointer-events: auto;
}
.portal-link:hover { color: #88eeff; }

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
