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

body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: white;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #172712;
  touch-action: none;
  user-select: none;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

button {
  outline: none;
  cursor: pointer;
  border: none;
  box-shadow: 3px 5px 0px 0px rgba(0, 0, 0, 0.75);
  touch-action: manipulation;
}

#score {
  position: absolute;
  font-family: "Press Start 2P", cursive;
  font-size: 0.9em;
  color: white;
  transform: translate(-50%, -50%);
  opacity: 0.9;
  max-width: 100px;
  text-align: center;
  line-height: 1.6em;
}

#controls {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: max(20px, env(safe-area-inset-left));
  z-index: 40;
  display: none;
  align-items: flex-end;
}

#controls #buttons {
  width: 86px;
  opacity: 0;
  transition: opacity 2s;
}

#controls #instructions {
  margin-left: 16px;
  max-width: min(320px, calc(100vw - 150px));
  background-color: rgba(0, 0, 0, 0.2);
  padding: 16px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 2s;
  line-height: 1.45;
}

#controls button {
  width: 100%;
  min-height: 52px;
  background-color: white;
  border: 1px solid black;
  margin-bottom: 10px;
}

#sound-toggle {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 45;
  min-width: 104px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.64);
  color: white;
  font-weight: 700;
  box-shadow: none;
  backdrop-filter: blur(8px);
}

#results {
  position: absolute;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background-color: rgba(20, 20, 20, 0.75);
  display: none;
  z-index: 51;
}

#results .content {
  width: min(560px, calc(100vw - 32px));
  max-width: 560px;
  padding: clamp(24px, 7vw, 50px);
  border-radius: 8px;
}

#results h1 {
  margin: 0 0 22px;
  font-size: clamp(2rem, 8vw, 3.8rem);
  line-height: 1.05;
}

#results p {
  margin: 0;
  font-size: clamp(1rem, 4.2vw, 1.6rem);
  line-height: 1.35;
}

@media (min-height: 425px) {
  #score {
    font-size: 1.5em;
    max-width: 150px;
  }

  #controls {
    display: flex;
  }
}

@media (max-width: 720px) {
  #score {
    font-size: clamp(0.85rem, 4vw, 1.25rem);
    max-width: 130px;
  }

  #controls {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    left: max(16px, env(safe-area-inset-left));
    justify-content: center;
    align-items: center;
  }

  #controls #buttons {
    display: flex;
    width: auto;
    gap: 14px;
  }

  #controls button {
    width: 76px;
    min-height: 64px;
    margin-bottom: 0;
  }

  #controls #instructions {
    position: absolute;
    bottom: 82px;
    left: 50%;
    width: min(360px, calc(100vw - 32px));
    max-width: none;
    margin-left: 0;
    padding: 12px 14px;
    transform: translateX(-50%);
    text-align: center;
    font-size: 0.92rem;
  }

  #sound-toggle {
    min-width: 92px;
    min-height: 40px;
    font-size: 0.9rem;
  }
}

@media (min-width: 721px) and (max-width: 1180px) {
  #controls {
    bottom: max(28px, env(safe-area-inset-bottom));
    left: max(28px, env(safe-area-inset-left));
  }

  #controls #buttons {
    width: 100px;
  }

  #controls button {
    min-height: 60px;
  }

  #controls #instructions {
    max-width: 360px;
    font-size: 1.05rem;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  #controls #instructions {
    display: none;
  }

  #results .content {
    padding: 22px;
  }
}
