:root {
  color-scheme: light;
  --ink: #17191b;
  --muted: #62676c;
  --line: #d8dadd;
  --paper: #f4f4f1;
  --surface: #ffffff;
  --red: #b6382e;
  --red-dark: #8e2821;
  --teal: #18746c;
  --gold: #b9871c;
  --blue: #2c6194;
  --radius: 6px;
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(44, 97, 148, 0.32);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.eyebrow,
.section-index,
.stage-number {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand-mark {
  align-items: center;
  background: var(--red);
  color: white;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.connection-state {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.76rem;
  gap: 6px;
}

.connection-state::before {
  background: var(--gold);
  border-radius: 50%;
  content: "";
  height: 7px;
  width: 7px;
}

.connection-state.connected::before {
  background: var(--teal);
}

.primary-command,
.secondary-command,
.danger-command,
.danger-outline-command,
.icon-command {
  align-items: center;
  border-radius: var(--radius);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
}

.primary-command {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: white;
}

.primary-command:hover:not(:disabled) {
  background: #303336;
}

.secondary-command {
  background: var(--surface);
  border: 1px solid #aeb2b6;
}

.secondary-command:hover:not(:disabled) {
  background: #ececea;
}

.danger-command {
  background: var(--red);
  border: 1px solid var(--red);
  color: white;
}

.danger-command:hover:not(:disabled) {
  background: var(--red-dark);
}

.danger-command.resume-command {
  background: var(--teal);
  border-color: var(--teal);
}

.danger-outline-command {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
}

.icon-command {
  background: transparent;
  border: 1px solid var(--line);
  font-size: 1.1rem;
  min-width: 38px;
  padding: 5px;
}

.text-link {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-feedback {
  color: var(--muted);
  font-size: 0.83rem;
  margin: 10px 0 0;
  min-height: 1.2em;
}

.form-feedback.success {
  color: var(--teal);
}

.form-feedback.error {
  color: var(--red);
}

/* Audience */

.audience-shell {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  min-height: 100dvh;
  max-width: 560px;
}

.audience-header,
.audience-footer {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 18px 20px;
}

.audience-header {
  border-bottom: 1px solid var(--line);
}

.audience-header h1 {
  font-size: 1.2rem;
  margin: 0;
}

.audience-stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 26px 20px;
}

.audience-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
}

.audience-message {
  border-left: 4px solid var(--red);
  padding: 10px 0 10px 20px;
}

.audience-message h2,
.audience-prompt h2,
.audience-result h2 {
  font-size: 1.8rem;
  line-height: 1.3;
  margin: 6px 0 10px;
  overflow-wrap: anywhere;
}

.audience-message p,
.audience-prompt > p:not(.stage-number) {
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

.screen-helper {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
  margin-top: 8px;
}

.message-code {
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 800;
}

.audience-prompt {
  margin-bottom: 20px;
}

.comment-form {
  display: grid;
  gap: 12px;
}

.comment-input-wrap {
  position: relative;
}

.comment-input-wrap textarea {
  border: 1px solid #aeb2b6;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 118px;
  padding: 14px 14px 32px;
  resize: vertical;
  width: 100%;
}

.comment-input-wrap span {
  bottom: 9px;
  color: var(--muted);
  font-size: 0.72rem;
  position: absolute;
  right: 10px;
}

.comment-form > button {
  background: var(--red);
  border: 0;
  border-radius: var(--radius);
  color: white;
  font-weight: 800;
  min-height: 50px;
}

.vote-options {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.vote-option {
  background: var(--surface);
  border: 1px solid #bfc2c5;
  border-radius: var(--radius);
  display: grid;
  grid-template-rows: 110px minmax(48px, auto);
  overflow: hidden;
  padding: 0;
  text-align: left;
}

.vote-option:hover:not(:disabled) {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(182, 56, 46, 0.12);
}

.vote-option img {
  height: 110px;
  object-fit: cover;
  width: 100%;
}

.option-placeholder,
.image-placeholder {
  align-items: center;
  background: #e7e7e3;
  color: #71757a;
  display: flex;
  font-size: 1.8rem;
  font-weight: 800;
  justify-content: center;
  min-height: 110px;
}

.vote-option-label {
  align-items: center;
  display: flex;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
  padding: 10px;
}

.audience-result {
  text-align: center;
}

.audience-result img,
.audience-result .image-placeholder {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  max-height: 320px;
  object-fit: cover;
  width: 100%;
}

.audience-result > p:not(.stage-number) {
  color: var(--muted);
  margin: 18px 0 0;
}

/* Authentication */

.auth-gate {
  align-items: center;
  background: #e9e9e6;
  display: flex;
  inset: 0;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  position: fixed;
  z-index: 100;
}

.auth-dialog {
  background: var(--surface);
  border-top: 5px solid var(--red);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  max-width: 380px;
  padding: 28px;
  width: 100%;
}

.auth-dialog h1 {
  font-size: 1.6rem;
  margin: 4px 0 24px;
}

.auth-dialog label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 7px;
}

.auth-dialog input {
  border: 1px solid #aeb2b6;
  border-radius: var(--radius);
  font-size: 1.25rem;
  margin-bottom: 14px;
  padding: 11px 12px;
  width: 100%;
}

.auth-dialog button {
  width: 100%;
}

/* Admin */

.admin-shell {
  min-height: 100dvh;
}

.admin-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.admin-header-actions {
  align-items: center;
  display: flex;
  gap: 14px;
}

.control-layout {
  margin: 0 auto;
  max-width: 1440px;
  padding: 20px 24px 50px;
}

.control-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 18px;
}

.section-heading {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-heading h2 {
  font-size: 1rem;
  margin: 0;
}

.phase-band {
  align-items: center;
  display: grid;
  gap: 20px;
  grid-template-columns: 150px minmax(0, 1fr);
}

.phase-band .section-heading {
  margin: 0;
}

.phase-switch {
  display: grid;
  grid-template-columns: repeat(7, minmax(74px, 1fr));
  min-width: 0;
}

.phase-switch button {
  background: #f7f7f5;
  border: 1px solid var(--line);
  border-right: 0;
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 42px;
  padding: 7px 8px;
}

.phase-switch button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.phase-switch button:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-right: 1px solid var(--line);
}

.phase-switch button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.visibility-summary {
  border-top: 1px solid var(--line);
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-top: 14px;
}

.visibility-summary > div {
  border-right: 1px solid var(--line);
  min-width: 0;
  padding: 0 14px;
}

.visibility-summary > div:first-child {
  padding-left: 0;
}

.visibility-summary > div:last-child {
  border-right: 0;
}

.visibility-summary span,
.judge-context span {
  color: var(--muted);
  display: block;
  font-size: 0.68rem;
  margin-bottom: 4px;
}

.visibility-summary strong,
.judge-context strong {
  display: block;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.phase-badge,
.metric,
.status-pill {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.phase-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
}

.control-columns {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 330px;
}

.poll-workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: 250px minmax(0, 1fr);
}

.poll-list {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 14px;
}

.poll-list-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  display: grid;
  gap: 8px;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  min-height: 50px;
  padding: 8px;
  text-align: left;
}

.poll-list-item:hover,
.poll-list-item.active {
  background: #eeeeeb;
}

.poll-list-item.active {
  border-left-color: var(--red);
}

.poll-list-item > span,
.poll-list-item small {
  color: var(--muted);
  font-size: 0.7rem;
}

.poll-list-item strong {
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.poll-console {
  min-width: 0;
}

.poll-summary-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.poll-summary-heading h3 {
  font-size: 1.15rem;
  line-height: 1.45;
  margin: 7px 0 12px;
  overflow-wrap: anywhere;
}

.status-pill {
  color: var(--teal);
}

.status-pill.judge {
  color: var(--gold);
}

.status-pill.skipped {
  color: var(--muted);
}

.poll-option-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 4px 0 14px;
}

.poll-option-strip > div {
  border: 1px solid var(--line);
  min-width: 0;
}

.poll-option-strip img,
.poll-option-strip > div > span {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: #e8e8e4;
  display: flex;
  height: auto;
  justify-content: center;
  object-fit: cover;
  width: 100%;
}

.poll-option-strip small {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
  min-height: 42px;
  overflow-wrap: anywhere;
  padding: 7px;
}

.poll-results {
  border-top: 1px solid var(--line);
  margin: 14px 0;
  padding-top: 12px;
}

.result-row {
  margin-bottom: 10px;
}

.result-row > div:first-child {
  display: flex;
  font-size: 0.8rem;
  justify-content: space-between;
  margin-bottom: 5px;
}

.result-track {
  background: #e2e3e2;
  height: 7px;
  overflow: hidden;
}

.result-track span {
  background: var(--teal);
  display: block;
  height: 100%;
  transition: width 180ms ease;
}

.poll-editor {
  display: grid;
  gap: 12px;
}

.poll-editor label {
  color: var(--muted);
  display: grid;
  font-size: 0.73rem;
  font-weight: 700;
  gap: 5px;
}

.poll-editor input {
  border: 1px solid #aeb2b6;
  border-radius: var(--radius);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

.poll-option-editor {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-row {
  display: flex;
  gap: 18px;
}

.check-row label {
  align-items: center;
  color: var(--ink);
  display: flex;
  flex-direction: row;
}

.command-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.command-row.compact > button {
  min-height: 34px;
  padding: 6px 10px;
}

.section-note {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
  margin: 10px 0 0;
  overflow-wrap: anywhere;
}

.gauge-value {
  font-size: 1.5rem;
}

.gauge-track {
  background: linear-gradient(90deg, #346b8d 0 50%, #d4d5d3 50% 50.5%, #b83d32 50.5% 100%);
  height: 14px;
  overflow: hidden;
  position: relative;
}

.gauge-track span {
  background: rgba(255, 255, 255, 0.7);
  display: block;
  height: 100%;
  transition: width 180ms ease;
}

.gauge-track i {
  background: var(--ink);
  height: 20px;
  left: 50%;
  position: absolute;
  top: -3px;
  width: 2px;
}

.stepper {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 38px 1fr 38px 1fr;
  margin-top: 12px;
}

.stepper button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 1.2rem;
  height: 38px;
}

.stepper span {
  color: var(--muted);
  font-size: 0.7rem;
}

.timer-display {
  display: block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 2.35rem;
  font-weight: 700;
  margin: 6px 0 14px;
}

.inline-form {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: auto 52px auto 52px minmax(62px, 1fr);
  margin-top: 12px;
}

.inline-form label {
  color: var(--muted);
  font-size: 0.7rem;
}

.inline-form input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 34px;
  padding: 5px;
  width: 100%;
}

.background-options,
.stacked-commands {
  display: grid;
  gap: 8px;
}

.background-options button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  font-size: 0.8rem;
  font-weight: 700;
  gap: 9px;
  grid-template-columns: 38px 1fr;
  min-height: 44px;
  padding: 5px;
  text-align: left;
}

.background-options button.active {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.background-swatch {
  display: block;
  height: 30px;
}

.background-swatch.courtroom {
  background: #3e2522;
}

.background-swatch.evidence {
  background: #d9d5c8;
  border: 1px solid #aaa;
}

.background-swatch.plain {
  background: #1b1c1d;
}

.share-list {
  display: grid;
  gap: 12px;
}

.share-item {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.share-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.share-item p {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  margin: 0 0 4px;
}

.share-item strong {
  display: block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.share-copy {
  justify-self: start;
  min-height: 32px;
  padding: 6px 10px;
}

.history-list {
  max-height: 380px;
  overflow: auto;
}

.history-item {
  align-items: center;
  border-top: 1px solid #e5e6e5;
  display: grid;
  gap: 10px;
  grid-template-columns: 70px minmax(0, 1fr) 58px;
  min-height: 42px;
  padding: 7px 0;
}

.history-item time,
.history-item span {
  color: var(--muted);
  font-size: 0.68rem;
}

.history-item p {
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 0;
  overflow-wrap: anywhere;
}

.empty-state {
  color: var(--muted);
  font-size: 0.8rem;
}

.toast {
  background: var(--ink);
  bottom: 24px;
  color: white;
  left: 50%;
  max-width: calc(100vw - 32px);
  opacity: 0;
  padding: 11px 16px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 80;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--red);
}

/* Display */

.display-root {
  background: #111314;
  color: white;
  height: 100vh;
  overflow: hidden;
  position: relative;
  width: 100vw;
}

.display-backdrop {
  inset: 0;
  position: absolute;
}

.display-root[data-background="courtroom"] .display-backdrop {
  background:
    linear-gradient(90deg, rgba(83, 42, 37, 0.8), rgba(16, 18, 19, 0.35) 38%, rgba(16, 18, 19, 0.35) 62%, rgba(83, 42, 37, 0.8)),
    linear-gradient(#191b1d 0 15%, #332623 15% 82%, #121415 82%);
}

.display-root[data-background="evidence"] .display-backdrop {
  background:
    linear-gradient(rgba(255, 255, 255, 0.83), rgba(236, 233, 224, 0.9)),
    repeating-linear-gradient(0deg, transparent 0 29px, rgba(0, 0, 0, 0.08) 29px 30px);
}

.display-root[data-background="evidence"] {
  color: var(--ink);
}

.display-root[data-background="plain"] .display-backdrop {
  background: #17191b;
}

.display-header,
.display-footer {
  align-items: center;
  display: flex;
  justify-content: space-between;
  left: 0;
  padding: 3vh 4vw;
  position: absolute;
  right: 0;
  z-index: 5;
}

.display-header {
  top: 0;
}

.display-footer {
  bottom: 0;
  display: grid;
  font-size: 0.85rem;
  gap: 24px;
  grid-template-columns: 1fr auto auto;
}

.display-header p,
.display-header h1 {
  margin: 0;
}

.display-header p {
  font-size: 0.8rem;
  font-weight: 700;
}

.display-header h1 {
  font-size: 1.45rem;
}

.display-phase {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  padding: 9px 14px;
}

.display-status-block {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: right;
}

.display-status-block > strong {
  font-size: 0.78rem;
  font-weight: 700;
}

.display-connection {
  opacity: 0.65;
}

.display-content {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  padding: 14vh 8vw;
  position: relative;
  text-align: center;
  z-index: 2;
}

.display-message p,
.turn-title p,
.vote-display > p,
.display-result-card > p {
  font-size: 0.85rem;
  font-weight: 800;
  margin: 0 0 10px;
}

.display-message h2,
.turn-title h2,
.vote-display h2,
.display-result-card h2 {
  font-size: 3.4rem;
  line-height: 1.2;
  margin: 0;
}

.turn-title {
  border-bottom: 4px solid var(--red);
  padding: 0 70px 22px;
}

.waiting-display {
  align-items: center;
  display: grid;
  gap: 6vw;
  grid-template-columns: minmax(0, 1fr) 380px;
  text-align: left;
  width: min(1060px, 88vw);
}

.audience-join {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  display: grid;
  gap: 18px;
  grid-template-columns: 150px minmax(0, 1fr);
  padding: 18px;
}

.audience-join img {
  background: white;
  display: block;
  height: 150px;
  width: 150px;
}

.audience-join p,
.audience-join strong,
.audience-join span {
  display: block;
  margin: 0;
}

.audience-join p {
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 7px;
}

.audience-join strong {
  font-size: 1.2rem;
  line-height: 1.35;
}

.audience-join span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
  margin-top: 8px;
}

.audience-share-url {
  border-top: 1px solid #dddddc;
  color: var(--muted);
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.45;
  margin-top: 12px;
  overflow-wrap: anywhere;
  padding-top: 10px;
}

.audience-share-url b {
  color: var(--ink);
  display: block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.64rem;
  font-weight: 700;
  margin-top: 3px;
}

.ballot-box {
  border: 4px solid currentColor;
  height: 120px;
  margin: 0 auto 28px;
  position: relative;
  width: 190px;
}

.ballot-box::before {
  background: currentColor;
  content: "";
  height: 5px;
  left: 50%;
  position: absolute;
  top: 22px;
  transform: translateX(-50%);
  width: 92px;
}

.ballot-box span {
  border: 3px solid var(--gold);
  height: 54px;
  left: 68px;
  position: absolute;
  top: -56px;
  transform: rotate(8deg);
  width: 74px;
}

.ballot-box i {
  background: var(--red);
  bottom: 17px;
  height: 12px;
  left: 30px;
  position: absolute;
  width: 42px;
}

.counting-line {
  animation: counting 1.4s ease-in-out infinite;
  background: currentColor;
  display: block;
  height: 3px;
  margin: 24px auto 0;
  transform-origin: center;
  width: 180px;
}

@keyframes counting {
  0%,
  100% { transform: scaleX(0.25); }
  50% { transform: scaleX(1); }
}

.display-result-card {
  width: min(720px, 75vw);
}

.display-result-card img,
.display-image-placeholder {
  aspect-ratio: 16 / 9;
  border: 8px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  height: auto;
  margin-bottom: 20px;
  object-fit: cover;
  width: 100%;
}

.display-image-placeholder {
  align-items: center;
  background: #d8d8d4;
  color: #4f5356;
  display: flex;
  font-size: 2rem;
  font-weight: 800;
  justify-content: center;
}

.comment-layer,
.vote-activity-layer {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: 8;
}

.danmaku-comment {
  animation: danmaku-move var(--duration) linear forwards;
  color: white;
  font-size: var(--comment-size, 2rem);
  font-weight: 800;
  left: 100%;
  max-width: none;
  position: absolute;
  text-shadow:
    -2px -2px 0 rgba(0, 0, 0, 0.9),
    2px -2px 0 rgba(0, 0, 0, 0.9),
    -2px 2px 0 rgba(0, 0, 0, 0.9),
    2px 2px 0 rgba(0, 0, 0, 0.9);
  top: calc(8vh + var(--lane) * 6.6vh);
  white-space: nowrap;
}

.danmaku-comment.measuring {
  animation: none;
  visibility: hidden;
}

@keyframes danmaku-move {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100vw - 100%)); }
}

