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

body {
  margin: 0;
  font-family: "Press Start 2P", cursive;
  font-size: clamp(1.2rem, 2.6vw, 2rem);
  color: white;
  overflow: hidden;
  touch-action: manipulation;
}
canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
}
button {
  outline: none;
  cursor: pointer;
  border: none;
  box-shadow: 3px 5px 0px 0px rgba(0, 0, 0, 0.75);
}
#counter {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 30;
}
#level {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  font-size: 0.5em;
  z-index: 30;
}
#settingsBar {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 38px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 30;
  font-size: 0.36em;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 10px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  backdrop-filter: blur(3px);
}
#settingsBar label {
  white-space: nowrap;
}
#settingsBar select {
  font-family: inherit;
  font-size: 1em;
  padding: 4px 6px;
}
#settingsBar .switchLabel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#settingsBar button {
  font-family: inherit;
  font-size: 1em;
  padding: 6px 10px;
  background: #ffe680;
  color: #111;
}
#assistBadge {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 96px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  font-size: 0.3em;
  color: #1f2b06;
  background: #d8f58d;
  border: 2px solid #8ca84b;
  border-radius: 999px;
  padding: 6px 12px;
  visibility: hidden;
}
#rotateHint {
  position: fixed;
  left: 50%;
  bottom: calc(max(140px, env(safe-area-inset-bottom) + 110px));
  transform: translateX(-50%);
  z-index: 20;
  font-size: 0.28em;
  color: #f3f3f3;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 10px;
  padding: 6px 10px;
  visibility: hidden;
}
#end {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  visibility: hidden;
  z-index: 45;
}
#pauseOverlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  visibility: hidden;
  z-index: 50;
}
#pausePanel {
  text-align: center;
  background: rgba(20, 20, 20, 0.9);
  border: 3px solid #ffffff;
  padding: clamp(16px, 3vw, 24px);
  min-width: min(340px, 90vw);
}
#pausePanel h2 {
  margin: 0 0 10px;
}
#pausePanel p {
  margin: 0;
  font-size: 0.42em;
}
#resumeBtn {
  margin-top: 18px;
  font-family: inherit;
  font-size: 0.55em;
  padding: 12px 24px;
  background: #9cf79b;
  color: #111;
}
#endPanel {
  text-align: center;
  background: rgba(20, 20, 20, 0.85);
  border: 3px solid white;
  padding: clamp(16px, 3vw, 24px);
  min-width: min(320px, 88vw);
}
#gameOverTitle {
  margin: 0 0 18px;
  color: #ff6565;
}
#end p {
  margin: 12px 0;
  font-size: 0.45em;
}
#end button {
  background-color: red;
  color: white;
  margin-top: 18px;
  padding: 16px 40px;
  font-family: inherit;
  font-size: 0.65em;
}
#controlls {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 25;
}
#controlls div {
  display: grid;
  grid-template-columns: 62px 62px 62px;
  grid-template-rows: auto auto;
  grid-column-gap: 12px;
  grid-row-gap: 12px;
  margin-bottom: max(16px, env(safe-area-inset-bottom));
}
#controlls button {
  width: 100%;
  min-height: 54px;
  background-color: white;
  border: 1px solid lightgray;
}
#controlls button:first-of-type {
  grid-column: 1/-1;
}

@media (max-width: 700px) {
  #level,
  #counter {
    font-size: 0.6em;
  }

  #settingsBar {
    top: calc(max(12px, env(safe-area-inset-top)) + 32px);
    gap: 8px;
    font-size: 0.32em;
    width: min(94vw, 620px);
    justify-content: center;
    flex-wrap: wrap;
  }

  #assistBadge {
    top: calc(max(12px, env(safe-area-inset-top)) + 110px);
  }

  #endPanel {
    min-width: 0;
    width: 85%;
    padding: 18px;
  }

  #controlls div {
    grid-template-columns: 54px 54px 54px;
    grid-column-gap: 10px;
    grid-row-gap: 10px;
  }
}

@media (max-width: 420px) {
  #level,
  #counter {
    font-size: 0.5em;
  }

  #end p {
    font-size: 0.42em;
  }

  #settingsBar {
    font-size: 0.3em;
  }

  #rotateHint {
    width: min(88vw, 320px);
    text-align: center;
    bottom: calc(max(170px, env(safe-area-inset-bottom) + 130px));
  }

  #controlls div {
    grid-template-columns: 48px 48px 48px;
  }

  #controlls button {
    min-height: 46px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  #settingsBar {
    top: calc(max(8px, env(safe-area-inset-top)) + 8px);
    gap: 6px;
    font-size: 0.27em;
    padding: 6px 8px;
  }

  #assistBadge {
    top: calc(max(8px, env(safe-area-inset-top)) + 56px);
    font-size: 0.24em;
  }

  #controlls div {
    grid-template-columns: 42px 42px 42px;
    grid-column-gap: 8px;
    grid-row-gap: 8px;
    margin-bottom: max(8px, env(safe-area-inset-bottom));
  }

  #controlls button {
    min-height: 36px;
  }

  #controlls svg {
    width: 20px;
    height: 20px;
  }
}
