:root { color-scheme: dark; --ui: #c0c0c0; --ink: #111; --amber: #ffb454; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #050403; overflow: hidden; overscroll-behavior: none;
  font: 12px/1.3 "MS Sans Serif", Tahoma, Geneva, Verdana, sans-serif; color: #eee; }
#stage { position: fixed; inset: 0; background: #000; }
#css3d, #gl, #grain { position: absolute; inset: 0; width: 100%; height: 100%; }
#css3d { z-index: 1; overflow: hidden; }
#gl { z-index: 2; display: block; touch-action: none; outline: none; cursor: grab; }
#gl.dragging { cursor: grabbing; }
#gl.hot { cursor: pointer; }
#gl.pass { pointer-events: none; }
#grain { z-index: 3; pointer-events: none; mix-blend-mode: multiply;
  background: radial-gradient(ellipse at 50% 46%, rgba(255,255,255,1) 55%, rgba(120,100,90,1) 100%); opacity: .9; }
#fade { position: absolute; inset: 0; z-index: 4; background: #000; opacity: 0; pointer-events: none; transition: opacity .32s linear; }
#fade.on { opacity: 1; }
body.swimming #gl { cursor: crosshair; }
body.swimming #title, body.swimming #btn-reset { opacity: 0; pointer-events: none; }
.crt-carrier { position: relative; overflow: hidden; background: #000; }
.crt-mount { width: 640px; height: 480px; position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; background: #000; outline: none; }
.crt-fallback { position: absolute; inset: 0; display: grid; place-items: center; background: #008080; color: #fff; font-size: 16px; }

#title { position: fixed; left: 20px; top: 16px; z-index: 5; pointer-events: none; text-shadow: 0 1px 6px rgba(0,0,0,.8); transition: opacity .5s; }
#title h1 { margin: 0; font: 400 26px/1 Georgia, "Times New Roman", serif; letter-spacing: .14em; text-transform: uppercase; color: #f3e6cf; }
#title p { margin: 6px 0 0; font-size: 12px; color: #d9c8a8; opacity: .85; }
body.focus #title { opacity: 0; }

#btn-reset, #btn-back, #btn-clear { font: inherit; color: var(--ink); background: var(--ui); padding: 4px 9px; min-height: 24px; cursor: pointer;
  border: 2px solid; border-color: #fff #404040 #404040 #fff; box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf; }
#btn-reset:active, #btn-back:active, #btn-clear:active { border-color: #404040 #fff #fff #404040; box-shadow: inset 1px 1px 0 #808080; }
#btn-reset:focus-visible, #btn-back:focus-visible, #btn-clear:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
#btn-reset { position: fixed; right: 14px; bottom: 14px; z-index: 5; opacity: .82; transition: opacity .3s; }
#btn-reset:hover { opacity: 1; }
body.focus #btn-reset, body.writing #btn-reset, body.writing #title { opacity: 0; pointer-events: none; }
#btn-clear { position: fixed; right: 14px; bottom: 14px; z-index: 6; }
body.writing #gl { cursor: crosshair; }
#btn-back { font: inherit; color: var(--ink); background: var(--ui); padding: 5px 10px; min-height: 26px; cursor: pointer;
  border: 2px solid; border-color: #fff #404040 #404040 #fff; box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf; }
#panel button:active, #panel button[aria-pressed="true"] { border-color: #404040 #fff #fff #404040; box-shadow: inset 1px 1px 0 #808080;
  background: repeating-conic-gradient(#c0c0c0 0% 25%, #d8d8d8 0% 50%) 0 0 / 2px 2px; }
#panel button:focus-visible, #btn-back:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
#panel .slider { display: flex; align-items: center; gap: 6px; color: var(--ink); padding: 0 6px; }
#panel input[type=range] { width: 96px; accent-color: #000080; }
#btn-back { position: fixed; left: 16px; top: 16px; z-index: 6; }
#btn-back kbd { font: inherit; border: 1px solid #808080; padding: 0 3px; margin-left: 4px; }
#tip { position: fixed; z-index: 7; pointer-events: none; max-width: 230px; padding: 3px 7px 4px; background: #ffffe1; color: #000;
  border: 1px solid #000; box-shadow: 2px 2px 0 rgba(0,0,0,.35); transform: translate(14px, 18px); line-height: 1.3; }
#tip.flip-x { transform: translate(calc(-100% - 12px), 18px); }
#tip.flip-y { transform: translate(14px, calc(-100% - 12px)); }
#tip.flip-x.flip-y { transform: translate(calc(-100% - 12px), calc(-100% - 12px)); }
#tip b { display: block; font-weight: bold; white-space: nowrap; }
#tip span { display: block; }
#tip i { display: block; color: #555; font-size: 11px; }
#tip.note span { font: 15px/1.25 "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive; }

#loader { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #050403; transition: opacity .9s ease; }
#loader.done { opacity: 0; pointer-events: none; }
#loader .box { width: min(320px, 80vw); text-align: center; }
#loader .name { font: 400 22px/1 Georgia, serif; letter-spacing: .2em; text-transform: uppercase; color: #f3e6cf; margin-bottom: 18px; }
#loader .bar { height: 14px; padding: 2px; background: #000; border: 2px solid; border-color: #404040 #fff #fff #404040; }
#loader .bar i { display: block; height: 100%; width: 0%; background: repeating-linear-gradient(90deg, var(--amber) 0 8px, transparent 8px 10px); }
#loader .msg { margin-top: 10px; color: #b9a88a; min-height: 1.3em; }
#loader.error .msg { color: #ff8a70; }
@media (max-width: 640px) {
  #title h1 { font-size: 18px; } #title p { font-size: 11px; max-width: 70vw; }
}
@media (prefers-reduced-motion: reduce) { #loader, #btn-reset, #title { transition: none; } }

