:root {
  --bg: #0e0c10;
  --panel: #16141a;
  --line: #2c2830;
  --ink: #e2d6b8;
  --dim: #8c7e66;
  --phosphor: #40c470;
  --phosphor-dim: #226e42;
  --highlight: #d2e0fa;
  --warn: #e0a050;
  --bad: #e06a5a;
  --paper: #f4f0e2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Pixelify Sans", ui-monospace, monospace; font-size: 17px; line-height: 1.3;
       font-variant-ligatures: none; }  /* the pixel font draws "fi" and "fl" as one odd glyph */
h1, h2 { font-weight: normal; margin: 0; }
/* Titles: Jacquard 24 is drawn on a 24 px grid, so keep it at 24 or 48. */
h1, .card > h2, #room-title, .outcome .name { font-family: "Jacquard 24", serif; font-weight: 400; }
h1 { font-size: 48px; line-height: 1; color: var(--phosphor); }
h2 { font-size: 19px; font-weight: 600; color: var(--highlight); margin: 10px 0 6px; }
.card > h2, #room-title { font-size: 48px; line-height: 1; font-weight: 400; }
#room-title { font-size: 24px; }
button, input, select { font: inherit; color: var(--ink); }
button {
  background: #24202a; border: 2px solid var(--line); padding: 2px 10px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--phosphor); color: var(--phosphor); }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid var(--highlight); outline-offset: 1px; }
button:disabled { opacity: .45; cursor: default; }
input, select { background: #0b0e0c; border: 2px solid var(--line); padding: 1px 6px; min-width: 0; }
.dim { color: var(--dim); }
.error { color: var(--bad); }

.bar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-bottom: 2px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.status { color: var(--dim); flex: 1; min-width: 200px; }
.bar-buttons { display: flex; gap: 8px; margin-left: auto; }
@media (max-width: 720px) { .status { order: 3; flex-basis: 100%; min-width: 0; } }
.icon-btn { width: 40px; height: 36px; padding: 0; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; shape-rendering: crispEdges; }
#pause .when-paused, #pause.paused .when-running { display: none; }
#pause.paused .when-paused { display: block; }
#pause.paused { color: var(--phosphor); border-color: var(--phosphor); }
/* the settings menu drops down under the gear */
.menu { position: fixed; inset: auto; margin: 0; padding: 6px; background: var(--panel); color: var(--ink);
        border: 2px solid var(--warn); box-shadow: 0 0 0 4px #000, 0 8px 24px rgba(0, 0, 0, .6); }
.menu:popover-open { display: flex; flex-direction: column; gap: 6px; }
.menu button { text-align: left; white-space: nowrap; padding: 4px 12px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 16px; padding: 12px 16px; align-items: start; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.stage { min-width: 0; }

.room-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.facts { color: var(--dim); }
/* A device's menu opens in the room, next to the device; only that device's card shows. */
.device-menu { position: absolute; z-index: 5; width: min(330px, 94%); background: var(--panel); border: 2px solid var(--warn);
               padding: 4px 8px 8px; box-shadow: 0 0 0 3px #000, 0 8px 24px rgba(0, 0, 0, .6);
               max-height: calc(100% - 8px); overflow: auto; }
.device-menu[hidden] { display: none; }
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--warn); }
.close-menu { width: 30px; height: 28px; padding: 0; }
.device-menu .sig-card { display: none; margin: 4px 0 0; }
.device-menu[data-card="screen"] .sig-card[data-card="screen"],
.device-menu[data-card="sound"] .sig-card[data-card="sound"],
.device-menu[data-card="printer"] .sig-card[data-card="printer"] { display: block; }
.devices { display: flex; gap: 8px; justify-content: center; margin: 6px 0 0; }
.devices button { min-width: 96px; }
.devices button.fresh { border-color: var(--warn); color: var(--warn); }
.view-wrap { position: relative; width: min(100%, max(560px, (100vh - 330px) * 640 / 224)); margin: 0 auto; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; display: block; background: #000; }
#view { border: 2px solid var(--line); width: 100%; height: auto; }
.tip {
  position: absolute; pointer-events: none; background: #0c080a; color: var(--highlight);
  border: 2px solid var(--highlight); padding: 0 6px; white-space: nowrap; transform: translate(-50%, -100%);
}
.tip.look { color: var(--dim); border-color: var(--line); }  /* only information: nothing to click */
.banner {
  position: absolute; left: 8px; right: 8px; top: 8px; background: rgba(12, 8, 10, .92); color: var(--warn);
  border: 2px solid var(--warn); padding: 4px 8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
}
.banner[hidden] { display: none; }
.banner .answers { display: flex; flex-wrap: wrap; gap: 6px; color: var(--ink); }
.banner button { border-color: var(--warn); }
.subtitle { min-height: 2.4em; margin: 6px 0; color: var(--paper); font-size: 20px; }
.subtitle .who { color: var(--phosphor); }
.subtitle .refused { color: var(--bad); }
.notice { min-height: 1.3em; margin: 0 0 6px; color: var(--warn); }
.notice span { display: block; }

.previews { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 100%; }
.preview { background: none; border: 2px solid var(--line); padding: 0; text-align: left; min-width: 0; display: flex; flex-direction: column; }
.preview:hover { border-color: var(--phosphor); }
.preview.active { border-color: var(--highlight); }
.preview canvas { width: 100%; height: auto; aspect-ratio: 640 / 224; }
.preview .cap { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; padding: 2px 6px; color: var(--dim); }
.cap-foot { display: flex; flex-direction: column; font-size: 14px; }
.cap .st:empty { display: none; }
.cap .st.urgent { color: var(--bg); background: var(--warn); align-self: flex-start; padding: 0 6px; }
.cap .st.unread { color: var(--highlight); }
.preview .cap b { color: var(--ink); font-weight: normal; }
.preview.alert { border-color: var(--warn); }

.panel { background: var(--panel); border: 2px solid var(--line); padding: 4px 12px 12px; max-height: calc(100vh - 80px); overflow: auto; }
.hint { color: var(--dim); margin: 0 0 8px; }
#signals.resting { opacity: .5; }
/* Signal cards: quiet borders, colour only in the title and icon; a card lights up when it changes. */
#signals [hidden] { display: none !important; }
.sig-card { --c: var(--ink); border: 2px solid color-mix(in srgb, var(--c) 35%, var(--line)); background: #1a1720; padding: 8px 10px; margin: 8px 0; transition: border-color .3s; }
.sig-card[data-card="screen"] { --c: var(--phosphor); }
.sig-card[data-card="sound"] { --c: var(--warn); }
.sig-card[data-card="printer"] { --c: var(--highlight); }
.sig-card.fresh { border-color: var(--c); }
.sig-card.locked { border-style: dashed; opacity: .55; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--c); }
.sig-icon svg { display: block; width: 24px; height: 24px; fill: var(--c); shape-rendering: crispEdges; }
.card-line { margin: 4px 0; color: var(--ink); font-size: 15px; }
.card-sub { margin: 0; color: var(--dim); font-size: 14px; }
.sig-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.sig-row input, .sig-row select { flex: 1; min-width: 0; }
.sig-row .where { flex-basis: 100%; }
.sig-row button, .sig-row input, .sig-row select { min-height: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.chip { font-size: 14px; padding: 1px 8px; border-color: color-mix(in srgb, var(--phosphor) 45%, var(--line)); }
.typed { border: 2px solid var(--warn); background: rgba(224, 160, 80, .12); color: var(--warn); padding: 6px 8px; margin: 4px 0 8px; }
.feedback { min-height: 1.2em; margin: 6px 0; }
.feedback .r { display: block; }
.ok { color: var(--phosphor); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.log { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.log li { border-top: 1px solid var(--line); padding: 3px 0; }
.log .act { color: var(--ink); }
.log .res { color: var(--dim); display: block; }
.log .heard { color: var(--warn); display: block; }
.log .elena { color: var(--phosphor); }

/* Title and morning screens: painted backgrounds, everything else drawn on top. */
/* "safe" keeps a screen taller than the window scrollable from its top */
.screen { position: fixed; inset: 0; z-index: 10; background: #07050a; overflow: auto; display: grid; align-items: safe center; justify-items: center; }
.screen[hidden] { display: none; }
.card { background: var(--panel); border: 2px solid var(--phosphor-dim); max-width: 640px; padding: 16px 20px; }
.card p { margin: 8px 0; }

.screen { grid-template-columns: minmax(0, 1fr); }
#intro { background: #07050a url(/assets/screens/home.jpg) center / cover; }
#intro::before { content: ""; position: fixed; inset: 0; backdrop-filter: blur(16px) brightness(.4); }
.scene { position: relative; width: min(100%, 240vh); height: min(100vh, 83.3vw); justify-self: center; container-type: inline-size; }
#home { width: 100%; height: 100%; }
/* the buttons sit on the dark front of the desk, between Marycel's chair and the drawers */
.home-actions { position: absolute; left: var(--hx, 50%); width: var(--hw, 16.5%); min-width: max-content; top: var(--hy, 74%); display: flex; flex-direction: column; gap: 1cqw; }
.home-actions button { font-size: max(15px, 1.6cqw); padding: .45cqw 1cqw; background: rgba(10, 18, 12, .82); border-color: var(--phosphor-dim); }
#start { color: var(--phosphor); border-color: var(--phosphor); }
#start:not(:disabled):hover { background: #12301c; }
.home-actions .error { margin: 0; font-size: max(13px, 1.2cqw); }
@media (max-width: 720px) {
  .screen { align-items: start; }
  .scene { width: 100%; height: auto; }
  #home { height: auto; aspect-ratio: 16 / 9; }
  .home-actions { position: static; width: auto; padding: 12px 16px; }
}

/* Pop-up windows: the story before the night, and how to play. */
.dialog {
  background: var(--panel); color: var(--ink); border: 2px solid var(--warn); padding: 20px 24px;
  width: min(820px, calc(100% - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  box-shadow: 0 0 0 4px #000, 0 12px 40px rgba(0, 0, 0, .6);
}
.dialog::backdrop { background: rgba(7, 5, 10, .75); }
.dialog > h2 { font-family: "Jacquard 24", serif; font-weight: 400; font-size: 48px; line-height: 1; color: var(--warn); margin: 0 48px 12px 0; }
.dialog p { margin: 8px 0; }
.tips { margin: 0 0 8px; padding-left: 20px; }
.tips li { margin: 5px 0; font-size: 15px; }
#screen-line.asking { color: var(--warn); }
.goal { font-size: 18px; margin: 0 0 12px; }
.how-lead { margin: 4px 0 6px; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 7px 4px; color: var(--warn); list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+ "; color: var(--dim); }
.faq details[open] summary::before { content: "- "; }
.faq details p { margin: 0 0 10px; padding: 0 4px 0 18px; font-size: 15px; }

/* The guided tour: a spotlight on one part of the screen and a card beside it. */
.tour { position: fixed; inset: 0; z-index: 60; }
.tour[hidden] { display: none; }
.tour-spot { position: fixed; border: 2px solid var(--warn); box-shadow: 0 0 0 9999px rgba(7, 5, 10, .72);
             pointer-events: none; transition: top .2s, left .2s, width .2s, height .2s; }
.tour-card { position: fixed; width: min(320px, calc(100vw - 32px)); background: var(--panel); color: var(--ink);
             border: 2px solid var(--warn); padding: 12px 14px; box-shadow: 0 0 0 3px #000, 0 8px 24px rgba(0, 0, 0, .6); }
.tour-card h3 { margin: 0 0 4px; color: var(--warn); font-size: 20px; font-weight: 400; }
.tour-card p { margin: 0 0 12px; font-size: 16px; }
.tour-actions { display: flex; gap: 8px; align-items: center; }
.tour-count { margin-right: auto; color: var(--dim); font-size: 14px; }
.dialog a { color: var(--phosphor); }
/* the X stays in reach while a long window scrolls */
.dialog .close { position: sticky; top: 0; float: right; margin: -10px -14px 0 8px; width: 40px; height: 40px; padding: 0; font-size: 20px; z-index: 1; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.dialog-actions button { font-size: 20px; padding: 4px 16px; }
.dialog .go { color: var(--phosphor); border-color: var(--phosphor); }
.steps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.steps li { background: #1c1622; border: 2px solid var(--c); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.steps li:nth-child(1) { --c: var(--highlight); }
.steps li:nth-child(2) { --c: var(--phosphor); }
.steps li:nth-child(3) { --c: var(--warn); }
.steps li:nth-child(4) { --c: #b48ce6; }
.steps li > b { color: var(--c); font-size: 20px; }
.steps p { margin: 0; font-size: 15px; }
.steps .icon { width: 96px; height: 96px; align-self: center; image-rendering: pixelated; background: url(/assets/screens/how-icons.png) 0 0 / 400% 100% no-repeat; }
.steps li:nth-child(2) .icon { background-position: 33.333% 0; }
.steps li:nth-child(3) .icon { background-position: 66.667% 0; }
.steps li:nth-child(4) .icon { background-position: 100% 0; }
@media (max-width: 720px) {
  .dialog { padding: 16px; }
  .dialog > h2 { font-size: 24px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .steps li { display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 10px; }
  .steps .icon { width: 64px; height: 64px; grid-row: span 2; }
}

.morning { background: #1a1008 url(/assets/screens/ending.jpg) center / cover no-repeat; }
.morning-inner { width: min(1100px, 100%); padding: 24px 16px; text-align: center; }
.morning-inner > h2 { font-family: "Jacquard 24", serif; font-size: 48px; line-height: 1; color: var(--paper); text-shadow: 0 2px 0 #000, 0 0 12px rgba(0, 0, 0, .8); margin-bottom: 16px; }
.outcomes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; text-align: left; }
.outcome { background: rgba(22, 16, 14, .9); border: 2px solid var(--warn); padding: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .5); }
.outcome canvas { width: 100%; height: auto; aspect-ratio: 640 / 224; border: 2px solid #000; }
.outcome h3 { font-weight: 600; margin: 6px 0 0; color: var(--highlight); }
.outcome .name { color: var(--warn); font-size: 48px; line-height: 1; margin: 4px 0; }
.outcome p { margin: 4px 0; }
.outcome summary { cursor: pointer; color: var(--dim); }
.outcome ul { margin: 4px 0 0; padding-left: 18px; color: var(--dim); }
#again { margin-top: 16px; font-size: 20px; padding: 4px 16px; border-color: var(--warn); background: rgba(22, 16, 14, .92); }
#again:hover { color: var(--warn); }
