/* Point to font file */
@font-face {
  font-family: 'Comfortaa';
  src: url('Comfortaa-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: "Comfortaa", cursive, sans-serif;
  background-color: #D0CBC7; /* Same background color matching the game canvas */
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Prevents the user from clicking and dragging to highlight text */
  -webkit-user-select: none; /* Safari/WebKit */
  user-select: none;/* Standard */
  cursor: default;
}

#container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#container #game {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1; /* Puts canvas in the background layer */
  will-change: transform;
  transform: translateZ(0);
}

/* Splash Screen Container */
#splash-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #D0CBC7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100; /* Ensure it stays on top of all elements */
  transition: opacity 0.8s ease, visibility 0.8s;
}

#splash-screen.hide {
  opacity: 0;
  visibility: hidden;
}

/* "Stacker" slides in from the right */
#splash-title {
  font-size: 9vmin;
  font-weight: bold;
  color: #333344;
  margin-bottom: 2vh;
  transform: translateX(100vw);
  opacity: 0;
  animation: slideInFromRight 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* "by" fades in */
#splash-by {
  font-size: 3.5vmin;
  color: #333344;
  opacity: 0;
  margin-bottom: 2vh;
  animation: fadeIn 0.6s ease 1s forwards;
}

/* "author" slides up from below */
#splash-author {
  font-size: 7.5vmin;
  font-weight: bold;
  color: #333344;
  transform: translateY(40px);
  opacity: 0;
  animation: slideUp 1s cubic-bezier(0.25, 1, 0.5, 1) 1.4s forwards;
}

/* Splash Animation Keyframes */
@keyframes slideInFromRight {
  0% { transform: translateX(100%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 0.6; }
}

@keyframes slideUp {
  0% { transform: translateY(40px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Centered UI layer*/
#ui-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  
  /* Maintain the 350:600 scaling proportions for the text/buttons */
  aspect-ratio: 350 / 600;
  width: 100vw;
  height: 100vh;
  max-width: calc(100vh * (350 / 600));
  max-height: calc(100vw * (600 / 350));
  
  pointer-events: none; 
  z-index: 10;
  overflow: hidden;
}

#container #score {
  position: absolute;
  top: 4vh;
  width: 100%;
  text-align: center;
  font-size: 10vmin; 
  transition: transform 0.5s ease;
  color: #333344;
  transform: translatey(-200px) scale(1);
  font-weight: bold;
  z-index: 10;
}

/* Slide score down when playing or resetting */
#container.playing #score,
#container.resetting #score {
  transform: translatey(0px) scale(1);
}

/* Enlarge and focus score when game ends */
#container.ended #score {
  transform: translatey(6vh) scale(1.5);
}

/* Temporary Best Score Badge */
#container #best-score-badge {
  position: absolute;
  top: 15vh; /* Sitting directly under the score number */
  width: 100%;
  text-align: center;
  font-size: 3.5vmin;
  color: #333344;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  transform: translatey(-20px);
  z-index: 10;
}

/* Slides down and appears semi transparent when game starts playing */
#container.playing #best-score-badge {
  opacity: 0.5;
  transform: translatey(0);
}

/* Hide and fade away */
#container #best-score-badge.hide {
  opacity: 0 !important;
  transform: translatey(-20px) !important;
}

#container #instructions {
  position: absolute;
  width: 90%;
  top: 20vh;
  left: 5%;
  text-align: center;
  font-size: 3vmin; 
  transition: opacity 0.5s ease, transform 0.5s ease;
  opacity: 0;
  color: #333344;
  transform: translatey(-30px);
  pointer-events: none;
  z-index: 10;
}

#container.playing #instructions {
  opacity: 1;
  transform: translatey(0);
}

#container #instructions.hide {
  opacity: 0 !important;
  transform: translatey(-30px) !important;
}

/* Game Over overlay screen */
#container .game-over {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 85%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

#container .game-over * {
  transition: opacity 0.5s ease, transform 0.5s ease;
  opacity: 0;
  transform: translatey(-30px);
  color: #333344;
  text-align: center;
}

#container .game-over h2 {
  margin: 0;
  padding: 0;
  font-size: 7vmin; 
}

#container .game-over p {
  margin: 1.5vh 15px 0 15px;
  font-size: 3.5vmin; 
}

#container.ended .game-over {
  pointer-events: auto; /* Allow clicking to restart */
}

#container.ended .game-over * {
  opacity: 1;
  transform: translatey(0);
}

#container.ended .game-over p {
  transition-delay: 0.3s;
}

/* Start screen overlay */
#container .game-ready {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  pointer-events: none;
  z-index: 10;
}

#container .game-ready #start-button {
  transition: opacity 0.5s ease, transform 0.5s ease;
  opacity: 0;
  transform: translatey(-30px);
  border: 0.4vmin solid #333344; 
  padding: 1.5vh 6vw; 
  background-color: transparent;
  color: #333344;
  font-size: 5.5vmin; 
  cursor: pointer;
  border-radius: 3vmin; 
  font-weight: bold;
  pointer-events: auto; /* Allow clicking the start button */
}

#container.ready .game-ready {
  pointer-events: auto;
}

#container.ready .game-ready #start-button {
  opacity: 1;
  transform: translatey(0);
}