body {
  background: url('images/bg_mobile.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;
  margin: 0;
  padding: 0;
}

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: 15px;
  text-align: center;
}

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

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

#wallet-address {
  font-size: 12px;
  margin-top: 10px;
  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: 8px;
  border-radius: 4px;
}

/* HEADER with title in top-left, buttons on right */
#header {
  position: sticky;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  padding: 5px;
}

#title {
  font-size: 28px; /* Smaller title */
  background: #a21a1a;
  color: #fff;
  padding: 8px 15px;
  border-radius: 6px;
  font-weight: 900;
  margin: 0;
  position: absolute;
  top: 10px;
  left: 10px;
}

#header-right {
  display: flex;
  gap: 10px;
  align-items: center;
  position: absolute;
  top: 10px;
  right: 10px;
}

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

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

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

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

#game-container {
  position: relative;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 60px); /* Adjust for header */
  margin-top: 20px; /* Add space above grid */
}

#scores {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 100px; /* Move scores down */
  margin-bottom: 50px; /* Ensure space below scores */
}

#score-box, #best-box {
  background: #9a4949;
  padding: 12px 30px; /* Adjusted for balance */
  border-radius: 8px;
  color: #fff;
  text-align: center;
  box-shadow: 0 0 12px #f04545;
}

#score-box .label,
#best-box .label {
  font-size: 20px; /* Adjusted for readability */
  font-weight: bold;
}

#score,
#best {
  font-size: 32px; /* Adjusted for clarity without overwhelming */
  font-weight: 900;
  margin-top: 4px;
}

#grid-wrapper {
  display: flex;
  justify-content: center;
  flex-grow: 1;
}

#grid {
  position: relative;
  background: #9a4949;
  width: 90vw;
  height: 90vw;
  max-width: 500px;
  max-height: 500px;
  border-radius: 5px;
  margin: 0 auto;
}

.cell, .tile {
  position: absolute;
  width: calc((90vw - 75px) / 4);
  height: calc((90vw - 75px) / 4);
  max-width: calc((500px - 75px) / 4);
  max-height: calc((500px - 75px) / 4);
  border-radius: 5px;
  font-size: 5vw;
  max-font-size: 55px;
  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: 15px 30px;
  border-radius: 6px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  text-align: center;
  box-shadow: 0 0 12px #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: 8px;
  padding: 15px;
  width: 80vw;
  max-width: 350px;
  z-index: 10;
}

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

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

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

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

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

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

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

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

#info-modal {
  position: fixed;
  top: 10px; left: 60px; 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: 15px;
  border-radius: 6px;
  text-align: center;
  max-width: 90vw;
  font-family: 'Courier New', Courier, monospace;
  box-shadow: 0 0 12px #f04545;
}

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

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

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

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

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

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

#or-separator {
  font-size: 14px;
  color: #fff;
  margin: 5px;
  font-weight: bold;
}
#signup-container {
  max-width: 90vw;
  margin: 20px auto;
  background: rgba(0,0,0,0.6);
  padding: 15px;
  border-radius: 6px;
  text-align: center;
  box-shadow: 0 0 12px #f04545;
}

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

#signup-form input[type="email"] {
  width: 80%;
  padding: 8px 12px;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  margin-bottom: 10px;
}

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

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

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

.auth-box input[type="text"],
.auth-box input[type="email"] {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 14px;
}

.auth-box button {
  background: #a21a1a;
  color: #fff;
  border: none;
  padding: 8px 25px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-box button:hover {
  background: #ff5c5c;
  box-shadow: 0 0 12px #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;
}