.vote-activity-token {
  animation: vote-token 1.7s cubic-bezier(0.25, 0.8, 0.35, 1) var(--delay) forwards;
  background: white;
  border: 2px solid var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
  height: 40px;
  left: var(--start-x);
  opacity: 0;
  position: absolute;
  top: 14%;
  width: 58px;
}

@keyframes vote-token {
  0% {
    opacity: 0;
    transform: translate(-50%, -60px) rotate(-12deg);
  }
  20% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(50vw - var(--start-x)), 43vh) rotate(8deg) scale(0.5);
  }
}

.overlay-mode {
  background: transparent;
}

.overlay-mode .display-root,
.overlay-mode .display-backdrop {
  background: transparent !important;
}

.overlay-mode .display-header,
.overlay-mode .display-footer,
.overlay-mode .display-content {
  display: none;
}

/* Judge */

.judge-shell {
  min-height: 100dvh;
}

.judge-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px 26px;
}

.judge-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.judge-context {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 auto;
  max-width: 1200px;
  padding: 14px 24px;
}

.judge-context > div {
  border-right: 1px solid var(--line);
  min-width: 0;
  padding: 0 18px;
}

.judge-context > div:first-child {
  padding-left: 0;
}

.judge-context > div:last-child {
  border-right: 0;
}

