/* --- Base Setup --- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  position: relative;
}

/* --- Background --- */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: url("assets/bg.jpg") no-repeat center center;
  background-size: cover;
  z-index: -1;
}

body {
  font-family: 'Changa', sans-serif;
  color: #3a2f58;
  box-sizing: border-box;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* --- Main Content Container --- */
.container {
  max-width: 480px;
  width: 100%;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(180, 162, 219, 0.4);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* --- Compact Title --- */
h1 {
  font-size: 1.8rem;
  margin: 0 0 8px 0;
  color: #6e5aa0;
  text-shadow: 1px 1px 2px #fff;
}

/* Wrapper Top section */
.top-buttons-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.button-group-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Button Style --- */
.button-63 {
  align-items: center;
  border: 0;
  border-radius: 8px;
  box-shadow: rgba(151, 65, 252, 0.2) 0 15px 30px -5px;
  box-sizing: border-box;
  color: #FFFFFF;
  display: flex;
  font-family: Phantomsans, sans-serif;
  font-size: 20px;
  justify-content: center;
  line-height: 1em;
  min-width: 140px;
  height: 40px;   
  padding: 0 20px;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.button-63:active,
.button-63:hover {
  outline: 0;
  transform: scale(1.05);
}

.button-63.connect-wallet {
  background-image: linear-gradient(144deg,#AF40FF, #5B42F3 50%,#00DDEB);
}
.button-63.gm-button {
  background-image: linear-gradient(144deg, #a8ff78, #78ffd6 50%, #a8ff78);
  min-width: 110px;
}
.button-63.submit-score {
  background-image: linear-gradient(144deg, #ff416c, #ff4b2b 50%, #ff416c);
}

/* --- GM, Submit, and Score Display --- */
.button-63.connect-wallet,
.button-63.gm-button,
.button-63.submit-score,
#score-display {
  font-size: 0.85rem;    
  min-width: 120px;      
  height: 36px;         
  padding: 0 16px;
  box-sizing: border-box;
}

/* --- Score Display --- */
#score-display {
  background-color: rgba(234, 229, 250, 0.8);
  color: #3a2f58;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 0.9rem;
  border: 1px solid #c9bee5;
  display: flex;
  align-items: center;
  height: 30px; 
}


/* --- Score Form --- */
#scoreForm {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 5px 0;
}
input[type="text"] {
  padding: 8px;
  width: 90%;
  box-sizing: border-box;
  margin-bottom: 8px;
  border: 1px solid #c9bee5;
  border-radius: 8px;
  font-size: 0.8rem;
  text-align: center;
}
.bottom-buttons-wrapper {
  display: flex;
  justify-content: space-between;
  width: 90%;
}
.bottom-buttons-wrapper button {
  flex-basis: 48%;
}

/* --- Game Board --- */
#game {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0;
}
.tile {
  width: 100%;
  padding-top: 100%;
  border-radius: 6px;
  position: relative;
  font-size: 1.3rem;
  font-weight: bold;
  color: #fff;
  backdrop-filter: blur(4px);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.tile::after {
  content: attr(data-value);
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* --- Animation --- */
.tile.new {
  animation: tile-pop 200ms ease-in;
}
.tile.merge {
  animation: tile-merge 200ms cubic-bezier(0, 0.2, 0, 1.5);
}
@keyframes tile-pop {
  0%   { transform: scale(0.3); opacity: 0; }
  80%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes tile-merge {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}


.tile-0    { background-color: #e3f4ff; }
.tile-2    { background-color: #c0e6ff; color: #333; }
.tile-4    { background-color: #9cd8ff; color: #333; }
.tile-8    { background-color: #7acaff; }
.tile-16   { background-color: #55bbff; }
.tile-32   { background-color: #33acff; }
.tile-64   { background-color: #11aafe; }
.tile-128  { background-color: #0d8ed4; }
.tile-256  { background-color: #0a75b3; }
.tile-512  { background-color: #085c91; color: #fff; }
.tile-1024 { background-color: #064571; color: #fff; }
.tile-2048 { background-color: #042f52; color: #fff; }
.tile-4096 { background-color: #021b33; color: #fff; }
.tile-8192 { background-color: #010d1a; color: #fff; }


/* --- Leaderboard & Footer --- */
#leaderboard {
  margin-top: 8px;
  text-align: left;
  background: rgba(234, 230, 248, 0.85); 
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(111, 82, 255, 0.15); 
  max-height: 140px;
  overflow-y: auto;
  font-family: 'Changa', sans-serif;
  font-size: 0.9rem;
  color: #3a2f58;
  user-select: none;
}

#leaderboard h3 {
  margin-bottom: 2px; /* کمتر کردن فاصله زیر عنوان */
  padding-bottom: 4px;
  border-bottom: 2px solid #6e5aa0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #5b3e96;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#leaderboard div,
#leaderboard p {
  margin-top: 0;
  padding-top: 2px;
  margin-bottom: 4px;
}

#leaderboard strong {
  color: #6e5aa0;
}

.footer {
  text-align: center;
  font-size: 0.7rem;
  padding: 5px 0 0 0;
  margin: 10px auto 0 auto;
  color: #6e5aa0;
}
.footer p { margin: 0; }
.footer a {
  color: #6e5aa0;
  text-decoration: none;
  margin: 0 3px;
}
.footer a:hover {
  text-decoration: underline;
}

@media (min-width: 500px) and (min-height: 700px) {
  h1 { font-size: 2.2rem; }
  .button-63, #score-display { padding: 12px 20px; font-size: 1rem; }
  input[type="text"] { padding: 10px; font-size: 1rem; }
  .tile { font-size: 1.5rem; }
  #game { gap: 10px; }
}
