/* ============================================
   Motion Games - Modern Dark Theme
   ============================================ */

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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-orange: #f97316;
  --accent-red: #ef4444;
  --glow-primary: rgba(99, 102, 241, 0.5);
  --glow-pink: rgba(236, 72, 153, 0.5);
  --glow-cyan: rgba(6, 182, 212, 0.5);
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

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

.loader {
  width: 60px;
  height: 60px;
  border: 4px solid var(--bg-card);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-screen p {
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  margin-bottom: 30px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-pink)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 40px var(--glow-primary);
}

.score-panel {
  background: var(--bg-card);
  padding: 15px 30px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 30px var(--glow-primary);
}

.score-label {
  color: var(--text-secondary);
  margin-right: 10px;
}

.score-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: 0 0 20px var(--glow-cyan);
}

.sound-toggle {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 14px 18px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.25);
  font-weight: 600;
}

.sound-toggle:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 30px var(--glow-cyan);
  transform: translateY(-1px);
}

.sound-toggle.muted {
  opacity: 0.75;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

/* Game Menu */
.game-menu {
  text-align: center;
  padding: 40px 0;
}

.menu-title {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(
    135deg,
    var(--accent-cyan),
    var(--accent-primary),
    var(--accent-pink)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.menu-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 50px;
}

/* Game Cards */
.game-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 25px;
  padding: 20px;
}

.game-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 40px 30px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-pink)
  );
  opacity: 0;
  transition: var(--transition);
  z-index: 0;
}

.game-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px var(--glow-primary);
  border-color: var(--accent-primary);
}

.game-card:hover::before {
  opacity: 0.1;
}

.game-card > * {
  position: relative;
  z-index: 1;
}

.card-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
  transition: var(--transition);
}

.game-card:hover .card-icon {
  transform: scale(1.2);
  filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.5));
}

.game-card h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.game-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Individual card colors */
.game-card[data-game="balloon"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(239, 68, 68, 0.4);
  border-color: var(--accent-red);
}

.game-card[data-game="fruit"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(16, 185, 129, 0.4);
  border-color: var(--accent-green);
}

.game-card[data-game="runner"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(249, 115, 22, 0.4);
  border-color: var(--accent-orange);
}

.game-card[data-game="shooter"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(6, 182, 212, 0.4);
  border-color: var(--accent-cyan);
}

.game-card[data-game="pose"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(236, 72, 153, 0.4);
  border-color: var(--accent-pink);
}

.game-card[data-game="brickbreaker"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(139, 92, 246, 0.4);
  border-color: var(--accent-secondary);
}

.game-card[data-game="highjump"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(251, 191, 36, 0.4);
  border-color: #fbbf24;
}

.game-card[data-game="fishcatch"]:hover {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(14, 165, 233, 0.4);
  border-color: #0ea5e9;
}

/* Game Area */
.game-area {
  padding: 20px 0;
}

.game-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  aspect-ratio: 16/9;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--bg-secondary);
  box-shadow: 0 0 80px rgba(99, 102, 241, 0.2);
  border: 2px solid var(--accent-primary);
}

.input-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror effect */
  opacity: 0.7;
}

.game-canvas,
.pose-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pose-canvas {
  z-index: 1;
}

.game-canvas {
  z-index: 2;
}

/* Game Controls */
.game-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.game-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.game-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.game-timer {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-cyan);
  text-shadow: 0 0 20px var(--glow-cyan);
}

/* Buttons */
.btn {
  padding: 15px 30px;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-back {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-back:hover {
  background: var(--accent-red);
  border-color: var(--accent-red);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
}

.btn-restart {
  background: var(--accent-primary);
  color: white;
}

.btn-restart:hover {
  background: var(--accent-secondary);
  box-shadow: 0 0 30px var(--glow-primary);
  transform: scale(1.05);
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--accent-primary),
    var(--accent-secondary)
  );
  color: white;
  box-shadow: 0 0 30px var(--glow-primary);
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 0 50px var(--glow-primary);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: var(--bg-card);
  border-color: var(--accent-primary);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--bg-card);
  padding: 50px;
  border-radius: var(--border-radius);
  text-align: center;
  border: 1px solid var(--accent-primary);
  box-shadow: 0 0 100px var(--glow-primary);
  animation: modalPop 0.3s ease;
}

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

.modal-content h2 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  background: linear-gradient(
    135deg,
    var(--accent-cyan),
    var(--accent-primary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.final-score {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.final-score span {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-pink);
  text-shadow: 0 0 30px var(--glow-pink);
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

/* Fullscreen layout */
.container:fullscreen,
.container:-webkit-full-screen {
  max-width: none;
  width: 100vw;
  height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

.container:fullscreen .header,
.container:-webkit-full-screen .header {
  padding: 12px 16px;
  margin-bottom: 0;
}

.container:fullscreen #game-area,
.container:-webkit-full-screen #game-area {
  flex: 1;
  display: flex !important;
  flex-direction: column;
  padding: 0;
}

.container:fullscreen .game-container,
.container:-webkit-full-screen .game-container {
  flex: 1;
  min-height: 0;
  max-width: none;
  width: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.container:fullscreen .game-controls,
.container:-webkit-full-screen .game-controls {
  margin-top: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .logo {
    font-size: 1.5rem;
  }

  .menu-title {
    font-size: 2rem;
  }

  .game-cards {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .game-card {
    padding: 30px 20px;
  }

  .card-icon {
    font-size: 3rem;
  }

  .game-controls {
    flex-direction: column;
    gap: 15px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .modal-content {
    margin: 20px;
    padding: 30px;
  }

  .modal-buttons {
    flex-direction: column;
  }
}

/* Animations */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 20px var(--glow-primary);
  }
  50% {
    box-shadow: 0 0 40px var(--glow-primary);
  }
}

/* Game specific styles */
.particle {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  animation: particleFade 0.5s ease-out forwards;
}

@keyframes particleFade {
  to {
    opacity: 0;
    transform: scale(2);
  }
}

/* Hand indicator */
.hand-indicator {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-cyan), transparent);
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 100;
  box-shadow: 0 0 30px var(--accent-cyan);
}