.judge-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 280px minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1200px;
  padding: 32px 24px;
}

.judge-gauge,
.judge-decision {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 320px;
  padding: 24px;
}

.judge-gauge > p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0;
}

.judge-gauge > strong {
  display: block;
  font-size: 3rem;
  margin: 30px 0;
  text-align: center;
}

.gauge-scale {
  color: var(--muted);
  display: flex;
  font-size: 0.7rem;
  justify-content: space-between;
  margin-top: 8px;
}

.judge-decision {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.judge-standby,
.judge-prompt {
  max-width: 700px;
  text-align: center;
}

.judge-standby h2,
.judge-prompt h2 {
  font-size: 1.8rem;
  line-height: 1.4;
  margin: 6px 0 10px;
}

.judge-standby p,
.judge-prompt > p:last-child {
  color: var(--muted);
  line-height: 1.6;
}

.judge-options {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 20px;
  width: 100%;
}

.judge-options button {
  background: var(--surface);
  border: 1px solid #aeb2b6;
  border-radius: var(--radius);
  display: grid;
  grid-template-rows: 100px minmax(42px, auto) 30px;
  overflow: hidden;
  padding: 0;
}

.judge-options button:hover:not(:disabled) {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(182, 56, 46, 0.13);
}

.judge-options img,
.judge-options .option-placeholder {
  height: 100px;
  object-fit: cover;
  width: 100%;
}

.judge-options button > span:nth-last-child(2) {
  align-items: center;
  display: flex;
  font-size: 0.8rem;
  font-weight: 700;
  justify-content: center;
  overflow-wrap: anywhere;
  padding: 8px;
}

.judge-options strong {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Counsel */

.counsel-shell {
  --role-accent: var(--blue);
  min-height: 100dvh;
}

body[data-role="prosecution"] .counsel-shell {
  --role-accent: var(--red);
}

.counsel-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 24px;
}

.counsel-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.counsel-header-actions {
  align-items: center;
  display: flex;
  gap: 14px;
}

.counsel-emergency {
  background: var(--red);
  color: white;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 24px;
  text-align: center;
}

.counsel-overview {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  margin: 0 auto;
  max-width: 1200px;
  padding: 28px 24px 22px;
}

.counsel-phase-panel,
.counsel-timer-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--role-accent);
  border-radius: var(--radius);
  min-height: 210px;
  padding: 24px;
}

