.fullscreenButton {
  position: fixed;
  z-index: 50;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 8px);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 2px;
  width: 52px;
  min-height: 48px;
  padding: 5px 2px;
  color: var(--game-ivory);
  border: 1px solid var(--game-cyan-line);
  border-radius: 12px;
  background: var(--glass-bg-strong);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.fullscreenButton svg { width: 21px; height: 21px; }
.fullscreenButton span { font: 700 8px/1.15 var(--utility); text-align: center; }
.fullscreenExit { display: none; }
.fullscreenButton[aria-pressed="true"] .fullscreenEnter { display: none; }
.fullscreenButton[aria-pressed="true"] .fullscreenExit { display: block; }
.fullscreenButton:hover, .fullscreenButton:focus-visible { border-color: var(--game-gold-light); }
.fullscreenButton:focus-visible, .fullscreenHelp button:focus-visible { outline: 2px solid var(--game-gold-light); outline-offset: 3px; }

.has-fullscreen-button .topbar { right: calc(env(safe-area-inset-right, 0px) + 68px); }

/* Keep navigation and the new control at opposite corners throughout a run. */
.has-fullscreen-button:has(.app.mobile-run-active) .backToOverview {
  right: auto;
  left: calc(env(safe-area-inset-left, 0px) + 10px);
}

.has-fullscreen-button .app.mobile-run-active .runBalance {
  right: calc(env(safe-area-inset-right, 0px) + 68px);
}

@media (max-width: 1023px) {
  .has-fullscreen-button .brand { display: none; }
}

/* Keep all header controls in reach on narrow phones, including the balance. */
@media (max-width: 600px) and (orientation: portrait) {
  .has-fullscreen-button .accountCluster {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px 48px;
    gap: 4px;
  }
  .has-fullscreen-button .accountCluster > .wallet {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    margin: 0;
    padding: 4px 8px;
  }
  .has-fullscreen-button .wallet strong { font-size: 14px; overflow-wrap: anywhere; }
  .has-fullscreen-button .audioControl { grid-column: 2; grid-row: 1; }
  .has-fullscreen-button .gameUtilityMenu { grid-column: 3; grid-row: 1; }
}

html:fullscreen { width: 100%; height: 100%; background: var(--game-bg); }
html:-webkit-full-screen { width: 100%; height: 100%; background: var(--game-bg); }

.fullscreenHelp {
  width: min(400px, calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 32px));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
  overflow: auto;
  padding: 22px;
  color: var(--game-ivory);
  border: 1px solid var(--game-cyan-line);
  border-radius: 18px;
  background: #101b26;
  box-shadow: 0 16px 60px #0009;
}

.fullscreenHelp::backdrop { background: #030810bd; }
.fullscreenHelp h2 { margin: 0 0 12px; font: 700 24px/1.15 var(--display); }
.fullscreenHelp p { margin: 12px 0; font-size: 14px; line-height: 1.5; }
.fullscreenHelp button {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 10px;
  color: #111b24;
  border: 0;
  border-radius: 10px;
  background: var(--gold-gradient);
  font-weight: 700;
}

@media (orientation: landscape) and (max-height: 500px) {
  .fullscreenHelp { width: min(600px, calc(100% - 100px)); padding: 14px 20px; }
  .fullscreenHelp h2 { font-size: 20px; }
  .fullscreenHelp p { margin: 8px 0; font-size: 13px; }
}
