/* Color Slide Game - Main Styles */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --primary-color: #e9af51;
  --primary-hover: #d19a3f;
  --bg-dark: #0f0f23;
  --bg-darker: #0a0a1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #252540;
  --text-primary: #ffffff;
  --text-secondary: #b8b8d1;
  --text-muted: #6b6b8a;
  --red-ball: #ff6b6b;
  --blue-ball: #3b82f6;
  --yellow-ball: #ffe66d;
  --green-ball: #95e1d3;
  --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.15);
  --shadow-heavy: 0 15px 35px rgba(0, 0, 0, 0.2);
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: "Inter", sans-serif;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-darker) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

/* Background Pattern */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(
      circle at 25% 25%,
      rgba(233, 175, 81, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 75% 75%,
      rgba(78, 205, 196, 0.1) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: -1;
}

/* Reset Button */
.reset-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-hover)
  );
  color: var(--bg-dark);
  font-weight: 600;
  font-size: 1rem;
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 100;
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-heavy);
}

.reset-btn:active {
  transform: translateY(0);
}

/* Main Container */
.game-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

/* Color Indicators */
.color-indicators {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
  padding: 0 10px;
}

.color-indicator {
  height: 12px;
  border-radius: 6px;
  box-shadow: var(--shadow-light);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
}

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

.color-indicator:hover::before {
  left: 100%;
}

.color-indicator:hover {
  transform: scaleY(1.3);
  box-shadow: var(--shadow-medium);
}

.color-red {
  background: linear-gradient(135deg, var(--red-ball), #ff5252);
  box-shadow: 0 0 10px rgba(255, 107, 107, 0.3);
}

.color-blue {
  background: linear-gradient(135deg, var(--blue-ball), #2196f3);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.color-yellow {
  background: linear-gradient(135deg, var(--yellow-ball), #ffeb3b);
  box-shadow: 0 0 10px rgba(255, 230, 109, 0.3);
}

.color-green {
  background: linear-gradient(135deg, var(--green-ball), #4caf50);
  box-shadow: 0 0 10px rgba(149, 225, 211, 0.3);
}

/* Game Board */
.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
  padding: 15px;
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-heavy);
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.game-board::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(135deg, var(--primary-color), transparent);
  border-radius: var(--border-radius-lg);
  z-index: -1;
  opacity: 0.3;
}

/* Board Cells */
.board-cell {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-darker);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.board-cell:hover {
  background: var(--bg-card-hover);
  transform: scale(1.02);
  box-shadow: var(--shadow-medium);
}

.board-cell.empty {
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  cursor: default;
}

.board-cell.empty:hover {
  transform: none;
  box-shadow: none;
}

/* Game Balls */
.game-ball {
  width: 85%;
  height: 85%;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.game-ball::before {
  content: "";
  position: absolute;
  top: 15%;
  left: 15%;
  width: 30%;
  height: 30%;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  filter: blur(1px);
}

.game-ball:hover {
  transform: scale(1.05);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3), 0 6px 12px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.2);
}

.board-cell.empty .game-ball {
  transform: scale(0);
  opacity: 0;
  cursor: default;
}

/* Ball Colors */
.ball-red {
  background: var(--red-ball);
}

.ball-blue {
  background: var(--blue-ball);
}

.ball-yellow {
  background: var(--yellow-ball);
}

.ball-green {
  background: var(--green-ball);
}

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

.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  padding: 30px;
  border-radius: var(--border-radius-lg);
  text-align: center;
  color: var(--text-primary);
  transform: scale(0.9) translateY(20px);
  transition: var(--transition);
  max-width: 90%;
  width: 700px;
  box-shadow: var(--shadow-heavy);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.modal-backdrop.visible .modal-content {
  transform: scale(1) translateY(0);
}

.modal-content::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(135deg, var(--primary-color), transparent);
  border-radius: var(--border-radius-lg);
  z-index: -1;
  opacity: 0.3;
}

.modal-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--primary-color), #ffd93d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-stats {
  background: var(--bg-darker);
  padding: 20px;
  border-radius: var(--border-radius);
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-btn {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-hover)
  );
  color: var(--bg-dark);
  font-weight: 700;
  font-size: 1.1rem;
  padding: 15px 40px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 10px;
}

.modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-heavy);
}

.modal-btn.secondary {
  background: linear-gradient(135deg, var(--text-muted), var(--text-secondary));
}

/* Modal Layout - 30% board, 70% how to play */
.modal-sections {
  display: grid;
  grid-template-columns: 30% 70%;
  gap: 25px;
  margin-bottom: 25px;
  align-items: start;
}

/* Goal Section */
.goal-section {
  text-align: center;
}

.goal-title {
  color: var(--primary-color);
  font-size: 1.3rem;
  margin-bottom: 15px;
  font-weight: 600;
}

/* Solved Board in Modal */
.solved-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 140px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  background: var(--bg-card);
  padding: 8px;
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.solved-cell {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
}

.solved-cell::before {
  content: "";
  position: absolute;
  top: 15%;
  left: 15%;
  width: 30%;
  height: 30%;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  filter: blur(1px);
}

