/* After Bingo's page: the canvas at 9:16 as large as the window allows, centred, in Aart's bingo hall, the same in
   fullscreen. The hall (lobby.webp, from scripts/lobby-background.py) is as tall as the canvas and centred on it, so the
   menus' own backdrop, its middle at 9:16, runs on into it; a window wider than 4:3 shows it fading into a blurred,
   darker copy (lobby-fill.webp) past its sides. The olive is under both, and the canvas is clear until the game draws,
   so the loader stands in the hall. The game fills the first viewport; the page scrolls past it to a text about the game
   (#about), for a reader and for a search engine, which reads no canvas. The colours are UiTheme's: Backdrop, Forward,
   Panel, Ink, Outline. */
:root {
  --olive: #3f4a26;
  --mustard: #f2b630;
  --cream: #fff3d9;
  --ink: #241810;
  --outline: #1b120b;
}

html,
body {
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
  background: var(--olive);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

#frame {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  scroll-margin-top: 0;
  background: var(--olive) url("lobby-fill.webp") center / cover;
}

#frame::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  height: min(100vh, calc(100vw * 16 / 9));
  aspect-ratio: 4 / 3;
  transform: translate(-50%, -50%);
  background: url("lobby.webp") center / cover;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 10%, #000 90%, transparent);
  pointer-events: none;
}

#game {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  container-type: inline-size;
}

/* A phone's address bar comes and goes: the dynamic viewport is the part that shows. */
@supports (height: 100dvh) {
  #frame {
    height: 100dvh;
  }

  #game {
    width: min(100dvw, calc(100dvh * 9 / 16));
    height: min(100dvh, calc(100dvw * 16 / 9));
  }

  #frame::before {
    height: min(100dvh, calc(100dvw * 16 / 9));
  }
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  outline: none;
  touch-action: none;
}

#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

#loader[hidden] {
  display: none;
}

#loader-name {
  color: var(--cream);
  font-size: 32px;
  font-size: clamp(22px, 9cqw, 48px);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 var(--outline);
}

#loader-bar {
  width: 60%;
  height: 22px;
  box-sizing: border-box;
  border: 3px solid var(--outline);
  border-radius: 8px;
  background: var(--cream);
  overflow: hidden;
}

#loader-fill {
  width: 0;
  height: 100%;
  background: var(--mustard);
  transition: width 0.2s ease-out;
}

#loader-message {
  max-width: 80%;
  min-height: 1.4em;
  color: var(--cream);
  font-size: 15px;
  text-align: center;
}

#fullscreen {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  padding: 9px;
  border: 3px solid var(--outline);
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#fullscreen.awake {
  opacity: 1;
  pointer-events: auto;
}

#fullscreen[hidden] {
  display: none;
}

#fullscreen svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#fullscreen .leave,
#fullscreen.on .enter {
  display: none;
}

#fullscreen.on .leave {
  display: inline;
}

/* The link to the text and the way back, in the fullscreen button's look */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  box-sizing: border-box;
  padding: 0 12px 0 18px;
  border: 3px solid var(--outline);
  border-radius: 22px;
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.pill svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#about-link {
  position: absolute;
}

#about-link[hidden] {
  display: none;
}

#about-link.compact {
  width: 44px;
  padding: 0;
  justify-content: center;
}

#about-link.compact span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

#about {
  padding: 40px 16px 56px;
  user-select: text;
  -webkit-touch-callout: default;
}

#about .card {
  max-width: 36em;
  margin: 0 auto;
  padding: 24px 22px;
  border: 3px solid var(--outline);
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
}

#about h1 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.2;
}

#about h2 {
  margin: 28px 0 8px;
  font-size: 21px;
  line-height: 1.25;
}

#about p {
  margin: 0 0 12px;
}

#about p a {
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

#about .more {
  margin-top: 24px;
}

#about .back {
  margin-top: 8px;
}

#banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(90vw, 480px);
}

#banner div {
  padding: 8px 14px;
  border: 3px solid var(--outline);
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink);
  font-size: 14px;
}

#banner .error {
  background: #d4553a;
  color: #fff;
}
