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

body {
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #000000 100%);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #d4af37;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  max-width: 500px;
  width: 100%;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

h1 {
  font-size: 3.5rem;
  font-weight: bold;
  color: #d4af37;
  text-shadow: 0 2px 12px rgba(212, 175, 55, 0.5);
}

.scores-container {
  display: flex;
  gap: 10px;
}

.score-container {
  background: rgba(26, 26, 26, 0.9);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  padding: 10px 20px;
  text-align: center;
  min-width: 80px;
}

.score-label {
  font-size: 0.8rem;
  color: #999999;
  text-transform: uppercase;
  margin-bottom: 5px;
}

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

.above-game {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.game-intro {
  color: #cccccc;
  font-size: 1rem;
}

.game-intro strong {
  color: #d4af37;
}

.restart-button {
  background: #d4af37;
  color: #000000;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.restart-button:hover {
  background: #b8941f;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(212, 175, 55, 0.5);
}

.game-container {
  position: relative;
  background: rgba(26, 26, 26, 0.9);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.grid-container {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 15px;
  position: relative;
  z-index: 1;
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.grid-cell {
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  aspect-ratio: 1;
}

.tile-container {
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 15px;
  z-index: 2;
  pointer-events: none;
}

.tile {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  font-weight: bold;
  border-radius: 8px;
  transition: all 0.15s ease-in-out;
  width: 106px;
  height: 106px;
}

.tile-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.tile-2 { background: #d4af37; color: #000000; }
.tile-4 { background: #b8941f; color: #000000; }
.tile-8 { background: #9d7e1a; color: #ffffff; }
.tile-16 { background: #826815; color: #ffffff; }
.tile-32 { background: #675210; color: #ffffff; }
.tile-64 { background: #4c3c0c; color: #ffffff; }
.tile-128 { background: #d4af37; color: #000000; font-size: 1.8rem; box-shadow: 0 0 20px rgba(212, 175, 55, 0.5); }
.tile-256 { background: #b8941f; color: #000000; font-size: 1.8rem; box-shadow: 0 0 20px rgba(184, 148, 31, 0.5); }
.tile-512 { background: #9d7e1a; color: #ffffff; font-size: 1.8rem; box-shadow: 0 0 20px rgba(157, 126, 26, 0.5); }
.tile-1024 { background: #826815; color: #ffffff; font-size: 1.5rem; box-shadow: 0 0 20px rgba(130, 104, 21, 0.5); }
.tile-2048 { background: #675210; color: #ffffff; font-size: 1.5rem; box-shadow: 0 0 30px rgba(212, 175, 55, 0.8); }
.tile-super { background: #000000; color: #d4af37; font-size: 1.2rem; box-shadow: 0 0 30px rgba(212, 175, 55, 1); }

/* Tile positioning - 4x4 grid with 15px gaps */
.tile-position-1-1 { transform: translate(0px, 0px); }
.tile-position-1-2 { transform: translate(121px, 0px); }
.tile-position-1-3 { transform: translate(242px, 0px); }
.tile-position-1-4 { transform: translate(363px, 0px); }
.tile-position-2-1 { transform: translate(0px, 121px); }
.tile-position-2-2 { transform: translate(121px, 121px); }
.tile-position-2-3 { transform: translate(242px, 121px); }
.tile-position-2-4 { transform: translate(363px, 121px); }
.tile-position-3-1 { transform: translate(0px, 242px); }
.tile-position-3-2 { transform: translate(121px, 242px); }
.tile-position-3-3 { transform: translate(242px, 242px); }
.tile-position-3-4 { transform: translate(363px, 242px); }
.tile-position-4-1 { transform: translate(0px, 363px); }
.tile-position-4-2 { transform: translate(121px, 363px); }
.tile-position-4-3 { transform: translate(242px, 363px); }
.tile-position-4-4 { transform: translate(363px, 363px); }

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

@keyframes appear {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

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

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

.game-message {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 12px;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  text-align: center;
  padding: 20px;
}

.game-message.game-won,
.game-message.game-over {
  display: flex;
}

.game-message p {
  font-size: 3rem;
  font-weight: bold;
  color: #d4af37;
  margin-bottom: 30px;
  text-shadow: 0 2px 12px rgba(212, 175, 55, 0.5);
}

.game-message .lower {
  display: flex;
  gap: 15px;
}

.keep-playing-button,
.retry-button {
  background: #d4af37;
  color: #000000;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.keep-playing-button:hover,
.retry-button:hover {
  background: #b8941f;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(212, 175, 55, 0.5);
}

.game-explanation {
  color: #999999;
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
}

.game-explanation strong {
  color: #d4af37;
}

.game-explanation .important {
  display: block;
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.back-button {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 20px;
  background: transparent;
  color: #d4af37;
  border: 2px solid #d4af37;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  text-align: center;
}

.back-button:hover {
  background: #d4af37;
  color: #000000;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(212, 175, 55, 0.4);
}

@media (max-width: 520px) {
  h1 {
    font-size: 2.5rem;
  }
  
  .tile {
    font-size: 1.5rem;
  }
  
  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 1.3rem;
  }
  
  .tile-1024,
  .tile-2048 {
    font-size: 1.1rem;
  }
  
  .tile-super {
    font-size: 0.9rem;
  }
  
  .game-message p {
    font-size: 2rem;
  }
}
