/* ==========================================================================
   NEBULA STRIKE - MOBILE FIRST RADICAL REDESIGN
   ========================================================================== */

:root {
  /* HSL Color Palette */
  --bg-color: hsl(240, 40%, 3%);
  --card-bg: hsla(240, 30%, 6%, 0.75);
  --border-color: hsla(240, 20%, 30%, 0.25);
  --text-primary: hsl(0, 0%, 95%);
  --text-muted: hsl(240, 10%, 70%);

  /* Neon Glow Colors */
  --neon-blue: hsl(190, 100%, 50%);
  --neon-purple: hsl(275, 100%, 55%);
  --neon-green: hsl(135, 100%, 50%);
  --neon-red: hsl(355, 100%, 55%);
  --neon-yellow: hsl(45, 100%, 50%);

  /* Typography */
  --font-hud: 'Orbitron', sans-serif;
  --font-ui: 'Outfit', sans-serif;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-ui);
  overflow: hidden; /* No scrolling */
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overscroll-behavior: none; /* Prevent pull-to-refresh */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ==========================================================================
   AMBIENT BACKGROUND (STARS)
   ========================================================================== */

.stars, .twinkling {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw; height: 100vh;
  display: block;
  z-index: -2;
}

.stars {
  background: #000 url('./stars.png') repeat top center;
  background-size: cover;
}

.twinkling {
  background: transparent url('./twinkling.png') repeat top center;
  animation: move-twink-back 200s linear infinite;
  opacity: 0.4;
  z-index: -1;
}

@keyframes move-twink-back {
  from { background-position: 0 0; }
  to { background-position: -10000px 5000px; }
}

/* ==========================================================================
   APP LAYOUT CONTAINER
   ========================================================================== */

.app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Glassmorphism utility card */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 
              inset 0 0 15px rgba(255, 255, 255, 0.05);
  padding: 30px 20px;
  width: 90%;
  max-width: 400px;
  transition: box-shadow var(--transition-normal), border var(--transition-normal);
  z-index: 20;
}

/* ==========================================================================
   AUTH SCREEN
   ========================================================================== */

#auth-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#auth-screen.active {
  display: flex;
  animation: fadeIn 0.5s ease-out forwards;
}

.logo-container {
  text-align: center;
  margin-bottom: 25px;
}

.logo-text {
  font-family: var(--font-hud);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2), 
               0 0 20px var(--neon-purple);
  margin-bottom: 5px;
}

.neon-purple { color: var(--neon-purple); text-shadow: 0 0 10px var(--neon-purple); }
.neon-blue { color: var(--neon-blue); text-shadow: 0 0 8px var(--neon-blue); }
.neon-green { color: var(--neon-green); text-shadow: 0 0 8px var(--neon-green); }
.neon-yellow { color: var(--neon-yellow); text-shadow: 0 0 8px var(--neon-yellow); }
.neon-red { color: var(--neon-red); text-shadow: 0 0 8px var(--neon-red); }

.tagline {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.tab-header {
  display: flex;
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  font-family: var(--font-hud);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.tab-btn.active {
  background: var(--neon-purple);
  color: white;
  box-shadow: 0 0 15px rgba(157, 0, 255, 0.5);
}

.auth-form {
  display: none;
  width: 100%;
}

.auth-form.active {
  display: block;
  animation: slideUp 0.4s ease;
}

.input-group {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-size: 0.8rem;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.input-group input {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  color: white;
  font-family: var(--font-ui);
  font-size: 1rem;
  outline: none;
  transition: all var(--transition-fast);
  -webkit-appearance: none;
}

.input-group input:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

.neon-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-family: var(--font-hud);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.2), 
              0 0 20px rgba(157, 0, 255, 0.2);
  transition: all var(--transition-normal);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.neon-btn:active {
  transform: scale(0.98);
}

.neon-btn.btn-purple {
  background: linear-gradient(135deg, var(--neon-purple), #ff007f);
  box-shadow: 0 0 15px rgba(157, 0, 255, 0.2);
}

.error-msg {
  color: var(--neon-red);
  font-size: 0.8rem;
  margin-bottom: 15px;
  text-align: center;
}

.success-msg {
  color: var(--neon-green);
  font-size: 0.8rem;
  margin-bottom: 15px;
  text-align: center;
}

/* ==========================================================================
   GAMEPLAY SCREEN
   ========================================================================== */

#game-screen {
  display: none;
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
}

#game-screen.active {
  display: block;
  animation: fadeIn 0.6s ease;
}

/* HUD Overlay */
.hud-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  z-index: 20;
  pointer-events: none; /* Let touches pass through to canvas */
}

/* Re-enable pointer events for interactive HUD elements */
.hud-header .icon-btn {
  pointer-events: auto;
}

.stats-info {
  display: flex;
  flex-direction: row;
  gap: 15px;
}

