/* Reset and Base Styles */
html, body {
  margin: 0;
  padding: 0;
  background: #A533FF; /* Purple background */
  color: #FFFFFF; /* White text */
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
}

.container {
  width: 500px;
  margin: 30px auto;
  text-align: center;
}

/* Heading */
.heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.title {
  font-size: 80px;
  font-weight: bold;
  margin: 0;
  color: #FFFFFF; /* White */
}

/* Scores */
.scores-container {
  display: flex;
  justify-content: flex-end;
}

.score-container, .best-container {
  position: relative;
  display: inline-block;
  background: #FFFFFF; /* White background */
  padding: 15px 25px;
  font-size: 25px;
  height: 25px;
  line-height: 47px;
  font-weight: bold;
  border-radius: 3px;
  color: #000000; /* Black text for readability */
  margin-left: 8px;
  text-align: center;
  transition: transform 100ms ease-in-out; /* For score increment animation */
}

.score-container.score-added {
  transform: scale(1.1); /* Scale up briefly when score increments */
}

.score-container:after, .best-container:after {
  position: absolute;
  width: 100%;
  top: 10px;
  left: 0;
  text-transform: uppercase;
  font-size: 13px;
  line-height: 13px;
  text-align: center;
  color: #000000; /* Black for contrast */
}

.score-container:after {
  content: "Score";
}

.best-container:after {
  content: "Best";
}

/* Wallet Button and Address */
#connect-wallet {
  padding: 10px 20px;
  font-size: 18px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  background: #0057FF; /* Blue */
  color: #FFFFFF; /* White text */
  font-weight: bold;
  transition: background-color 0.3s;
}

#connect-wallet.disconnected {
  background: #0057FF;
  color: #FFFFFF;
}

#connect-wallet.connected {
  background: #FF008C; /* Pink */
  color: #FFFFFF; /* White text */
}

#connect-wallet:hover:not(:disabled) {
  background: #CC0070; /* Darker pink */
}

#connect-wallet:disabled {
  background: #666666;
  cursor: not-allowed;
}

#wallet-address {
  margin-left: 10px;
  font-size: 14px;
  color: #FFFFFF; /* White text on purple background */
}

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

.game-intro {
  margin: 0;
  font-size: 18px;
  color: #FFFFFF; /* White text on purple background */
}

.restart-button {
  display: inline-block;
  background: #0057FF; /* Blue */
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: #FFFFFF; /* White text */
  height: 40px;
  line-height: 42px;
  cursor: pointer;
  font-weight: bold;
}

.restart-button:hover {
  background: #0033CC; /* Darker blue */
}

/* Game Container */
.game-container {
  background: #0057FF; /* Blue grid background */
  border-radius: 6px;
  width: 500px;
  height: 500px;
  padding: 15px;
  box-sizing: border-box;
  position: relative;
  margin: 0 auto;
}

.grid-container {
  position: absolute;
  z-index: 1;
  top: 15px;
  left: 15px;
  width: 470px;
  height: 470px;
}

.grid-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
}

.grid-row:last-child {
  margin-bottom: 0;
}

.grid-cell {
  width: 106.25px;
  height: 106.25px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2); /* Semi-transparent white on blue */
}

.tile-container {
  position: absolute;
  z-index: 2;
  top: 15px;
  left: 15px;
  width: 470px;
  height: 470px;
}

.tile {
  width: 106.25px;
  height: 106.25px;
  line-height: 106.25px;
  border-radius: 3px;
  background: #FF008C; /* Base magenta */
  text-align: center;
  font-weight: bold;
  z-index: 10;
  font-size: 55px;
  position: absolute;
  transition: left 100ms ease-in-out, top 100ms ease-in-out; /* For sliding */
}