.counsel-phase-panel > p,
.counsel-timer-panel > p {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  margin: 0;
}

.counsel-phase-panel h2 {
  font-size: 2.6rem;
  margin: 26px 0 18px;
}

.counsel-phase-panel > strong {
  color: var(--muted);
  font-size: 1rem;
}

.counsel-phase-panel > strong.active {
  color: var(--role-accent);
}

.counsel-phase-panel > strong.stopped {
  color: var(--red);
}

.counsel-timer-panel output {
  display: block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 3.6rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  margin: 28px 0 16px;
}

.counsel-timer-panel > strong {
  color: var(--muted);
  font-size: 0.85rem;
}

.counsel-timer-panel > strong.running {
  color: var(--teal);
}

.counsel-results-section {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding: 22px max(24px, calc((100vw - 1152px) / 2));
}

.counsel-results {
  display: grid;
  gap: 0;
}

.counsel-result {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: 42px 112px minmax(0, 1fr);
  min-height: 96px;
  padding: 12px 0;
}

.counsel-result-index {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
}

.counsel-result img,
.counsel-result-placeholder {
  aspect-ratio: 16 / 9;
  height: 64px;
  object-fit: cover;
  width: 112px;
}

.counsel-result-placeholder {
  align-items: center;
  background: #e3e3df;
  color: var(--muted);
  display: flex;
  font-size: 1.25rem;
  font-weight: 800;
  justify-content: center;
}

