:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18212c;
  background: #f1f4f7;
  font-synthesis: none;
  --navy: #153246;
  --teal: #13748a;
  --line: #d7e0e7;
  --muted: #617181;
  --panel: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
.site-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem); color: #fff; background: var(--navy);
}
.site-header h1 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.7rem); }
.eyebrow { margin: 0 0 .2rem; color: #a8d8e0; font-size: .7rem; letter-spacing: .14em; }
.header-actions, .player-actions, .playback-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
main { width: min(1600px, 100%); margin: 0 auto; padding: 1rem; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 5px 20px #132c3c0c; }
.catalogue-panel { padding: 1rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
h2, h3, p { margin-top: 0; }
h2 { margin-bottom: .2rem; font-size: 1.15rem; }
h3 { margin-bottom: .6rem; }
.muted { color: var(--muted); font-size: .9rem; }
.error { color: #a3342c !important; }
.section-heading .muted { margin-bottom: 0; }
.search-controls { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin-bottom: .8rem; }
.search-controls label:not(.check-control) { display: grid; gap: .3rem; color: #4b5b6a; font-size: .8rem; }
.search-field { flex: 1 1 230px; }
input[type="search"], input[type="text"], select {
  width: 100%; min-height: 40px; padding: .5rem .65rem; border: 1px solid #bdcad4; border-radius: 7px; color: #18212c; background: #fff;
}
input:focus, select:focus, button:focus-visible { outline: 3px solid #49a6bb70; outline-offset: 1px; }
.check-control { display: inline-flex; align-items: center; gap: .45rem; min-height: 40px; color: #344656; font-size: .88rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--teal); }
.table-scroll { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { padding: .55rem .65rem; text-align: left; border-bottom: 1px solid #e7edf1; }
th { position: sticky; z-index: 1; top: 0; color: #3c4e5d; background: #f5f8fa; font-size: .78rem; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f3fafb; }
tbody tr[aria-selected="true"] { background: #e4f4f6; }
.empty-cell { padding: 1.2rem; color: var(--muted); text-align: center; }
.results-count { margin: .6rem 0 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .8fr); align-items: start; gap: 1rem; margin-top: 1rem; }
.player-panel, .referee-panel { padding: 1rem; }
.player-heading { align-items: center; }
.player-heading > div:first-child { min-width: 200px; }
#selected-link { max-width: 65ch; overflow-wrap: anywhere; }
.player-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #111; border-radius: 8px; }
#stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
#player, #player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
#transition { position: absolute; inset: 0; z-index: 2; opacity: 0; background: #111; transition: opacity 120ms ease-out; pointer-events: none; }
#transition.visible { opacity: 1; }
#transition img { width: 100%; height: 100%; object-fit: contain; }
.player-message { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; padding: 1rem; color: #e8edf0; text-align: center; pointer-events: none; }
.playback-controls { justify-content: flex-start; margin-top: .75rem; }
.button { min-height: 38px; padding: .48rem .72rem; border: 1px solid transparent; border-radius: 7px; cursor: pointer; font-weight: 650; font-size: .84rem; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { color: #fff; background: var(--teal); }
.button-primary:hover:not(:disabled) { background: #0d5e70; }
.button-secondary { color: #233746; border-color: #cbd6de; background: #fff; }
.button-secondary:hover:not(:disabled) { background: #eff6f8; }
.button-danger { color: #873a32; border-color: #e6c5c1; background: #fff; }
.referee-panel[hidden], .vote-results[hidden] { display: none; }
.referee-panel fieldset { margin: .8rem 0; padding: .7rem; border: 1px solid var(--line); border-radius: 8px; }
.referee-panel legend { padding: 0 .3rem; font-weight: 700; font-size: .9rem; }
.choice-row, .choice-grid { display: flex; flex-wrap: wrap; gap: .55rem; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.choice-item { display: inline-flex; align-items: center; gap: .42rem; min-height: 32px; color: #344656; font-size: .88rem; }
.field-label { display: grid; gap: .35rem; margin: .7rem 0; color: #344656; font-size: .88rem; }
.certainty-label { display: flex; justify-content: space-between; align-items: center; font-weight: 650; }
.certainty-label span { color: var(--teal); }
.range-row { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .8rem; }
.range-row input { flex: 1; accent-color: var(--teal); }
.official-control { margin: .5rem 0; font-weight: 700; }
.status-message { min-height: 1.3em; margin: .5rem 0; color: var(--teal); font-size: .9rem; }
.status-message.error { color: #a3342c; }
.vote-results { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.result-section { margin: .8rem 0; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(80px, 1.4fr) auto; align-items: center; gap: .5rem; margin: .35rem 0; font-size: .8rem; }
.bar-track { height: 9px; overflow: hidden; border-radius: 99px; background: #e6edf1; }
.bar-fill { height: 100%; background: var(--teal); }
.bar-value { min-width: 70px; color: #536575; text-align: right; }
.official-decision { padding: .7rem; border-radius: 7px; background: #eef7f8; }
dialog { width: min(420px, calc(100% - 2rem)); padding: 1rem; border: 1px solid var(--line); border-radius: 12px; color: #18212c; box-shadow: 0 15px 60px #071b2c55; }
dialog::backdrop { background: #101d28a8; }
dialog h2 { margin-bottom: .5rem; }
dialog p { color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: .6rem; padding: 1rem clamp(1rem, 3vw, 2.5rem); color: var(--muted); font-size: .78rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
body.fullsize-mode #catalogue-section, body.fullsize-mode #referee-panel { display: none; }
body.fullsize-mode #workspace { display: block; margin: 0; }
body.fullsize-mode main { width: 100%; padding: .5rem; }
body.fullsize-mode #player-panel { height: calc(100vh - 1rem); display: flex; flex-direction: column; }
body.fullsize-mode #player-frame { flex: 1; min-height: 0; aspect-ratio: auto; }
body.fullsize-mode .player-heading { flex-wrap: wrap; }
body.fullsize-mode .player-heading > div:first-child { display: flex; align-items: baseline; gap: .8rem; }
body.fullsize-mode #selected-link { margin: 0; }
body.fullsize-mode footer { display: none; }
body.referee-mode #catalogue-section { display: none; }
body.referee-mode #workspace { grid-template-columns: minmax(0, 1fr) minmax(340px, .85fr); margin-top: 0; }
@media (max-width: 900px) {
  .workspace, body.referee-mode #workspace { grid-template-columns: 1fr; }
  .player-actions { gap: .4rem; }
  .table-scroll { max-height: 320px; }
}
@media (max-width: 600px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  main { padding: .65rem; }
  .catalogue-panel, .player-panel, .referee-panel { padding: .75rem; }
  .section-heading { flex-direction: column; }
  .player-heading { flex-direction: column; align-items: stretch; }
  .player-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .player-actions .button { width: 100%; }
  .search-controls { align-items: stretch; flex-direction: column; }
  .search-controls > * { width: 100%; }
  .bar-row { grid-template-columns: minmax(80px, 1fr) minmax(50px, .8fr) auto; gap: .3rem; }
  footer { flex-direction: column; }
}
body.referee-mode #random-button {
  display: none;
}
body.referee-mode #referee-mode-button {
  display: none;
}