/* The canvas page's styles: linked by shell.html (dev) and by web's /play view. */
html, body { margin: 0; height: 100%; background: #111; overflow: hidden; }
/* No border and no padding: mouse coordinates are canvas pixels. */
#canvas { display: block; background: #000; touch-action: none; }
/* Loading screen (#pbr-status): full-page overlay until the login window is up.
   pbr-shell.js fills it (brand ball, step, real MB bar, steps, error with retry).
   Pure CSS, no image: the only request it may make is the site logo. */
#pbr-status {
  --ld-bg: #f6f3fb; --ld-glow: #e4dcf8; --ld-card: #ffffff; --ld-ink: #1c1233; --ld-soft: #4a4263;
  --ld-line: #d9d1ec; --ld-track: #e6e0f5; --ld-accent: #ff6b6b; --ld-accent2: #ffa500;
  --ld-gold: #ffcb05; --ld-link: #4a1fa8; --ld-error: #b3261e;
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  padding: 16px; color: var(--ld-ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(120% 90% at 50% 0%, var(--ld-glow) 0%, var(--ld-bg) 62%);
  opacity: 1; transition: opacity .5s ease; touch-action: none;
}
@media (prefers-color-scheme: dark) {
  #pbr-status {
    --ld-bg: #0e063d; --ld-glow: #224578; --ld-card: rgba(23, 12, 79, .86); --ld-ink: #f0f4ff; --ld-soft: #b9c2dd;
    --ld-line: rgba(255, 255, 255, .14); --ld-track: rgba(255, 255, 255, .13); --ld-link: #ffd700; --ld-error: #ff9a93;
  }
  #pbr-status .ld-logo { background: none; padding: 0; }
}
#pbr-status.done { opacity: 0; pointer-events: none; }
#pbr-status[hidden] { display: none; }
#pbr-status .ld-card {
  width: min(92vw, 26rem); box-sizing: border-box; padding: 24px 24px 20px; text-align: center;
  background: var(--ld-card); border: 1px solid var(--ld-line); border-radius: 20px;
  box-shadow: 0 18px 44px rgba(10, 4, 36, .28);
}
/* The logo is white: on the light card it sits on the brand navy. */
#pbr-status .ld-logo { display: block; margin: 0 auto 14px; height: 22px; width: auto; max-width: 70%; background: #0f224a; padding: 6px 12px; border-radius: 10px; box-sizing: content-box; }
#pbr-status .ld-ball {
  position: relative; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px solid #1c1233; box-sizing: border-box; overflow: hidden;
  background: linear-gradient(180deg, var(--ld-accent) 0 47%, #1c1233 47% 53%, #fff 53% 100%);
  animation: ld-spin 1.4s cubic-bezier(.5, .1, .5, .9) infinite;
}
#pbr-status .ld-ball::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: var(--ld-gold); border: 3px solid #1c1233; box-sizing: border-box;
}
#pbr-status.error .ld-ball { animation: none; filter: grayscale(1); opacity: .6; }
@keyframes ld-spin { to { transform: rotate(360deg); } }
#pbr-status .ld-title { margin: 0 0 12px; font-size: 1.15rem; font-weight: 700; }
#pbr-status .ld-bar { height: 10px; border-radius: 999px; overflow: hidden; background: var(--ld-track); }
#pbr-status .ld-fill {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--ld-accent), var(--ld-accent2)); transition: width .3s ease-out;
}
#pbr-status .ld-meter { margin: 8px 0 0; display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; color: var(--ld-soft); font-variant-numeric: tabular-nums; }
#pbr-status .ld-steps { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; font-size: .9rem; }
#pbr-status .ld-steps li { position: relative; padding: 3px 0 3px 26px; color: var(--ld-soft); }
#pbr-status .ld-steps li::before {
  content: ""; position: absolute; left: 3px; top: 8px; width: 12px; height: 12px; box-sizing: border-box;
  border-radius: 50%; border: 2px solid var(--ld-line);
}
#pbr-status .ld-steps li.active { color: var(--ld-ink); font-weight: 600; }
#pbr-status .ld-steps li.active::before { border-color: var(--ld-accent); background: radial-gradient(circle, var(--ld-accent) 0 35%, transparent 40%); }
#pbr-status .ld-steps li.done::before { border-color: var(--ld-accent2); background: var(--ld-accent2); }
#pbr-status .ld-hint { margin: 12px 0 0; min-height: 1.3em; font-size: .8rem; color: var(--ld-soft); }
#pbr-status .ld-err { margin: 0; }
#pbr-status .ld-err p { margin: 0 0 8px; }
#pbr-status .ld-err .ld-errtitle { color: var(--ld-error); font-weight: 700; font-size: 1.05rem; }
#pbr-status .ld-err code { display: block; margin: 0 0 14px; font: .75rem/1.3 ui-monospace, Menlo, Consolas, monospace; color: var(--ld-soft); word-break: break-word; }
#pbr-status .ld-retry {
  appearance: none; border: 0; cursor: pointer; padding: 12px 28px; border-radius: 999px; font: 700 1rem system-ui, sans-serif;
  color: #fff; background: linear-gradient(45deg, var(--ld-accent), var(--ld-accent2)); box-shadow: 0 8px 22px rgba(255, 107, 107, .35);
}
#pbr-status .ld-retry:focus-visible { outline: 3px solid var(--ld-gold); outline-offset: 3px; }
#pbr-status [hidden] { display: none; }
/* A phone on its side is short: drop the decoration, keep bar and step. */
@media (max-height: 460px) {
  #pbr-status .ld-card { display: grid; grid-template-columns: auto 1fr; column-gap: 18px; align-items: center; text-align: left; width: min(94vw, 38rem); padding: 14px 18px; }
  #pbr-status .ld-side { grid-row: 1 / span 6; text-align: center; }
  #pbr-status .ld-side .ld-logo { margin: 8px auto 0; }
  #pbr-status .ld-ball { margin: 0 auto; }
  #pbr-status .ld-title { margin-bottom: 8px; font-size: 1rem; }
  #pbr-status .ld-steps { margin-top: 8px; font-size: .82rem; }
  #pbr-status .ld-hint { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #pbr-status { transition: none; }
  #pbr-status .ld-ball { animation: none; }
  #pbr-status .ld-fill { transition: none; }
}
#pbr-fatal {
  display: none; position: absolute; left: 16px; right: 16px; bottom: 16px;
  padding: 12px; background: #3a1010; color: #fff; font: 14px/1.4 sans-serif;
  white-space: pre-wrap; z-index: 7;
}
/* The phone keyboard's real <input> (see pbr-shell.js). It sits inside the visible
   page, 16 px so iOS does not zoom, and invisible: off-screen it makes iOS scroll the
   page to it. It takes no touches: the canvas does. */
