/* Red Scare: committee room at night.
   Dark blotter desk, manila dossiers, typed forms, rubber stamps. */
:root {
  --desk: #13201a;
  --desk-2: #1a2b23;
  --manila: #cdb47c;
  --manila-d: #a58b52;
  --ledger: #e8ebe2;
  --ledger-d: #cdd3c4;
  --ink: #172033;
  --ink-soft: #4a566b;
  --lamp: #e3a72f;
  --red: #b0281f;
  --blue: #2b4c99;
  --ok: #2f6b4f;
  --type: "American Typewriter", "Courier New", Courier, "Liberation Mono", "Cousine", monospace;
  --stamp: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", "Helvetica Neue", sans-serif;
  --serif: Georgia, "Times New Roman", "Liberation Serif", serif;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--type);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ledger);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(227, 167, 47, .17), transparent 62%),
    var(--noise),
    var(--desk);
  background-attachment: fixed;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- paper and folders ---------- */
.paper {
  background: var(--noise), var(--ledger);
  color: var(--ink);
  border-radius: 3px;
  padding: 16px 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 12px 26px rgba(0, 0, 0, .38);
}
.paper h2 { font-family: var(--serif); font-size: 1.35rem; line-height: 1.15; margin-bottom: 6px; }
.paper h3 { font-size: 1rem; margin-bottom: 4px; }
.paper .soft, .soft { color: var(--ink-soft); }
.on-desk .soft, .desk-note { color: #9fb2a6; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }

.folder {
  position: relative;
  background: var(--noise), var(--manila);
  color: var(--ink);
  border-radius: 2px 7px 4px 4px;
  padding: 18px 10px 9px 11px;
  min-height: 58px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .1), 0 4px 10px rgba(0, 0, 0, .4);
  overflow: hidden;
  text-align: left;
}
.folder::before {
  content: "";
  position: absolute; left: 0; top: 0;
  width: 42%; height: 9px;
  background: var(--manila-d);
  border-radius: 2px 7px 0 0;
}
.folder .ph { display: block; width: 54px; margin: 0 0 5px; }
.folder .ph svg, .ph svg { display: block; width: 100%; height: auto; border: 2px solid #f3ecd8; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); filter: sepia(.18) saturate(.9); background: #b9b39a; }
.ph.big { width: 78px; flex: none; }
.folder.dead .ph svg { filter: grayscale(1) brightness(.8); }
.folder .bio { display: block; font-size: .68rem; line-height: 1.2; color: #5b4c26; font-style: italic; margin-top: 2px; }
.idrow { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.idrow .idname { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; line-height: 1.15; }
.folder .nm { display: block; font-weight: 700; font-size: .98rem; line-height: 1.15; overflow-wrap: anywhere; }
.folder .st { display: block; font-size: .78rem; color: #5b4c26; margin-top: 2px; min-height: 1.1em; }
.folder.witness { outline: 3px solid var(--lamp); outline-offset: 1px; background: var(--noise), #dcc58b; }
.folder.dead { background: var(--noise), #8f8466; color: #2c2a22; }
.folder.dead .nm { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(176, 40, 31, .75); }
.folder.me::after {
  content: "you"; position: absolute; right: 7px; top: 1px; font-size: .7rem; color: var(--ink);
}
.folder .stamp { position: absolute; right: 5px; bottom: 5px; font-size: .95rem; }
.folder.stamped { padding-bottom: 34px; }
.folder.pick { cursor: pointer; transition: transform .08s ease; }
.folder.pick:hover { transform: translateY(-2px); }
.folder.pick:active { transform: translateY(0); }
.folder.picked { outline: 3px solid var(--red); outline-offset: 1px; }
.folder.picked .st { color: var(--red); font-weight: 700; }
.folder.disabled { opacity: .5; pointer-events: none; }

/* ---------- stamps ---------- */
.stamp {
  display: inline-block;
  font-family: var(--stamp);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .07em;
  line-height: 1;
  color: var(--red);
  border: .14em solid currentColor;
  border-radius: 3px;
  padding: .12em .4em .08em;
  transform: rotate(-7deg);
  mix-blend-mode: multiply;
  opacity: .9;
  white-space: nowrap;
}
.stamp.blue { color: var(--blue); transform: rotate(5deg); }
.stamp.big { font-size: 2.2rem; }
.stamp.slam { animation: slam .5s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes slam {
  0% { transform: rotate(-7deg) scale(2.6); opacity: 0; }
  55% { transform: rotate(-7deg) scale(.92); opacity: .95; }
  78% { transform: rotate(-7deg) scale(1.05); }
  100% { transform: rotate(-7deg) scale(1); }
}
.stamp.blue.slam { animation-name: slam-blue; }
@keyframes slam-blue {
  0% { transform: rotate(5deg) scale(2.6); opacity: 0; }
  55% { transform: rotate(5deg) scale(.92); opacity: .95; }
  78% { transform: rotate(5deg) scale(1.05); }
  100% { transform: rotate(5deg) scale(1); }
}

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px;
  border: 2px solid var(--ink); border-radius: 3px;
  background: var(--ink); color: var(--ledger);
  font-weight: 700;
  transition: transform .08s ease, background .12s ease;
}
.btn:hover { background: #24304a; }
.btn:active { transform: translateY(1px); }
.btn.lamp { background: var(--lamp); border-color: #7a560c; color: #2a1d02; }
.btn.lamp:hover { background: #efb73f; }
.btn.red { background: var(--red); border-color: #6e150f; color: #fff; }
.btn.red:hover { background: #c3322a; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: rgba(23, 32, 51, .08); }
.on-desk .btn.ghost, .btn.ghost.light { color: var(--ledger); border-color: #51675a; }
.on-desk .btn.ghost:hover, .btn.ghost.light:hover { background: rgba(255, 255, 255, .07); }
.btn.small { min-height: 34px; padding: 4px 11px; font-size: .88rem; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }

.field { display: block; }
.field > span { display: block; font-size: .9rem; margin-bottom: 4px; }
.input {
  width: 100%; min-height: 46px; padding: 9px 12px;
  background: #f6f7f2; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 3px;
}
textarea.input { min-height: 84px; resize: vertical; }
.input.bad { border-color: var(--red); }
.error-line { color: var(--red); font-weight: 700; min-height: 1.4em; font-size: .92rem; }
.on-desk .error-line { color: #ff9a8f; }
.redx {
  display: inline-grid; place-items: center; width: 1.5em; height: 1.5em;
  border: 3px solid var(--red); border-radius: 50%; color: var(--red);
  font-family: var(--stamp); font-size: 1.1rem; line-height: 1;
}

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: rgba(23, 32, 51, .1); font-size: .82rem; font-weight: 700;
}
.chip.loyal { background: rgba(47, 107, 79, .18); color: #1f5139; }
.chip.sleeper { background: rgba(176, 40, 31, .16); color: #8c1f18; }
.chip.demagogue { background: rgba(227, 167, 47, .3); color: #5d4208; }

/* ---------- clock and meter ---------- */
.clock {
  font-family: var(--type); font-weight: 700; color: var(--lamp);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.clock.low { color: #ff8a78; }
.meter { height: 12px; background: rgba(0, 0, 0, .35); border: 2px solid #51675a; border-radius: 7px; overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--lamp), var(--red)); transition: width .6s ease; }
.meter.progress > i { background: var(--lamp); }
.paper .meter { border-color: var(--ink); background: rgba(23, 32, 51, .15); }

.phase-name { font-family: var(--serif); font-weight: 700; font-size: 1.55rem; line-height: 1.1; }
.phase-help { color: #b9c9be; }

/* ---------- newspaper clipping ---------- */
.gazette { background: var(--noise), #ecebe2; color: #1d1d1d; font-family: var(--serif); padding: 14px 18px 16px; border-radius: 2px; box-shadow: 0 12px 26px rgba(0, 0, 0, .38); }
.gazette .mast { font-size: 1.7rem; font-weight: 700; text-align: center; border-bottom: 3px double #1d1d1d; padding-bottom: 6px; margin-bottom: 8px; font-style: italic; }
.gazette .item { padding: 8px 0; border-bottom: 1px solid #b9b8ac; }
.gazette .item:last-child { border-bottom: 0; }
.gazette .hed { font-weight: 700; font-size: 1.15rem; line-height: 1.2; }
.gazette .sub { font-size: .92rem; color: #444; margin-top: 2px; }
.gazette .empty { color: #666; font-style: italic; padding: 10px 0; }

/* ---------- student shell ---------- */
.shell { max-width: 620px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 10px 14px 8px;
  background: rgba(19, 32, 26, .96); border-bottom: 2px solid #2d4338;
}
.topbar .where { font-size: .84rem; color: #9fb2a6; }
.topbar .phase-name { font-size: 1.2rem; }
.topbar .clock { font-size: 1.7rem; grid-row: 1 / span 2; grid-column: 2; }
.topbar .meter-row { grid-column: 1 / span 2; display: flex; align-items: center; gap: 8px; font-size: .78rem; color: #9fb2a6; }
.topbar .meter-row .meter { flex: 1; height: 8px; }
.content { flex: 1; padding: 14px 14px 96px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 620px; margin: 0 auto;
  background: #0f1a15; border-top: 2px solid #2d4338;
}
.tabbar button { min-height: 58px; border: 0; background: transparent; color: #9fb2a6; font-weight: 700; position: relative; }
.tabbar button[aria-selected="true"] { color: var(--lamp); box-shadow: inset 0 3px 0 var(--lamp); }
.tabbar .badge { position: absolute; top: 7px; right: 22%; background: var(--red); color: #fff; font-size: .72rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

.grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.banner { padding: 10px 12px; border-radius: 3px; background: rgba(227, 167, 47, .14); border: 2px solid var(--lamp); color: #f5deaa; }
.banner.danger { background: rgba(176, 40, 31, .2); border-color: #d9584d; color: #ffd2cc; }
.banner strong { color: #fff; }
.file-card { background: var(--noise), var(--manila); color: var(--ink); border-radius: 3px 12px 4px 4px; padding: 16px; position: relative; box-shadow: 0 12px 26px rgba(0, 0, 0, .38); }
.file-card::before { content: ""; position: absolute; left: 0; top: -9px; width: 38%; height: 10px; background: var(--manila-d); border-radius: 4px 9px 0 0; }
.file-card h2 { font-family: var(--serif); font-size: 1.6rem; margin-bottom: 4px; }
.file-card .stamp { margin-bottom: 8px; }
.cell-list { margin: 8px 0 0; padding-left: 18px; }
.witness-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed rgba(23, 32, 51, .3); }
.witness-line:last-child { border-bottom: 0; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 3px; overflow: hidden; }
.seg button { border: 0; background: transparent; min-height: 40px; padding: 4px 12px; font-weight: 700; color: var(--ink); }
.seg button[aria-pressed="true"].c { background: var(--blue); color: #fff; }
.seg button[aria-pressed="true"].b { background: var(--red); color: #fff; }
.msg { padding: 8px 0; border-bottom: 1px dashed rgba(23, 32, 51, .3); }
.msg:last-child { border-bottom: 0; }
.msg .meta { font-size: .8rem; color: var(--ink-soft); }
.msg.flag { opacity: .55; }

/* ---------- landing ---------- */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.landing .card { width: min(560px, 100%); }
.landing h1 { font-family: var(--serif); font-size: clamp(2.2rem, 7vw, 3.4rem); line-height: 1; margin-bottom: 10px; }
.landing .tag { color: #b9c9be; margin-bottom: 22px; }
.landing .choices { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.landing .choice { text-align: left; padding: 18px 16px; text-decoration: none; display: block; }
.landing .choice b { display: block; font-family: var(--serif); font-size: 1.4rem; }
@media (max-width: 480px) { .landing .choices { grid-template-columns: 1fr; } }

/* ---------- projector ---------- */
body.projector { overflow: hidden; height: 100vh; font-size: clamp(14px, 1.15vw, 22px); }
.pj { height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 31vw 5.2vw; gap: 1.4vw; padding: 1.6vw; }
.pj-board { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pj-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 1vw; gap: 1vw; }
.pj-head .phase-name { font-size: 2.5em; }
.pj-head .where { color: #9fb2a6; font-size: 1.1em; }
.pj-clock { font-size: 4.2em; line-height: 1; }
.pj-grid { flex: 1; min-height: 0; display: grid; gap: .7vw; align-content: start; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); }
.pj-grid .folder { min-height: 0; padding: 1.5vw .6vw .5vw .7vw; }
.pj-grid .folder .nm { font-size: 1.05em; }
.pj-grid .folder .st { font-size: .72em; }
.pj-grid .folder .stamp { font-size: calc(.7vw * 6 / var(--cols, 6) + .3vw); letter-spacing: .03em; padding: .1em .22em .06em; right: .3vw; bottom: .35vw; max-width: 96%; }
.pj-grid .folder.stamped { padding-bottom: 2.6vw; }
.pj-side { display: flex; flex-direction: column; gap: 1.2vw; min-height: 0; overflow: hidden; }
.pj-side .paper, .pj-side .gazette { padding: 1.1vw 1.3vw; }
.pj-side h2 { font-size: 1.7em; }
.pj-thermo { display: flex; flex-direction: column; align-items: center; gap: .8vw; padding-top: .4vw; }
.thermo { position: relative; flex: 1; width: 2.2vw; min-height: 0; background: rgba(0, 0, 0, .35); border: 3px solid #51675a; border-radius: 1.2vw 1.2vw 1.6vw 1.6vw; overflow: hidden; }
.thermo > i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, var(--red), var(--lamp)); transition: height .8s ease; }
.pj-thermo .num { font-family: var(--serif); font-size: 2.4em; font-weight: 700; line-height: 1; }
.pj-thermo .lbl { font-size: .95em; color: #9fb2a6; text-align: center; }
.code-xl { font-family: var(--stamp); font-size: 6.2vw; letter-spacing: .1em; line-height: 1; color: var(--red); display: inline-block; transform: rotate(-3deg); border: .08em solid currentColor; padding: .06em .22em .02em .3em; mix-blend-mode: multiply; }
.spot { display: grid; gap: .8vw; }
.spot .folder { padding: 2.2vw 1.2vw 1vw; }
.spot .folder .nm { font-size: 2.1em; }
.pj-big { font-size: 1.15em; }
.pj-list { margin: .4vw 0 0; padding: 0; list-style: none; }
.pj-list li { padding: .35vw 0; border-bottom: 1px dashed rgba(23, 32, 51, .3); }
.pj-list li:last-child { border-bottom: 0; }

/* ---------- teacher ---------- */
body.teacher { font-size: 15px; }
.t-top {
  position: sticky; top: 0; z-index: 8; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  padding: 10px 16px; background: rgba(15, 26, 21, .97); border-bottom: 2px solid #2d4338;
}
.t-top .code { font-family: var(--stamp); font-size: 2rem; letter-spacing: .12em; color: var(--lamp); }
.t-top .clock { font-size: 1.8rem; }
.t-wrap { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; padding: 16px; align-items: start; }
@media (max-width: 960px) { .t-wrap { grid-template-columns: 1fr; } }
.t-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.t-tabs button { min-height: 38px; padding: 4px 14px; border: 2px solid #51675a; border-radius: 3px; background: transparent; color: #b9c9be; font-weight: 700; }
.t-tabs button[aria-selected="true"] { background: var(--lamp); border-color: #7a560c; color: #2a1d02; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-weight: 700; border-bottom: 2px solid var(--ink); padding: 5px 6px; position: sticky; top: 0; background: var(--ledger); }
table.t td { padding: 5px 6px; border-bottom: 1px solid var(--ledger-d); vertical-align: top; }
table.t tr.out td { color: #7b8394; text-decoration: line-through; text-decoration-color: rgba(176, 40, 31, .6); }
table.t tr.out td.keep { text-decoration: none; }
.scroll { max-height: 62vh; overflow: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-weight: 700; }
.tip-ok { color: var(--ok); font-weight: 700; }
.tip-wait { color: #9b6a00; }
.flagged { background: rgba(176, 40, 31, .14); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* projector: portraits sized from the row height (set by projector.js as --phh) */
.pj-grid .folder .ph { width: calc(var(--phh, 60px) * .833); margin-bottom: .3vw; }
.pj-grid .folder .ph svg { border-width: 1px; }
.pj-grid .folder .bio { display: none; }
.pj-grid .folder.stamped { padding-bottom: .6vw; }
.pj-grid .folder .stamp { top: calc(1.5vw + var(--phh, 60px) * .45); bottom: auto; }
.spot .folder { display: flex; flex-wrap: wrap; align-items: center; column-gap: 1.4vw; }
.spot .folder .ph.huge { width: 9vw; margin: 0; }
.spot .folder .ph.huge svg { border-width: 3px; }
.spot .folder .nm, .spot .folder .bio, .spot .folder .st { flex: 1 1 60%; }
.spot .folder .bio { display: block; font-size: 1.05em; }
.pj-grid .folder .nm { font-size: calc(.62vw * 6 / var(--cols, 6) + .3vw); line-height: 1.1; overflow-wrap: normal; word-break: normal; }
.pj-grid .folder .st { font-size: calc(.5vw * 6 / var(--cols, 6) + .22vw); }

/* sound button, pop-ups, shake, outcry tally */
.sound-btn { position: fixed; left: 8px; bottom: 6px; z-index: 30; background: rgba(0, 0, 0, .45); color: #cdbf93; border: 1px solid #6b5d34; border-radius: 3px; font-size: .8vw; padding: 3px 9px; cursor: pointer; }
.sound-btn.on { opacity: .35; }
.toasts { position: fixed; top: 42vh; left: 0; width: 61vw; display: flex; flex-direction: column; align-items: center; gap: .6vw; z-index: 20; pointer-events: none; }
.toast { max-width: 56vw; display: flex; align-items: center; gap: 1.2vw; padding: .8vw 1.8vw .8vw .8vw; background: var(--noise), #f2ead6; color: var(--ink); border: .25vw solid var(--red); border-radius: 4px; box-shadow: 0 1vw 3vw rgba(0, 0, 0, .6); transform: rotate(-1.2deg); animation: toast-in .28s cubic-bezier(.2, .9, .3, 1.25) both; }
.toast.defend { border-color: var(--blue); transform: rotate(1deg); }
.toast .ph { width: 4vw; }
.toast .tt { font-size: 1.8vw; line-height: 1.2; font-weight: 700; }
.toast.accuse .tt b:first-child { color: var(--red); }
.toast.out { animation: toast-out .4s ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-4vw) scale(.8) rotate(-4deg); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-2vw) scale(.95); } }
.pj.shake { animation: shake .7s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake { 10%, 90% { transform: translate(-3px, 1px); } 20%, 80% { transform: translate(5px, -2px); } 30%, 50%, 70% { transform: translate(-8px, 2px); } 40%, 60% { transform: translate(8px, -1px); } }
.outcry { display: grid; grid-template-columns: 1fr 1fr; gap: .8vw; margin: .6vw 0; }
.oc { border: .2vw solid var(--ink); border-radius: 3px; padding: .5vw .8vw; display: grid; grid-template-columns: auto 1fr; column-gap: .7vw; align-items: baseline; }
.oc .n { font-size: 3vw; font-weight: 800; line-height: 1; }
.oc .l { font-size: 1.2vw; text-transform: uppercase; letter-spacing: .08em; }
.oc .who { grid-column: 1 / -1; font-size: .95vw; line-height: 1.25; min-height: 2.4vw; opacity: .8; }
.oc.a { color: var(--red); border-color: var(--red); }
.oc.d { color: var(--blue); border-color: var(--blue); }
.seg button { flex: 1; }
.stack > .seg { display: flex; }
