:root {
  --bg: #0b1020;
  --panel: #141b30;
  --panel-2: #1b2440;
  --line: #2a3557;
  --text: #ebe7df;
  --muted: #9aa3b8;
  --gold: #e0b84f;
  --gold-dim: #a8862f;
  --red: #e5383b;
  --green: #5fbf7f;
  --blue: #6ea8fe;
  --wood: #7a4a26;
  --radius: 10px;
  --pixel: 'Silkscreen', ui-monospace, monospace;
  --body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
}
a {
  color: var(--gold);
}
.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}
h1,
h2,
h3 {
  line-height: 1.2;
}
h1 {
  font-family: var(--pixel);
  font-weight: 400;
  letter-spacing: 0.02em;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  margin: 0.9rem 0 0.3rem;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.9rem;
}
.fineprint {
  color: var(--muted);
  font-size: 0.82rem;
}

/* header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(#141b30, #0f1528);
  border-bottom: 2px solid var(--wood);
  flex-wrap: wrap;
}
.logo {
  font-family: var(--pixel);
  color: var(--gold);
  text-decoration: none;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 18px;
  height: 18px;
  background:
    linear-gradient(var(--gold), var(--gold)) 3px 3px / 12px 6px no-repeat,
    linear-gradient(#a0703a, #a0703a) 8px 9px / 3px 6px no-repeat,
    linear-gradient(var(--gold), var(--gold)) 1px 15px / 16px 3px no-repeat;
  image-rendering: pixelated;
}
.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.nav a:hover,
.nav a.active {
  background: var(--panel-2);
  color: var(--gold);
}
.sim-banner {
  background: #2a1d0b;
  color: #f2d48a;
  text-align: center;
  font-size: 0.8rem;
  padding: 4px 12px;
  font-family: var(--pixel);
  letter-spacing: 0.04em;
}
.foot {
  margin-top: 48px;
  padding-bottom: 32px;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
}

/* panels and forms */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 16px 0;
}
.notice {
  background: #1c2a1f;
  border: 1px solid #355e3b;
  color: #cfe8d2;
  padding: 10px 14px;
  border-radius: 8px;
}
.error {
  background: #3a1416;
  border: 1px solid #7a2a2e;
  color: #ffd6d6;
  padding: 10px 14px;
  border-radius: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover {
  border-color: var(--gold-dim);
}
.btn.primary {
  background: var(--gold);
  color: #1a1306;
  border-color: var(--gold);
  font-weight: 700;
}
.btn.subtle {
  background: transparent;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
label {
  display: block;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.92rem;
}
label.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--text);
}
input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  font: inherit;
  color: var(--text);
  background: #0e1426;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
input[type='checkbox'] {
  width: auto;
  margin-top: 4px;
}
input:focus,
select:focus,
textarea:focus,
.btn:focus-visible,
.nav a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
fieldset.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 10px 0;
  padding: 8px 12px;
}
legend {
  font-family: var(--pixel);
  color: var(--gold);
  font-size: 0.8rem;
}
.row3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.thumb {
  max-width: 160px;
  border-radius: 6px;
  display: block;
  margin: 6px 0;
}
.linkbox {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.linkbox code {
  background: #0e1426;
  padding: 6px 8px;
  border-radius: 6px;
  word-break: break-all;
  font-size: 0.82rem;
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--gold-dim);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 50;
}