.solved-cell.empty {
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

.solved-cell.empty::before {
  display: none;
}

/* How to Play Section */
.how-to-play {
  text-align: left;
}

.how-to-play h3 {
  color: var(--primary-color);
  font-size: 1.3rem;
  margin-bottom: 15px;
  font-weight: 600;
}

.how-to-play ul {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.how-to-play li {
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-left: 20px;
  position: relative;
  line-height: 1.5;
  font-size: 0.95rem;
}

.how-to-play li::before {
  content: "•";
  color: var(--primary-color);
  font-weight: bold;
  position: absolute;
  left: 0;
}

/* Responsive Design */

/* Large screens (1200px and up) */
@media (min-width: 1200px) {
  .game-container {
    max-width: 600px;
  }

  .game-board {
    max-width: 500px;
  }

  .modal-content {
    width: 800px;
  }
}

/* Medium screens (768px to 1199px) */
@media (max-width: 1199px) and (min-width: 768px) {
  .game-container {
    max-width: 520px;
  }

  .game-board {
    max-width: 450px;
  }

  .modal-content {
    width: 90%;
    max-width: 700px;
  }
}

/* Small tablets (481px to 767px) */
@media (max-width: 767px) and (min-width: 481px) {
  .game-container {
    max-width: 480px;
  }

  .game-board {
    max-width: 400px;
  }

  .modal-content {
    width: 95%;
    padding: 25px 20px;
  }

  .modal-title {
    font-size: 2.2rem;
  }

  .modal-sections {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .solved-board {
    max-width: 130px;
  }

  .how-to-play ul {
    grid-template-columns: 1fr;
  }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
  body {
    padding: 15px;
  }

  .reset-btn {
    top: 15px;
    right: 15px;
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .game-container {
    max-width: 100%;
  }

  .color-indicators {
    gap: 8px;
    margin-bottom: 15px;
  }

  .game-board {
    gap: 8px;
    padding: 12px;
    max-width: 100%;
  }

  .modal-content {
    padding: 20px 15px;
    width: 95%;
  }

  .modal-title {
    font-size: 1.8rem;
  }

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

  .modal-sections {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .solved-board {
    max-width: 100px;
    gap: 3px;
    padding: 6px;
  }

  .goal-title,
  .how-to-play h3 {
    font-size: 1.1rem;
  }

  .how-to-play ul {
    grid-template-columns: 1fr;
  }

  .how-to-play li {
    font-size: 0.9rem;
  }

  .modal-btn {
    padding: 12px 30px;
    font-size: 1rem;
    margin: 5px;
  }
}

/* Extra small phones (320px and below) */
@media (max-width: 320px) {
  body {
    padding: 10px;
  }

  .reset-btn {
    top: 10px;
    right: 10px;
    padding: 8px 16px;
    font-size: 0.8rem;
  }

  .game-board {
    gap: 6px;
    padding: 10px;
  }

  .color-indicators {
    gap: 6px;
    margin-bottom: 12px;
  }

  .modal-content {
    padding: 15px 10px;
  }

  .modal-title {
    font-size: 1.6rem;
  }

  .solved-board {
    max-width: 80px;
    gap: 2px;
    padding: 4px;
  }

  .modal-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    padding: 10px;
  }

  .game-container {
    max-width: 400px;
  }

  .color-indicators {
    margin-bottom: 10px;
  }

  .modal-content {
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-sections {
    gap: 15px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .game-ball,
  .solved-cell {
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3), 0 3px 6px rgba(0, 0, 0, 0.2);
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .board-cell:hover,
  .game-ball:hover,
  .color-indicator:hover {
    transform: none;
  }

  .reset-btn:hover,
  .modal-btn:hover {
    transform: none;
  }

  .board-cell:active,
  .game-ball:active {
    transform: scale(0.95);
  }

  .reset-btn:active,
  .modal-btn:active {
    transform: scale(0.95);
  }
}

/* iPad and tablet specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
  .game-container {
    max-width: 500px;
  }

  .game-board {
    max-width: 420px;
  }

  .modal-content {
    width: 85%;
    max-width: 600px;
  }
}

/* iPhone notch and safe area support */
@supports (padding: max(0px)) {
  body {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .reset-btn {
    top: max(20px, env(safe-area-inset-top) + 10px);
    right: max(20px, env(safe-area-inset-right) + 10px);
  }
}

/* Ensure minimum touch target size for accessibility */
@media (max-width: 480px) {
  .board-cell {
    min-height: 44px;
    min-width: 44px;
  }

  .reset-btn {
    min-height: 44px;
    min-width: 80px;
  }

  .modal-btn {
    min-height: 44px;
    min-width: 120px;
  }
}

/* Prevent text selection on game elements */
.game-board,
.board-cell,
.game-ball,
.reset-btn,
.modal-btn {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling for modals */
.modal-backdrop {
  -webkit-overflow-scrolling: touch;
}

/* Optimize for reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .ball-moving {
    animation: none;
  }

  .loading {
    animation: none;
  }
}

/* Animation for ball movement */
@keyframes ballMove {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.ball-moving {
  animation: ballMove 0.3s ease-in-out;
}

/* Loading animation */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}
