/* After Bingo's page: the canvas at 16:9 as large as the window allows, centred, in Aart's bingo hall, the same in
   fullscreen (order 37a; 9:16 before), and a handheld held sideways fills its whole screen with it (6 Nov 2026). The
   hall (lobby.webp, from scripts/lobby-background.py) is as wide as a 16:9 canvas and centred on it, so the menus' own
   backdrop, its middle at 16:9, runs on into it above and below; a window taller than 4:3 shows it fading into a
   blurred, darker copy (lobby-fill.webp) past its top and bottom, and a window wider than 16:9 shows the copy alone at
   the sides. The olive is under both, and the canvas is clear until the game draws, so the loader stands in the hall.
   A handheld held upright sees the rotate guard over the game (#rotate). 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%;
  width: min(100%, calc(100vh * 16 / 9));
  aspect-ratio: 4 / 3;
  transform: translate(-50%, -50%);
  background: url("lobby.webp") center / cover;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent);
  pointer-events: none;
}

/* The menu's dark over the hall while a panel is open, so it stays one picture with the canvas. The canvas blends
   UiTheme.MenuDim's 0.55 in linear colour and CSS blends in sRGB, so 0.36 here draws what 0.55 draws there. */
#frame.dimmed {
  background: linear-gradient(rgba(27, 18, 11, 0.36), rgba(27, 18, 11, 0.36)), url("lobby-fill.webp") center / cover, var(--olive);
}

#frame.dimmed::before {
  background: linear-gradient(rgba(27, 18, 11, 0.36), rgba(27, 18, 11, 0.36)), url("lobby.webp") center / cover;
}

/* The game and the hall take the frame's width, not 100vw: a scrollbar that takes room (Windows) leaves the frame
   narrower than the viewport, and a canvas sized by the viewport shrank off 16:9 there. */
#game {
  position: relative;
  width: min(100%, calc(100vh * 16 / 9));
  aspect-ratio: 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(100%, calc(100dvh * 16 / 9));
  }

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

/* A handheld held sideways (#frame.handheld): the game fills the screen, so its controls stand at the screen's own edges
   as Brawl's do (6 Nov 2026, Aart). The camera's 9 tiles tall show as many across as the screen is wide (19.5 on
   19.5:9); with no band round the game, neither the fullscreen button nor the link to the text shows. */
@media (orientation: landscape) {
  #frame.handheld #game {
    width: 100%;
    height: 100%;
  }
}

#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-logo {
  width: 40%;
  width: min(40cqw, 640px);
  height: auto;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.3));
}

#loader-bar {
  width: 34%;
  width: min(34cqw, 544px);
  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;
  z-index: 2;
  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 rotate guard (order 37a): a handheld held upright (#frame.handheld, the game's own rule in index.html) sees the
   game small under a dim with the two hands holding a phone sideways and one line. The game runs on under it, the
   fullscreen button and the banner stay over it, and the media query takes it away the frame the window turns wider
   than tall. */
#rotate {
  display: none;
}

@media (orientation: portrait) {
  #frame.handheld #rotate {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 24px;
    background: rgba(27, 18, 11, 0.86);
    color: var(--cream);
  }
}

#rotate svg {
  display: block;
  width: min(60vw, 300px);
  height: auto;
}

#rotate p {
  margin: 0;
  font-size: 1.5em;
  font-weight: 800;
  text-align: center;
}

/* 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;
  z-index: 2;
  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;
}