/* channel and trial */
.channel-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.channel-head h1 {
  margin-bottom: 0;
  font-size: 1rem;
  color: var(--gold);
}
.channel-head p {
  margin: 0;
}
.intro {
  max-width: 820px;
}
.trial-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.trial-title {
  margin-bottom: 0;
  font-size: clamp(1rem, 1.8vw, 1.4rem);
}
.trial-sub {
  margin-top: 4px;
  font-size: 0.9rem;
}
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.tone-control select {
  display: inline-block;
  width: auto;
}
.trial-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  margin-top: 10px;
  align-items: start;
}
.stage {
  position: relative;
  width: min(100%, calc((100vh - 250px) * 16 / 9));
  justify-self: center;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--wood);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.bug {
  position: absolute;
  top: 3%;
  left: 2%;
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--pixel);
  font-size: clamp(0.55rem, 1.2vw, 0.85rem);
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 10px;
  border-radius: 4px;
}
.bug .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1.2s infinite;
}
.bug.rerun .dot {
  background: var(--blue);
  animation: none;
}
.bug-phase {
  color: var(--gold);
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}
.tone-pill {
  position: absolute;
  top: 3%;
  right: 2%;
  font-family: var(--pixel);
  font-size: clamp(0.5rem, 1vw, 0.75rem);
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--muted);
}
.cost-meter {
  position: absolute;
  top: 11%;
  right: 2%;
  font-family: var(--pixel);
  font-size: clamp(0.45rem, 0.9vw, 0.65rem);
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--muted);
}
.offrec {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--pixel);
  color: #ffd27a;
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 10px;
  border-radius: 4px;
  font-size: clamp(0.55rem, 1.1vw, 0.8rem);
}
.lower-third {
  position: absolute;
  left: 3%;
  bottom: 22%;
  background: linear-gradient(90deg, #8b1e2d, #5b1420);
  border-left: 6px solid var(--gold);
  padding: 4px 14px 5px;
  max-width: 60%;
}
.lt-name {
  font-family: var(--pixel);
  font-size: clamp(0.6rem, 1.4vw, 1rem);
}
.lt-role {
  font-size: clamp(0.55rem, 1vw, 0.8rem);
  color: #f2d9b3;
}
.caption {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 5%;
  min-height: 1.6em;
  text-align: center;
  font-size: clamp(0.75rem, 1.7vw, 1.15rem);
  text-shadow:
    0 1px 2px #000,
    0 0 6px #000;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 6px;
  padding: 4px 10px;
}
.caption:empty {
  display: none;
}
.caption.filler {
  font-style: italic;
  color: var(--muted);
}
.banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  font-family: var(--pixel);
  font-size: clamp(1.4rem, 6vw, 4rem);
  color: #fff;
  background: var(--red);
  padding: 4px 22px;
  border: 4px solid #fff;
  animation: slam 0.25s ease-out;
}
@keyframes slam {
  from {
    transform: translateX(-50%) rotate(-4deg) scale(1.8);
    opacity: 0;
  }
}
.stamp {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%) rotate(-8deg);
  font-family: var(--pixel);
  font-size: clamp(1rem, 4vw, 2.6rem);
  padding: 2px 16px;
  border: 4px solid currentColor;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  animation: slam 0.2s ease-out;
}
.stamp.sustained {
  color: #ff8f8f;
}
.stamp.overruled {
  color: #9fe0b0;
}
.title-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: radial-gradient(rgba(10, 14, 30, 0.82), rgba(10, 14, 30, 0.95));
  text-align: center;
  padding: 5%;
  animation: fade 0.4s ease-out;
}
.card-title {
  font-family: var(--pixel);
  color: var(--gold);
  font-size: clamp(1.1rem, 4vw, 2.8rem);
}
.card-line {
  font-size: clamp(0.65rem, 1.4vw, 1rem);
  color: var(--text);
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.exhibit-pop {
  position: absolute;
  top: 8%;
  right: 3%;
  width: min(42%, 420px);
  max-height: 62%;
  overflow: hidden;
  background: #f4efe1;
  color: #1d1a14;
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: fade 0.3s ease-out;
  font-size: clamp(0.6rem, 1.1vw, 0.85rem);
}
.exhibit-pop img {
  max-width: 100%;
  max-height: 160px;
  display: block;
  margin: 6px 0;
}
.ex-id {
  font-family: var(--pixel);
  color: #8b1e2d;
}
.ex-title {
  font-weight: 700;
}
.vote-board {
  position: absolute;
  top: 9%;
  right: 6%;
  width: min(34%, 300px);
  background: #f7f7f2;
  color: #1b1b1b;
  border: 3px solid #cfcfcf;
  border-radius: 4px;
  padding: 6px 10px;
  font-family: var(--pixel);
  font-size: clamp(0.5rem, 1vw, 0.78rem);
}
.vb-title {
  color: #1d3f8a;
  margin-bottom: 4px;
}
.vb-row {
  display: grid;
  grid-template-columns: 2.5em 1fr auto;
  gap: 6px;
}
.vb-row .ok {
  color: #2f7d46;
}
.vb-row .open {
  color: #a0522d;
}
.stage-status {
  position: absolute;
  inset: auto 0 45% 0;
  text-align: center;
  font-family: var(--pixel);
  font-size: clamp(0.6rem, 1.2vw, 0.9rem);
  color: var(--gold);
  text-shadow: 0 1px 3px #000;
}
.sound {
  position: absolute;
  right: 2%;
  bottom: 18%;
  font-size: clamp(0.6rem, 1vw, 0.85rem);
  background: rgba(0, 0, 0, 0.6);
}
.side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: min(calc(100vh - 250px), calc((100vw - 32px - 376px) * 9 / 16));
}
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1;
  background: none;
  color: var(--muted);
  border: 0;
  padding: 10px 6px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.view-toggle {
  font-size: 0.78rem;
  margin: 8px 12px;
}
.panes {
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
}
.pane {
  overflow-y: auto;
  padding: 4px 12px 12px;
  flex: 1;
}
.transcript {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.86rem;
}
.tr {
  padding: 5px 0;
  border-bottom: 1px solid #1f2843;
  display: grid;
  grid-template-columns: 3.2em 1fr;
  column-gap: 6px;
}
.tr-time {
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 0.7rem;
  padding-top: 2px;
  grid-row: span 2;
}
.tr-who {
  color: var(--gold);
  font-weight: 700;
}
.tr.off-record,
.tr.filler {
  opacity: 0.7;
  font-style: italic;
}
.tr.jury-room .tr-who {
  color: var(--blue);
}
.tr.objection .tr-text,
.tr.ruling .tr-text {
  font-weight: 700;
}
.tr-card {
  font-family: var(--pixel);
  color: var(--gold-dim);
  font-size: 0.72rem;
  padding: 8px 0 2px;
}
.ex-card img {
  max-width: 100%;
  border-radius: 6px;
}
.ex-card pre {
  white-space: pre-wrap;
  font-size: 0.8rem;
  background: #0e1426;
  padding: 8px;
  border-radius: 6px;
}
.jp-round h3 {
  font-size: 0.95rem;
  color: var(--gold);
}
.jp-round p {
  font-size: 0.84rem;
  margin: 4px 0;
}
.vf li {
  margin: 4px 0;
}
.verdict-panel h2 {
  font-family: var(--pixel);
  color: var(--gold);
}

/* docket and roster */
.docket {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.docket-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.docket-card:hover {
  border-color: var(--gold-dim);
}
.roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.lawyer h2 {
  margin: 8px 0 0;
  font-size: 1.1rem;
}
.portrait {
  width: 96px;
  height: 102px;
  image-rendering: pixelated;
  border-radius: 8px;
  border: 2px solid var(--wood);
}
.prose h2 {
  font-size: 1.1rem;
  color: var(--gold);
  margin-top: 1.4em;
}

@media (max-width: 960px) {
  .trial-grid {
    grid-template-columns: 1fr;
  }
  .stage {
    width: 100%;
  }
  .side {
    height: 420px;
  }
  .row3 {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  .banner,
  .stamp,
  .title-card,
  .exhibit-pop,
  .bug .dot {
    animation: none;
  }
}
