/* ==========================================================================
   Cloud Runner - Cyberpunk Jump-and-Run CSS
   ========================================================================== */

:root {
  --bg-dark: #07060e;
  --bg-card: rgba(14, 12, 28, 0.9);
  --neon-cyan: #00f0ff;
  --neon-pink: #ff007f;
  --neon-yellow: #ffe600;
  --neon-red: #ff2a55;
  --text-main: #e8ecf8;
  --text-muted: #8890ad;
  --font-cyber: 'Consolas', 'Lucida Console', Monaco, 'Courier New', 'Segoe UI', monospace, sans-serif;
  --border-neon: 1px solid rgba(0, 240, 255, 0.4);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-cyber);
  touch-action: manipulation;
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 30%, #15102a 0%, #07060e 100%);
  overflow: hidden;
}

/* ==========================================================================
   HUD Header
   ========================================================================== */

#game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(7, 6, 14, 0.92) 0%, rgba(7, 6, 14, 0.5) 80%, transparent 100%);
  z-index: 10;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.hud-label {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.lives-container {
  display: flex;
  gap: 4px;
}

.life-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.life-icon svg {
  width: 20px;
  height: 20px;
}

.life-icon.active {
  color: var(--neon-pink);
  filter: drop-shadow(0 0 6px var(--neon-pink));
}

.life-icon.lost {
  color: #3b354d;
  opacity: 0.35;
  transform: scale(0.85);
}

.hud-discs-group {
  gap: 8px;
  background: rgba(14, 12, 28, 0.6);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255, 230, 0, 0.3);
}

.disc-hud-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.6));
  animation: disc-glow 2s infinite ease-in-out;
}

@keyframes disc-glow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.5)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 8px rgba(255, 0, 127, 0.8)); }
}

.highlight-yellow {
  color: var(--neon-yellow);
  font-weight: bold;
}

.hud-score-group {
  gap: 16px;
}

.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-value {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.neon-cyan {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
}

.neon-yellow {
  color: var(--neon-yellow);
  text-shadow: 0 0 10px var(--neon-yellow);
}

.cyber-icon-btn {
  background: rgba(18, 15, 36, 0.85);
  border: 1px solid rgba(0, 240, 255, 0.4);
  color: var(--neon-cyan);
  border-radius: 4px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.cyber-icon-btn:hover, .cyber-icon-btn:active {
  background: rgba(0, 240, 255, 0.25);
  box-shadow: 0 0 15px var(--neon-cyan);
  transform: scale(1.05);
}

/* ==========================================================================
   Canvas & Viewport
   ========================================================================== */

#canvas-container {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas {
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.15), 0 0 80px rgba(255, 0, 127, 0.1);
  max-width: 100%;
  max-height: 100%;
}

/* ==========================================================================
   UI Overlays & Modals
   ========================================================================== */

.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 12, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
  opacity: 1;
  visibility: visible;
  padding: 16px;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.overlay-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.2), inset 0 0 20px rgba(0, 240, 255, 0.05);
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  clip-path: polygon(0 14px, 14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px));
}

.overlay-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink), var(--neon-yellow));
}

.cyber-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid var(--neon-cyan);
  padding: 4px 12px;
  margin-bottom: 10px;
  border-radius: 2px;
}

.badge-danger {
  color: var(--neon-red);
  background: rgba(255, 42, 85, 0.1);
  border-color: var(--neon-red);
}

.game-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #ffffff;
  text-shadow: 0 0 15px var(--neon-cyan), 0 0 30px rgba(0, 240, 255, 0.4);
  margin-bottom: 4px;
}

.gameover-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--neon-red);
  text-shadow: 0 0 15px var(--neon-red), 0 0 30px rgba(255, 42, 85, 0.4);
  margin-bottom: 8px;
}

.game-subtitle {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--neon-pink);
  margin-bottom: 20px;
}

.instructions-box {
  width: 100%;
  background: rgba(10, 8, 22, 0.85);
  border: 1px solid rgba(136, 144, 173, 0.2);
  padding: 14px;
  margin-bottom: 20px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instruction-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-main);
  flex-wrap: wrap;
}

