/* Copyright (c) 2026 Dany Rashwan. All rights reserved. */

:root {
  --neon-blue: #00e5ff;
  --neon-pink: #ff00ff;
  --neon-green: #00ff00;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --neon-shadow-blue: 0 0 5px var(--neon-blue), 0 0 10px var(--neon-blue),
    0 0 20px rgba(0, 229, 255, 0.5);
  --neon-shadow-pink: 0 0 5px var(--neon-pink), 0 0 10px var(--neon-pink),
    0 0 20px rgba(255, 0, 255, 0.5);
  --neon-shadow-green: 0 0 5px var(--neon-green), 0 0 10px var(--neon-green),
    0 0 20px rgba(0, 255, 0, 0.5);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background-color: #000;
  font-family: 'Consolas', 'Courier New', monospace;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  overscroll-behavior: none;
  touch-action: none;
  background: radial-gradient(circle at 50% 40%, #041018 0%, #000 60%);
}

#game-area {
  position: relative;
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 10px)
    calc(var(--safe-bottom) + 10px) calc(var(--safe-left) + 10px);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Main game surface */
#gameCanvas {
  display: block;
  border: 2px solid var(--neon-blue);
  box-shadow: var(--neon-shadow-blue);
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 5;
  border-radius: 12px;
  background: #000;
  touch-action: none;
}

/* Top-center live score */
#scoreboard {
  position: absolute;
  top: calc(var(--safe-top) + 18px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 30px;
  color: var(--neon-blue);
  font-size: clamp(2.5rem, 8vw, 8rem);
  font-weight: 700;
  z-index: 10;
  user-select: none;
}

#scoreboard .score {
  min-width: 120px;
  text-align: center;
  text-shadow: var(--neon-shadow-blue);
}

#scoreboard .divider {
  width: 2px;
  height: 80px;
  background-color: var(--neon-pink);
  box-shadow: var(--neon-shadow-pink);
}

/* Centered state message: start, pause, game over */
#message-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  text-align: center;
  pointer-events: none;
}

#game-message {
  margin: 0;
  color: var(--neon-green);
  font-size: clamp(1.2rem, 5vw, 3rem);
  font-weight: 700;
  text-shadow: var(--neon-shadow-green);
  opacity: 1;
  transition: opacity 0.3s;
}

#game-message.hidden {
  opacity: 0;
}

#mobile-hud {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 14px);
  transform: translateX(-50%);
  width: min(92vw, 680px);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 30;
  pointer-events: none;
}

#mobile-hud .mobile-buttons {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  pointer-events: auto;
}

.mobile-btn {
  appearance: none;
  border: 1px solid rgba(0, 229, 255, 0.7);
  border-radius: 12px;
  min-height: 42px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.22), rgba(0, 20, 26, 0.9));
  color: #c8fbff;
  font: 700 0.9rem/1 'Consolas', 'Courier New', monospace;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.45);
}

.mobile-btn:active {
  transform: translateY(1px) scale(0.985);
}

.mobile-btn:disabled {
  opacity: 0.5;
  box-shadow: none;
}

#mobile-hint {
  margin: 0;
  color: rgba(200, 251, 255, 0.95);
  font-size: clamp(0.7rem, 2.6vw, 0.9rem);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.65);
  user-select: none;
  text-align: center;
  pointer-events: none;
}

/* Fixed legal footer inside the game area */
#copyright-note {
  position: absolute;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 8px);
  margin: 0;
  color: rgba(0, 229, 255, 0.85);
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
  font-size: clamp(0.75rem, 1.2vw, 1rem);
  letter-spacing: 0.06em;
  user-select: none;
  z-index: 25;
}

body.mobile-mode #mobile-hud {
  display: flex;
}

body.mobile-mode #copyright-note {
  opacity: 0.78;
}

@media (max-width: 900px) {
  #scoreboard {
    top: calc(var(--safe-top) + 10px);
    gap: 16px;
    font-size: clamp(2rem, 12vw, 3.8rem);
  }

  #scoreboard .score {
    min-width: 72px;
  }

  #scoreboard .divider {
    height: 48px;
  }

  #copyright-note {
    right: 10px;
    bottom: calc(var(--safe-bottom) + 6px);
    font-size: clamp(0.6rem, 2.8vw, 0.82rem);
  }

  #game-message {
    width: min(92vw, 620px);
    font-size: clamp(1rem, 5vw, 1.6rem);
    line-height: 1.25;
  }
}

@media (pointer: coarse), (max-width: 900px) {
  body {
    align-items: stretch;
  }

  #game-area {
    align-items: stretch;
  }

  #gameCanvas {
    align-self: center;
  }

  #message-area {
    top: 43%;
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  #mobile-hint::after {
    content: ' Rotate to landscape for the best gameplay.';
  }
}

@media (prefers-reduced-motion: reduce) {
  #game-message {
    transition: none;
  }

  .mobile-btn {
    transition: none;
  }
}
