@font-face {
  font-family: "VT323";
  src: url(fonts/VT323.woff2) format("woff2");
  font-display: block;
}

:root {
  --teal: #008080;
  --sticky: #ffff80;
  --void: #140c1c;
  --scab: #3a0010;
  --blood: #6b0f1a;
  --wound: #a4243b;
  --bone: #e8d9c0;
  --wren-light: #c00000;
  --wren-dark: #ff5555;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: #222; }
body { font-family: "Pixelated MS Sans Serif", Arial, sans-serif; font-size: 11px; overflow: hidden; }
img, canvas { image-rendering: pixelated; }
.vt { font-family: "VT323", monospace; }
.small { font-size: 11px; }
.error { color: var(--wren-light); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* Page-level screens (boot, pause, end): normal resolution, scrollable. */
.page { position: fixed; inset: 0; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 24px 12px; background: #000; z-index: 50; }
.page.overlay { background: rgba(0, 0, 0, 0.82); }
.boot-window { width: min(620px, 100%); }
.boot-window .window-body { font-size: 12px; line-height: 1.45; }
.boot-head { display: flex; gap: 12px; align-items: center; }
.boot-top { font-size: 20px; margin: 0; }
.boot-title { font-size: 40px; margin: 8px 0 0; letter-spacing: 1px; }
.boot-tag { font-size: 20px; margin: 0 0 12px; }
.boot-window fieldset { margin: 10px 0; }
.boot-window ul { margin: 4px 0 0 18px; padding: 0; }
.consent-row { margin: 8px 0 12px; }
.consent-row p { margin: 4px 0; }
.status { margin-left: 8px; font-weight: 700; }
.status.on { color: #006400; }
.boot-name { margin-top: 12px; }
.boot-name input { width: 180px; }

/* The stage: a 512x384 logical screen, scaled by JS, letterboxed on black. */
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#screen { position: relative; width: 512px; height: 384px; background: var(--teal); overflow: hidden; transform-origin: center; }
#screen.possessed { background: var(--blood); }

#icons { position: absolute; left: 4px; top: 6px; bottom: 30px; width: 64px; }
.icon { position: absolute; left: -2px; width: 70px; display: flex; flex-direction: column; align-items: center; cursor: default; padding: 2px; outline: none; }
.icon .label { color: #fff; font-size: 11px; letter-spacing: -0.5px; white-space: nowrap; margin-top: 2px; padding: 0 1px; text-align: center; }
.icon:focus .label, .icon.selected .label { background: navy; outline: 1px dotted #fff; }
#icon-pal { top: 0; } #icon-wren { top: 58px; } #icon-claims { top: 116px; } #icon-note { top: 174px; } #icon-bin { top: 290px; }
.glyph { width: 32px; height: 32px; position: relative; background: center / 32px 32px no-repeat; image-rendering: pixelated; }
.g-pal { background-image: url(img/pal.svg); }
.cracked .g-pal { background-image: url(img/pal-cracked.svg); }
.g-folder { background-image: url(img/folder.svg); }
.g-file { background-image: url(img/file.svg); }
.g-wren { background-image: url(img/wren-file.svg); }
.g-bin { background-image: url(img/bin.svg); }
.full .g-bin { background-image: url(img/bin-full.svg); }
@keyframes appear { 0% { opacity: 0; } 30% { opacity: 1; } 45% { opacity: 0.2; } 60%, 100% { opacity: 1; } }
.icon.appear:not([hidden]) { animation: appear 1.2s steps(6) 1; }
.calm .icon.appear { animation: none; }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }
.icon.pulse .glyph { animation: bob 0.6s steps(2) 6; }
.icon.pulse .label { background: #c00000; outline: 1px dotted #fff; }
.calm .icon.pulse .glyph { animation: none; }
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 28; pointer-events: none; opacity: 0; transform: scaleX(-1);
  filter: grayscale(1) contrast(1.5) brightness(0.8) sepia(1) hue-rotate(-50deg) saturate(3); mix-blend-mode: screen; transition: opacity 1.2s steps(6); }
.win .title-bar { cursor: move; touch-action: none; }
.drop-target .g-bin { outline: 2px dotted #fff; }
.icon.binned { display: none; }

@keyframes shake { 0%, 100% { translate: 0; } 25% { translate: -2px 0; } 75% { translate: 2px 0; } }
.shake { animation: shake 0.4s steps(4) 1; }
.calm .shake { animation: none; }

#sticky { position: absolute; right: 6px; top: 6px; width: 118px; background: var(--sticky); padding: 6px; font-family: "VT323", monospace; font-size: 15px; line-height: 14px; color: #222; box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35); }
#sticky p { margin: 0 0 6px; }
#sticky ul { list-style: none; margin: 0; padding: 0; }
#sticky li::before { content: "[ ] "; }
#sticky li.done { text-decoration: line-through; }
#sticky li.done::before { content: "[x] "; }

.win { position: absolute; }
.win { z-index: 2; }
.win.front { z-index: 4; }
#win-chat { left: 74px; top: 6px; width: 308px; height: 312px; }
#win-note { left: 160px; top: 40px; width: 300px; height: 262px; }
.chat-body { display: flex; flex-direction: column; height: calc(100% - 22px); margin: 4px; }
#chat-log { flex: 1; overflow-y: auto; background: #fff; padding: 4px; box-shadow: inset -1px -1px #fff, inset 1px 1px grey, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a; }
#chat-log .line { margin: 0 0 5px; white-space: pre-wrap; word-wrap: break-word; }
#chat-log .who { font-weight: 700; }
#chat-log .player .who { color: navy; }
#chat-log .sys { color: #555; font-style: italic; }
#chat-log .wren { font-family: "VT323", monospace; font-size: 15px; color: var(--wren-light); }
#chat-log u.quote { text-decoration: underline; text-decoration-color: var(--wren-light); border: 0; }
#chat-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 0 0; }
#chat-form { margin-top: 4px; }
#chat-input { flex: 1; min-width: 0; }
#chat-send { min-width: 50px; }
.note-body { display: flex; flex-direction: column; height: calc(100% - 22px); margin: 4px; gap: 4px; }
#note-text { flex: 1; overflow: auto; margin: 0; padding: 6px; white-space: pre-wrap; font-family: "VT323", monospace; font-size: 15px; line-height: 15px; color: #000; }
#note-text.wren-type { color: var(--wren-light); font-size: 17px; line-height: 17px; }
#note-text .stamp { color: var(--wren-light); font-size: 22px; }
#note-input { flex: 1; min-width: 0; }

#taskbar { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; background: silver; box-shadow: inset 0 1px #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 4px; z-index: 5; }
.tb-brand { font-weight: 700; padding: 3px 6px; box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff; }
.tray { display: flex; align-items: center; gap: 6px; padding: 2px 6px; box-shadow: inset -1px -1px #dfdfdf, inset 1px 1px grey; }
.tray label { margin-right: 4px; }

/* Possessed: the desktop goes to the corruption palette; chat and Notepad keep contrast. */
.possessed #taskbar { background: var(--scab); color: var(--bone); }
.possessed .tb-brand, .possessed .tray { color: var(--bone); }
.tb-brand { min-width: 0; min-height: 0; background: silver; font: inherit; font-weight: 700; color: inherit; }
.tb-brand[aria-expanded="true"] { box-shadow: inset 1px 1px #0a0a0a, inset -1px -1px #fff; }
.possessed .tb-brand { background: var(--scab); }
#start-menu { position: absolute; left: 2px; bottom: 26px; z-index: 6; display: flex; background: silver; box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey; padding: 3px; }
#start-banner { writing-mode: vertical-rl; transform: rotate(180deg); background: linear-gradient(navy, #1084d0); color: silver; font-weight: 700; font-size: 14px; padding: 6px 2px; }
#start-items { display: flex; flex-direction: column; min-width: 120px; }
#start-items button { all: unset; display: block; padding: 4px 10px 4px 8px; cursor: default; }
#start-items button:hover, #start-items button:focus { background: navy; color: #fff; }
#start-items button.red { color: var(--wren-light); font-family: "VT323", monospace; font-size: 16px; }
#start-items button.red:hover, #start-items button.red:focus { background: var(--wren-light); color: #fff; }
#start-items hr { border: 0; border-top: 1px solid grey; border-bottom: 1px solid #fff; margin: 3px 2px; width: auto; }
.possessed #start-banner { background: linear-gradient(var(--scab), var(--wound)); color: var(--bone); }
.possessed .title-bar { background: linear-gradient(90deg, var(--scab), var(--wound)); }
.possessed #sticky { background: var(--bone); }
.possessed #sticky li:last-child { color: var(--wren-light); }

#cursor { position: absolute; left: 0; top: 0; width: 12px; height: 18px; background: var(--wren-dark); clip-path: polygon(0 0, 0 100%, 30% 75%, 50% 100%, 65% 92%, 45% 68%, 100% 68%); z-index: 20; pointer-events: none; }
#blocker { position: absolute; inset: 0; z-index: 19; cursor: none; }
.drag-ghost { position: absolute; z-index: 18; pointer-events: none; }

dialog.window { padding: 3px; border: 0; min-width: 260px; max-width: 360px; }
dialog::backdrop { background: transparent; }
.dialog-buttons { justify-content: center; margin-top: 10px; }

.end-window .window-body { font-size: 12px; }
.end-title { font-size: 44px; margin: 4px 0; }
#end-lines p { font-size: 20px; margin: 2px 0; }
#end.absorbed .end-window { background: #5a0a14; color: var(--bone); }
#end.absorbed fieldset legend { background: #5a0a14; }
#end.absorbed a { color: var(--wren-dark); }

#trace { position: fixed; right: 8px; bottom: 8px; width: min(520px, 90vw); max-height: 60vh; overflow: auto; z-index: 60; font-size: 11px; font-family: monospace; }

body.fade #stage { transition: opacity 1.2s steps(8); opacity: 0; }
body.wait, body.wait * { cursor: wait !important; }

/* POST: a black BIOS screen that types out, then Halcyon 95 Setup. */
#post { position: fixed; inset: 0; background: #000; color: #b8b8b8; padding: 28px 32px; z-index: 60; overflow: hidden; display: flex; flex-direction: column; }
/* 98.css paints every pre white with an inset border; the BIOS stays black. */
#post-text { margin: 0; padding: 0; background: none; box-shadow: none; font-size: clamp(13px, 2.6vw, 22px); line-height: 1.2; white-space: pre-wrap; flex: 1; overflow: hidden; }
#post-text .bad { color: var(--wren-dark); }
.post-skip { margin: 8px 0 0; font-size: 18px; color: #555; }

.setup-page { align-items: center; background: var(--teal); }
.setup { width: min(660px, 100%); }
.setup-body { display: flex; gap: 14px; margin: 0; padding: 12px; }
.setup-side { flex: 0 0 150px; background: linear-gradient(180deg, #008080, #000080); color: #fff; padding: 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.setup-side-title { font-size: 30px; line-height: 0.95; margin: 6px 0 0; }
.setup-side-tag { font-size: 18px; margin: 0; color: #ffff80; }
.setup-main { flex: 1; font-size: 12px; line-height: 1.45; min-width: 0; }
.setup-main h2 { font-size: 16px; margin: 2px 0 8px; }
.setup-main #name { width: 220px; }
.setup-main details { margin: 2px 0 0 2px; }
.setup-main details summary { cursor: pointer; }
.setup-main details ul { margin: 4px 0 0 18px; padding: 0; }
.setup-buttons { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 12px 10px; box-shadow: inset 0 1px #808080, inset 0 2px #fff; }
.muted { color: #444; }
@media (max-width: 560px) { .setup-side { display: none; } }

/* CRT glass: faint scanlines and a vignette over the whole screen (static; under 6%). */
#screen::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 30;
  background: repeating-linear-gradient(rgba(0, 0, 0, 0.055) 0 1px, transparent 1px 2px), radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.32) 100%); }
#screen.possessed::after { background: repeating-linear-gradient(rgba(0, 0, 0, 0.07) 0 1px, transparent 1px 2px), radial-gradient(ellipse at center, transparent 50%, rgba(40, 0, 8, 0.55) 100%); }

/* THE POSSESSION: static and a flicker (never more than 3 a second; off in calm mode). */
#static { position: absolute; inset: 0; z-index: 29; pointer-events: none; opacity: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -0.4'/></filter><rect width='128' height='128' filter='url(%23n)'/></svg>");
  background-size: 128px 128px; }
@keyframes static-burst { 0% { opacity: 0; background-position: 0 0; } 20% { opacity: 0.22; background-position: 37px 11px; } 40% { background-position: -23px 41px; } 60% { opacity: 0.16; background-position: 13px -29px; } 100% { opacity: 0; background-position: 0 0; } }
#static.burst { animation: static-burst 0.9s steps(5) 1; }
@keyframes flicker { 0%, 100% { filter: none; } 30% { filter: brightness(0.86); } 60% { filter: brightness(0.94); } }
#screen.flicker { animation: flicker 0.7s steps(2) 1; }
.calm #static, .calm #screen.flicker { animation: none; opacity: 0; }

/* End cards reveal line by line. */
.reveal > * { opacity: 0; transition: opacity 0.5s steps(4); }
.reveal > .shown { opacity: 1; }
.calm .reveal > * { opacity: 1; transition: none; }
#end:not(.absorbed) { background: #000; }

.end-hero { background: #000; color: #e8e8e8; margin: -8px -8px 12px; padding: 22px 16px 18px; text-align: center; box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.9); }
.end-hero .end-title { color: #fff; font-size: 72px; letter-spacing: 6px; margin: 2px 0 6px; }
.end-hero p { font-size: 22px; margin: 2px 0; }
.end-voice { color: var(--wren-dark); font-size: 24px !important; min-height: 26px; }
#end.absorbed .end-hero { background: #3a0010; }
#end.absorbed .end-voice { color: var(--bone); }

/* Lost diary pages, in the free space under the sticky note. */
.g-page { background-image: url(img/page.svg); }
#pages .icon { left: auto; width: 62px; }
#pages .icon .label { font-size: 10px; }

/* DEFRAG.EXE: always moving, eating Wren's red sectors. */
#win-defrag { right: 6px; bottom: 32px; width: 124px; }
#win-defrag .title-bar-text { font-size: 10px; }
.defrag-body { margin: 2px; }
#defrag-grid { display: block; width: 116px; height: 32px; image-rendering: pixelated; background: #fff; box-shadow: inset 1px 1px grey; }
.defrag-status { font-size: 10px; line-height: 12px; margin-top: 2px; white-space: pre; }

/* A split-second frame over the game screen (one at a time, under 3 a second; never in calm mode),
   sized in the screen's own 512x384 pixels so the longest line fits at any zoom. */
#flash { position: absolute; inset: 0; z-index: 1000; pointer-events: none; display: grid; place-items: center; text-align: center; padding: 24px; overflow-wrap: anywhere; }
#flash.pal { background: navy; color: #fff; font: 700 40px/1.1 "Pixelated MS Sans Serif", sans-serif; }
#flash.wren { background: #050005; color: var(--wren-dark); font: 60px/0.95 "VT323", monospace; text-shadow: 2px 0 var(--blood); }
