/* Third City: Union paperwork.
   A typed and stamped form on a desk blotter. Ink, paper and the red of a
   rubber stamp; blue for what the Union approves of. No web fonts: the
   stacks below pick the best typewriter, book and slab faces a device has. */

:root {
  --paper: #efe6d2;
  --paper-deep: #e4d9c0;
  --ink: #23201b;
  --ink-soft: #5e5648;
  --rule: #b6a98d;
  --stamp: #a3301c;
  --blue: #23497a;
  --marker: rgba(244, 204, 74, 0.5);
  --desk: #2c352f;
  --desk-deep: #1f2622;
  --shadow: rgba(0, 0, 0, 0.45);

  --type: "Courier Prime", "Courier New", Courier, "Nimbus Mono PS", "Liberation Mono", monospace;
  --book: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --slab: Rockwell, "Rockwell Nova", "Roboto Slab", "Bitstream Charter", "DejaVu Serif", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1e1c18;
    --paper-deep: #282520;
    --ink: #e9dfca;
    --ink-soft: #a89d88;
    --rule: #5a5245;
    --stamp: #e2634b;
    --blue: #8db4e6;
    --marker: rgba(226, 99, 75, 0.28);
    --desk: #101311;
    --desk-deep: #090b0a;
    --shadow: rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--book);
  font-size: 17px;
  line-height: 1.55;
  background: var(--desk-deep);
}

/* ── the desk and the sheet ─────────────────────────────────────────────── */

.desk {
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(0px, 3vw, 36px) clamp(0px, 2.5vw, 28px) 48px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 4px),
    radial-gradient(ellipse at 50% 0%, var(--desk) 0%, var(--desk-deep) 85%);
}

.sheet {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(18px, 3.2vw, 40px) clamp(16px, 3.6vw, 48px) 20px clamp(16px, 5vw, 68px);
  background:
    linear-gradient(90deg, transparent 0 calc(100% - 1px), rgba(0, 0, 0, 0.04) 100%),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(120, 100, 60, 0.035) 27px 28px),
    var(--paper);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 18px 40px -12px var(--shadow), 0 2px 6px var(--shadow);
  transform: rotate(-0.15deg);
}
/* Two punched holes down the left margin, for the Union's ring binders. */
.sheet::before {
  content: "";
  position: absolute;
  left: clamp(4px, 1.6vw, 24px);
  top: 0;
  bottom: 0;
  width: 18px;
  pointer-events: none;
  background:
    radial-gradient(circle at 9px 120px, var(--desk-deep) 0 7px, transparent 8px),
    radial-gradient(circle at 9px calc(100% - 120px), var(--desk-deep) 0 7px, transparent 8px);
}

/* ── letterhead ─────────────────────────────────────────────────────────── */

.letterhead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: end;
  padding-bottom: 12px;
  border-bottom: 3px double var(--ink);
}
.lh-seal { width: 62px; height: 62px; color: var(--stamp); transform: rotate(-8deg); }
.lh-seal .emblem { width: 100%; height: 100%; }
.lh-over {
  margin: 0;
  font-family: var(--type);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.letterhead h1 {
  margin: 0;
  font-family: var(--slab);
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.letterhead h1 a { color: inherit; text-decoration: none; }
.lh-form { text-align: right; font-family: var(--type); font-size: 13px; }
.form-no {
  display: inline-block;
  padding: 2px 8px;
  border: 1.5px solid var(--ink);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lh-nav { margin-top: 8px; display: flex; gap: 14px; justify-content: flex-end; flex-wrap: wrap; }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  font-family: var(--type);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--stamp); }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--stamp); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.typed { font-family: var(--type); font-size: 15px; }
.small { font-size: 13px; color: var(--ink-soft); }
.view { padding-top: 22px; animation: settle 0.35s ease-out both; }
.narrow { max-width: 620px; }
@keyframes settle { from { opacity: 0; transform: translateY(6px); } }

/* ── drawings ───────────────────────────────────────────────────────────── */

