/* Neon Space Invaders - Premium Responsive Stylesheet */
:root {
  --bg-color: #03030b;
  --panel-bg: rgba(8, 8, 20, 0.85);
  --border-color: rgba(0, 240, 255, 0.2);
  --neon-cyan: #00f0ff;
  --neon-magenta: #ff007f;
  --neon-green: #39ff14;
  --neon-yellow: #fff000;
  --neon-blue: #0077ff;
  --text-primary: #ffffff;
  --text-secondary: #8c8da0;
  --font-family: 'Outfit', sans-serif;
}

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

body {
  background-color: var(--bg-color);
  font-family: var(--font-family);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 0, 127, 0.08) 0%, transparent 40%);
}

/* App Container matching canvas size, supports transform scaling */
#appContainer {
  position: relative;
  width: 800px;
  height: 600px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 
              0 0 35px rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: transform 0.1s ease-out;
}

/* Canvas styling */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background-color: #010105;
}

/* Heads Up Display (HUD) */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(3, 3, 11, 0.9) 0%, rgba(3, 3, 11, 0) 100%);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.hud-value {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 1px;
}

/* Overlay Panels (Menus, Leaderboard, Forms) */
.overlay-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  pointer-events: all;
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

.overlay-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
}

.hidden {
  display: none !important;
}

/* Logo Design */
.game-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 35px;
  text-align: center;
}

.logo-top {
  font-size: 2.2rem;
  font-weight: 300;
  letter-spacing: 12px;
  text-indent: 12px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.logo-bottom {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 4px;
  text-shadow: 0 0 8px var(--neon-magenta), 0 0 20px rgba(255, 0, 127, 0.45);
}

/* Buttons */
.btn {
  display: inline-block;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 12px 28px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 260px;
  text-align: center;
  margin-bottom: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-blue) 100%);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.6);
  background: linear-gradient(135deg, #4ef2ff 0%, #3a97ff 100%);
}

.btn-secondary {
  background: transparent;
  color: #fff;
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.35);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 16px;
  width: auto;
  font-size: 0.75rem;
  flex: 1;
  margin-bottom: 0;
  border-radius: 6px;
}

.btn-outline:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.05);
}

.btn-link {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  text-decoration: underline;
  font-size: 0.8rem;
  width: auto;
  cursor: pointer;
  margin-top: 10px;
}

.btn-link:hover {
  color: #fff;
}

.auth-buttons-group {
  display: flex;
  gap: 10px;
  width: 260px;
  margin-bottom: 12px;
}

/* User Greeting in Menu */
.user-greeting {
  font-size: 0.95rem;
  margin-bottom: 20px;
  font-weight: 400;
  letter-spacing: 1px;
}

/* Forms styling */
form {
  width: 280px;
  display: flex;
  flex-direction: column;
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 15px;
  align-items: flex-start;
  width: 100%;
}

.form-group label {
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s ease;
}

.form-group input:focus {
  border-color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.03);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

/* Table / Leaderboard */
.table-container {
  width: 100%;
  max-width: 500px;
  max-height: 250px;
  overflow-y: auto;
  margin: 15px 0 25px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 700;
  position: sticky;
  top: 0;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Custom Scrollbar */
.table-container::-webkit-scrollbar {
  width: 6px;
}
.table-container::-webkit-scrollbar-track {
  background: transparent;
}
.table-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.table-container::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan);
}

/* Game Instructions */
.game-instructions {
  margin-top: 25px;
  text-align: center;
  color: var(--text-secondary);
}

.game-instructions h3 {
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: #fff;
  margin-bottom: 8px;
}

.game-instructions p {
  font-size: 0.8rem;
  margin-bottom: 5px;
}

.game-instructions .key {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-family: monospace;
  color: #fff;
  margin: 0 2px;
}

.game-instructions .hint {
  font-size: 0.75rem;
  color: var(--neon-yellow);
  margin-top: 8px;
  font-weight: 600;
}

/* Audio toggle */
.audio-control {
  margin-top: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.checkbox-label input {
  display: none;
}

.custom-checkbox {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  margin-right: 8px;
  position: relative;
  display: inline-block;
  transition: all 0.2s ease;
}

.checkbox-label input:checked + .custom-checkbox {
  background: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
}

.checkbox-label input:checked + .custom-checkbox::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #000;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Game Over overlay stats */
.final-stats {
  margin: 15px 0;
  text-align: center;
  font-size: 1.15rem;
  line-height: 1.8;
}

#saveScorePrompt {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 15px 20px;
  margin: 10px 0;
  text-align: center;
  width: 320px;
}

.prompt-text {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.prompt-subtext {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.prompt-actions {
  display: flex;
  justify-content: center;
}

.prompt-actions .btn {
  font-size: 0.75rem;
  padding: 8px 16px;
  width: auto;
  margin-bottom: 0;
}

#scoreSavedStatus {
  margin: 15px 0;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Level stats details */
.level-stats {
  margin: 25px 0;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.8;
}

/* Neon Text Helpers */
.neon-text-cyan {
  color: var(--neon-cyan);
  text-shadow: 0 0 5px var(--neon-cyan);
}

.neon-text-magenta {
  color: var(--neon-magenta);
  text-shadow: 0 0 5px var(--neon-magenta);
}

.neon-text-green {
  color: var(--neon-green);
  text-shadow: 0 0 5px var(--neon-green);
}

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

/* Toast Notification Overlay */
.toast {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(8, 8, 20, 0.95);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid var(--neon-magenta);
  box-shadow: 0 5px 25px rgba(255, 0, 127, 0.3);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  z-index: 99;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  opacity: 1;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
}

/* Animation classes */
.blink {
  animation: blinkAnim 1.5s infinite alternate;
}

@keyframes blinkAnim {
  0% {
    opacity: 0.4;
  }
  100% {
    opacity: 1;
    text-shadow: 0 0 8px var(--neon-magenta), 0 0 25px var(--neon-magenta);
  }
}

/* Mobile responsive layout overrides */
@media (max-width: 820px), (max-height: 620px) {
  body {
    padding: 0;
  }
  
  /* Reset relative scaling bounds on body since we transform-scale the main app container */
  #appContainer {
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}