.hud-section {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-family: var(--font-hud);
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.hud-value {
  font-family: var(--font-hud);
  font-weight: 700;
  font-size: 1rem;
  color: white;
  text-shadow: 0 0 5px var(--neon-blue);
}

.lives-container {
  display: flex;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--neon-red);
  text-shadow: 0 0 5px var(--neon-red);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.icon-btn:active {
  background: var(--neon-red);
  border-color: var(--neon-red);
  box-shadow: 0 0 10px rgba(255, 15, 63, 0.6);
  transform: scale(0.9);
}

/* Game Canvas Wrapper */
.canvas-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 5;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

#gameCanvas {
  display: block;
  background: linear-gradient(180deg, #010105 0%, #03030a 100%);
  width: 100vw;
  height: 100vh;
  object-fit: cover;
}

/* ==========================================================================
   GAMEPLAY SCREEN OVERLAYS
   ========================================================================== */

.game-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(2, 2, 8, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 30;
  padding: 20px;
  text-align: center;
}

.game-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease-out;
}

.game-overlay h2 {
  font-family: var(--font-hud);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: white;
  text-shadow: 0 0 10px rgba(255,255,255,0.2), 
               0 0 20px var(--neon-blue);
  margin-bottom: 10px;
}

.overlay-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 20px;
  max-width: 90%;
}

.controls-guide {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 25px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  width: 100%;
  max-width: 320px;
}

kbd {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--neon-yellow);
  font-family: monospace;
  font-weight: bold;
}

/* Touch indicator text for mobile */
.controls-guide::after {
  content: "Mobile: Touch & drag to move. Tap to shoot.";
  display: block;
  margin-top: 8px;
  color: var(--neon-green);
  font-weight: bold;
  text-shadow: 0 0 5px rgba(0, 255, 0, 0.3);
}

.neon-red-text { color: var(--neon-red) !important; text-shadow: 0 0 10px rgba(255, 15, 63, 0.5) !important; }
.neon-green-text { color: var(--neon-green); text-shadow: 0 0 8px var(--neon-green); font-weight: bold; }

.final-score-box {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: 12px;
  font-family: var(--font-hud);
  font-size: 1.1rem;
  margin: 15px 0 25px;
  letter-spacing: 1px;
  box-shadow: inset 0 0 10px rgba(0, 242, 254, 0.1);
}

.overlay-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.font-orbitron { font-family: var(--font-hud) !important; }

/* ==========================================================================
   LEADERBOARD MODAL SCREEN
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 15px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--card-bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9),
              0 0 20px rgba(157, 0, 255, 0.2);
  border: 1px solid rgba(157, 0, 255, 0.4);
  border-radius: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.modal-header h2 {
  font-family: var(--font-hud);
  font-size: 1.2rem;
  letter-spacing: 1px;
  text-shadow: 0 0 10px var(--neon-purple);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:active { color: var(--neon-red); transform: scale(0.9); }

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-family: var(--font-ui);
}

.leaderboard-table th {
  font-family: var(--font-hud);
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 8px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 0.5px;
}

.leaderboard-table td {
  padding: 10px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
}

.leaderboard-table tbody tr:nth-child(1) td:first-child { color: var(--neon-yellow); font-weight: bold; font-size: 1rem; text-shadow: 0 0 5px var(--neon-yellow); }
.leaderboard-table tbody tr:nth-child(2) td:first-child { color: hsl(200, 100%, 75%); font-weight: bold; }
.leaderboard-table tbody tr:nth-child(3) td:first-child { color: hsl(30, 80%, 60%); font-weight: bold; }

/* ==========================================================================
   ANIMATIONS & EFFECTS
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   MEDIA QUERIES (Mobile Portrait Optimization)
   ========================================================================== */

@media screen and (orientation: portrait) {
  .hud-header {
    padding: 15px 10px;
  }
  .hud-value {
    font-size: 1.1rem;
  }
  .glass-card {
    padding: 25px 15px;
  }
  .logo-text {
    font-size: 1.8rem;
  }
}
/* Mobile Responsiveness adjustments */
@media(max-width: 820px) {
  body, html {
    overflow: hidden;
    width: 100%;
    height: 100%;
  }
  .app-container {
    padding: 0;
    height: 100%;
  }
  #game-screen {
    width: 100%;
    height: 100%;
  }
  .hud-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    background: rgba(4, 4, 12, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-color);
    margin: 0;
    padding: 12px 15px;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }
  .hud-section {
    flex: 1 1 30%;
  }
  .hud-value {
    font-size: 0.95rem;
  }
  .hud-label {
    font-size: 0.65rem;
  }
  .canvas-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    aspect-ratio: auto;
    z-index: 1;
  }
}
@media screen and (orientation: landscape) and (max-height: 500px) {
  .hud-header {
    padding: 5px 15px;
  }
  .glass-card {
    padding: 15px;
    margin-top: 10px;
  }
  .logo-container {
    margin-bottom: 10px;
  }
  .logo-text {
    font-size: 1.5rem;
  }
}