#pbr-text-editor {
  position: fixed; left: 0; top: 8px; width: 2px; height: 2px; margin: 0; padding: 0; border: 0;
  font: 16px sans-serif; color: transparent; caret-color: transparent; background: transparent;
  opacity: 0; pointer-events: none; z-index: 1;
}
/* A phone: the page is exactly the screen and never scrolls, rubber-bands or selects;
   the canvas is placed by pbr-shell.js inside the safe areas. */
html.pbr-phone, html.pbr-phone body {
  position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
html.pbr-phone #canvas { position: fixed; outline: none; }
/* Shown only while a phone is upright. No orientation lock: several
   browsers ignore it, and a desktop window must stay as the user sized it. */
#pbr-rotate {
  display: none; position: absolute; inset: 0; z-index: 6;
  background: rgba(0, 0, 0, 0.78); color: #fff;
  align-items: center; justify-content: center; text-align: center;
  padding: 24px; font: 20px/1.4 sans-serif;
}
#pbr-rotate.show { display: flex; }
/* The install invitation (pbr-shell.js): a small pill at the top, over the login and
   character screens only. Nothing on a desktop, in an installed app or after it was closed. */
#pbr-install {
  position: fixed; z-index: 8; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 8px); max-width: min(92vw, 34rem);
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; box-sizing: border-box;
  background: rgba(14, 6, 61, .92); color: #f0f4ff; border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px;
  font: 13px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
#pbr-install[hidden] { display: none; }
#pbr-install .in-go {
  appearance: none; border: 0; cursor: pointer; padding: 7px 14px; border-radius: 999px; font: 700 13px system-ui, sans-serif;
  color: #1c1233; background: #ffcb05; white-space: nowrap;
}
#pbr-install .in-x {
  appearance: none; border: 0; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; font: 18px/1 system-ui, sans-serif;
  color: #f0f4ff; background: rgba(255, 255, 255, .12);
}
