:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #000000;
  --muted: rgba(0, 0, 0, 0.6);
  --line: rgba(0, 0, 0, 0.2);
  --line-strong: #000000;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Helvetica Neue", Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

.screen {
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.setup-screen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 20px;
  overflow-y: auto;
}

.setup-layout {
  width: min(1080px, 100%);
}

.setup-form {
  display: grid;
  gap: 18px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.selection-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 10px;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 14px 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--line-strong);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
}

button {
  font-family: inherit;
  border-radius: 0;
}

.primary {
  border: 1px solid var(--line-strong);
  background: var(--ink);
  color: #ffffff;
  padding: 0 16px;
  font-size: 1rem;
  cursor: pointer;
  min-width: 160px;
  height: 42px;
  text-align: center;
}

.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

.status:empty {
  display: none;
}

.status.error {
  color: #b00000;
}

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

.queue-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.queue-list {
  display: grid;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 6px;
  padding-right: 6px;
  min-height: 140px;
  max-height: 50vh;
  scroll-behavior: smooth;
}

.queue-item {
  border: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  width: 100%;
  min-width: 0;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.queue-item:hover {
  border-color: var(--line-strong);
}

.queue-item.selected {
  border-color: var(--line-strong);
  background: #fafafa;
}

.queue-item.loading {
  opacity: 0.7;
}

.queue-item.error {
  border-color: #b00000;
}

.queue-meta {
  font-size: 0.9rem;
  font-weight: 500;
}

.queue-status {
  font-size: 0.8rem;
  color: var(--muted);
}

.queue-preview {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
}

.details {
  position: fixed;
  top: 24px;
  right: 24px;
  width: min(360px, 42vw);
  height: calc(100vh - 48px);
  background: #ffffff;
  border-left: 1px solid var(--line);
  padding: 16px;
  display: grid;
  gap: 14px;
  overflow-y: auto;
}

.editor {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: grid;
  gap: 16px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.answers-editor {
  display: grid;
  gap: 10px;
}

.answers-editor-head {
  display: grid;
  grid-template-columns: 1fr auto;
  font-size: 0.85rem;
  color: var(--muted);
}

.answer-edit-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.answer-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.answer-tag.correct {
  color: var(--ink);
  font-weight: 600;
}

.editor-footer {
  display: flex;
  justify-content: flex-start;
}

.preview {
  border: 1px solid var(--line);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.preview-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.preview-question {
  font-size: 1rem;
  font-weight: 500;
}

.preview-media {
  border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
  background: #ffffff;
}

.preview-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-answers {
  display: grid;
  gap: 6px;
}

.preview-answer {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
}

.preview-answer.correct {
  font-weight: 600;
}

.preview-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stage-screen {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  padding: 10px 20px 20px;
  overflow-x: hidden;
  overflow-y: auto;
}

.stage-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.brand {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  justify-self: start;
}

.stage-body {
  --stage-max-width: 980px;
  width: min(var(--stage-max-width), 100%, 100vh);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
  justify-content: flex-start;
}

.topic {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  justify-self: center;
  text-align: center;
}

.media {
  width: 100%;
  height: auto;
  background: #ffffff;
  align-self: stretch;
  margin-top: 8px;
}

.media img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
}

.question {
  font-size: clamp(1.25rem, 2.1vw, 1.8rem);
  line-height: 1.2;
  margin: 0;
}

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

.answer {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.answer:hover {
  border-color: var(--line-strong);
}

.answer:disabled {
  cursor: not-allowed;
}

.answer-letter {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.75rem;
}

.answer.is-correct {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--line-strong);
}

.answer.is-correct .answer-letter {
  background: #ffffff;
  color: var(--ink);
}

.answer.is-wrong {
  border-style: dashed;
  text-decoration: line-through;
}

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

.result-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.result-text {
  margin: 0;
  color: var(--muted);
}

.stage-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 4px;
}

.ghost {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
  padding: 0 16px;
  font-size: 0.95rem;
  cursor: pointer;
  min-width: 160px;
  height: 42px;
  text-align: center;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.ghost.danger {
  border-color: #b00000;
  color: #b00000;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px;
}

.login-form {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

.login-error {
  border: 1px solid var(--line-strong);
  padding: 10px 12px;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .stage-screen {
    padding: 16px;
    overflow-y: auto;
  }

  .stage-body {
    height: auto;
  }

  .details {
    position: fixed;
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .answers {
    grid-template-columns: 1fr;
  }

  .media {
    width: 100%;
  }
}

@media (max-height: 720px) {
  .question {
    font-size: clamp(1.1rem, 2vw, 1.6rem);
  }

  .answer {
    padding: 7px 9px;
    font-size: 0.85rem;
  }
}

@media (orientation: landscape) {
  .media {
    height: 60vh;
  }

  .media img {
    height: 100%;
  }
}
