body {
  background: url('images/bg-quaisquad.png') no-repeat center center fixed;
  background-size: cover;
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
}
body {
  overscroll-behavior: none;
  touch-action: none;
}

/* ✅ ONLY auth wrapper uses full flex centering */
#auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#auth-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

#connect-wallet-button,
#start-game-button,
#play-email-button {
  display: inline-block;
  padding: 20px 60px;
  font-size: 28px;
  font-weight: bold;
  margin: 20px;
  background: #a21a1a;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 0 20px #f04545;
  transition: all 0.3s ease;
}

#connect-wallet-button:hover,
#start-game-button:hover,
#play-email-button:hover {
  background: #ff5c5c;
  box-shadow: 0 0 30px #f04545;
}

#wallet-address {
  font-size: 22px;
  margin-top: 20px;
  color: #fff;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 1px;
  text-shadow: 2px 2px 4px #a21a1a;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 20px;
  border-radius: 6px;
}

/* HEADER pinned with logo left and leaderboard right */
#header {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

#header-right {
  display: flex;
  gap: 15px;
  align-items: center;
}

#title {
  font-size: 80px;
  background: #a21a1a;
  color: #fff;
  padding: 20px 40px;
  border-radius: 10px;
  font-weight: 900;
  margin: 0;
  position: absolute;
  top: -120px;
  left: 20px;
}

#leaderboard-btn {
  display: inline-block;
  background: #a21a1a;
  color: #fff;
  padding: 15px 30px;
  border-radius: 8px;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  text-decoration: none;
  box-shadow: 0 0 15px #f04545;
  transition: all 0.2s ease;
  position: absolute;
  top: -120px;
  right: 20px;
}

#leaderboard-btn:hover {
  background: #ff5c5c;
  box-shadow: 0 0 25px #f04545;
}

#info-btn {
  display: inline-block;
  background: #a21a1a;
  color: #fff;
  padding: 15px 30px;
  border-radius: 8px;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  text-decoration: none;
  box-shadow: 0 0 15px #f04545;
  transition: all 0.2s ease;
  position: absolute;
  top: -120px;
  right: 200px;
}

#info-btn:hover {
  background: #ff5c5c;
  box-shadow: 0 0 25px #f04545;
}

#game-container {
  position: relative;
  margin-top: 155px;
}

#scores {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 20px;
  position: absolute;
  top: -125px;
  left: 50%;
  transform: translateX(-50%);
}

#score-box, #best-box {
  background: #9a4949;
  padding: 10px 40px;
  border-radius: 10px;
  color: #fff;
  text-align: center;
  box-shadow: 0 0 15px #f04545;
}

#score-box .label,
#best-box .label {
  font-size: 24px;
  font-weight: bold;
}

#score,
#best {
  font-size: 40px;
  font-weight: 900;
  margin-top: 5px;
}

#grid-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 100px; /* Increased margin to add gap between scores and grid */
}

#grid {
  position: relative;
  background: #9a4949;
  width: 520px;
  height: 520px;
  border-radius: 5px;
}

.cell, .tile {
  position: absolute;
  width: calc((500px - 50px) / 4);
  height: calc((500px - 50px) / 4);
  border-radius: 5px;
  font-size: 45px;
  font-weight: 900;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  text-shadow: 2px 2px 4px #000, -2px -2px 4px #000;
}

.cell {
  background: #cdc1b4;
}

.tile {
  transition: all 0.1s ease;
}

/* Tile images + fallback */
.tile-2 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile2.jpg') center/cover no-repeat;
}
.tile-4 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile4.jpg') center/cover no-repeat;
}
.tile-8 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile8.png') center/cover no-repeat;
}
.tile-16 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile16.jpg') center/cover no-repeat;
}
.tile-32 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile32.jpg') center/cover no-repeat;
}
.tile-64 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile64.jpg') center/cover no-repeat;
}
.tile-128 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile128.jpg') center/cover no-repeat;
}
.tile-256 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile256.jpg') center/cover no-repeat;
}
.tile-512 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile512.jpg') center/cover no-repeat;
}
.tile-1024 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile1024.jpg') center/cover no-repeat;
}
.tile-2048 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile2048.jpg') center/cover no-repeat;
}
.tile-4096 {
  background:
    linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)),
    url('images/tile4096.jpg') center/cover no-repeat;
}

#milestone-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a1a1a;
  border: 2px solid #f04545;
  color: #f04545;
  padding: 30px 50px;
  border-radius: 8px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 24px;
  text-align: center;
  box-shadow: 0 0 20px #f04545;
  z-index: 20;
}

