html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #071128;
  color: #fff;
  font: 600 1rem system-ui, sans-serif;
}

main {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

#game-stage {
  container-type: size;
  position: relative;
  overflow: hidden;
}

canvas {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  min-width: 0;
  outline: none;
  touch-action: none;
}

@media (pointer: coarse) and (orientation: portrait) {
  canvas {
    width: min(100%, 56.25cqh);
    height: min(100%, 177.778cqw);
    max-height: 100%;
  }
}

#game-menu {
  grid-row: 2;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 4px max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom));
  background: #131f3c;
}

#game-menu[hidden],
.gamemonetize-ad-active #game-menu {
  visibility: hidden;
  pointer-events: none;
}

#game-menu[hidden] {
  display: none;
}

#game-menu button,
#pause-menu button,
.more-games {
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid #6885be;
  border-radius: 8px;
  background: #243759;
  color: #fff;
  text-align: center;
  font: inherit;
  font-size: .85rem;
  text-decoration: none;
  cursor: pointer;
}

.more-games {
  border-color: #ffcf55;
  background: linear-gradient(110deg, #ffb11c, #ffe078);
  color: #291900;
  font-weight: 800;
}

#settings-more-games {
  position: absolute;
  top: 73%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

#settings-more-games[hidden],
.gamemonetize-ad-active #settings-more-games {
  display: none;
}

@media (pointer: coarse) {
  #game-menu button, #pause-menu button, .more-games { min-height: 44px; }
}

#pause-menu {
  width: min(290px, 80vw);
  border: 1px solid #6885be;
  border-radius: 16px;
  padding: 18px;
  color: #fff;
  background: #131f3c;
  text-align: center;
}

#pause-menu::backdrop { background: #050b1bbf; }
#pause-menu h2 { margin: 0 0 14px; }
#pause-menu form { display: grid; gap: 8px; }

#reward-ad-status {
  position: fixed;
  z-index: 10;
  inset: max(8px, env(safe-area-inset-top)) 0 auto;
  width: max-content;
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  margin-inline: auto;
  padding: 8px 14px;
  border: 1px solid #6885be;
  border-radius: 8px;
  background: #131f3c;
  color: #fff;
  font-size: .875rem;
  text-align: center;
  pointer-events: none;
}

#reward-ad-status:empty { opacity: 0; }

@media (max-width: 480px) {
  #reward-ad-status { max-width: calc(100% - 112px); }
}
