/* 2048 Game specific styles */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  padding: 20px;
  border-radius: 12px;
  color: white;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
}

.score-container {
  display: flex;
  gap: 15px;
}

.score-box {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 15px 20px;
  text-align: center;
  min-width: 90px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.score-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.score-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-value {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.game-controls {
  display: flex;
  gap: 10px;
}

.game-controls .btn {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.game-controls .btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.game-controls .btn:active {
  transform: translateY(0);
}

.game-container {
  position: relative;
  margin: 0 auto;
  width: 320px;
  height: 320px;
  background: linear-gradient(135deg, #bbada0, #a39489);
  border-radius: 12px;
  padding: 10px;
  box-sizing: border-box;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  border: 3px solid rgba(255, 255, 255, 0.1);
}

.grid-container {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 300px;
  height: 300px;
}

.grid-row {
  display: flex;
  margin-bottom: 10px;
}

.grid-row:last-child {
  margin-bottom: 0;
}

.grid-cell {
  width: 65px;
  height: 65px;
  background: rgba(238, 228, 218, 0.35);
  border-radius: 6px;
  margin-right: 10px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.grid-cell:last-child {
  margin-right: 0;
}

.tile-container {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 300px;
  height: 300px;
}

.tile {
  position: absolute;
  width: 65px;
  height: 65px;
  border-radius: 6px;
  font-weight: bold;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  animation: appear 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

@keyframes appear {
  0% {
    opacity: 0;
    transform: scale(0) rotate(180deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.tile-merged {
  animation: merge 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 10;
}

@keyframes merge {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  }
  100% {
    transform: scale(1);
  }
}

.tile-moving {
  z-index: 5;
  transition: all 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Tile colors with gradients and glow effects */
.tile-2 { 
  background: linear-gradient(135deg, #eee4da, #e4d5c7); 
  color: #776e65; 
  font-size: 32px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.tile-4 { 
  background: linear-gradient(135deg, #ede0c8, #e4d1b5); 
  color: #776e65; 
  font-size: 32px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.tile-8 { 
  background: linear-gradient(135deg, #f2b179, #f0a05a); 
  color: #f9f6f2; 
  font-size: 32px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 8px rgba(242, 177, 121, 0.4);
}
.tile-16 { 
  background: linear-gradient(135deg, #f59563, #f3844a); 
  color: #f9f6f2; 
  font-size: 30px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 8px rgba(245, 149, 99, 0.4);
}
.tile-32 { 
  background: linear-gradient(135deg, #f67c5f, #f46b46); 
  color: #f9f6f2; 
  font-size: 30px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 8px rgba(246, 124, 95, 0.4);
}
.tile-64 { 
  background: linear-gradient(135deg, #f65e3b, #f44d22); 
  color: #f9f6f2; 
  font-size: 30px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 8px rgba(246, 94, 59, 0.4);
}
.tile-128 { 
  background: linear-gradient(135deg, #edcf72, #ebc459); 
  color: #f9f6f2; 
  font-size: 28px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 12px rgba(237, 207, 114, 0.5);
  animation: glow-128 2s ease-in-out infinite alternate;
}
.tile-256 { 
  background: linear-gradient(135deg, #edcc61, #ebc148); 
  color: #f9f6f2; 
  font-size: 28px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 12px rgba(237, 204, 97, 0.5);
  animation: glow-256 2s ease-in-out infinite alternate;
}
.tile-512 { 
  background: linear-gradient(135deg, #edc850, #ebbd37); 
  color: #f9f6f2; 
  font-size: 28px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 12px rgba(237, 200, 80, 0.5);
  animation: glow-512 2s ease-in-out infinite alternate;
}
.tile-1024 { 
  background: linear-gradient(135deg, #edc53f, #ebb926); 
  color: #f9f6f2; 
  font-size: 24px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 15px rgba(237, 197, 63, 0.6);
  animation: glow-1024 1.5s ease-in-out infinite alternate;
}
.tile-2048 { 
  background: linear-gradient(135deg, #edc22e, #ebb615); 
  color: #f9f6f2; 
  font-size: 24px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 20px rgba(237, 194, 46, 0.8);
  animation: glow-2048 1s ease-in-out infinite alternate;
}
.tile-4096 { 
  background: linear-gradient(135deg, #3c3a32, #2c2a22); 
  color: #f9f6f2; 
  font-size: 24px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  box-shadow: 0 4px 20px rgba(60, 58, 50, 0.6);
  animation: glow-super 1s ease-in-out infinite alternate;
}
.tile-8192 { 
  background: linear-gradient(135deg, #3c3a32, #2c2a22); 
  color: #f9f6f2; 
  font-size: 20px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  box-shadow: 0 4px 25px rgba(60, 58, 50, 0.8);
  animation: glow-super 0.8s ease-in-out infinite alternate;
}

/* Glow animations for high-value tiles */
@keyframes glow-128 {
  0% { box-shadow: 0 4px 12px rgba(237, 207, 114, 0.5); }
  100% { box-shadow: 0 4px 20px rgba(237, 207, 114, 0.8); }
}

@keyframes glow-256 {
  0% { box-shadow: 0 4px 12px rgba(237, 204, 97, 0.5); }
  100% { box-shadow: 0 4px 20px rgba(237, 204, 97, 0.8); }
}

@keyframes glow-512 {
  0% { box-shadow: 0 4px 12px rgba(237, 200, 80, 0.5); }
  100% { box-shadow: 0 4px 20px rgba(237, 200, 80, 0.8); }
}

@keyframes glow-1024 {
  0% { box-shadow: 0 4px 15px rgba(237, 197, 63, 0.6); }
  100% { box-shadow: 0 4px 25px rgba(237, 197, 63, 1); }
}

@keyframes glow-2048 {
  0% { 
    box-shadow: 0 4px 20px rgba(237, 194, 46, 0.8);
    transform: scale(1);
  }
  100% { 
    box-shadow: 0 4px 30px rgba(237, 194, 46, 1);
    transform: scale(1.02);
  }
}

@keyframes glow-super {
  0% { 
    box-shadow: 0 4px 20px rgba(60, 58, 50, 0.6);
    transform: scale(1);
  }
  100% { 
    box-shadow: 0 4px 35px rgba(255, 215, 0, 0.8);
    transform: scale(1.03);
  }
}

.game-instructions {
  margin-top: 20px;
  background: #f8f9fa;
  border: 1px solid #e1e8ed;
  border-radius: 8px;
  padding: 16px;
}

.instruction-title {
  font-weight: 600;
  color: #495057;
  margin-bottom: 12px;
  font-size: 16px;
}

.instruction-content p {
  margin: 8px 0;
  color: #6c757d;
  font-size: 14px;
  line-height: 1.5;
}

.instruction-content strong {
  color: #495057;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background-color: #fff;
  margin: 15% auto;
  padding: 0;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease-in-out;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 20px 0;
  text-align: center;
}

.modal-header h3 {
  margin: 0;
  color: #495057;
  font-size: 20px;
}

.modal-body {
  padding: 20px;
  text-align: center;
}

.modal-body p {
  margin: 0 0 15px;
  color: #6c757d;
}

.final-score {
  font-size: 18px;
  font-weight: 600;
  color: #495057;
}

.final-score span:last-child {
  color: #ff6b6b;
  font-size: 24px;
}

.modal-footer {
  padding: 0 20px 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Responsive design */
@media (max-width: 768px) {
  .game-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .score-container {
    justify-content: center;
  }
  
  .game-controls {
    justify-content: center;
  }
  
  .game-container {
    width: 280px;
    height: 280px;
  }
  
  .grid-container,
  .tile-container {
    width: 260px;
    height: 260px;
  }
  
  .grid-cell,
  .tile {
    width: 55px;
    height: 55px;
  }
  
  .tile {
    font-size: 28px;
  }
  
  .tile-16,
  .tile-32,
  .tile-64 {
    font-size: 26px;
  }
  
  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 24px;
  }
  
  .tile-1024,
  .tile-2048,
  .tile-4096 {
    font-size: 20px;
  }
  
  .tile-8192 {
    font-size: 18px;
  }
}

/* Game loading animation */
.game-container::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  border-radius: 15px;
  animation: borderGlow 3s linear infinite;
  z-index: -1;
}

@keyframes borderGlow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Floating animation for score boxes */
.score-box {
  animation: float 3s ease-in-out infinite;
}

.score-box:nth-child(1) { animation-delay: 0s; }
.score-box:nth-child(2) { animation-delay: 0.5s; }
.score-box:nth-child(3) { animation-delay: 1s; }
.score-box:nth-child(4) { animation-delay: 1.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-3px); }
}

@media (max-width: 480px) {
  .game-container {
    width: 240px;
    height: 240px;
  }
  
  .grid-container,
  .tile-container {
    width: 220px;
    height: 220px;
  }
  
  .grid-cell,
  .tile {
    width: 45px;
    height: 45px;
  }
  
  .tile {
    font-size: 24px;
  }
  
  .tile-16,
  .tile-32,
  .tile-64 {
    font-size: 22px;
  }
  
  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 20px;
  }
  
  .tile-1024,
  .tile-2048,
  .tile-4096 {
    font-size: 16px;
  }
  
  .tile-8192 {
    font-size: 14px;
  }
}