/* ==========================================================================
   NEON RUNNER - CYBERPUNK SYNTHWAVE STYLESHEET
   ========================================================================== */

:root {
  --neon-cyan: #00f3ff;
  --neon-pink: #ff007f;
  --neon-purple: #9d00ff;
  --neon-yellow: #ffe600;
  --neon-green: #05ffa1;
  --neon-orange: #ff7700;
  --bg-dark: #0a0614;
  --bg-card: rgba(16, 10, 32, 0.88);
  --border-neon: rgba(0, 243, 255, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: #fff;
  font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Background Atmosphere */
body {
  background: radial-gradient(circle at 50% 20%, #1e0938 0%, #0c0418 60%, #05020a 100%);
}

.game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

#game-container {
  position: relative;
  width: min(960px, 96vw, calc((100dvh - 24px) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #06020c;
  box-shadow: 
    0 0 30px rgba(0, 243, 255, 0.25),
    0 0 80px rgba(255, 0, 127, 0.15),
    inset 0 0 40px rgba(0, 0, 0, 0.8);
  border: 2px solid var(--neon-cyan);
  border-radius: 8px;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

/* CRT Scanline & Screen Vignette Overlay */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.6) 100%);
  background-size: 100% 4px, 100% 100%;
  opacity: 0.65;
  z-index: 5;
}

/* ==========================================================================
   HEADS-UP DISPLAY (HUD)
   ========================================================================== */

.overlay-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
  z-index: 10;
  font-family: 'Orbitron', monospace;
}

.hud-top {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.hud-box {
  background: rgba(10, 5, 25, 0.75);
  border: 1px solid rgba(0, 243, 255, 0.35);
  border-radius: 4px;
  padding: 4px 12px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.15);
}

.hud-label {
  font-size: 10px;
  color: var(--neon-cyan);
  letter-spacing: 1.5px;
  font-weight: 700;
  text-shadow: 0 0 5px var(--neon-cyan);
}

.hud-val {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
}

.mult-box {
  border-color: rgba(255, 0, 127, 0.5);
}
.mult-box .hud-label {
  color: var(--neon-pink);
  text-shadow: 0 0 5px var(--neon-pink);
}
.mult-active {
  color: var(--neon-pink);
  text-shadow: 0 0 8px var(--neon-pink);
}

.highscore-box {
  margin-left: auto;
  border-color: rgba(5, 255, 161, 0.4);
}
.highscore-box .hud-label {
  color: var(--neon-green);
  text-shadow: 0 0 5px var(--neon-green);
}
.highscore-box .hud-val {
  color: var(--neon-green);
}

/* Overdrive Charge Meter */
.hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.overdrive-container {
  width: min(340px, 45%);
  background: rgba(10, 5, 25, 0.75);
  border: 1px solid rgba(255, 230, 0, 0.3);
  border-radius: 6px;
  padding: 8px 12px;
  backdrop-filter: blur(4px);
}

.overdrive-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.overdrive-header .hud-label {
  color: var(--neon-yellow);
  text-shadow: 0 0 5px var(--neon-yellow);
}

.overdrive-text {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.overdrive-bar-bg {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 230, 0, 0.4);
}

.overdrive-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff7700, #ffe600, #00f3ff);
  box-shadow: 0 0 10px #ffe600;
  transition: width 0.15s ease-out;
}

.overdrive-ready {
  animation: pulse-border 0.8s infinite alternate;
}

@keyframes pulse-border {
  from {
    border-color: #ffe600;
    box-shadow: 0 0 12px #ffe600;
  }
  to {
    border-color: #00f3ff;
    box-shadow: 0 0 20px #00f3ff;
  }
}

