/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  overflow: hidden;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
  position: relative;
  touch-action: none; /* Prevent default touch behaviors */
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(
      circle at 20% 20%,
      rgba(59, 130, 246, 0.1) 1px,
      transparent 1px
    ),
    radial-gradient(
      circle at 80% 80%,
      rgba(139, 92, 246, 0.1) 1px,
      transparent 1px
    );
  background-size: 50px 50px, 30px 30px;
  animation: gridMove 20s linear infinite;
  pointer-events: none;
  z-index: -1;
}

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

/* Canvas Styling */
canvas {
  display: block;
  cursor: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

/* HUD Elements */
.hud-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 1rem;
  z-index: 100;
}

.hud-label {
  position: absolute;
  font-family: "Orbitron", monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: #e5e7eb;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.8),
    0 0 20px rgba(59, 130, 246, 0.4);
  background: rgba(15, 15, 35, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  backdrop-filter: blur(10px);
  animation: hudPulse 2s ease-in-out infinite;
}

@keyframes hudPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

#score {
  position: static;
}

#timer {
  position: static;
}

#combo {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
  color: #fbbf24;
  opacity: 0;
  transition: all 0.3s ease;
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.5);
  z-index: 100;
}

#combo.visible {
  opacity: 1;
  animation: comboGlow 0.5s ease-out;
}

/* Audio Controls */
.audio-controls {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  
}