.counsel-result p {
  color: var(--muted);
  font-size: 0.76rem;
  margin: 0 0 5px;
}

.counsel-result h3 {
  font-size: 1.15rem;
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .phase-band {
    display: block;
  }

  .phase-band .section-heading {
    margin-bottom: 14px;
  }

  .phase-switch {
    grid-template-columns: repeat(4, 1fr);
  }

  .phase-switch button,
  .phase-switch button:first-child,
  .phase-switch button:last-child {
    border: 1px solid var(--line);
    border-radius: 0;
  }

  .visibility-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 14px;
  }

  .visibility-summary > div:nth-child(2) {
    border-right: 0;
  }

  .waiting-display {
    gap: 28px;
    grid-template-columns: 1fr;
    text-align: center;
  }

  .audience-join {
    margin: 0 auto;
    max-width: 420px;
    text-align: left;
  }

  .control-columns,
  .judge-layout,
  .counsel-overview {
    grid-template-columns: 1fr;
  }

  .control-side {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-side .control-band {
    margin-bottom: 0;
  }
}

@media (max-width: 720px) {
  .admin-header {
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
  }

  .admin-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .admin-header-actions .text-link {
    display: none;
  }

  .control-layout {
    padding: 12px;
  }

  .poll-workspace {
    grid-template-columns: 1fr;
  }

  .poll-list {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    flex-direction: row;
    overflow-x: auto;
    padding: 0 0 10px;
  }

  .poll-list-item {
    flex: 0 0 210px;
  }

  .control-side {
    display: block;
  }

  .control-side .control-band {
    margin-bottom: 12px;
  }

  .poll-option-editor {
    grid-template-columns: 1fr;
  }

  .history-item {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .history-item > span {
    display: none;
  }

  .judge-layout {
    padding: 16px 12px;
  }

  .counsel-header {
    padding: 12px 14px;
  }

  .counsel-overview {
    padding: 16px 12px;
  }

  .counsel-phase-panel,
  .counsel-timer-panel {
    min-height: 0;
    padding: 20px;
  }

  .counsel-phase-panel h2 {
    font-size: 2rem;
    margin: 18px 0 12px;
  }

  .counsel-timer-panel output {
    font-size: 2.8rem;
    margin: 20px 0 12px;
  }

  .counsel-results-section {
    padding: 18px 14px;
  }

  .judge-context {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 14px;
  }

  .judge-context > div:nth-child(2) {
    border-right: 0;
  }

  .judge-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .audience-header,
  .audience-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .audience-stage {
    padding: 22px 14px;
  }

  .vote-options {
    gap: 8px;
  }

  .vote-option {
    grid-template-rows: 92px minmax(52px, auto);
  }

  .vote-option img,
  .option-placeholder {
    height: 92px;
    min-height: 92px;
  }

  .phase-switch {
    grid-template-columns: repeat(2, 1fr);
  }

  .poll-option-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .counsel-result {
    gap: 10px;
    grid-template-columns: 30px 84px minmax(0, 1fr);
  }

  .counsel-result img,
  .counsel-result-placeholder {
    height: 48px;
    width: 84px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
