/**
 * style.css
 * Cyberpunk Neon Theme for Space Invaders
 * Responsive design: 320px - 2560px
 */

/* ==================== ROOT VARIABLES ==================== */
:root {
  /* Cyberpunk Neon Colors */
  --color-primary: #00ffff;      /* Cyan */
  --color-secondary: #ff00ff;    /* Magenta */
  --color-accent: #ffff00;       /* Yellow */
  --color-background: #0a0a1a;   /* Dark blue/black */
  --color-surface: #1a1a2e;      /* Slightly lighter surface */
  --color-text: #ffffff;         /* White */
  --color-text-dim: #8888aa;     /* Dimmed text */

  /* Shadows and Glows */
  --glow-cyan: 0 0 20px var(--color-primary), 0 0 40px var(--color-primary);
  --glow-magenta: 0 0 20px var(--color-secondary), 0 0 40px var(--color-secondary);
  --glow-yellow: 0 0 20px var(--color-accent), 0 0 40px var(--color-accent);
  --glow-mixed: 0 0 10px var(--color-primary), 0 0 20px var(--color-secondary);

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Typography */
  --font-mono: 'Courier New', 'Courier', monospace;
  --font-size-base: 16px;
}

/* ==================== RESET & BASE ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(
    135deg,
    #0a0a1a 0%,
    #1a0a2e 50%,
    #0a0a1a 100%
  );
  position: relative;
}

/* Animated background grid */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(var(--color-primary) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-primary) 1px, transparent 1px);
  background-size: 50px 50px;
  opacity: 0.05;
  animation: grid-drift 20s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes grid-drift {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(50px, 50px);
  }
}

/* ==================== GAME CONTAINER ==================== */
#game-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ==================== CANVAS ==================== */
#game-canvas {
  display: block;
  background: var(--color-background);
  border: 2px solid var(--color-primary);
  box-shadow: var(--glow-cyan);
  max-width: 100%;
  max-height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* Canvas container for aspect ratio maintenance */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ==================== TOUCH CONTROLS ==================== */
.touch-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    to top,
    rgba(26, 26, 46, 0.95) 0%,
    rgba(26, 26, 46, 0.7) 70%,
    transparent 100%
  );
  display: none;
  justify-content: space-around;
  align-items: center;
  padding: var(--spacing-md);
  z-index: 100;
}

.touch-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.1);
  border: 2px solid var(--color-primary);
  box-shadow: var(--glow-cyan);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  color: var(--color-primary);
  user-select: none;
  touch-action: none;
  transition: all 0.2s ease;
}

.touch-button:active {
  background: rgba(0, 255, 255, 0.3);
  transform: scale(0.95);
  box-shadow: 0 0 30px var(--color-primary), 0 0 60px var(--color-primary);
}

.touch-button.shoot {
  border-color: var(--color-accent);
  color: var(--color-accent);
  box-shadow: var(--glow-yellow);
}

.touch-button.shoot:active {
  background: rgba(255, 255, 0, 0.3);
  box-shadow: 0 0 30px var(--color-accent), 0 0 60px var(--color-accent);
}

/* Show touch controls on mobile devices */
@media (hover: none) and (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}

/* ==================== LOADING SCREEN ==================== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-background);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

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

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(0, 255, 255, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: var(--glow-cyan);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: var(--spacing-lg);
  font-size: 20px;
  color: var(--color-primary);
  text-shadow: var(--glow-cyan);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ==================== NEON TEXT EFFECTS ==================== */
.neon-text {
  text-shadow: var(--glow-cyan);
  animation: neon-flicker 3s infinite alternate;
}

@keyframes neon-flicker {
  0%, 100% {
    text-shadow: var(--glow-cyan);
  }
  50% {
    text-shadow: 0 0 10px var(--color-primary);
  }
}

/* ==================== PARTICLE EFFECTS ==================== */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--color-accent);
  border-radius: 50%;
  pointer-events: none;
  animation: particle-rise 2s ease-out forwards;
  box-shadow: 0 0 10px var(--color-accent);
}

@keyframes particle-rise {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) scale(0);
    opacity: 0;
  }
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Extra Small devices (320px - 480px) */
@media screen and (max-width: 480px) {
  :root {
    --font-size-base: 14px;
  }

  #game-canvas {
    border-width: 1px;
  }

  .touch-button {
    width: 60px;
    height: 60px;
    font-size: 20px;
  }

  .touch-controls {
    height: 100px;
  }
}

/* Small devices (481px - 768px) */
@media screen and (min-width: 481px) and (max-width: 768px) {
  :root {
    --font-size-base: 15px;
  }
}

/* Medium devices (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  :root {
    --font-size-base: 16px;
  }
}

/* Large devices (1025px - 1440px) */
@media screen and (min-width: 1025px) and (max-width: 1440px) {
  :root {
    --font-size-base: 17px;
  }
}

/* Extra Large devices (1441px+) */
@media screen and (min-width: 1441px) {
  :root {
    --font-size-base: 18px;
  }
}

/* Portrait orientation adjustments */
@media screen and (orientation: portrait) {
  #game-canvas {
    max-width: 100vw;
    max-height: 75vh;
  }

  .touch-controls {
    height: 140px;
  }
}

/* Landscape orientation adjustments */
@media screen and (orientation: landscape) {
  #game-canvas {
    max-width: 75vw;
    max-height: 100vh;
  }

  .touch-controls {
    flex-direction: row;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-xl);
  }
}

/* ==================== ACCESSIBILITY ==================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  body::before {
    animation: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  #game-canvas {
    border-width: 3px;
  }

  .touch-button {
    border-width: 3px;
  }
}

/* ==================== SCANLINE EFFECT ==================== */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1) 0px,
    transparent 1px,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 3px
  );
  pointer-events: none;
  z-index: 999;
  opacity: 0.3;
  animation: scanline 8s linear infinite;
}

@keyframes scanline {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(10px);
  }
}

/* ==================== CORNER DECORATIONS ==================== */
.corner-decoration {
  position: fixed;
  width: 40px;
  height: 40px;
  border: 2px solid var(--color-primary);
  box-shadow: var(--glow-cyan);
  pointer-events: none;
  z-index: 10;
}

.corner-decoration.top-left {
  top: var(--spacing-md);
  left: var(--spacing-md);
  border-right: none;
  border-bottom: none;
}

.corner-decoration.top-right {
  top: var(--spacing-md);
  right: var(--spacing-md);
  border-left: none;
  border-bottom: none;
}

.corner-decoration.bottom-left {
  bottom: var(--spacing-md);
  left: var(--spacing-md);
  border-right: none;
  border-top: none;
}

.corner-decoration.bottom-right {
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  border-left: none;
  border-top: none;
}

/* ==================== SCREEN SHAKE ==================== */
.screen-shake {
  animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-3px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(3px, 0, 0);
  }
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
  display: none !important;
}

.no-select {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.fullscreen {
  width: 100vw;
  height: 100vh;
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */
#game-canvas {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Hardware acceleration */
.touch-button,
.particle,
.loading-spinner {
  transform: translateZ(0);
  will-change: transform;
}
