*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #071018;
  color: var(--cream);
  font-family: var(--body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

:root, body.desk-america {
  --sky: #0b1c33;
  --sky-mid: #13263f;
  --deep: #071018;
  --metal: #d4b56a;
  --metal-deep: #b8923e;
  --cream: #f4efe4;
  --paper: #f7f1e4;
  --ink: #142033;
  --muted: #5c6a7a;
  --stone: #1a2d48;
  --display: Didot, "Bodoni MT", "Bodoni 72", "New Century Schoolbook", "Times New Roman", serif;
  --body: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Times New Roman", serif;
  --ui: "Avenir Next Condensed", "Century Gothic", Futura, "Gill Sans", "Gill Sans MT", "Segoe UI", sans-serif;
}

body.desk-ontario {
  --sky: #1c2428;
  --sky-mid: #12181b;
  --deep: #0e1416;
  --metal: #c4895a;
  --metal-deep: #9a6840;
  --cream: #f3eee4;
  --paper: #f4efe6;
  --ink: #1a221c;
  --muted: #6a736c;
  --stone: #242c30;
  --moss: #3d5a4c;
  --display: "Big Caslon", "Calisto MT", Calisto, Garamond, "Palatino Linotype", Palatino, serif;
  --body: "Palatino Linotype", Palatino, "Book Antiqua", "Times New Roman", serif;
  background: #0e1416;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  cursor: pointer;
  touch-action: none;
}

#hud {
  position: fixed;
  top: max(0.7rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  padding: 0.28rem 0.7rem 0.22rem;
  font-family: var(--ui);
  font-size: clamp(0.78rem, 2.4vw, 1.05rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--metal);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  border: 1px solid rgba(212, 181, 106, 0.28);
  background: rgba(7, 16, 24, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.desk-ontario #hud {
  border-color: rgba(196, 137, 90, 0.32);
}

#mute {
  position: fixed;
  top: max(0.65rem, env(safe-area-inset-top));
  right: max(0.65rem, env(safe-area-inset-right));
  z-index: 8;
  font-family: var(--ui);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream);
  background: rgba(7, 16, 24, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 0.38rem 0.55rem;
  cursor: pointer;
  opacity: 0.85;
}

#mute:hover, #mute:focus-visible {
  opacity: 1;
  border-color: var(--metal);
  outline: none;
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(7, 16, 24, 0.5);
  overflow: auto;
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#overlay.is-open { display: flex; }

.card {
  position: relative;
  width: min(28rem, 100%);
  max-height: calc(100dvh - 2.4rem);
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--metal);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  padding: 1.55rem 1.6rem 1.2rem;
  touch-action: auto;
}

.card .corner {
  position: absolute;
  top: 0.7rem;
  right: 0.85rem;
  margin: 0;
}

.card .corner a,
#site-footer a {
  color: inherit;
  text-underline-offset: 2px;
}

.card .corner a {
  font-family: var(--ui);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

#card-seal {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--metal);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  background: var(--cream);
  margin: 0.1rem 0 0.7rem;
}

.kicker {
  margin: 0;
  font-family: var(--ui);
  font-size: 0.64rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--metal-deep);
}

h1 {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.45rem, 4.2vw, 2.05rem);
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--ink);
}

body.desk-ontario h1 {
  font-style: normal;
}

.rule {
  margin: 0.75rem 0 0.85rem;
  height: 0;
  border: 0;
  border-top: 1px solid var(--metal);
  width: 4.2rem;
}

#card-copy {
  margin: 0 0 1.15rem;
  font-size: 1.02rem;
  line-height: 1.5;
}

ol.docket {
  list-style: none;
  margin: 0 0 1.05rem;
  padding: 0.4rem 0.7rem 0.35rem;
  border: 1px solid var(--metal);
  background: var(--cream);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

ol.docket[hidden],
.clerk-wrap[hidden] {
  display: none !important;
}

ol.docket li {
  display: grid;
  grid-template-columns: 1.7em 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  margin: 0;
  padding: 0.28rem 0;
  font-family: var(--ui);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid rgba(184, 146, 62, 0.22);
}

ol.docket li:last-child {
  border-bottom: 0;
}

.docket-rank {
  color: var(--metal-deep);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.docket-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docket-score {
  color: var(--metal-deep);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
}

body.desk-ontario ol.docket li {
  border-bottom-color: rgba(154, 104, 64, 0.28);
}

.clerk-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.38rem;
  margin: 0 0 1rem;
  font-family: var(--ui);
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--metal-deep);
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
}

#clerk-name {
  display: block;
  width: 100%;
  font-family: var(--body);
  font-size: 1.02rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--metal);
  padding: 0.55rem 0.65rem;
  outline: none;
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
}

#clerk-name:focus,
#clerk-name:focus-visible {
  border-color: var(--metal-deep);
  box-shadow: 0 0 0 2px rgba(184, 146, 62, 0.28);
}

body.desk-ontario #clerk-name:focus,
body.desk-ontario #clerk-name:focus-visible {
  box-shadow: 0 0 0 2px rgba(154, 104, 64, 0.3);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

#card-action,
#card-retry {
  display: inline-block;
  font-family: var(--ui);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.72rem 1.15rem;
  cursor: pointer;
  border: 1px solid var(--metal);
}

#card-action {
  color: var(--cream);
  background: var(--sky);
}

#card-retry {
  color: var(--ink);
  background: var(--cream);
}

#card-retry[hidden] {
  display: none !important;
}

#card-action:hover, #card-action:focus-visible {
  background: var(--sky-mid);
  outline: 2px solid var(--metal);
  outline-offset: 2px;
}

#card-retry:hover, #card-retry:focus-visible {
  background: var(--paper);
  outline: 2px solid var(--metal);
  outline-offset: 2px;
}

#card-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

.legal, #site-footer {
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--muted);
}

.legal {
  margin: 1rem 0 0;
}

#site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  padding: 0.45rem 0.8rem calc(0.45rem + env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(244, 239, 228, 0.78);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(7, 16, 24, 0.55));
}

#site-footer a { pointer-events: auto; color: rgba(244, 239, 228, 0.9); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
