:root {
  color-scheme: dark;
  font-family: Arial, sans-serif;
  background: #001153;
  color: white;
  --navy: #001153;
  --panel: #28366d;
  --panel-light: #424f85;
  --blue: #0069d2;
  --line: rgba(255,255,255,.15);
  --text-muted: rgba(255,255,255,.72);
}
* { box-sizing: border-box; }
body { margin: 0; }
body.control-page { min-width: 0; overflow: hidden; background: #000; min-height: 100dvh; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: #dbe9ff; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #ffcf48; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

.director-viewport { position: fixed; inset: 0; overflow: hidden; background: #000; }
.director-canvas { position: absolute; top: 50%; left: 50%; translate: -50% -50%; background: var(--navy); }
.director.director-page {
  width: 100%; height: 100%; max-width: none; padding: 26px 32px 30px;
  display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 18px;
}
.director .topbar { margin: 0; gap: 1rem; }
.director .panel-header, .director .navigation { gap: .65rem; }
.console-grid { display: grid; grid-template-columns: 610px 516px minmax(0, 1fr); gap: 18px; min-height: 0; }
.console-left { min-height: 0; display: grid; grid-template-rows: 390px minmax(0, 1fr); gap: 18px; }
.director .panel { min-width: 0; min-height: 0; }
.director .control, .director .live-table { overflow: auto; }
.panel-top { margin-bottom: 1rem; }
.current-stage { padding: .85rem; background: var(--panel-light); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.current-stage p, .stage-note { color: var(--text-muted); }
.current-stage h3 { font-size: 1.2rem; margin-top: .25rem; }
.stage-note { margin: .7rem 0 0; line-height: 1.4; }
.live-status, .lost-status { display: inline-flex; align-items: center; gap: .4rem; font-size: .875rem; }
.live-status::before, .lost-status::before { content: ''; background: #00b050; border-radius: 50%; width: .5rem; height: .5rem; }
.lost-status::before { background: #ff3b4d; }
.director .next { min-height: 42px; height: auto; padding: .65rem; width: 100%; margin-top: .8rem; text-align: left; white-space: normal; }
.next-question { display: grid; gap: .4rem; margin-top: .8rem; }
.next-question select { min-width: 0; text-overflow: ellipsis; }
.live-table .panel-top span { color: var(--text-muted); font-size: .875rem; }
.live-table .r1-score-table { width: 100%; margin: 0; }
.live-table .r1-score { grid-template-columns: 2.6rem minmax(0, 1fr) 2.25rem; font-size: .9rem; }
.live-table .r1-score span { min-height: 26px; padding-block: 2px; }
.director button:disabled { opacity: .6; }
.clock { color: #ffc000; font-variant-numeric: tabular-nums; }
.director-clock { white-space: nowrap; font-size: 1.4rem; font-weight: bold; }
.log ol { padding: 0; margin: 0; list-style: none; }
.log li { display: grid; grid-template-columns: auto 1fr; gap: .65rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.log time { color: var(--text-muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.log li.undone span { color: var(--text-muted); text-decoration: line-through; }
.log li.undone small { display: inline-block; text-decoration: none; }
.undo-confirm { background: #493b24; padding: .6rem; margin-bottom: .75rem; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }
.notice { padding: .6rem; margin: .65rem 0; background: #552d43; color: #ffe4df; }
.audience-panel { display: flex; flex-direction: column; }
.audience-screen { background: var(--navy); flex: 1; min-height: 0; overflow: auto; padding: .55rem; }
.audience-screen .r1-board, .audience-screen .r1-score-table, .audience-screen .r1-qualified { width: 100%; margin: 0; }
.audience-screen .r1-question { min-height: 3.2rem; font-size: 1.1rem; }
.audience-screen .r1-answer { min-height: 2.1rem; font-size: 1rem; grid-template-columns: 2.2rem 1fr; }
.audience-screen .r1-score span { min-height: 25px; padding-block: 2px; }
.audience-wait { padding: 1.2rem; background: var(--panel); text-align: center; }
.activity-panel { display: flex; flex-direction: column; }
.activity-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 14px; }
.activity-tabs button { border: 0; min-height: 42px; background: var(--panel-light); color: white; font-weight: bold; }
.activity-tabs button[aria-selected="true"] { background: var(--blue); }
.activity-content { flex: 1; min-height: 0; overflow: auto; }
.director [hidden] { display: none !important; }
.media-preload { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.director-media { margin-top: .5rem; }
.director-media video { display: block; width: 100%; max-height: 190px; }
.table-prompt { color: #241900; background: #ffc000; padding: .65rem; margin: .65rem 0; text-align: center; font-weight: bold; animation: pulse-table 1s infinite alternate; }
@keyframes pulse-table { to { background: #e1a600; } }
.screen { min-height: 100dvh; }
.screen-header { display: flex; justify-content: space-between; gap: .6rem; padding: .65rem clamp(.6rem, 4vw, 2rem); background: var(--panel); }
.screen-header span:first-child { font-weight: bold; }
.screen-body { max-width: 1180px; margin: auto; padding: .75rem; }
.screen-wait { text-align: center; padding: clamp(1rem, 10vh, 6rem) 1rem; }
.screen-wait h1 { font-size: clamp(1.1rem, 4vw, 1.65rem); }
.screen-wait p { margin-top: .65rem; }
.embedded .screen-header { padding: .5rem; font-size: .875rem; }
.embedded .screen-body { padding: .4rem; }
.embedded .r1-media img, .embedded .r1-media video { max-height: 92px; }
.embedded .r1-score span { min-height: 23px; padding-block: 2px; }

.login { width: min(90%, 360px); background: var(--panel); margin: 8vh auto; padding: 20px; }
.login h1 { font-size: 1.5rem; margin-bottom: .8rem; }
.login form, .login label { display: grid; gap: .4rem; }
.login form { gap: .75rem; }
.login [hidden] { display: none; }
.login a { color: inherit; }
.login input, .login button, .screen .secondary-action { background: var(--panel-light); border: 0; color: white; padding: .55rem; }
.login .primary { background: var(--blue); }
.login .notice { margin: 0; }
@media (prefers-reduced-motion: reduce) { .table-prompt { animation: none; } }

.answer-review-list { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.review-item {
  display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1fr) 157px;
  align-items: center; gap: .55rem; min-width: 0; min-height: 64px;
  padding: .42rem .55rem; background: var(--panel-light);
}
.review-person, .review-content { display: grid; min-width: 0; gap: .2rem; }
.review-item strong, .review-answer { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-state { display: inline-flex; align-items: center; gap: .4rem; color: #ffd2d6; font-size: .85rem; white-space: nowrap; }
.connection-state::before { content: ''; background: #ff6e79; width: .48rem; height: .48rem; border-radius: 50%; flex: 0 0 auto; }
.connection-state.online { color: #b4ffd4; }
.connection-state.online::before { background: #45e48c; }
.connection-state.hidden-tab { color: #ffe591; }
.connection-state.hidden-tab::before { background: #ffc000; }
.review-result.correct, .review-result.credited { color: #afffd0; }
.review-result.wrong { color: #ffd3d7; }
.review-action { display: grid; justify-items: start; gap: .25rem; }
.review-action a { font-size: .875rem; }
.review-item .secondary-action { padding: .25rem .45rem; font-size: .8rem; text-align: left; }
.audience-screen .r1-answers { grid-template-columns: 1fr; }
.audience-screen .r1-score { grid-template-columns: 2.7rem minmax(0, 1fr) 2.5rem; font-size: 1rem; }
.audience-screen .r1-qualified li { grid-template-columns: 2.6rem minmax(0, 1fr); font-size: 1rem; }

.comment-request { display: block; margin: .75rem auto; }
.live-table .r1-score { grid-template-columns: 2.6rem minmax(0, 1fr) 4rem; }
.live-table .r1-score > :last-child { padding: 0; }
.live-table .score-editor {
  width: 100%;
  min-height: 26px;
  padding: 2px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
}
.live-table button.score-editor:not(:disabled) { cursor: pointer; }
.live-table .score-editor:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
