* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
  /* border: 1px solid red; */
}

.loading-scene {
  height: 100%;
  width: 100%;
  z-index: 15;
}

.loading-background {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, rgba(33, 166, 150, 1) 70%, rgb(12, 71, 71) 100%);
  z-index: -1;
}

.loading {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  position: absolute;
  top: 50%;
  width: 100%;
  transform: translateY(-50%);
}

.loading-text,
.lobby-text {
  color: white;
  font-size: 30px;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  height: 96vh;
  width: 100%;
  background-color: #0f4c5c;
  background: url("Background.svg") no-repeat center center fixed;
  /* Optional background color */
}
.header {
  display: flex;
  align-items: center;
  width: 100%;
  height: 10%;
  color: white;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}

.profile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-radius: 10px;
  margin-bottom: 10px;
}

.mid {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 40%;
}

#profile-pic {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin-right: 8px;
}

.name {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 400;
  font-size: x-large;
  justify-self: center;
  white-space: nowrap;        /* Prevents text from wrapping to a new line */
  overflow: hidden;           /* Hides any overflow text */
  text-overflow: ellipsis;    /* Displays an ellipsis (...) when text overflows */
  max-width: 200px;           /* Adjust this value based on your layout needs */
}

/* Media Query for Small Devices */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    align-items: center;
    height: auto;
    padding: 5px;
  }
  
  .profile {
    flex-direction: column;
    align-items: center;
  }
  
  .mid {
    width: 100%;
    justify-content: center;
    margin: 5px 0;
  }
  
  #profile-pic {
    width: 30px;
    height: 30px;
    margin-right: 4px;
  }
  
  .name {
    font-size: medium;
    max-width: 100%;
  }
  
  .left,
  .right {
    width: 100%;
    text-align: center;
    margin: 2px 0;
  }
}


.stats {
  width: 90%;
  margin-bottom: 20px;
}

.game-content {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  padding: 20px;
  width: 100%;
  height: 100%;
}

.score {
  font-family: "Futura", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
  padding: 10px;
  color: white;
}

.score-container {
  font-size: 30px;
  font-weight: bold;
  color: white;
  border-radius: 3px;
  padding: 10px 20px;
}

.score-container:before {
  font-size: 13px;
  text-transform: uppercase;
  color: #eee4da;
  position: absolute;
  left: 50%;
  top: 5px;
  transform: translateX(-50%);
}

.restart {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Board container */
#board {
  position: relative;
  display: grid;
  width: 80vw;
  height: 80vw;
  max-width: 500px;
  max-height: 500px;
  background-color: #06534e;
  border-radius: 10px;
  padding: 10px;
  padding-bottom: 0px;
}

/* Background layer */
#background {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  /* Match the gap in #board */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Reset */
#restart {
  font-family: "Futura", sans-serif;
  font-size: 24px;
  font-weight: bold;
  border-radius: 3px;
  padding: 0 10px;
  text-decoration: none;
  background-color: #f57c00;
  height: 40px;
  width: 1000%;
  cursor: pointer;
  color: white;
  border: 0px;
  margin-bottom: 8px;
  border-radius: 18px;
}

/* Blank cells in the background */
.blanks {
  background-color: rgb(204 192 178 / 15%);
  border-radius: 3px;
}

/* Foreground layer for tiles */
#foreground {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  /* Tiles won't block interactions if needed */
}

/* Tile styles */
.tile {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: #fff;
  font-size: 1.5rem;
  border-radius: 5px;
  background-color: #ffcc66; /* Default tile color */
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

#board .tile-2 {
  color: #f9f6f2;
  background: #24ad9c;
}

#board .tile-4 {
  color: #f9f6f2;
  background: #54a580;
}

#board .tile-8 {
  color: #f9f6f2;
  background: #7b9f69;
}

#board .tile-16 {
  color: #f9f6f2;
  background: #d78e6a;
}

#board .tile-32 {
  color: #f9f6f2;
  background: #cf9038;
}

#board .tile-64 {
  color: #f9f6f2;
  background: #e78c2a;
}

#board .tile-128 {
  color: #f9f6f2;
  background: #f38a23;
  font-size: 21px;
}

#board .tile-256 {
  color: #f9f6f2;
  background: #fe891c;
  font-size: 21px;
}