.sub-instruction {
  font-size: 11px;
  color: var(--text-muted);
}

.key-badge {
  background: #1c1833;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 3px 7px;
  font-size: 10px;
  font-weight: bold;
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.3);
}

.highlight-cyan {
  color: var(--neon-cyan);
  font-weight: bold;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */

.cyber-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 26px;
  font-family: var(--font-cyber);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  touch-action: manipulation;
}

.cyber-btn-primary {
  background: var(--neon-cyan);
  color: #05040a;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.cyber-btn-primary:hover, .cyber-btn-primary:active {
  background: #ffffff;
  box-shadow: 0 0 30px var(--neon-cyan), 0 0 10px #ffffff;
  transform: translateY(-2px);
}

.cyber-btn-secondary {
  background: var(--neon-pink);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(255, 0, 127, 0.4);
  padding: 10px 16px;
  font-size: 11px;
}

.cyber-btn-secondary:hover, .cyber-btn-secondary:active {
  background: #ff3399;
  box-shadow: 0 0 25px var(--neon-pink);
}

.gameover-stats {
  margin-bottom: 16px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 30px;
  font-weight: 900;
}

.highscore-entry-form {
  width: 100%;
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-align: left;
}

.input-row {
  display: flex;
  gap: 6px;
}

.input-row input {
  flex: 1;
  background: rgba(8, 7, 16, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.4);
  color: var(--neon-cyan);
  font-family: var(--font-cyber);
  font-size: 13px;
  font-weight: bold;
  padding: 9px 12px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

.leaderboard-section {
  width: 100%;
  margin-bottom: 20px;
}

.leaderboard-title {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--neon-pink);
  margin-bottom: 6px;
  text-align: left;
}

.highscore-list {
  list-style: none;
  background: rgba(8, 7, 16, 0.7);
  border: 1px solid rgba(136, 144, 173, 0.15);
  border-radius: 4px;
  padding: 4px 0;
  max-height: 120px;
  overflow-y: auto;
}

.highscore-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 12px;
  font-size: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.highscore-item:last-child {
  border-bottom: none;
}

.highscore-item .rank {
  color: var(--neon-yellow);
  font-weight: bold;
  width: 24px;
  text-align: left;
}

.highscore-item .name {
  flex: 1;
  text-align: left;
  color: var(--text-main);
  font-weight: 600;
}

.highscore-item .score {
  color: var(--neon-cyan);
  font-weight: bold;
}

/* ==========================================================================
   Mobile Touch Controls & Responsive Breakpoints
   ========================================================================== */

#mobile-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 15;
  display: none;
}

.mobile-touch-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.25);
  border: 2px solid var(--neon-cyan);
  color: var(--neon-cyan);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font-cyber);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.35);
  touch-action: manipulation;
  transition: transform 0.1s, background-color 0.1s;
}

.mobile-touch-btn:active {
  background: rgba(0, 240, 255, 0.6);
  transform: scale(0.92);
}

/* Responsive adjustments for Mobile & Portrait */
@media (pointer: coarse), (max-width: 768px) {
  #mobile-controls {
    display: block;
  }
}

@media (max-width: 480px) {
  #game-hud {
    padding: 0 10px;
    height: 50px;
  }

  .hud-group {
    gap: 6px;
  }

  .hud-score-group {
    gap: 10px;
  }

  .hud-label {
    font-size: 8px;
    letter-spacing: 1px;
  }

  .hud-value {
    font-size: 15px;
  }

  .life-icon svg {
    width: 16px;
    height: 16px;
  }

  .cyber-icon-btn {
    width: 32px;
    height: 32px;
  }

  .game-title {
    font-size: 24px;
    letter-spacing: 2px;
  }

  .gameover-title {
    font-size: 24px;
    letter-spacing: 2px;
  }

  .overlay-card {
    padding: 20px 14px;
  }

  .mobile-touch-btn {
    width: 68px;
    height: 68px;
    bottom: 16px;
    right: 16px;
  }
}
