/**
 * base.css
 *
 * Purpose: CSS reset, base typography, body styles, and the main
 * game-container structure. This must load first.
 *
 * Dependencies: None (loads first)
 *
 * Key Styles:
 * - CSS reset (box-sizing, margins, padding)
 * - Body gradient background
 * - Game container card layout
 * - Base font settings
 */

/* ==================== BASE STYLES ==================== */

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

body {
  font-family:
    "Nunito",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  min-height: 100dvh; /* Use dynamic viewport height for mobile */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  padding-top: 15px;
  overflow: hidden; /* Prevent body scrolling */
}

.game-container {
  max-width: 600px;
  width: 100%;
  height: calc(100vh - 30px); /* Account for body padding */
  height: calc(100dvh - 30px); /* Use dynamic viewport height */
  max-height: calc(100dvh - 30px);
  background: white;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  margin: 0 15px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ==================== ANIMATIONS ==================== */

@keyframes cardFlip {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

@keyframes correctPulse {
  0% {
    box-shadow: 0 0 0 rgba(39, 174, 96, 0.6);
  }
  50% {
    box-shadow: 0 0 30px rgba(39, 174, 96, 0.8);
  }
  100% {
    box-shadow: 0 0 20px rgba(39, 174, 96, 0.6);
  }
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

@keyframes wrongPulse {
  0% {
    box-shadow: 0 0 0 rgba(231, 76, 60, 0.6);
    transform: translateX(0);
  }
  25% {
    box-shadow: 0 0 25px rgba(231, 76, 60, 0.8);
    transform: translateX(-8px);
  }
  50% {
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.8);
    transform: translateX(0);
  }
  75% {
    box-shadow: 0 0 25px rgba(231, 76, 60, 0.8);
    transform: translateX(8px);
  }
  100% {
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.6);
    transform: translateX(0);
  }
}

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

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

@keyframes levelBounce {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes welcomeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== MESSAGES ==================== */

.message {
  text-align: center;
  font-size: 1.1em;
  min-height: 26px;
  margin-top: 10px;
  font-weight: bold;
  flex-shrink: 0;
}

.message.success {
  color: #27ae60;
}

.message.error {
  color: #ff7675;
}

/* ==================== WIN SCREEN ==================== */

.win-screen {
  display: none;
  text-align: center;
}

.win-screen.active {
  display: block;
}

.win-title {
  font-size: 3em;
  color: #27ae60;
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}

.win-message {
  font-size: 1.5em;
  color: #666;
  margin-bottom: 30px;
}

.play-again-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 1.2em;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.3s;
}

.play-again-btn:hover {
  transform: scale(1.05);
}

/* ==================== LEVEL OVERLAY ==================== */

.level-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(102, 126, 234, 0.95);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

.level-overlay.active {
  display: flex;
}

.level-overlay-content {
  color: white;
  font-size: 4em;
  font-weight: bold;
  animation: levelBounce 1.5s ease-out;
}

/* ==================== OFFLINE INDICATOR ==================== */

.offline-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #ff7675;
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 1500;
  animation: slideInRight 0.3s ease-out;
}

.offline-indicator.visible {
  display: block;
}

.checking-indicator {
  font-size: 0.8em;
  color: #999;
  margin-top: 5px;
  min-height: 16px;
}

/* ==================== BACK TO GAME BUTTON ==================== */

.back-to-game-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 1.2em;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.3s;
  width: 100%;
  margin-top: 20px;
}

.back-to-game-btn:hover {
  transform: scale(1.02);
}
