/* Game specific styles for 2048 */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.back-btn {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.3s ease;
}

.back-btn:hover {
  transform: translateX(-5px);
  color: var(--primary);
}

.game-container {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-bottom: 3rem;
  position: relative;
}

.game-info {
  background-color: var(--surface);
  padding: 2rem;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.score-container {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.score-box {
  flex: 1;
  background-color: var(--primary);
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.score-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

#score, #best-score {
  font-size: 1.8rem;
  font-weight: bold;
}

.controls {
  display: flex;
  gap: 1rem;
}

.action-btn {
  background-color: var(--accent);
  color: var(--text);
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 30px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
}

.action-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(255, 137, 6, 0.4);
}

.action-btn.secondary {
  background-color: rgba(255, 255, 255, 0.2);
}

.game-description {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.board-sizes,
.themes {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.size-buttons,
.theme-buttons {
  display: flex;
  gap: 0.5rem;
}

.size-btn,
.theme-btn {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: none;
  padding: 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.size-btn.active,
.theme-btn.active {
  background-color: var(--primary);
}

.mobile-controls {
  display: none; /* Hidden on desktop, shown on mobile */
}

.d-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.d-pad button {
  width: 3rem;
  height: 3rem;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.d-pad button:active {
  background-color: var(--primary);
  transform: scale(0.95);
}

.middle-row {
  display: flex;
  gap: 0.5rem;
}

.game-board-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.game-board {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1/1;
  background-color: var(--surface);
  border-radius: 15px;
  padding: 15px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 15px;
  position: relative;
}

.grid-cell {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.tile {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  transition: transform 0.15s ease, opacity 0.15s ease;
  z-index: 10;
  font-size: 2rem;
}

/* Default theme tile colors */
.tile-2 {
  background-color: #eee4da;
  color: #776e65;
}

.tile-4 {
  background-color: #ede0c8;
  color: #776e65;
}

.tile-8 {
  background-color: #f2b179;
  color: white;
}

.tile-16 {
  background-color: #f59563;
  color: white;
}

.tile-32 {
  background-color: #f67c5f;
  color: white;
}

.tile-64 {
  background-color: #f65e3b;
  color: white;
}

.tile-128 {
  background-color: #edcf72;
  color: white;
  font-size: 1.8rem;
}

.tile-256 {
  background-color: #edcc61;
  color: white;
  font-size: 1.8rem;
}

.tile-512 {
  background-color: #edc850;
  color: white;
  font-size: 1.8rem;
}

.tile-1024 {
  background-color: #edc53f;
  color: white;
  font-size: 1.4rem;
}

.tile-2048 {
  background-color: #edc22e;
  color: white;
  font-size: 1.4rem;
  box-shadow: 0 0 30px rgba(237, 194, 46, 0.5);
}

.tile-super {
  background-color: #3c3a32;
  color: white;
  font-size: 1.2rem;
}

/* Neon theme */
.neon .game-board {
  background-color: #121212;
  box-shadow: 0 0 20px rgba(127, 90, 240, 0.5);
}

.neon .grid-cell {
  background-color: rgba(255, 255, 255, 0.05);
}

.neon .tile {
  box-shadow: 0 0 10px currentColor;
  text-shadow: 0 0 5px currentColor;
}

.neon .tile-2 {
  background-color: #2d3b8a;
  color: #88a0ff;
}

.neon .tile-4 {
  background-color: #4b1b89;
  color: #bb88ff;
}

.neon .tile-8 {
  background-color: #721c85;
  color: #ff88f2;
}

.neon .tile-16 {
  background-color: #8a1d77;
  color: #ff88c2;
}

.neon .tile-32 {
  background-color: #9c1d5c;
  color: #ff8888;
}

.neon .tile-64 {
  background-color: #a61e45;
  color: #ff9d88;
}

.neon .tile-128 {
  background-color: #a62e30;
  color: #ffbd88;
  font-size: 1.8rem;
}

.neon .tile-256 {
  background-color: #9c6e1e;
  color: #ffdd88;
  font-size: 1.8rem;
}

.neon .tile-512 {
  background-color: #888c17;
  color: #eeff88;
  font-size: 1.8rem;
}

.neon .tile-1024 {
  background-color: #1a8c2e;
  color: #adff88;
  font-size: 1.4rem;
}

.neon .tile-2048 {
  background-color: #1a8c8a;
  color: #88fff0;
  font-size: 1.4rem;
  box-shadow: 0 0 30px rgba(26, 140, 138, 0.8);
}

.neon .tile-super {
  background-color: #ffffff;
  color: #000000;
  text-shadow: 0 0 10px #ffffff;
  font-size: 1.2rem;
}

/* Pastel theme */
.pastel .game-board {
  background-color: #f0f0f0;
}

.pastel .grid-cell {
  background-color: rgba(0, 0, 0, 0.05);
}

.pastel .tile {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.pastel .tile-2 {
  background-color: #FFAFAF;
  color: #333;
}

.pastel .tile-4 {
  background-color: #FFCFC9;
  color: #333;
}

.pastel .tile-8 {
  background-color: #FFE6C9;
  color: #333;
}

.pastel .tile-16 {
  background-color: #FFFAC9;
  color: #333;
}

.pastel .tile-32 {
  background-color: #E6FFC9;
  color: #333;
}

.pastel .tile-64 {
  background-color: #C9FFF1;
  color: #333;
}

.pastel .tile-128 {
  background-color: #C9E6FF;
  color: #333;
  font-size: 1.8rem;
}

.pastel .tile-256 {
  background-color: #C9C9FF;
  color: #333;
  font-size: 1.8rem;
}

.pastel .tile-512 {
  background-color: #E6C9FF;
  color: #333;
  font-size: 1.8rem;
}

.pastel .tile-1024 {
  background-color: #FFC9F3;
  color: #333;
  font-size: 1.4rem;
}

.pastel .tile-2048 {
  background-color: #FFC9C9;
  color: #333;
  font-size: 1.4rem;
  box-shadow: 0 0 20px rgba(255, 201, 201, 0.8);
}

.pastel .tile-super {
  background-color: #ffffff;
  color: #333;
  box-shadow: 0 0 15px rgba(255, 201, 201, 0.8);
  font-size: 1.2rem;
}

/* Score popup */
#score-popup {
  position: absolute;
  top: 20px;
  right: 20px;
  background-color: var(--accent);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: bold;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.5s ease;
  z-index: 100;
}

#score-popup.show {
  opacity: 1;
  transform: translateY(0);
}

/* Game over overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(22, 22, 26, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

.overlay-content {
  text-align: center;
  padding: 2rem;
  background-color: var(--surface);
  border-radius: 15px;
  max-width: 90%;
  width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#game-result {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

#game-result.win {
  color: var(--secondary);
}

#final-score {
  font-size: 1.2rem;
}

#win-tile-container {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}

.win-tile {
  width: 100px;
  height: 100px;
  background-color: #edc22e;
  color: white;
  border-radius: 10px;
  font-weight: bold;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(237, 194, 46, 0.5);
}

#new-best {
  color: var(--secondary);
  font-weight: bold;
  display: none;
}

.overlay-buttons {
  display: flex;
  gap: 1rem;
}

/* Media Queries */
@media (max-width: 768px) {
  .game-container {
      grid-template-columns: 1fr;
  }
  
  .game-info {
      order: 2;
  }
  
  .game-board-container {
      order: 1;
  }
  
  .mobile-controls {
      display: block;
  }
  
  .game-board {
      gap: 10px;
      padding: 10px;
  }
  
  .tile {
      font-size: 1.5rem;
  }
  
  .tile-128,
  .tile-256,
  .tile-512 {
      font-size: 1.3rem;
  }
  
  .tile-1024,
  .tile-2048,
  .tile-super {
      font-size: 1rem;
  }
}

/* Animations */
@keyframes appear {
  0% {
      opacity: 0;
      transform: scale(0);
  }
  60% {
      transform: scale(1.1);
  }
  100% {
      opacity: 1;
      transform: scale(1);
  }
}

@keyframes pop {
  0% {
      transform: scale(1);
  }
  50% {
      transform: scale(1.2);
  }
  100% {
      transform: scale(1);
  }
}

.tile-new {
  animation: appear 0.2s ease;
}

.tile-merged {
  animation: pop 0.2s ease;
}

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

.overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

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

.win-tile {
  animation: pulse 1.5s infinite;
}