#game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: none;
  background: rgba(211, 84, 99, 0.8);
  border: 2px solid #c15656;
  border-radius: 10px;
  padding: 20px;
  width: 400px;
  z-index: 10;
}

#game-over-text {
  font-size: 50px;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 20px;
}

#restart-button {
  padding: 15px 40px;
  font-size: 24px;
  font-weight: bold;
  background: #270509;
  border: none;
  border-radius: 3px;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 4px #ba5c5c;
  transition: all 0.2s ease;
}

#restart-button:hover {
  background: #9c8570;
}

#restart-button:active {
  box-shadow: none;
  transform: translateY(2px);
}
#leaderboard-container {
  max-width: 600px;
  margin: 25px auto 50px auto;
  padding: 40px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 10px;
  color: #fff;
  text-align: center;
  font-family: 'Courier New', Courier, monospace;
}

#leaderboard-container h1 {
  font-size: 50px;
  margin-bottom: 30px;
  color: #f04545;
  text-shadow: 2px 2px #000;
}

.lb-entry {
  background: #9a4949;
  padding: 15px 20px;
  margin: 10px 0;
  border-radius: 8px;
  font-size: 20px;
  box-shadow: 0 0 10px #f04545;
}

#back-link {
  display: inline-block;
  margin-top: 30px;
  background: #a21a1a;
  color: #fff;
  padding: 15px 30px;
  border-radius: 8px;
  font-weight: bold;
  text-decoration: none;
  box-shadow: 0 0 15px #f04545;
  transition: all 0.2s ease;
}

#back-link:hover {
  background: #ff5c5c;
  box-shadow: 0 0 25px #f04545;
}

#info-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#info-content {
  background: #1a1a1a;
  border: 2px solid #f04545;
  color: #f9f6f2;
  padding: 40px;
  border-radius: 8px;
  text-align: center;
  max-width: 400px;
  font-family: 'Courier New', Courier, monospace;
  box-shadow: 0 0 20px #f04545;
}

#info-content h2 {
  margin-top: 0;
  color: #f04545;
}

#close-info {
  margin-top: 20px;
  padding: 10px 30px;
  background: #a21a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

#close-info:hover {
  background: #ff5c5c;
}
#pagination {
  margin: 20px 0;
  display: flex;
  justify-content: center;
  gap: 20px;
}

#pagination button {
  background: #a21a1a;
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  cursor: pointer;
  box-shadow: 0 0 15px #f04545;
  transition: all 0.2s ease;
}

#pagination button:hover {
  background: #ff5c5c;
  box-shadow: 0 0 25px #f04545;
}

#pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

#or-separator {
  font-size: 20px;
  color: #fff;
  margin: 10px;
  font-weight: bold;
}
#signup-container {
  max-width: 500px;
  margin: 200px auto;
  background: rgba(0,0,0,0.6);
  padding: 40px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 0 20px #f04545;
}

#signup-container h1 {
  font-size: 36px;
  color: #fff;
  margin-bottom: 30px;
  text-shadow: 2px 2px #a21a1a;
}

#signup-form input[type="email"] {
  width: 70%;
  padding: 15px 20px;
  font-size: 18px;
  border: none;
  border-radius: 6px;
  margin-bottom: 20px;
}

#signup-form button {
  display: inline-block;
  padding: 15px 40px;
  font-size: 20px;
  font-weight: bold;
  background: #a21a1a;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 0 15px #f04545;
  transition: all 0.3s ease;
}

#signup-form button:hover {
  background: #ff5c5c;
  box-shadow: 0 0 25px #f04545;
}
#status-message {
  font-family: 'Courier New', monospace;
  font-size: 20px;
  text-align: center;
  margin-top: 20px;
}
/* Shared auth box style */
.auth-box {
  background: rgba(0, 0, 0, 0.5);
  padding: 40px 60px;
  border-radius: 10px;
  box-shadow: 0 0 30px #f04545;
  text-align: center;
  margin: 200px auto;
  max-width: 400px;
}

.auth-box h1 {
  font-size: 32px;
  color: #fff;
  margin-bottom: 30px;
  text-shadow: 2px 2px #f04545;
}

.auth-box input[type="text"],
.auth-box input[type="email"] {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 18px;
}

.auth-box button {
  background: #a21a1a;
  color: #fff;
  border: none;
  padding: 15px 40px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-box button:hover {
  background: #ff5c5c;
  box-shadow: 0 0 20px #f04545;
}
#username-note {
  font-size: 12px;
  margin-top: 5px;
  color: #fff;
  font-family: 'Courier New', Courier, monospace;
  text-shadow: 1px 1px 2px #a21a1a;
  opacity: 0.8;
}