#board .tile-512 {
  color: #f9f6f2;
  background: #edc850;
  font-size: 21px;
}

#board .tile-1024 {
  color: #f9f6f2;
  background: #edc53f;
  font-size: 15px;
}

#board .tile-2048 {
  color: #f9f6f2;
  background: #edc22e;
  font-size: 15px;
}

#board .tile-super {
  color: #f9f6f2;
  background: #3c3a32;
  font-size: 20px;
}

/* Preload logo animation */
.preload-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  z-index: 100;
  margin: -45px 0 0 -45px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-position: center center;
  animation: preload 1s linear infinite alternate;
  -webkit-animation-name: bounceIn;
  animation-name: bounceIn;
}

@keyframes bounceIn {
  from,
  20%,
  40%,
  60%,
  80%,
  to {
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  }
  0% {
    opacity: 0;
    transform: scale3d(0.3, 0.3, 0.3);
  }
  20% {
    transform: scale3d(1.1, 1.1, 1.1);
  }
  40% {
    transform: scale3d(0.9, 0.9, 0.9);
  }
  60% {
    opacity: 1;
    transform: scale3d(1.03, 1.03, 1.03);
  }
  80% {
    transform: scale3d(0.97, 0.97, 0.97);
  }
  to {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

.tile-new {
  animation: zoom-in 0.2s ease-in-out;
}

@keyframes zoom-in {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

/* 
Optional older "merged" approach:
tile-merged {
  background-color: #f96;
  animation: zoom-in-out 0.4s ease-in-out;
}
*/

@keyframes zoom-in-out {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* ============= NEW MERGED POP ANIMATION ============= */
/* This plays near the end of the slide. */
.tile-merged-pop {
  animation: pop-merge 100ms ease-in-out forwards;
}

@keyframes pop-merge {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
  font-family: Arial, Helvetica, sans-serif;
  background-color: #06534d !important;
  border-radius: 18px !important;
  width: 80%;
  max-width: 400px;
  height: 90vh;
  padding: 20px;
  margin: 10% auto;
  text-align: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: left;
  align-items: center;
  width: 100%;
  color: #ffffff94;
}

.modal-header img {
  margin-right: 10px;
  width: 20px;
  height: 20px;
}

.modal-header p {
  font-size: 14px;
  font-weight: 100;
}

.modal-body img {
  width: 80%;
  height: auto;
}

.modal-body h3 {
  padding-left: 20%;
  justify-self: left;
  color: #ffffffac;
  font-weight: 400;
  font-size: 24px;
}

.color_transparent {
  color: #ffffffac;
}

.modal-body h1 {
  padding: 0;
  color: #ffffff;
  font-weight: 100;
  font-size: 62px;
}

.modal-footer {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.modal-footer .btn {
  width: 40%;
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  background: #24ad9c;
  color: white;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.381);
  font-weight: 600;
}

#ModalRestartButton {
  background-color: #f07d13;
}

.btn:active {
  background-color: #000000 !important;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .modal-content {
    width: 90%;
    padding: 15px;
  }
  .modal-body h1 {
    font-size: 50px;
  }
  .modal-body h3 {
    font-size: 20px;
  }
  .modal-footer .btn {
    width: 45%;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .modal-content {
    width: 95%;
    padding: 10px;
  }
  .modal-body h1 {
    font-size: 40px;
  }
  .modal-body h3 {
    font-size: 18px;
  }
  .modal-footer .btn {
    width: 40%;
    font-size: 13px;
  }
}

@media (max-width: 500px) {
  .score {
    padding: 5px;
    font-size: 20px;
  }
  .score-container {
    padding: 5px 10px;
  }
}

@media (max-width: 400px) {
  .score {
    padding: 5px;
    font-size: 20px;
  }
  #restart {
    font-size: 10px;
    width: 60%;
  }
}

@media (max-width: 360px) {
  #board {
    width: 80vw;
    height: 80vw;
  }
  .score {
    padding: 1px;
    font-size: 18px;
  }
  #restart {
    font-size: 9px;
    width: 70%;
  }
}

@media (max-width: 200px) {
  .score {
    font-size: 16px;
  }
  #restart {
    font-size: 8px;
    width: 80%;
  }
}

.hidden {
  display: none;
} 