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

body {
  font-family: "Inter", sans-serif;
  touch-action: none;
  background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
  color: #f9fafb;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
      circle at 20% 80%,
      rgba(233, 175, 81, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(233, 175, 81, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 40% 40%,
      rgba(233, 175, 81, 0.05) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: -1;
}

/* Game Header */
.game-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  z-index: 100;
}

.shuffle-button {
  background: linear-gradient(135deg, #e9af51 0%, #d4a046 100%);
  color: #1f2937;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 8px 25px rgba(233, 175, 81, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
  font-size: 1rem;
}

.shuffle-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(233, 175, 81, 0.4);
}

.shuffle-button:active {
  transform: translateY(0);
}

.game-stats {
  display: flex;
  gap: 2rem;
}

.stat-item {
  text-align: center;
  background: rgba(233, 175, 81, 0.1);
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(233, 175, 81, 0.2);
  backdrop-filter: blur(5px);
  min-width: 80px;
}

.stat-label {
  font-size: 0.875rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
  display: block;
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #e9af51;
  text-shadow: 0 0 10px rgba(233, 175, 81, 0.5);
}

/* Main Game Container */
.game-container {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-title {
  font-size: 3.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, #e9af51 0%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(233, 175, 81, 0.5);
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    filter: drop-shadow(0 0 20px rgba(233, 175, 81, 0.3));
  }
  to {
    filter: drop-shadow(0 0 30px rgba(233, 175, 81, 0.6));
  }
}

.game-board-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

/* Game Board */
#game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  aspect-ratio: 1 / 1;
  padding: 12px;
  background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
  border-radius: 1rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(233, 175, 81, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#game-board::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(233, 175, 81, 0.1) 50%,
    transparent 70%
  );
  animation: shimmer 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0%,
  100% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(100%);
  }
}

/* Tile Styles */
.tile {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  background: linear-gradient(135deg, #e9af51 0%, #d4a046 100%);
  color: #1f2937;
  border: none;
  border-radius: 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tile:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.tile:hover::before {
  opacity: 1;
}

.tile:active {
  transform: scale(0.98);
}

.empty-tile {
  background: transparent !important;
  border: 2px dashed rgba(233, 175, 81, 0.3) !important;
  box-shadow: none !important;
  cursor: default;
}

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

.empty-tile::before {
  display: none;
}

/* Modal Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(233, 175, 81, 0.2);
  padding: 0;
  max-width: 42rem;
  width: 100%;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  overflow: hidden;
  position: relative;
}

.modal-backdrop.show .modal {
  transform: scale(1);
}

.modal::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #e9af51, #fbbf24, #e9af51);
  background-size: 200% 100%;
  animation: gradient-shift 3s ease-in-out infinite;
}

@keyframes gradient-shift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.modal-header {
  padding: 2rem 2rem 1rem;
  text-align: center;
  border-bottom: 1px solid rgba(233, 175, 81, 0.2);
}

.modal-title {
  font-size: 2rem;
  font-weight: 800;
  color: #e9af51;
  margin: 0;
}

.modal-content {
  padding: 1.5rem 2rem;
}

.start-modal-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.instructions-section {
  flex: 1;
  order: 2;
}

.instructions h3 {
  color: #e9af51;
  font-size: 1.25rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

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

.instructions li {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(233, 175, 81, 0.1);
  font-size: 1rem;
  line-height: 1.5;
}

.instructions li:last-child {
  border-bottom: none;
}

.difficulty-info {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(233, 175, 81, 0.1);
  border-radius: 0.75rem;
  border: 1px solid rgba(233, 175, 81, 0.2);
}

.difficulty-info p {
  margin: 0;
  font-size: 0.95rem;
  color: #d1d5db;
}

.board-preview-section {
  flex: 0 0 auto;
  text-align: center;
  order: 1;
}

.board-preview-section h3 {
  color: #e9af51;
  font-size: 1.25rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.preview-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  width: 180px;
  height: 180px;
  padding: 12px;
  background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
  border-radius: 0.75rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  margin: 0 auto;
}

.preview-tile {
  background: linear-gradient(135deg, #e9af51 0%, #d4a046 100%);
  color: #1f2937;
  border: none;
  border-radius: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.preview-empty {
  background: transparent;
  border: 1px dashed rgba(233, 175, 81, 0.3);
  box-shadow: none;
}

.modal-footer {
  padding: 1rem 2rem 2rem;
  text-align: center;
}

.start-button,
.play-again-button {
  background: linear-gradient(135deg, #e9af51 0%, #d4a046 100%);
  color: #1f2937;
  font-weight: 700;
  padding: 1rem 2rem;
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 8px 25px rgba(233, 175, 81, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  min-width: 200px;
  justify-content: center;
}

.start-button:hover,
.play-again-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(233, 175, 81, 0.4);
}

.start-button:active,
.play-again-button:active {
  transform: translateY(0);
}

.button-icon {
  font-size: 1.2rem;
}

/* Win Modal Specific Styles */
.win-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #10b981;
  margin: 0;
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.win-message {
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
  color: #f9fafb;
  text-align: center;
}

.final-stats {
  display: flex;
  justify-content: space-around;
  margin: 1.5rem 0;
  gap: 1rem;
}

.final-stats .stat-item {
  flex: 1;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.final-stats .stat-value {
  color: #10b981;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
  .game-header {
    padding: 1rem;
  }

  .game-stats {
    gap: 1rem;
  }

  .stat-item {
    padding: 0.5rem 1rem;
    min-width: 70px;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .game-container {
    padding: 7rem 1rem 1rem;
  }

  .game-title {
    font-size: 2.5rem;
  }

  .tile {
    font-size: 1.5rem;
  }

  .modal {
    margin: 1rem;
  }

  .modal-header {
    padding: 1.5rem 1.5rem 1rem;
  }

  .modal-content {
    padding: 1rem 1.5rem;
  }

  .modal-footer {
    padding: 1rem 1.5rem 1.5rem;
  }

  .start-button,
  .play-again-button {
    width: 100%;
    min-width: auto;
  }

  .start-modal-layout {
    flex-direction: column;
    gap: 1.5rem;
  }

  .board-preview-section {
    order: -1;
  }

  .preview-board {
    width: 150px;
    height: 150px;
  }
}

@media (max-width: 480px) {
  .game-header {
    flex-direction: column;
    gap: 1rem;
    padding: 0.75rem;
  }

  .game-stats {
    width: 100%;
    justify-content: space-around;
  }

  .stat-item {
    min-width: 60px;
  }

  .game-container {
    padding: 8rem 0.5rem 1rem;
  }

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

  .tile {
    font-size: 1.25rem;
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.min-h-screen {
  min-height: 100vh;
}
