/* Scrib Doon — Biddy Mode. The page is the world: no scroll, no zoom. */
:root {
  --bm-ink: #efe6d2;
  --bm-bg: #16040a;
  --bm-accent: #ffb000;
  --bm-card: #c9bba0;
  --bm-maroon: #5a1424;
  --bm-pixel: "VT323", "Courier New", monospace;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bm-bg); color: var(--bm-ink); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
.bm-world { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
.bm-css, .bm-gl { position: absolute !important; inset: 0; }
.bm-css { z-index: 0; pointer-events: none; }
.bm-gl { z-index: 1; cursor: grab; }
.bm-gl:active { cursor: grabbing; }

/* things that live in 3D as HTML */
.bm-screen { background: #000; }
.bm-screen iframe { width: 100%; height: 100%; border: 0; display: block; pointer-events: none; }
.bm-pic { background: #120609; overflow: hidden; }
.bm-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bm-pic--video::after { content: ""; position: absolute; left: 50%; top: 50%; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; background: rgba(0,0,0,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 7v10l8-5z'/%3E%3C/svg%3E") center/62px no-repeat; box-shadow: 0 0 0 4px rgba(255,255,255,.85); }
.bm-pic { position: relative; }

/* HUD */
.bm-hud { position: fixed; z-index: 5; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); pointer-events: none; }
.bm-hud__right { display: flex; gap: 8px; }
.bm-hud__btn { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; height: 44px; min-width: 44px; padding: 0 10px; border: 2px solid #000; background: var(--bm-card); color: #16040a; font: 22px/1 var(--bm-pixel); text-decoration: none; box-shadow: inset 2px 2px 0 #fff8e6, inset -2px -2px 0 #7d6c50; cursor: pointer; justify-content: center; }
.bm-hud__btn:visited { color: #16040a; }
.bm-hud__btn svg { width: 22px; height: 22px; }
.bm-hud__btn:focus-visible { outline: 3px solid var(--bm-accent); outline-offset: 2px; }
.bm-hud__btn[hidden] { display: none; }

/* the "use" prompt */
.bm-prompt { position: fixed; z-index: 4; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px); display: flex; align-items: center; gap: 10px; max-width: min(92vw, 560px); padding: 8px 16px 8px 8px; background: rgba(22,4,10,.86); border: 2px solid var(--bm-accent); color: var(--bm-ink); font: 22px/1.1 var(--bm-pixel); opacity: 0; transition: opacity .2s, transform .25s; pointer-events: none; }
.bm-prompt.is-on { opacity: 1; transform: translate(-50%, 0); }
.bm-ov .bm-prompt, .bm-ov .bm-bubble { opacity: 0; }
.bm-prompt b { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--bm-accent); color: #16040a; font: 24px/1 var(--bm-pixel); }
.bm-prompt span { white-space: nowrap; }
.bm-prompt em { font-style: normal; opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-prompt em::before { content: "· "; }

/* speech bubble over Biddy */
.bm-bubble { position: fixed; z-index: 4; transform: translate(-50%, calc(-100% - 10px)); max-width: 260px; padding: 8px 12px; background: #fff8e6; color: #16040a; border: 2px solid #000; border-radius: 14px; font: italic 900 17px/1.2 "Arial Black", Impact, sans-serif; text-align: center; opacity: 0; transition: opacity .15s; pointer-events: none; }
.bm-bubble::after { content: ""; position: absolute; left: 50%; bottom: -10px; margin-left: -8px; border: 8px solid transparent; border-top-color: #000; border-bottom: 0; }
.bm-bubble.is-on { opacity: 1; }

.bm-toast { position: fixed; z-index: 6; left: 50%; top: max(70px, calc(env(safe-area-inset-top) + 60px)); transform: translateX(-50%); padding: 8px 14px; background: var(--bm-card); color: #16040a; border: 2px solid #000; font: 21px/1.1 var(--bm-pixel); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
.bm-toast.is-on { opacity: 1; }

/* touch controls: shown on touch screens only */
.bm-stick, .bm-pad { display: none; }
.bm-touch .bm-pad { display: grid; position: fixed; z-index: 4; right: max(16px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); grid-template-columns: 64px 64px; grid-template-rows: 64px 64px; gap: 10px; }
.bm-pad button { width: 64px; height: 64px; border-radius: 50%; border: 3px solid #000; font: 30px/1 var(--bm-pixel); color: #16040a; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); touch-action: none; }
.bm-pad button.is-down { transform: scale(.92); box-shadow: inset 0 3px 0 rgba(0,0,0,.25); }
.bm-pad__a { grid-column: 2; grid-row: 2; background: var(--bm-accent); }
.bm-pad__b { grid-column: 2; grid-row: 1; background: #ff6a5a; }
.bm-pad__x { grid-column: 1; grid-row: 2; background: #7fc8ff; }
.bm-touch .bm-prompt { bottom: auto; top: max(68px, calc(env(safe-area-inset-top) + 58px)); transform: translate(-50%, -12px); }
.bm-touch .bm-prompt.is-on { transform: translate(-50%, 0); }
.bm-touch .bm-toast { top: max(122px, calc(env(safe-area-inset-top) + 112px)); }
.bm-touch .bm-stick { display: block; position: fixed; z-index: 4; left: 90px; top: calc(100% - 120px); width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid rgba(239,230,210,.45); background: rgba(22,4,10,.35); opacity: .55; pointer-events: none; transition: opacity .2s; }
.bm-touch .bm-stick.is-on { opacity: 1; }
.bm-stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: var(--bm-ink); border: 3px solid #000; }

/* start / help */
.bm-start { position: fixed; z-index: 8; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 120%, rgba(226,112,42,.55), transparent 60%), rgba(22,4,10,.9); overflow: auto; touch-action: pan-y; }
.bm-start[hidden] { display: none; }
.bm-start__box { width: min(860px, 100%); text-align: center; }
.bm-start__title { margin: 0 0 6px; padding: 0 .22em .06em .08em; font: italic 900 clamp(48px, 11vw, 112px)/.95 "Arial Black", Impact, sans-serif; background: linear-gradient(180deg, #fff 0%, #d9dde6 45%, #8a8f9c 52%, #f2f4f8 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #5a1424) drop-shadow(0 6px 0 #2a0911); }
.bm-start__lede { max-width: 58ch; margin: 10px auto 18px; font-size: 17px; line-height: 1.5; color: #e6d8bd; }
.bm-start__controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: left; }
.bm-start__controls > div { background: var(--bm-card); color: #16040a; border: 2px solid #000; padding: 10px 14px; box-shadow: 6px 6px 0 rgba(0,0,0,.4); }
.bm-start__controls h2 { margin: 0 0 6px; font: 26px/1 var(--bm-pixel); color: var(--bm-maroon); text-transform: uppercase; }
.bm-start__controls ul { margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.75; }
kbd { display: inline-block; min-width: 1.3em; padding: 0 5px; border: 1.5px solid #16040a; border-bottom-width: 3px; border-radius: 4px; background: #f4ecd9; font: 15px/1.25 var(--bm-pixel); text-align: center; }
.bm-touch .bm-start__controls > div:nth-child(-n+2) { display: none; }
.bm-touch .bm-start__controls { grid-template-columns: 1fr; max-width: 320px; margin: 0 auto; }
@media (max-width: 760px) { .bm-start__controls { grid-template-columns: 1fr; } }
.bm-load { position: relative; height: 26px; margin: 18px auto 0; max-width: 360px; border: 2px solid #000; background: #2a0911; overflow: hidden; }
.bm-load i { position: absolute; inset: 0 auto 0 0; width: 4%; background: var(--bm-accent); transition: width .2s; }
.bm-load span { position: relative; font: 20px/22px var(--bm-pixel); color: #fff; mix-blend-mode: difference; }
.bm-loaded .bm-load { display: none; }
.bm-start__go { margin-top: 18px; font-size: 30px; padding: 10px 40px; }
.bm-start__go:disabled { opacity: .5; }
.bm-start__note { margin: 12px 0 0; font-size: 14px; color: #c9b796; }

.bm-btn { display: inline-block; padding: 8px 22px; border: 2px solid #000; background: var(--bm-accent); color: #16040a; font: 24px/1.1 var(--bm-pixel); text-decoration: none; cursor: pointer; box-shadow: 4px 4px 0 #000; }
.bm-btn:visited { color: #16040a; }
.bm-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* up close */
.bm-overlay { position: fixed; z-index: 7; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(10,2,5,.82); touch-action: pan-y; }
.bm-overlay[hidden] { display: none; }
.bm-overlay__box { position: relative; max-width: min(960px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.bm-overlay__close { position: absolute; z-index: 2; right: 0; top: 0; width: 44px; height: 44px; border: 2px solid #000; background: var(--bm-card); color: #16040a; cursor: pointer; display: grid; place-items: center; }
.bm-overlay__close svg { width: 22px; height: 22px; }
.bm-piece { margin: 0; display: grid; justify-items: center; gap: 10px; padding-top: 52px; }
.bm-piece__img { max-width: 100%; max-height: 68vh; display: block; border: 3px solid #000; background: #120609; }
.bm-piece__video { height: min(68vh, 760px); max-width: 100%; background: #000; border: 3px solid #000; }
.bm-piece__video iframe { width: 100%; height: 100%; border: 0; display: block; }
.bm-piece figcaption { display: grid; gap: 4px; text-align: center; font-size: 15px; }
.bm-piece figcaption strong { font-size: 17px; }
.bm-piece figcaption a { color: var(--bm-accent); }
.bm-piece figcaption small { opacity: .6; font: 18px/1 var(--bm-pixel); }
.bm-overlay__nav { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }
.bm-overlay__nav button { min-width: 96px; height: 44px; border: 2px solid #000; background: var(--bm-card); color: #16040a; font: 22px/1 var(--bm-pixel); cursor: pointer; }
.bm-overlay__nav button:focus-visible, .bm-piece a:focus-visible { outline: 3px solid var(--bm-accent); outline-offset: 2px; }
.bm-card { width: min(560px, 92vw); margin-top: 52px; padding: 18px 20px 22px; background: var(--bm-card); color: #16040a; border: 2px solid #000; box-shadow: 8px 8px 0 rgba(0,0,0,.45); }
.bm-card h2 { margin: 0 0 8px; font: 700 24px/1.2 Georgia, serif; }
.bm-card p { margin: 0 0 14px; line-height: 1.5; }
.bm-card__type { font: 22px/1 var(--bm-pixel); color: var(--bm-maroon); text-transform: uppercase; }
.bm-notes { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 8px; max-height: 46vh; overflow: auto; }
.bm-notes li { background: #f4e7b8; padding: 8px 10px; border: 1.5px solid #16040a; }
.bm-notes q { display: block; font-style: italic; }
.bm-notes span { display: block; margin-top: 4px; font: 18px/1 var(--bm-pixel); color: var(--bm-maroon); }
.bm-noscript { position: fixed; inset: 0; display: grid; place-items: center; z-index: 9; background: var(--bm-bg); }
.bm-noscript a { color: var(--bm-accent); }
@media (prefers-reduced-motion: reduce) { .bm-prompt, .bm-toast, .bm-bubble { transition: none; } }

/* Film over the world: grain, a warm 70s grade with lifted blacks, a soft
   vignette. Compositor-only motion (transform steps) so phones keep up. */
.bm-film { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(ellipse 75% 70% at 50% 48%, transparent 55%, rgba(18,6,2,.55) 100%),
    linear-gradient(180deg, rgba(60,90,110,.07), rgba(255,150,60,.08)),
    rgba(52,28,14,.07); }
.bm-film__grain { position: absolute; inset: -100px; background-size: 256px 256px; opacity: .13; mix-blend-mode: overlay; animation: bm-grain .5s steps(6) infinite; will-change: transform; }
@keyframes bm-grain {
  0% { transform: translate(0, 0); } 17% { transform: translate(-37px, 21px); } 33% { transform: translate(52px, -44px); }
  50% { transform: translate(-18px, 63px); } 67% { transform: translate(71px, 12px); } 83% { transform: translate(-60px, -29px); } 100% { transform: translate(0, 0); }
}
.bm-touch .bm-film__grain { mix-blend-mode: normal; opacity: .07; }
@media (prefers-reduced-motion: reduce) { .bm-film__grain { animation: none; } }
