/* bunker — one stylesheet, no framework, no CDN (the CSP blocks everything but
   this origin anyway).

   The look is two eras stacked on purpose: a Windows 98 window frame — the
   desktop these three grew up arguing on — sitting on graph paper, holding a
   dark RPG interface. The chrome is the nostalgia, the inside is the game. */

:root {
  /* 98 chrome */
  --face: #c3c7cb;
  --face-hi: #ffffff;
  --face-lo: #82858a;
  --face-dk: #3f4246;
  --title-a: #101a5c;
  --title-b: #2a6fd6;

  /* The game inside */
  --ink: #e8ecf4;
  --ink-dim: #97a0b5;
  --ink-faint: #6a748c;
  --bg: #131a2e;
  --bg-2: #1a2340;
  --bg-3: #0d1220;
  --line: #2c3760;

  --hot: #e8564a;
  --cool: #3aa8d8;
  --gold: #f6d05e;
  --go: #4fd18b;
  --dead: #6a748c;

  --pad: 12px;
  --mono: ui-monospace, "DejaVu Sans Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 10px;
  min-height: 100vh;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  /* Graph paper: the plan of a bunker nobody ever drew. */
  background-color: #070b16;
  background-image:
    linear-gradient(rgba(90, 130, 220, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 130, 220, 0.10) 1px, transparent 1px),
    linear-gradient(rgba(90, 130, 220, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 130, 220, 0.04) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- The window ---------- */

.win {
  max-width: 1100px;
  margin: 0 auto;
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: #fff;
  font-weight: bold;
  letter-spacing: 0.04em;
}

.titlebar-icon {
  width: 14px; height: 14px; flex: none;
  background: var(--gold);
  border: 1px solid #7a5f10;
  /* a tiny bunker: a slab with a slit */
  background-image: linear-gradient(#7a5f10 0 0);
  background-size: 8px 2px;
  background-position: 3px 6px;
  background-repeat: no-repeat;
}

.titlebar-text {
  flex: 1 1 auto;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.titlebar-buttons { display: flex; gap: 2px; flex: none; }

.tbtn {
  width: 18px; height: 16px;
  display: grid; place-items: center;
  font-size: 11px; line-height: 1; color: #000;
  background: var(--face);
  border: 1px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
}

.winbody {
  background: var(--bg);
  border: 2px solid;
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
  margin: 3px;
  padding: 0;
}

/* ---------- Menu bar ---------- */

.menubar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 2px 4px;
  background: var(--face);
  border-bottom: 1px solid var(--face-dk);
  flex-wrap: wrap;
}

.menu-item {
  display: inline-block;
  padding: 3px 9px;
  color: #101216;
  text-decoration: none;
  font-size: 13px;
  background: none;
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
}

.menu-item:hover,
.menu-item.on {
  background: var(--title-a);
  color: #fff;
}

.menu-dead { color: var(--face-lo); cursor: default; }
.menu-dead:hover { background: none; color: var(--face-lo); }
.menu-out { margin-left: auto; display: flex; }

/* ---------- Shared bits ---------- */

.panel {
  margin: var(--pad);
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.panel-title {
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
}

.panel-body { padding: 10px; }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  padding: 6px 12px;
  color: #101216;
  background: var(--face);
  border: 2px solid;
  border-color: var(--face-hi) var(--face-dk) var(--face-dk) var(--face-hi);
  cursor: pointer;
}

.btn:active {
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
  padding: 7px 11px 5px 13px;
}

.btn-primary { background: var(--gold); }
.btn-small { font-size: 11px; padding: 3px 8px; font-weight: normal; }
.btn-tiny { font-size: 12px; padding: 0 6px; line-height: 1.4; }

.btn-wizz {
  background: var(--hot);
  color: #fff;
  letter-spacing: 0.08em;
}

.btn-lock {
  background: var(--go);
  width: 100%;
  letter-spacing: 0.08em;
}

.field {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--bg-3);
  border: 2px solid;
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
  min-width: 0;
}

.field::placeholder { color: var(--ink-faint); }
.field:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.flash,
.wizz-alert {
  margin: var(--pad) var(--pad) 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  font-size: 13px;
}

.wizz-alert {
  border-color: var(--hot);
  background: rgba(232, 86, 74, 0.14);
  color: #ffd9d5;
}

.wizz-alert strong { color: var(--hot); letter-spacing: 0.1em; }
.wizz-count { color: var(--ink-dim); }

/* Pixel art: never smoothed, never stretched out of ratio. */
.px { display: block; width: 100%; height: auto; }
.px-hero { width: 100%; max-width: 44px; }
.px-doodle { width: 100%; max-width: 120px; }


/* ---------- Utilities that exist because of the CSP ----------
   style-src is 'self', so a style="" attribute is dropped by the browser without
   an error on the page — a bar with no width renders full, which is the most
   misleading failure available. Widths therefore come from these classes, in 5%
   steps (see views.WidthClass), and the per-person colour from --pc below.
   app.js still sets widths directly: the CSSOM is not covered by CSP. */

.w-0 { width: 0%; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }

.pc1 { --pc: #e8564a; }
.pc2 { --pc: #3aa8d8; }
.pc3 { --pc: #f6d05e; }

/* ---------- The construction site ---------- */

.site {
  display: grid;
  gap: var(--pad);
  padding: var(--pad);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(58, 168, 216, 0.10), transparent 70%),
    var(--bg-3);
}

.site-art {
  border: 1px solid var(--line);
  background: #0a0f1c;
  overflow: hidden;
}

.site-headline {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.06em;
}

.site-title {
  margin: 0;
  font-size: clamp(20px, 5vw, 30px);
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.site-caption { margin: 6px 0 12px; color: var(--ink-dim); }

.meter {
  position: relative;
  height: 22px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: repeating-linear-gradient(
    45deg, var(--gold) 0 8px, #d9b33f 8px 16px
  );
}

/* The label sits on top of a bar that is dark on the left and yellow on the
   right, so no single colour works: it was invisible at 0%. Light text with a
   hard dark outline reads on both. */
.meter-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.14em;
  color: #f4f7ff;
  text-shadow:
    0 1px 0 #0a0f1c, 0 -1px 0 #0a0f1c, 1px 0 0 #0a0f1c, -1px 0 0 #0a0f1c,
    0 0 4px rgba(10, 15, 28, 0.9);
}

/* ---------- Elected week ---------- */

.elected {
  margin: var(--pad);
  padding: 12px;
  border: 2px solid var(--go);
  background: rgba(79, 209, 139, 0.10);
}

.elected-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.elected-tag {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #0a0f1c;
  background: var(--go);
  padding: 2px 8px;
}

.elected-week { font-weight: bold; font-size: 16px; }
.elected-days { margin: 10px 0 4px; font-size: 15px; }
.elected-days strong { color: var(--go); font-size: 22px; }
.elected-line { margin: 10px 0 4px; }
.elected-now { color: var(--gold); font-weight: bold; font-size: 18px; }

.elected-units {
  margin: 4px 0 10px;
  padding-left: 18px;
  color: var(--ink-dim);
  font-size: 13px;
}

.elected-undo { margin-top: 6px; }

/* ---------- Columns ---------- */

.cols { display: grid; gap: 0; }

/* ---------- The boss ---------- */

.boss {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
  margin: var(--pad);
  padding: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-3));
}

.boss-down { opacity: 0.75; }
.boss-art { display: grid; place-items: center; }

.boss-name {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: bold;
  letter-spacing: 0.1em;
}

.boss-lvl { font-size: 11px; color: var(--ink-faint); letter-spacing: 0; }

.hp {
  height: 14px;
  margin: 6px 0 2px;
  background: var(--bg-3);
  border: 2px solid;
  border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk);
  overflow: hidden;
}

.hp-fill { height: 100%; transition: width 0.5s steps(12); }
.hp-green { background: var(--go); }
.hp-orange { background: var(--gold); }
.hp-red { background: var(--hot); }
.hp-num { font-size: 11px; color: var(--ink-dim); }
.boss-taunt { margin: 8px 0 0; font-size: 13px; color: var(--ink); font-style: italic; }

/* A hit flashes the boss red for a fifth of a second. */
.boss-hit { box-shadow: inset 0 0 0 2px var(--hot); }

/* ---------- The poll ---------- */

.week {
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  background: var(--bg-3);
}

.week + .week { margin-top: 8px; }
.week-hot { border-left-color: var(--go); }
.week-dead { border-left-color: var(--dead); opacity: 0.62; }

/* A week that has already started. The candidate list is fixed, so a poll that
   runs close to its target watches its own first rows expire; they stay visible
   (removing rows under people is disorienting) but read as unavailable. */
.week-past { opacity: 0.45; border-left-color: var(--dead); }
.week-past .week-num,
.week-past .week-span { text-decoration: line-through; }
.week-past .week-verdict { color: var(--dead); }

.vote-off { cursor: not-allowed; filter: grayscale(1); }
.week-elected { border-color: var(--go); border-left-color: var(--go); opacity: 1; }

.week-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.week-num { font-weight: bold; color: var(--gold); letter-spacing: 0.06em; }
.week-span { color: var(--ink); }

.week-verdict {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-faint);
  text-align: right;
}