.tile.tile-2 { background: #FF008C; color: #FFFFFF; } /* Deep magenta, white text */
.tile.tile-4 { background: #FF3399; color: #000000; } /* Neon pink, black text */
.tile.tile-8 { background: #CC0033; color: #FFFFFF; } /* Ruby red, white text */
.tile.tile-16 { background: #FF6633; color: #000000; } /* Fiery orange, black text */
.tile.tile-32 { background: #FF9933; color: #FFFFFF; } /* Amber, white text */
.tile.tile-64 { background: #00CC66; color: #000000; } /* Emerald green, black text */
.tile.tile-128 { background: #33CC99; color: #FFFFFF; } /* Teal, white text */
.tile.tile-256 { background: #00FFF0; color: #000000; } /* Cyan, black text */
.tile.tile-512 { background: #0066FF; color: #FFFFFF; } /* Sapphire blue, white text */
.tile.tile-1024 { background: #0033CC; color: #000000; font-size: 35px; } /* Cobalt blue, black text */
.tile.tile-2048 { background: #6633FF; color: #FFFFFF; font-size: 35px; } /* Indigo, white text */
.tile.tile-4096 { background: #9933CC; color: #000000; font-size: 35px; } /* Amethyst purple, black text */
.tile.tile-8192 { background: #6600CC; color: #FFFFFF; font-size: 35px; } /* Deep violet, white text */

/* Tile Positioning with left and top */
.tile-position-1-1 { left: 0px; top: 0px; }
.tile-position-1-2 { left: 0px; top: 121.25px; }
.tile-position-1-3 { left: 0px; top: 242.5px; }
.tile-position-1-4 { left: 0px; top: 363.75px; }
.tile-position-2-1 { left: 121.25px; top: 0px; }
.tile-position-2-2 { left: 121.25px; top: 121.25px; }
.tile-position-2-3 { left: 121.25px; top: 242.5px; }
.tile-position-2-4 { left: 121.25px; top: 363.75px; }
.tile-position-3-1 { left: 242.5px; top: 0px; }
.tile-position-3-2 { left: 242.5px; top: 121.25px; }
.tile-position-3-3 { left: 242.5px; top: 242.5px; }
.tile-position-3-4 { left: 242.5px; top: 363.75px; }
.tile-position-4-1 { left: 363.75px; top: 0px; }
.tile-position-4-2 { left: 363.75px; top: 121.25px; }
.tile-position-4-3 { left: 363.75px; top: 242.5px; }
.tile-position-4-4 { left: 363.75px; top: 363.75px; }

/* Tile Animations */
.tile-new {
  animation: appear 200ms ease 100ms;
  animation-fill-mode: backwards;
}

.tile-merged {
  animation: pop 200ms ease 100ms, flash 200ms ease 100ms;
  animation-fill-mode: backwards;
}

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

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

@keyframes flash {
  0% { background-color: rgba(255, 255, 255, 0.5); }
  100% { background-color: inherit; }
}

.game-message {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.5); /* White overlay */
  z-index: 100;
  text-align: center;
  padding-top: 100px;
}

.game-message p {
  font-size: 60px;
  font-weight: bold;
  margin: 0;
  color: #FFFFFF; /* White text */
}

.game-message .lower {
  display: block;
  margin-top: 59px;
}

.game-message a {
  display: inline-block;
  background: #0057FF; /* Blue */
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: #FFFFFF; /* White text */
  height: 40px;
  line-height: 42px;
  margin-left: 9px;
  cursor: pointer;
}

.game-message a:hover {
  background: #0033CC; /* Darker blue */
}

.game-message.game-over {
  display: block;
}

/* Leaderboard */
.leaderboard {
  margin: 20px 0;
  text-align: center;
}

.leaderboard h2 {
  font-size: 24px;
  margin-bottom: 10px;
  color: #FFFFFF; /* White text on purple background */
}

#leaderboard-table {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  border-collapse: collapse;
  background: #0057FF; /* Blue background like tiles */
}

#leaderboard-table th, #leaderboard-table td {
  padding: 10px;
  border: 1px solid #A533FF; /* Purple border */
  color: #FFFFFF; /* White text */
  background: #0057FF; /* Blue background for all cells */
}

#leaderboard-table th {
  background: #0057FF; /* Blue header */
  color: #FFFFFF; /* White text */
  font-weight: bold;
}

/* Remove tile color styling for rows */
#leaderboard-body tr:nth-child(1),
#leaderboard-body tr:nth-child(2),
#leaderboard-body tr:nth-child(3),
#leaderboard-body tr:nth-child(4),
#leaderboard-body tr:nth-child(5),
#leaderboard-body tr:nth-child(6),
#leaderboard-body tr:nth-child(7),
#leaderboard-body tr:nth-child(8),
#leaderboard-body tr:nth-child(9),
#leaderboard-body tr:nth-child(10) {
  background: #0057FF; /* Uniform blue background */
}

#refresh-leaderboard {
  padding: 10px 20px;
  font-size: 18px;
  background: #FF008C; /* Pink, matching Disconnect Wallet */
  color: #FFFFFF; /* White text */
  border: none;
  border-radius: 3px;
  cursor: pointer;
  margin: 10px 0;
  font-weight: bold;
}

#refresh-leaderboard:hover {
  background: #CC0070; /* Darker pink, matching Disconnect Wallet hover */
}

/* Wallet Prompt Modal */
#wallet-prompt {
  text-align: center;
  background: #FFFFFF; /* White background */
  border: 2px solid #0057FF; /* Blue border */
}

#wallet-prompt p {
  margin-bottom: 15px;
  font-size: 18px;
  color: #FFFFFF; /* White text */
}

#wallet-prompt button {
  padding: 8px 16px;
  margin: 0 5px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
}

#connect-now {
  background: #0057FF; /* Blue */
  color: #FFFFFF; /* White text */
}

#cancel-prompt {
  background: #FF008C; /* Pink */
  color: #FFFFFF; /* White text */
}

#connect-now:hover, #cancel-prompt:hover {
  opacity: 0.9;
}