.hud-controls-hint {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.neon-icon-btn {
  background: rgba(15, 10, 35, 0.85);
  border: 1px solid var(--neon-cyan);
  border-radius: 6px;
  color: #fff;
  width: 38px;
  height: 38px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.neon-icon-btn:hover {
  background: rgba(0, 243, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
}

/* Speed Up & Notifications */
.banner-notification {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  font-size: 26px;
  font-weight: 900;
  color: var(--neon-yellow);
  text-shadow: 0 0 15px var(--neon-yellow), 0 0 30px #ff7700;
  background: rgba(10, 5, 25, 0.9);
  padding: 10px 30px;
  border-radius: 8px;
  border: 2px solid var(--neon-yellow);
  letter-spacing: 3px;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
  pointer-events: none;
}

.banner-notification.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

/* ==========================================================================
   MODAL OVERLAYS (START, GAMEOVER, PAUSE)
   ========================================================================== */

.game-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 2, 12, 0.82);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.game-modal.active {
  display: flex;
}

.modal-card {
  width: min(520px, 90%);
  background: var(--bg-card);
  border: 2px solid var(--neon-cyan);
  border-radius: 12px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 
    0 0 30px rgba(0, 243, 255, 0.3),
    inset 0 0 20px rgba(0, 243, 255, 0.1);
  animation: modal-enter 0.3s ease-out;
}

.mini-card {
  width: min(380px, 85%);
  padding: 24px;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Glitch Typography */
.glitch-title {
  font-family: 'Orbitron', monospace;
  font-size: 38px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 4px;
  position: relative;
  text-shadow: 
    0 0 10px var(--neon-cyan),
    0 0 25px var(--neon-cyan),
    0 0 40px var(--neon-pink);
  margin-bottom: 2px;
}

.subtitle {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  color: var(--neon-pink);
  letter-spacing: 3px;
  font-weight: 700;
  margin-bottom: 20px;
  text-shadow: 0 0 8px var(--neon-pink);
}

.instructions-panel {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 243, 255, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: #e0e0ff;
}

.key-badge {
  background: rgba(0, 243, 255, 0.15);
  border: 1px solid var(--neon-cyan);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  color: var(--neon-cyan);
  box-shadow: 0 0 6px rgba(0, 243, 255, 0.3);
}

.item-legend {
  width: 100%;
  display: flex;
  justify-content: space-around;
  margin-bottom: 22px;
  font-size: 11px;
  color: #aaa;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-icon {
  font-size: 14px;
}
.shard-icon { color: var(--neon-cyan); text-shadow: 0 0 8px var(--neon-cyan); }
.shield-icon { color: var(--neon-green); text-shadow: 0 0 8px var(--neon-green); }
.dash-icon { color: var(--neon-yellow); text-shadow: 0 0 8px var(--neon-yellow); }

/* Neon Buttons */
.neon-btn {
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  font-weight: 800;
  padding: 12px 36px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  outline: none;
  position: relative;
  overflow: hidden;
}

.primary-btn {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.2), rgba(255, 0, 127, 0.3));
  border: 2px solid var(--neon-cyan);
  color: #fff;
  box-shadow: 0 0 18px rgba(0, 243, 255, 0.4);
}

.primary-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.4), rgba(255, 0, 127, 0.5));
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.8), 0 0 15px var(--neon-pink);
}

.pulse-glow {
  animation: btn-pulse 1.6s infinite ease-in-out;
}

@keyframes btn-pulse {
  0%, 100% {
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.85), 0 0 15px var(--neon-pink);
  }
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #e0e0e0;
}