.plate { margin: 0 0 14px; }
.plate-art {
  padding: 6px 8px 0;
  border: 1.5px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 3px;
  background: linear-gradient(180deg, transparent 55%, rgba(120, 100, 60, 0.07));
}
.plate figcaption {
  margin-top: 9px;
  font-family: var(--type);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.art { display: block; width: 100%; height: auto; color: var(--ink); }
.art .i, .emblem .i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.art .t, .emblem .t { fill: none; stroke: currentColor; stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.art .s, .emblem .s { fill: currentColor; stroke: none; }
.art .w { fill: currentColor; fill-opacity: 0.1; stroke: none; }
.art .p { fill: var(--paper); stroke: none; }
.art .g { fill: none; stroke: var(--paper); stroke-width: 2; stroke-linecap: round; opacity: 0.4; }
.art .r, .emblem .r { fill: none; stroke: var(--stamp); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.art .rs { fill: var(--stamp); stroke: none; }
.art .lbl { font-family: var(--type); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; fill: currentColor; }
.art .lbl.big { font-size: 15px; letter-spacing: 0.16em; }
.art .lbl.stamp { fill: var(--stamp); font-size: 12px; letter-spacing: 0.14em; }
.emblem { width: 20px; height: 20px; flex: none; }
.emblem .i { stroke-width: 1.8; }

/* ── the front desk ─────────────────────────────────────────────────────── */

.door { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); align-items: start; }
.door-about p { margin: 0 0 12px; }
.masthead { display: block; margin: 0 0 16px; }
.masthead img { display: block; width: 100%; height: auto; }
/* At the front desk the logo is the title, so the typed one steps aside (it stays for screen readers). */
.sheet[data-view="door"] .letterhead h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sheet[data-view="door"] .lh-over { font-size: 14px; padding-bottom: 14px; }

.tabs { display: flex; gap: 0; border-bottom: 1.5px solid var(--ink); }
.tab {
  padding: 7px 14px 6px;
  margin-bottom: -1.5px;
  border: 1.5px solid transparent;
  border-bottom: 0;
  background: none;
  color: var(--ink-soft);
  font-family: var(--type);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--ink); background: var(--paper); font-weight: 700; }
.tab:hover { color: var(--ink); }

.form { padding: 16px 0 6px; }
.form-head {
  margin: 0 0 14px;
  font-family: var(--slab);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.field { display: block; margin: 0 0 12px; padding: 0; border: 0; min-width: 0; }
.field-label {
  display: block;
  padding: 0;
  font-family: var(--type);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field-label em { font-style: normal; text-transform: none; letter-spacing: 0.02em; }
.field-label.strong { color: var(--ink); font-weight: 700; margin-top: 18px; margin-bottom: 8px; }
.field input:not([type="radio"]) {
  width: 100%;
  padding: 7px 2px 5px;
  border: 0;
  border-bottom: 1.5px solid var(--ink);
  border-radius: 0;
  background: linear-gradient(0deg, rgba(120, 100, 60, 0.1), transparent 70%);
  color: var(--blue);
  font-family: var(--type);
  font-size: 18px;
}
.field input:focus { outline: none; background: var(--marker); }
.form-error, .form-ok { margin: 0 0 12px; font-family: var(--type); font-size: 14px; }
.form-error { color: var(--stamp); }
.form-error::before { content: "REJECTED: "; font-weight: 700; letter-spacing: 0.08em; }
.form-ok { color: var(--blue); }

.stamp-btn {
  display: inline-block;
  margin: 4px 0 12px;
  padding: 10px 20px 9px;
  border: 2.5px solid var(--stamp);
  border-radius: 3px;
  background: none;
  color: var(--stamp);
  font-family: var(--slab);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transform: rotate(-1.2deg);
  transition: transform 0.12s, background 0.12s, color 0.12s;
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px var(--stamp);
}
.stamp-btn:hover { background: var(--stamp); color: var(--paper); transform: rotate(-1.2deg) scale(1.03); box-shadow: inset 0 0 0 2px var(--stamp), inset 0 0 0 3px var(--paper); }
.stamp-btn:active { transform: rotate(-1.2deg) scale(0.97); }
.stamp-btn:disabled { opacity: 0.5; cursor: progress; }
.stamp-btn.small { font-size: 14px; padding: 7px 14px 6px; }

.callings { display: grid; gap: 10px; margin-top: 6px; }
.calling { position: relative; display: block; padding: 10px 12px 10px 44px; border: 1.5px solid var(--rule); cursor: pointer; }
.calling:hover { border-color: var(--ink); }
.calling input { position: absolute; opacity: 0; }
.calling::before { content: ""; position: absolute; left: 12px; top: 13px; width: 18px; height: 18px; border: 1.5px solid var(--ink); }
.calling:has(input:checked) { border-color: var(--ink); background: var(--marker); }
.calling:has(input:checked)::after {
  content: "";
  position: absolute;
  left: 15px;
  top: 9px;
  width: 9px;
  height: 17px;
  border: solid var(--stamp);
  border-width: 0 3px 3px 0;
  transform: rotate(40deg);
}
.calling:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.calling-name { font-family: var(--slab); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.calling-blurb { display: block; }
.calling-skill { display: block; font-family: var(--type); font-size: 13px; color: var(--ink-soft); }

/* ── the game: record on the left, scene on the right ───────────────────── */

.game { display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: clamp(18px, 3vw, 38px); align-items: start; }

.quick { display: none; }

.record { display: grid; grid-template-columns: repeat(6, 1fr); border: 1.5px solid var(--ink); border-bottom-width: 0; border-right-width: 0; position: relative; }
.cell { grid-column: span 6; padding: 4px 8px 5px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); min-width: 0; }
.cell.half { grid-column: span 3; }
.cell.third { grid-column: span 2; }
.cell-label { display: block; font-family: var(--type); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-value { display: block; font-family: var(--type); font-size: 15px; font-weight: 700; color: var(--blue); overflow-wrap: anywhere; }
.cell-value.big { font-family: var(--slab); font-size: 30px; line-height: 1; color: var(--ink); }
.cell-value .soft { font-weight: 400; color: var(--ink-soft); }
.cell-title { display: block; font-family: var(--type); font-size: 12px; color: var(--stamp); letter-spacing: 0.04em; }

.bar { height: 10px; margin: 4px 0 2px; border: 1.5px solid var(--ink); background: transparent; }
.bar-fill { height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--ink) 0 2.5px, transparent 2.5px 4px); transition: width 0.35s ease-out; }
.bar.low .bar-fill { background: repeating-linear-gradient(-45deg, var(--stamp) 0 2.5px, transparent 2.5px 4px); }
.bar.spark .bar-fill { background: repeating-linear-gradient(90deg, var(--blue) 0 3px, transparent 3px 5px); }

.ticks { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 2px; }
.tick { width: 9px; height: 9px; border: 1.2px solid var(--ink); }
.tick.on { background: var(--ink); }

.permit {
  position: absolute;
  right: 6px;
  top: 30px;
  padding: 2px 7px;
  border: 2px solid var(--stamp);
  color: var(--stamp);
  font-family: var(--slab);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: center;
  transform: rotate(9deg);
  opacity: 0.88;
  pointer-events: none;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
}

.scene-title {
  display: inline-block;
  margin: 2px 0 12px;
  padding: 4px 12px 3px;
  border: 2.5px solid var(--stamp);
  color: var(--stamp);
  font-family: var(--slab);
  font-size: clamp(19px, 2.6vw, 25px);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.2;
  transform: rotate(-1.4deg);
  transform-origin: left center;
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px var(--stamp);
}
.scene-title.thump { animation: thump 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes thump { from { opacity: 0; transform: rotate(-5deg) scale(1.7); } }

.notice { margin: 0 0 12px; padding: 6px 10px; border-left: 4px solid var(--stamp); background: var(--marker); font-family: var(--type); font-size: 14px; }

.foe { margin: 0 0 12px; max-width: 420px; font-family: var(--type); font-size: 14px; }
.foe-name { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; }

.lines > * { animation: ink 0.3s ease-out both; }
.lines > :nth-child(2) { animation-delay: 0.04s; }
.lines > :nth-child(3) { animation-delay: 0.08s; }
.lines > :nth-child(4) { animation-delay: 0.12s; }
.lines > :nth-child(5) { animation-delay: 0.16s; }
.lines > :nth-child(6) { animation-delay: 0.2s; }
.lines > :nth-child(n + 7) { animation-delay: 0.24s; }
@keyframes ink { from { opacity: 0; transform: translateY(3px); } }

.lines p { margin: 0 0 10px; max-width: 64ch; }
.lines .good { color: var(--blue); font-family: var(--type); font-size: 15px; font-weight: 700; }
.lines .bad { color: var(--stamp); font-family: var(--type); font-size: 15px; font-weight: 700; }
.lines .dim { color: var(--ink-soft); font-family: var(--type); font-size: 14px; }
.lines h3 { margin: 16px 0 6px; font-family: var(--slab); font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase; }
.lines hr { margin: 14px 0; border: 0; border-top: 1.5px dashed var(--rule); }
.lines table { width: 100%; max-width: 640px; margin: 4px 0 12px; border-collapse: collapse; font-family: var(--type); font-size: 14px; }
.lines th { padding: 3px 8px 3px 0; border-bottom: 1.5px solid var(--ink); text-align: left; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); font-weight: 400; }
.lines td { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.lines td:first-child { white-space: nowrap; color: var(--ink-soft); width: 1%; padding-right: 14px; }
.lines tr.mine td { font-weight: 700; color: var(--blue); }
.lines td.num, .lines th.num { text-align: right; padding-right: 0; white-space: nowrap; }

.actions { list-style: none; margin: 16px 0 6px; padding: 12px 0 0; border-top: 3px double var(--ink); max-width: 640px; }
.actions li { margin: 0; }
.act {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 6px 6px 5px 4px;
  border: 0;
  background: linear-gradient(var(--marker), var(--marker)) no-repeat 0 50% / 0% 100%;
  color: var(--ink);
  font-family: var(--type);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: background-size 0.16s ease-out;
}
.act:hover:not(:disabled), .act:focus-visible { background-size: 100% 100%; }
.act .key { flex: none; width: 22px; height: 22px; border: 1.5px solid var(--ink); font-size: 13px; font-weight: 700; line-height: 19px; text-align: center; align-self: center; }
.act .emblem-wrap { display: inline-flex; align-self: center; }
.act .emblem { width: 18px; height: 18px; }
.act .label { font-weight: 700; }
.act .dots { flex: 1; min-width: 12px; border-bottom: 1.5px dotted var(--rule); transform: translateY(-4px); }
.act .note { color: var(--ink-soft); font-size: 13px; text-align: right; }
.act:disabled { cursor: not-allowed; color: var(--ink-soft); }
.act:disabled .label { font-weight: 400; text-decoration: line-through; text-decoration-color: var(--rule); }
.act:disabled .key { border-color: var(--rule); color: var(--rule); }
.act-why { margin: -2px 0 6px 36px; font-family: var(--type); font-size: 12.5px; color: var(--ink-soft); max-width: 60ch; }
.act-input { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 4px; font-family: var(--type); font-size: 16px; flex-wrap: wrap; }
.act-input .key { flex: none; width: 22px; height: 22px; border: 1.5px solid var(--ink); font-size: 13px; font-weight: 700; line-height: 19px; text-align: center; }
.act-input label { font-weight: 700; }
.act-input input { width: 8em; padding: 3px 4px; border: 0; border-bottom: 1.5px solid var(--ink); background: rgba(120, 100, 60, 0.1); color: var(--blue); font-family: var(--type); font-size: 16px; }
.act-input button { padding: 3px 10px; border: 1.5px solid var(--ink); background: none; color: var(--ink); font-family: var(--type); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.act-input button:hover { background: var(--ink); color: var(--paper); }
.busy .act, .busy .act-input button { cursor: progress; }
.keys-hint { margin: 4px 0 0; }

.smallprint {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 30px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-family: var(--type);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.noscript { margin: 20px; color: #fff; font-family: var(--type); }

/* ── admin ──────────────────────────────────────────────────────────────── */

.admin-bar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.admin-bar .field { margin: 0; flex: 1 1 220px; }
.admin-table { width: 100%; border-collapse: collapse; font-family: var(--type); font-size: 13.5px; }
.admin-table th { padding: 4px 8px 4px 0; border-bottom: 1.5px solid var(--ink); text-align: left; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); font-weight: 400; }
.admin-table td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
.admin-table tr.locked td { color: var(--stamp); }
.admin-table .tools { display: flex; gap: 8px; flex-wrap: wrap; }
.mini { padding: 2px 8px; border: 1.5px solid var(--ink); background: none; color: var(--ink); font-family: var(--type); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; }
.mini:hover { background: var(--ink); color: var(--paper); }
.mini.danger { border-color: var(--stamp); color: var(--stamp); }
.mini.danger:hover { background: var(--stamp); color: var(--paper); }
.admin-note { margin: 0 0 14px; padding: 8px 12px; border: 2px solid var(--blue); font-family: var(--type); font-size: 14px; }
.admin-note code { font-size: 18px; font-weight: 700; color: var(--stamp); user-select: all; }
.table-wrap { overflow-x: auto; }

/* ── smaller screens ────────────────────────────────────────────────────── */

@media (max-width: 880px) {
  .door { grid-template-columns: 1fr; }
  .game { grid-template-columns: 1fr; }
  .quick {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 0;
    padding: 6px 10px;
    border: 1.5px solid var(--ink);
    font-family: var(--type);
    font-size: 13px;
    color: var(--ink-soft);
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--paper);
  }
  .quick b { color: var(--blue); }
  .quick .low b { color: var(--stamp); }
  .game .scene { order: 1; }
  .game .record { order: 2; margin-top: 8px; }
  .record { grid-template-columns: repeat(12, 1fr); }
  .cell { grid-column: span 6; }
  .cell.half { grid-column: span 3; }
  .cell.third { grid-column: span 2; }
  .cell.wide-small { grid-column: span 12; }
  .sheet { transform: none; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .letterhead { grid-template-columns: auto 1fr; }
  .lh-form { grid-column: 1 / -1; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
  .lh-nav { margin-top: 0; }
  .lh-seal { width: 46px; height: 46px; }
  .record { grid-template-columns: repeat(6, 1fr); }
  .cell, .cell.wide-small { grid-column: span 6; }
  .cell.half { grid-column: span 3; }
  .cell.third { grid-column: span 2; }
  .act { font-size: 15px; flex-wrap: wrap; }
  .act .dots { display: none; }
  .act .note { flex-basis: 100%; text-align: left; padding-left: 32px; }
  .keys-hint { display: none; }
  .sheet::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
