@import url("https://fonts.googleapis.com/css?family=Press+Start+2P&display=swap");

/* CSS Variables for easy theming */
:root {
  --color-background: #222;
  --color-text: #eee;
  --color-primary: #60b347; /* Green for win */
  --color-secondary: #e74c3c; /* Red for lose */
  --border-style: 7px solid var(--color-text);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 62.5%;
}

body {
  font-family: "Press Start 2P", sans-serif;
  color: var(--color-text);
  background-color: var(--color-background);
  transition: background-color 0.5s ease; /* Smooth color transition */
}

/* Mobile First Layout 📱 */
header {
  /* position: relative; */
  padding: 2rem;
  border-bottom: var(--border-style);
  text-align: center;
}

h1 {
  font-size: 3rem;
  margin-bottom: 3rem;
}

.between {
  font-size: 1.4rem;
}

.again {
  position: absolute;
  bottom: 2rem;
  left: 30%;
  right: 30%;
  margin: 0 auto 0;
}

.number {
  background: var(--color-text);
  color: var(--color-background);
  font-size: 6rem;
  width: 15rem;
  padding: 3rem 0;
  text-align: center;
  position: relative; /* Changed from absolute for flow */
  margin: 2rem auto -5rem auto; /* Centers and overlaps the border */
  z-index: 10;
  transform: translateY(50%);
  transition: width 0.5s ease;
}

main {
  padding: 8rem 2rem 2rem 2rem; /* Add padding to account for overlapping number */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4rem;
}

.left,
.right {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.right {
  font-size: 1.8rem;
}

.guess {
  background: none;
  border: 4px solid var(--color-text);
  font-family: inherit;
  color: inherit;
  font-size: 4rem;
  padding: 2rem;
  width: 20rem;
  text-align: center;
  margin-bottom: 2rem;
}

.btn {
  border: none;
  background-color: var(--color-text);
  color: var(--color-background);
  font-size: 1.8rem;
  font-family: inherit;
  padding: 1.5rem 3rem;
  cursor: pointer;
  box-shadow: 0 4px #999;
  transition: all 0.1s ease-in-out;
}

.btn:hover {
  background-color: #ccc;
}

.btn:active {
  box-shadow: 0 2px #666;
  transform: translateY(2px);
}

.message {
  margin-bottom: 4rem;
  height: 3rem;
  font-size: 2rem;
}

.label-score,
.label-highscore {
  margin-bottom: 2rem;
}

/* Animations ✨ */
.win {
  animation: win-pulse 1s ease-in-out;
}

.shake {
  animation: shake-horizontal 0.5s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}

@keyframes win-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake-horizontal {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-10px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(10px);
  }
}

/* Desktop Responsive Layout 🖥️ */
@media (min-width: 768px) {
  h1 {
    font-size: 4rem;
  }

  main {
    flex-direction: row;
    justify-content: space-around;
    height: 65vh;
  }

  .left,
  .right {
    width: 45%;
  }

  .right {
    font-size: 2rem;
    text-align: left;
    align-items: flex-start;
  }
  header {
    position: relative;
  }
  .again {
    margin: 0;
    top: 2rem;
    left: 2rem;
    right: auto;
    bottom: auto;
  }
}