.secondary-btn:hover {
  border-color: #fff;
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

/* Game Over Styles */
.gameover-title {
  font-family: 'Orbitron', monospace;
  font-size: 32px;
  font-weight: 900;
  color: var(--neon-pink);
  letter-spacing: 3px;
  text-shadow: 0 0 15px var(--neon-pink), 0 0 30px rgba(255, 0, 127, 0.6);
  margin-bottom: 2px;
}

.gameover-sub {
  font-size: 13px;
  color: #aaa;
  letter-spacing: 2px;
  margin-bottom: 20px;
}

.results-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.result-item {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.res-label {
  font-size: 11px;
  color: #888;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.res-val {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 800;
}

.neon-pink { color: var(--neon-pink); text-shadow: 0 0 8px var(--neon-pink); }
.neon-cyan { color: var(--neon-cyan); text-shadow: 0 0 8px var(--neon-cyan); }
.neon-yellow { color: var(--neon-yellow); text-shadow: 0 0 8px var(--neon-yellow); }
.neon-green { color: var(--neon-green); text-shadow: 0 0 8px var(--neon-green); }

.new-record-badge {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 900;
  color: var(--neon-yellow);
  background: rgba(255, 230, 0, 0.15);
  border: 1px solid var(--neon-yellow);
  border-radius: 20px;
  padding: 6px 18px;
  margin-bottom: 20px;
  text-shadow: 0 0 10px var(--neon-yellow);
  animation: pulse-border 1s infinite alternate;
}

.new-record-badge.hidden {
  display: none;
}

.pause-title {
  font-family: 'Orbitron', monospace;
  font-size: 26px;
  font-weight: 800;
  color: var(--neon-cyan);
  text-shadow: 0 0 15px var(--neon-cyan);
  margin-bottom: 4px;
}

.pause-sub {
  font-size: 12px;
  color: #bbb;
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
}

/* ==========================================================================
   TOUCH CONTROLS (MOBILE / TOUCH DEVICES)
   ========================================================================== */

.touch-controls-layer {
  position: absolute;
  bottom: 14px;
  left: 0;
  width: 100%;
  padding: 0 20px;
  display: none; /* dynamically activated or visible on touch */
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 15;
}

@media (hover: none) and (pointer: coarse), (max-width: 820px) {
  .touch-controls-layer {
    display: flex;
  }
}

.touch-left, .touch-right {
  display: flex;
  gap: 14px;
}

.touch-action-btn {
  pointer-events: auto;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(10, 5, 25, 0.7);
  border: 2px solid var(--neon-cyan);
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
  cursor: pointer;
  touch-action: manipulation;
}

.touch-action-btn:active {
  background: rgba(0, 243, 255, 0.4);
  transform: scale(0.92);
}

.slide-btn {
  border-color: var(--neon-pink);
  box-shadow: 0 0 15px rgba(255, 0, 127, 0.4);
}
.slide-btn:active {
  background: rgba(255, 0, 127, 0.4);
}

.dash-btn {
  border-color: var(--neon-yellow);
  width: 56px;
  height: 56px;
  margin-top: auto;
  box-shadow: 0 0 15px rgba(255, 230, 0, 0.4);
}
.dash-btn:active {
  background: rgba(255, 230, 0, 0.4);
}

.jump-btn {
  width: 76px;
  height: 76px;
}

/* ==========================================================================
   MOBILE RESPONSIVE ADAPTATIONS (PORTRAIT & LANDSCAPE)
   ========================================================================== */

@media (max-width: 820px) and (orientation: portrait), (max-aspect-ratio: 1/1) and (max-width: 820px) {
  .game-wrapper {
    padding: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  #game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    aspect-ratio: unset;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: none;
  }

  #gameCanvas {
    width: 100vw;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    max-height: 52dvh;
    object-fit: contain;
  }

  .crt-overlay {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100vw;
    aspect-ratio: 16 / 9;
    max-height: 52dvh;
  }

  .overlay-hud {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100vw;
    aspect-ratio: 16 / 9;
    max-height: 52dvh;
    padding: 8px 10px;
  }

  .hud-top {
    gap: 5px;
  }

  .hud-box {
    padding: 3px 6px;
  }

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

  .hud-val {
    font-size: 13px;
  }

  .overdrive-container {
    width: 140px;
    padding: 4px 8px;
  }

  .overdrive-text {
    font-size: 8.5px;
  }

  .hud-controls-hint {
    gap: 6px;
  }

  .neon-icon-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .touch-controls-layer {
    display: flex;
    position: absolute;
    bottom: max(22px, env(safe-area-inset-bottom));
    left: 0;
    width: 100%;
    padding: 0 16px;
    z-index: 20;
  }

  .touch-action-btn {
    width: 66px;
    height: 66px;
    font-size: 11px;
  }

  .jump-btn {
    width: 76px;
    height: 76px;
    font-size: 12px;
  }

  .dash-btn {
    width: 54px;
    height: 54px;
  }

  .game-modal {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 16px;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
  }

  .game-modal.active {
    display: flex;
  }

  .modal-card {
    width: min(440px, 94vw);
    max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 18px;
  }

  .glitch-title {
    font-size: 26px;
    letter-spacing: 2px;
  }

  .instructions-panel {
    gap: 7px;
    margin-bottom: 14px;
    padding: 10px 12px;
  }

  .control-row {
    font-size: 10.5px;
  }

  .key-badge {
    font-size: 9.5px;
    padding: 3px 6px;
  }

  .item-legend {
    margin-bottom: 14px;
    gap: 6px;
  }

  .legend-item {
    font-size: 11px;
  }

  .primary-btn {
    padding: 12px 28px;
    font-size: 13.5px;
    width: 100%;
  }

  .results-grid {
    gap: 8px;
  }

  .res-val {
    font-size: 16px;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .game-wrapper {
    padding: 4px;
    height: 100vh;
    height: 100dvh;
  }

  #game-container {
    width: min(960px, 96vw, calc((100dvh - 8px) * 16 / 9));
    height: calc(100dvh - 8px);
    aspect-ratio: 16 / 9;
  }

  .modal-card {
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 18px;
  }

  .glitch-title {
    font-size: 22px;
    margin-bottom: 2px;
  }

  .subtitle {
    margin-bottom: 8px;
    font-size: 10px;
  }

  .instructions-panel {
    margin-bottom: 10px;
    padding: 8px 10px;
    gap: 6px;
  }

  .control-row {
    font-size: 10px;
  }

  .item-legend {
    display: none;
  }

  .overlay-hud {
    padding: 6px 12px;
  }

  .hud-val {
    font-size: 13px;
  }

  .touch-controls-layer {
    display: flex;
    bottom: 8px;
    padding: 0 12px;
  }

  .touch-action-btn {
    width: 52px;
    height: 52px;
    font-size: 9.5px;
  }

  .jump-btn {
    width: 58px;
    height: 58px;
  }

  .dash-btn {
    width: 44px;
    height: 44px;
  }
}

/* ==========================================================================
   ROTATE PROMPT
   Side-scrollers need the width, so upright phones are asked to turn sideways.
   ========================================================================== */
.rotate-prompt {
  display: none;
}

@media (max-width: 820px) and (orientation: portrait) and (pointer: coarse) {
  .rotate-prompt {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    background: #05020c;
    color: #00f3ff;
    font-family: 'Orbitron', sans-serif;
    text-align: center;
  }

  .rotate-phone {
    width: 44px;
    height: 76px;
    border: 3px solid #00f3ff;
    border-radius: 8px;
    box-shadow: 0 0 18px rgba(0, 243, 255, 0.6);
    animation: rotate-hint 2.4s ease-in-out infinite;
  }

  .rotate-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
  }

  .rotate-sub {
    font-size: 11px;
    letter-spacing: 1px;
    color: #99a0b5;
  }

  .rotate-dismiss {
    min-height: 44px;
    padding: 8px 20px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    color: #c2c8dc;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 1px;
  }
}

@keyframes rotate-hint {
  0%, 25% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(90deg); }
}

/* Short phone screens: keep every menu button inside its card */
@media (orientation: landscape) and (max-height: 600px) {
  .mini-card {
    width: min(520px, 94%);
    max-width: none;
  }

  .modal-buttons {
    flex-wrap: wrap;
    gap: 8px;
  }

  .neon-btn {
    width: auto;
    min-height: 40px;
    padding: 8px 14px;
    white-space: nowrap;
  }
}