.audio-button {
  background: rgba(15, 15, 35, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  color: #e5e7eb;
  font-family: "Orbitron", monospace;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.5rem;
  width: 3rem;
  height: 3rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
  backdrop-filter: blur(10px);
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.8),
    0 0 20px rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.audio-button.muted {
  background: rgba(15, 15, 35, 0.2);
  border-color: rgba(107, 114, 128, 0.3);
  color: #9ca3af;
  box-shadow: 0 0 10px rgba(107, 114, 128, 0.3);
  text-shadow: 0 0 10px rgba(107, 114, 128, 0.8),
    0 0 20px rgba(107, 114, 128, 0.4);
}


@keyframes comboGlow {
  0% {
    transform: translateX(-50%) scale(0.8);
    opacity: 0;
  }
  50% {
    transform: translateX(-50%) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

/* Mobile Touch Controllers */
.mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 200;
}

.mobile-controls.hidden {
  display: none;
}

.joystick-container {
  position: absolute;
  bottom: 2rem;
  width: 120px;
  height: 120px;
  pointer-events: auto;
}

.left-joystick {
  left: 2rem;
}

.joystick-base {
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 35, 0.8);
  border: 2px solid rgba(59, 130, 246, 0.5);
  border-radius: 50%;
  position: relative;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.joystick-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  background: linear-gradient(45deg, #3b82f6, #8b5cf6);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
}

.joystick-thumb:active {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.8);
}

.fire-button {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  width: 100px;
  height: 100px;
  background: linear-gradient(45deg, #ef4444, #dc2626);
  border: 2px solid rgba(239, 68, 68, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  font-family: "Orbitron", monospace;
  font-weight: 700;
  color: white;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
  transition: all 0.2s ease;
}

.fire-button:active {
  transform: scale(0.95);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
}

/* Game Overlays */
.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.5s ease-out;
}

.game-overlay.hidden {
  display: none;
}

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

/* Game Modal */
.game-modal {
  background: linear-gradient(
    135deg,
    rgba(15, 15, 35, 0.95) 0%,
    rgba(26, 26, 46, 0.95) 100%
  );
  border: 2px solid rgba(59, 130, 246, 0.5);
  border-radius: 20px;
  padding: 3rem;
  max-width: 600px;
  width: 80%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(59, 130, 246, 0.3), 0 20px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  animation: modalSlideIn 0.6s ease-out;
}

.game-modal.small {
  max-width: 400px;
  padding: 2rem;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Game Header */
.game-header {
  text-align: center;
  margin-bottom: 2rem;
}

.game-title {
  font-family: "Orbitron", monospace;
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(45deg, #3b82f6, #8b5cf6, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
  animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.2);
  }
}

.game-subtitle {
  font-size: 1.1rem;
  color: #9ca3af;
  font-weight: 500;
}

/* Game Content */
.game-content {
  margin-bottom: 2rem;
}

.mission-brief,
.objectives,
.controls,
.score-summary,
.performance-rating,
.achievements {
  margin-bottom: 2rem;
}

.mission-brief h2,
.objectives h3,
.controls h3,
.achievements h3 {
  font-family: "Orbitron", monospace;
  font-size: 1.5rem;
  color: #3b82f6;
  margin-bottom: 1rem;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.objectives-grid {
  display: block;
}

.objective-section h3 {
  font-family: "Orbitron", monospace;
  font-size: 1.5rem;
  color: #3b82f6;
  margin-bottom: 1rem;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.objective-section {
  margin-bottom: 2rem;
}

.objective-section:last-child {
  margin-bottom: 0;
}

.powerup-icon {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  text-align: center;
  line-height: 1.2em;
  border-radius: 50%;
  margin-right: 0.5rem;
  font-size: 1.2em;
  font-weight: bold;
}

.powerup-icon.time-freeze {
  color: #3b82f6;
  text-shadow: 0 0 5px rgba(59, 130, 246, 0.8);
}

.powerup-icon.supercharge {
  color: #ec4899;
  text-shadow: 0 0 5px rgba(236, 72, 153, 0.8);
}

.powerup-icon.slow-motion {
  color: #8b5cf6;
  text-shadow: 0 0 5px rgba(139, 92, 246, 0.8);
}

.powerup-icon.speed-boost {
  color: #10b981;
  text-shadow: 0 0 5px rgba(16, 185, 129, 0.8);
  border-radius: 0;
}

.powerup-icon.gravity-well {
  color: #8b5cf6;
  text-shadow: 0 0 5px rgba(139, 92, 246, 0.8);
  background: radial-gradient(
    circle,
    rgba(139, 92, 246, 0.3) 0%,
    transparent 70%
  );
}

.powerup-icon.hazard {
  color: #ef4444;
  text-shadow: 0 0 5px rgba(239, 68, 68, 0.8);
}

.mechanics-list {
  list-style: none;
  padding: 0;
}

.mechanic-item {
  color: #e5e7eb;
  margin-bottom: 0.5rem;
  padding-left: 0;
  position: relative;
  font-size: 1rem;
  display: flex;
  align-items: center;
}

.mission-brief p {
  color: #d1d5db;
  line-height: 1.6;
  font-size: 1rem;
}

.objectives ul {
  list-style: none;
  padding: 0;
}

.objectives li {
  color: #e5e7eb;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
  font-size: 1rem;
}

.objectives li::before {
  content: "▶";
  position: absolute;
  left: 0;
  color: #3b82f6;
  font-weight: bold;
}

/* Controls Grid */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.control-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(59, 130, 246, 0.1);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.control-item.mobile-control {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.key {
  background: #1f2937;
  color: #3b82f6;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-family: "Orbitron", monospace;
  font-weight: 700;
  border: 1px solid rgba(59, 130, 246, 0.5);
}

.control-item.mobile-control .key {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.5);
}

.action {
  color: #e5e7eb;
  font-weight: 500;
}

/* Score Summary */
.score-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

.score-item {
  text-align: center;
  background: rgba(15, 15, 35, 0.8);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.score-label {
  display: block;
  color: #9ca3af;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-value {
  display: block;
  font-family: "Orbitron", monospace;
  font-size: 2rem;
  font-weight: 900;
  color: #3b82f6;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* Performance Rating */
.performance-rating {
  text-align: center;
  margin-bottom: 2rem;
}

.stars {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.star {
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
  animation: starTwinkle 2s ease-in-out infinite;
}

.star:nth-child(2) {
  animation-delay: 0.2s;
}
.star:nth-child(3) {
  animation-delay: 0.4s;
}
.star:nth-child(4) {
  animation-delay: 0.6s;
}
.star:nth-child(5) {
  animation-delay: 0.8s;
}

@keyframes starTwinkle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

.rating-text {
  font-size: 1.2rem;
  color: #e5e7eb;
  font-weight: 600;
}

/* Achievements */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.achievement-item {
  background: rgba(15, 15, 35, 0.8);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  text-align: center;
  animation: achievementUnlock 0.5s ease-out;
}

@keyframes achievementUnlock {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.achievement-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.achievement-name {
  color: #fbbf24;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.achievement-desc {
  color: #9ca3af;
  font-size: 0.9rem;
}

/* Game Actions */
.game-actions {
  text-align: center;
  display: flex;
  flex-direction: row;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.game-button {
  font-family: "Orbitron", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1rem 2rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  min-width: 200px;
}

.game-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.game-button:hover::before {
  left: 100%;
}

.game-button.primary {
  background: linear-gradient(45deg, #3b82f6, #8b5cf6);
  color: white;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

.game-button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 25px rgba(59, 130, 246, 0.7);
}

.game-button.secondary {
  background: rgba(15, 15, 35, 0.8);
  color: #e5e7eb;
  border: 2px solid rgba(59, 130, 246, 0.5);
}

.game-button.secondary:hover {
  background: rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.game-button.danger {
  background: linear-gradient(45deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.game-button.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 25px rgba(239, 68, 68, 0.7);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .game-title {
    font-size: 1.5rem;
  }

  .game-modal {
    padding: 2.5rem;
    margin: 1rem;
  }

  .joystick-container {
    width: 110px;
    height: 110px;
  }

  .joystick-thumb {
    width: 35px;
    height: 35px;
  }

  .fire-button {
    width: 90px;
    height: 90px;
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {
  .game-title {
    font-size: 2rem;
  }

  .game-modal {
    padding: 2rem;
    margin: 1rem;
    width: 90%;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .objectives-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .score-summary {
    grid-template-columns: 1fr;
  }

  .game-actions {
    flex-direction: column;
  }

  .hud-label {
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
  }

  .audio-button {
    font-size: 1rem;
    padding: 0.25rem;
    width: 2.5rem;
    height: 2.5rem;
  }

  .hud-container {
    top: 0.5rem;
    right: 0.5rem;
    gap: 0.5rem;
  }

  /* Mobile Controls */
  .joystick-container {
    width: 100px;
    height: 100px;
    bottom: 1.5rem;
  }

  .left-joystick {
    left: 1.5rem;
  }

  .joystick-thumb {
    width: 30px;
    height: 30px;
  }

  .fire-button {
    width: 80px;
    height: 80px;
    bottom: 1.5rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 1.5rem;
  }

  .game-subtitle {
    font-size: 1rem;
  }

  .game-modal {
    padding: 1.5rem;
    margin: 0.5rem;
    width: 85%;
  }

  .mission-brief h2,
  .objectives h3,
  .controls h3 {
    font-size: 1.2rem;
  }

  .mechanic-item,
  .objectives li,
  .mission-brief p {
    font-size: 0.9rem;
  }

  .hud-label {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
  }

  .audio-button {
    font-size: 0.8rem;
    padding: 0.2rem;
    width: 2rem;
    height: 2rem;
  }

  .hud-container {
    top: 0.3rem;
    right: 0.3rem;
    gap: 0.3rem;
  }

  #combo {
    font-size: 1rem;
    bottom: 0.5rem;
  }

  /* Mobile Controls */
  .joystick-container {
    width: 80px;
    height: 80px;
    bottom: 1rem;
  }

  .left-joystick {
    left: 1rem;
  }

  .joystick-thumb {
    width: 25px;
    height: 25px;
  }

  .fire-button {
    width: 70px;
    height: 70px;
    bottom: 1rem;
    font-size: 0.6rem;
  }
}

@media (max-width: 360px) {
  .game-title {
    font-size: 1.3rem;
  }

  .game-modal {
    padding: 1rem;
  }

  .joystick-container {
    width: 70px;
    height: 70px;
    bottom: 0.8rem;
  }

  .left-joystick {
    left: 0.8rem;
  }

  .joystick-thumb {
    width: 20px;
    height: 20px;
  }

  .fire-button {
    width: 60px;
    height: 60px;
    bottom: 0.8rem;
    font-size: 0.5rem;
  }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .game-modal {
    max-height: 95vh;
    padding: 1.5rem;
  }

  .game-title {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
  }

  .game-header {
    margin-bottom: 1rem;
  }

  .game-content {
    margin-bottom: 1rem;
  }

  .mission-brief,
  .objectives,
  .controls {
    margin-bottom: 1rem;
  }

  .joystick-container {
    width: 70px;
    height: 70px;
    bottom: 0.5rem;
  }

  .left-joystick {
    left: 0.5rem;
  }

  .fire-button {
    width: 60px;
    height: 60px;
    bottom: 0.5rem;
    font-size: 0.5rem;
  }
}

/* Large Screens */
@media (min-width: 1400px) {
  .game-title {
    font-size: 2.5rem;
  }

  .game-modal {
    max-width: 700px;
    padding: 4rem;
  }

  .joystick-container {
    width: 140px;
    height: 140px;
  }

  .joystick-thumb {
    width: 50px;
    height: 50px;
  }

  .fire-button {
    width: 120px;
    height: 120px;
    font-size: 1.1rem;
  }
}

/* Scrollbar Styling */
.game-modal::-webkit-scrollbar {
  width: 8px;
}

.game-modal::-webkit-scrollbar-track {
  background: rgba(15, 15, 35, 0.5);
  border-radius: 4px;
}

.game-modal::-webkit-scrollbar-thumb {
  background: linear-gradient(45deg, #3b82f6, #8b5cf6);
  border-radius: 4px;
}

.game-modal::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(45deg, #2563eb, #7c3aed);
}
