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

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

html {
  font-size: 62.5%; /* 1rem = 10px */
  -webkit-text-size-adjust: 100%; /* Prevent iOS auto-zoom */
}

body {
  font-family: 'Press Start 2P', sans-serif;
  color: #eee;
  background-color: #222;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* LAYOUT */
header {
  position: relative;
  height: 35vh;
  min-height: 180px;
  border-bottom: 7px solid #eee;
  padding: 1rem;
}

main {
  height: 65vh;
  min-height: 300px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
  gap: 2rem;
  padding: 2rem 1rem;
}

/* SECTIONS */
.left, .right {
  flex: 1;
  min-width: 280px;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* TYPOGRAPHY & ELEMENTS */
h1 {
  font-size: clamp(2.8rem, 8vw, 4rem);
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  line-height: 1.3;
}

.number {
  background: #eee;
  color: #333;
  font-size: clamp(5rem, 12vw, 6rem);
  width: 15rem;
  max-width: 30vw;
  padding: 2rem 0;
  text-align: center;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 50%);
  border-radius: 1rem;
  transition: all 0.4s ease;
}

.between {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  position: absolute;
  top: 1.5rem;
  right: 1rem;
  white-space: nowrap;
  background: rgba(0,0,0,0.3);
  padding: 0.4rem 0.8rem;
  border-radius: 0.6rem;
}

.again {
  position: absolute;
  top: 1.5rem;
  left: 1rem;
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  padding: 0.8rem 1.2rem;
  white-space: nowrap;
}

.guess {
  background: none;
  border: 4px solid #eee;
  font-family: inherit;
  color: inherit;
  font-size: clamp(3.5rem, 10vw, 5rem);
  padding: 1.8rem;
  width: 80%;
  max-width: 25rem;
  text-align: center;
  margin-bottom: 2rem;
  border-radius: 1rem;
}

.btn {
  border: none;
  background-color: #eee;
  color: #222;
  font-family: inherit;
  font-size: clamp(1.6rem, 4.5vw, 2rem);
  padding: 1.5rem 2.5rem;
  cursor: pointer;
  border-radius: 1rem;
  transition: background 0.2s;
  min-height: 44px; /* iOS touch target */
}

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

.message {
  margin-bottom: 4rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
  text-align: center;
  line-height: 1.5;
  min-height: 3rem;
}

.label-score,
.label-highscore {
  font-size: clamp(1.4rem, 4vw, 2rem);
  margin-bottom: 1rem;
}

/* WIN STATE */
body.win {
  background-color: #60b347;
}

/* RESPONSIVE BREAKPOINTS */
@media (max-width: 480px) {
  header { height: 28vh; }
  main { height: 72vh; padding: 1rem; }

  .between { top: 1rem; right: 0.5rem; font-size: 1rem; }
  .again { top: 1rem; left: 0.5rem; font-size: 1.1rem; padding: 0.6rem 1rem; }

  .number { width: 12rem; font-size: 4.5rem; }
}

@media (max-width: 360px) {
  .guess { width: 90%; font-size: 3.2rem; }
  .btn { padding: 1.2rem 2rem; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  header { height: 40vh; }
  main { height: 60vh; }
  .number { transform: translate(-50%, 30%); }
}