.week-body { display: grid; gap: 8px; }
.week-them { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px 2px 2px;
  font-size: 11px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-dim);
}

.chip-who {
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  font-size: 10px;
  font-weight: bold;
  color: #0a0f1c;
  background: var(--pc, var(--ink-faint));
}

.chip.a-yes { border-color: var(--go); color: var(--go); }
.chip.a-maybe { border-color: var(--gold); color: var(--gold); }
.chip.a-no { border-color: var(--hot); color: var(--hot); }
.chip.a-none { opacity: 0.55; }
.chip-me { box-shadow: inset 0 0 0 1px var(--ink-faint); }

.week-vote { display: flex; gap: 6px; }

.vote {
  flex: 1 1 0;
  text-align: center;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  background: var(--bg-2);
  border: 2px solid;
  border-color: var(--face-lo) var(--face-dk) var(--face-dk) var(--face-lo);
  cursor: pointer;
  user-select: none;
}

.vote input { position: absolute; opacity: 0; width: 0; height: 0; }
.vote:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 1px; }
/* .on is what the server rendered; :has(:checked) is what the click does. Both
   are listed so the buttons respond instantly without waiting for a round trip,
   and still look right with JavaScript off. */
.vote.on,
.vote:has(input:checked) { border-color: var(--face-dk) var(--face-hi) var(--face-hi) var(--face-dk); color: #0a0f1c; }
.v-yes.on, .v-yes:has(input:checked) { background: var(--go); }
.v-maybe.on, .v-maybe:has(input:checked) { background: var(--gold); }
.v-no.on, .v-no:has(input:checked) { background: var(--hot); color: #fff; }

.week-lock { margin-top: 8px; }

.poll-submit {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 0 2px;
  background: linear-gradient(180deg, transparent, var(--bg-2) 30%);
}

.poll-owed { font-size: 12px; color: var(--ink-dim); }

/* ---------- Roster ---------- */

.roster { margin: 0; padding: 0; list-style: none; }

.mate {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
}

.mate + .mate { border-top: 1px solid var(--line); }
.mate-me { background: rgba(246, 208, 94, 0.06); }
.mate-info { display: grid; gap: 1px; min-width: 0; }
.mate-name { font-weight: bold; display: flex; align-items: center; gap: 6px; }

.dot {
  width: 8px; height: 8px; flex: none;
  background: var(--dead);
  border-radius: 50%;
}

.dot-on { background: var(--go); box-shadow: 0 0 6px var(--go); }
.mate-you { font-weight: normal; font-size: 11px; color: var(--ink-faint); }
.mate-class { font-size: 11px; color: var(--ink-dim); }
.mate-presence { font-size: 11px; color: var(--ink-faint); }

.stats { display: grid; gap: 2px; margin-top: 6px; }
.stat { display: grid; grid-template-columns: 92px 1fr; gap: 6px; align-items: center; }
.stat-label { font-size: 9px; letter-spacing: 0.08em; color: var(--ink-faint); }
.stat-bar { height: 6px; background: var(--bg-3); border: 1px solid var(--line); }
.stat-fill { display: block; height: 100%; background: var(--cool); }

/* ---------- Log ---------- */

.log { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.log-line { display: flex; flex-wrap: wrap; gap: 6px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.log-at { color: var(--ink-faint); flex: none; }
.log-who { font-weight: bold; color: var(--pc, var(--ink)); }
.log-text { color: var(--ink-dim); }
.log-empty { margin: 0; color: var(--ink-faint); font-size: 12px; }

/* ---------- Door + character select ---------- */

.door, .who { padding: 24px var(--pad) 32px; text-align: center; }
.door-art { max-width: 420px; margin: 0 auto 18px; border: 1px solid var(--line); overflow: hidden; }
.door-title, .who-title { margin: 0 0 6px; font-size: clamp(20px, 5vw, 28px); letter-spacing: 0.1em; }
.door-hint, .who-sub { margin: 0 auto 18px; max-width: 44ch; color: var(--ink-dim); font-size: 13px; }
.door-err { color: var(--hot); font-weight: bold; margin: 0 0 12px; }
.door-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.door-form .field { width: min(240px, 70vw); }
.door-foot { margin: 22px 0 0; font-size: 11px; color: var(--ink-faint); }

.who-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.hero-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 120px;
  padding: 12px 8px;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid;
  border-color: var(--face-lo) var(--face-dk) var(--face-dk) var(--face-lo);
  cursor: pointer;
}

.hero-card:hover { background: var(--bg-3); border-color: var(--gold); }
.hero-sprite { width: 52px; }
.hero-name { font-weight: bold; letter-spacing: 0.04em; }
.hero-class { font-size: 11px; color: var(--ink-dim); }

/* ---------- Programme ---------- */

.prog-head { padding: var(--pad) var(--pad) 0; }
.prog-title { margin: 0; font-size: clamp(18px, 4.5vw, 26px); letter-spacing: 0.06em; }
.prog-sub { margin: 4px 0 0; color: var(--ink-dim); font-size: 13px; }
.prog { margin: 0; padding: 0; list-style: none; }

.prog-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px dotted var(--line);
}

.prog-time { font-weight: bold; color: var(--gold); font-size: 13px; }
.prog-text { min-width: 0; }
.prog-author { font-size: 10px; color: var(--ink-faint); }
.prog-del { grid-column: 3; }
.prog-fixed .prog-text { color: var(--ink); }
.prog-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.field-time { width: 84px; }
.field-grow { flex: 1 1 200px; }

/* ---------- The WIZZ ---------- */

@keyframes wizz {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-6px, 3px) rotate(-0.4deg); }
  20% { transform: translate(7px, -4px) rotate(0.5deg); }
  30% { transform: translate(-8px, -2px) rotate(-0.5deg); }
  40% { transform: translate(6px, 5px) rotate(0.4deg); }
  50% { transform: translate(-5px, 2px); }
  60% { transform: translate(4px, -3px); }
  70% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -1px); }
  90% { transform: translate(-1px, 1px); }
}

body.shake .win { animation: wizz 0.75s ease-in-out 2; }

/* ---------- Wider screens ---------- */

@media (min-width: 720px) {
  body { padding: 24px 16px; }
  .site { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; }
  .site-art { max-width: none; }
  .week-body { grid-template-columns: minmax(0, 1fr) 280px; align-items: center; }
  .prog-item { grid-template-columns: 80px 1fr auto auto; }
}

@media (min-width: 980px) {
  .cols { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .col-side { border-left: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  body.shake .win { animation: none; }
  .hp-fill { transition: none; }
  .boss-hit { box-shadow: none; }
}
