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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1e2f 0%, #2d1b4e 100%);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

h1 {
  font-size: 2.5rem;
  background: linear-gradient(135deg, #ff6b6b 0%,  #5f27cd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score-label {
  font-size: 1.2rem;
  opacity: 0.8;
}

.score-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #ffd93d;
}

.board-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  max-width: 480px;
  width: 100%;
}

.tile {
  background: #3a3a5a;
  border-radius: 8px;
  color: #fff;
  font-size: 1.8rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background-color 0.2s ease;
  user-select: none;
}

.tile:empty {
  background: transparent;
}

.tile.slide {
  transform: scale(0.95);
}

.tile.merge {
  background: #ffd93d;
  color: #333;
}

.tile.win {
  animation: winPulse 0.5s ease infinite;
}

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

.message {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 2rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

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

.modal {
  background: #2d1b4e;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  backdrop-filter: blur(10px);
  min-width: 200px;
}

.new-game-btn {
  margin-top: 1rem;
  padding: 0.8rem 1.5rem;
  font-size: 1.2rem;
  font-weight: bold;
  background: linear-gradient(135deg, #ff6b6b 0%, #5f27cd 100%);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.new-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.new-game-btn:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 500px) {
  h1 { font-size: 2rem; }
  .score-value { font-size: 1.2rem; }
  .tile { font-size: 1.4rem; }
}