:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07131f;
  color: #f5f8fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, #193a58 0, transparent 35%),
    linear-gradient(145deg, #07131f 0%, #0c2335 100%);
}

main {
  width: min(94vw, 72rem);
  margin: 0 auto;
  padding: 4rem 0;
}

.card {
  background: rgba(8, 24, 37, 0.88);
  border: 1px solid rgba(152, 204, 241, 0.2);
  border-radius: 1.25rem;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.28);
  padding: clamp(1.5rem, 5vw, 3rem);
}

h1 { margin-top: 0; font-size: clamp(2rem, 7vw, 4rem); }
h2 { color: #a9d9ff; }
p { color: #c8d7e4; line-height: 1.6; }

label { display: block; margin: 1.25rem 0; color: #dcecf9; }

input, select, textarea, button {
  width: 100%;
  border-radius: 0.7rem;
  border: 1px solid #416783;
  padding: 0.9rem 1rem;
  font: inherit;
}

input, select, textarea {
  display: block;
  margin-top: 0.4rem;
  background: #081722;
  color: white;
}

textarea { width: 100%; resize: vertical; }

button {
  cursor: pointer;
  border: 0;
  background: #ffd34d;
  color: #18202a;
  font-weight: 750;
}

button.secondary {
  margin-top: 2rem;
  background: #24435a;
  color: #e9f5ff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.metrics div {
  background: #0b1c29;
  border: 1px solid #294c64;
  border-radius: 0.8rem;
  padding: 1rem;
}

.metrics strong, .metrics span { display: block; }
.metrics strong { font-size: 2rem; color: #ffd34d; }
.metrics span { color: #adc2d2; margin-top: 0.3rem; }

.media-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1.5rem;
}

.media-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  background: #0b1c29;
  border: 1px solid #294c64;
}

.media-item > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.media-item strong,
.media-item span { display: block; }
.media-item span { color: #adc2d2; margin-top: 0.25rem; }

.media-actions,
.heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

dialog {
  width: min(92vw, 44rem);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  border: 1px solid #416783;
  border-radius: 1rem;
  background: #0b1c29;
  color: #f5f8fb;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.dialog-actions { display: flex; gap: 0.8rem; }
.dialog-actions button { flex: 1; }

.admin-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0 2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #294c64;
}

button.admin-tab {
  width: auto;
  flex: 0 0 auto;
  border-radius: 0.65rem 0.65rem 0 0;
  background: transparent;
  color: #a9c1d3;
  border-bottom: 3px solid transparent;
}

button.admin-tab.active {
  background: #102b3e;
  border-bottom-color: #ffd34d;
  color: #fff;
}

.tab-panel { min-height: 24rem; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  padding: 0.8rem;
  text-align: left;
  border-bottom: 1px solid #294c64;
}

th { color: #a9d9ff; }

code {
  display: block;
  overflow-x: auto;
  padding: 0.8rem;
  border-radius: 0.6rem;
  background: #06111a;
  color: #d8edff;
}

.trivia-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.8rem;
}

.trivia-item {
  padding: 1rem;
  border: 1px solid #31546b;
  border-radius: 0.8rem;
  background: #0b1c29;
}

.trivia-item.inactive { opacity: 0.55; }
.trivia-item ol { padding-left: 1.5rem; color: #c5d6e2; }
.trivia-item .correct-answer { color: #a4efbd; font-weight: 700; }

.trivia-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  color: #adc2d2;
}

hr {
  border: 0;
  border-top: 1px solid #294c64;
  margin: 3rem 0;
}

.section-heading,
.version-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.section-heading h2 { margin-bottom: 0; }

button.compact,
button.publish {
  width: auto;
  padding: 0.65rem 0.9rem;
}

button.danger {
  background: #7b2831;
  color: white;
}

.storyboard-list {
  display: grid;
  gap: 0.8rem;
  margin: 1rem 0 2rem;
}

.storyboard-item {
  display: grid;
  grid-template-columns: auto minmax(10rem, 1fr) minmax(18rem, 2fr);
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid #31546b;
  border-radius: 0.8rem;
  background: #0b1c29;
}

.storyboard-item.dragging { opacity: 0.45; }
.storyboard-item.trivia-placeholder {
  border-color: #8c72d6;
  background: linear-gradient(135deg, #171d38, #241b3d);
}
.drag-handle { cursor: grab; color: #70c7ff; font-weight: 700; }
.storyboard-content strong,
.storyboard-content span { display: block; }
.storyboard-content span { color: #adc2d2; margin-top: 0.25rem; }

.storyboard-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.7rem;
}

.storyboard-controls label { margin: 0; }
.storyboard-controls input[type="number"] { width: 7rem; }
.storyboard-controls input[type="checkbox"] { width: auto; display: inline; }

details {
  border-top: 1px solid #294c64;
  padding-top: 1rem;
}

summary { cursor: pointer; color: #a9d9ff; font-weight: 700; }
.version-history { display: grid; gap: 0.6rem; margin-top: 1rem; }
.version-row { padding: 0.7rem; background: #0b1c29; border-radius: 0.6rem; }

@media (max-width: 760px) {
  .participant-body main {
    padding: 1rem 0;
  }

  .participant-body .card {
    padding: 1.25rem;
  }

  .participant-body p {
    line-height: 1.4;
  }

  .participant-body label {
    margin: 0.8rem 0;
  }

  .participant-body .mobile-answers button {
    min-height: 3.75rem;
    padding: 0.75rem;
  }

  .storyboard-item { grid-template-columns: 1fr; }
  .drag-handle { display: none; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .media-item { display: grid; }
  .media-actions { align-items: stretch; }
  .media-actions button { flex: 1 1 0; }
  .heading-actions { flex-wrap: wrap; }

  .section-heading .heading-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .section-heading .heading-actions button {
    width: 100%;
    margin: 0;
  }

  #participant-list {
    display: grid;
    gap: 1rem;
  }

  #participant-list tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 0.6rem;
    border: 1px solid #31546b;
    border-radius: 0.8rem;
    background: #0b1c29;
  }

  #participant-list td {
    display: grid;
    grid-template-columns: minmax(6rem, auto) 1fr;
    gap: 0.6rem;
    padding: 0.65rem;
    border: 0;
  }

  #participant-list td::before {
    content: attr(data-label);
    color: #a9d9ff;
    font-weight: 700;
  }

  #participant-list td:last-child {
    grid-column: 1 / -1;
    display: block;
  }

  #participant-list td:last-child::before { display: none; }
  #participant-list td:last-child button { width: 100%; }

  [data-panel="overview"] table,
  [data-panel="overview"] tbody { display: block; }
  [data-panel="overview"] thead { display: none; }
}

.eyebrow {
  color: #70c7ff;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hidden { display: none; }
.error { color: #ff9b9b; }
.status { color: #a4efbd; }
.last-entry { margin-bottom: 1rem; background: #24435a; color: #e9f5ff; }

.danger-zone {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid #633640;
}

.danger-zone h2 { color: #ffb0b7; }
.danger-zone button { width: auto; }

.display-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
}

.player-body {
  background: #000;
  overflow: hidden;
}

.player {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: #000;
}

.player-message { text-align: center; padding: 3rem; }
.ready-screen, .lobby-screen { display: grid; place-items: center; gap: 1rem; }
.ready-screen h1, .lobby-screen h1 { margin: 0; }
.join-qr { width: min(34vw, 22rem); aspect-ratio: 1; background: white; padding: 0.8rem; border-radius: 0.7rem; }
.join-qr.small { width: min(22vw, 12rem); }
.lobby-count { color: #ffd34d; font-size: clamp(2rem, 5vw, 4rem); font-weight: 900; }
.start-timer { color: #ffd34d; font-size: clamp(5rem, 15vw, 12rem); font-weight: 900; line-height: 1; }

.player-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.trivia-screen {
  padding: 6vh 7vw;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 2fr);
  gap: 4vh;
  background: radial-gradient(circle at top, #173b59, #06101a 65%);
}

.trivia-screen > .eyebrow { grid-column: 1 / -1; margin: 0; }

.trivia-screen h1 {
  margin: 0;
  align-self: center;
  font-size: clamp(2.5rem, 5vw, 5.5rem);
}

.display-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  width: 100%;
}

.display-answer {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 1.5rem 2rem;
  border: 3px solid #47728f;
  border-radius: 1.5rem;
  background: rgba(5, 19, 30, 0.88);
  font-size: clamp(1.5rem, 3vw, 3rem);
  text-align: left;
}

.display-answer .answer-letter { color: #ffd34d; font-weight: 900; }
.display-answer .answer-text { color: white; }
.display-answer .answer-count {
  margin-left: auto;
  color: white;
  font-size: inherit;
  font-weight: 900;
}
.display-answer .fastest-time {
  color: #ffd34d;
  font-size: 0.7em;
  font-weight: 800;
  white-space: nowrap;
}
.display-answer.correct {
  border-color: #35d47f;
  background: #12613b;
}
.display-answer.correct .answer-letter,
.display-answer.correct .answer-text,
.display-answer.correct .answer-count { color: white; }

.display-timer {
  position: absolute;
  left: 2.5rem;
  bottom: 2rem;
  min-width: 5rem;
  color: #ffd34d;
  font-size: 4rem;
  font-weight: 900;
}

.mobile-trivia h2 { color: white; font-size: clamp(1.5rem, 7vw, 2.4rem); }
.mobile-answers { display: grid; gap: 0.8rem; }
.mobile-answers button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  padding: 1rem;
  background: #24435a;
  color: white;
  font-size: 1.1rem;
}
.mobile-answers .answer-count {
  flex: 0 0 auto;
  font-size: inherit;
  font-weight: 900;
}
.mobile-answers button.correct { background: #16834b; }
.mobile-answers button.incorrect { background: #a62d3b; }
.mobile-answers button.selected { outline: 3px solid #ffd34d; outline-offset: 2px; }
.mobile-answers button:disabled { opacity: 1; }
.mobile-timer { color: #ffd34d; font-size: 1.4rem; font-weight: 800; }
.mobile-leaderboard ol { padding-left: 1.6rem; }
.mobile-leaderboard li { padding: 0.55rem 0; font-size: 1.1rem; }
.winner-message {
  margin: 0 0 1rem;
  color: #ffd34d;
  font-size: clamp(2.5rem, 12vw, 5rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
}
.mobile-media-text {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #31546b;
  border-radius: 0.8rem;
  background: #0b1c29;
  color: #e9f5ff;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.mobile-media-text h1,
.mobile-media-text h2,
.mobile-media-text h3,
.mobile-media-text h4 { color: #a9d9ff; }

.builtin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 1rem 0;
}

.version-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.builtin-screen {
  padding: 6vh 8vw;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2rem;
  background: radial-gradient(circle at top, #173b59, #06101a 68%);
}

.builtin-screen h1 { margin: 0; }
.qr-screen img {
  width: min(48vh, 32vw);
  height: min(48vh, 32vw);
  padding: 1rem;
  border-radius: 1rem;
  background: white;
}
.qr-screen .qr-url {
  margin: 0;
  color: white;
  font-size: clamp(1.4rem, 2.5vw, 2.6rem);
}

.qr-content {
  width: min(90vw, 100rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(28rem, 0.85fr);
  align-items: center;
  gap: 5vw;
}

.qr-wifi-notice {
  margin: 0;
  color: white;
  font-size: clamp(2.2rem, 4vw, 4.5rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
}

.qr-code-column {
  display: grid;
  justify-items: center;
  gap: 1rem;
}

.display-leaderboard {
  width: min(82vw, 75rem);
  margin: 0;
  padding-left: 4rem;
  font-size: clamp(1.5rem, 3vw, 3.2rem);
}
.display-leaderboard li { padding: 0.4rem 1rem; }
.display-leaderboard li::marker { color: #ffd34d; font-weight: 900; }
.display-leaderboard li span,
.display-leaderboard li strong { display: inline-block; }
.display-leaderboard li span { width: 65%; text-align: left; }
.display-leaderboard li strong { color: #a4efbd; }

.network-setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(24rem, 0.8fr);
  align-items: center;
  gap: 6vw;
  padding: 7vh 8vw;
  background: radial-gradient(circle at top, #17496b, #06101a 70%);
  color: white;
}

.network-setup-overlay.hidden { display: none; }
.network-setup-copy { text-align: left; }
.network-setup-copy h1 {
  margin: 0.4rem 0 2rem;
  font-size: clamp(4rem, 8vw, 8rem);
}
.network-setup-copy p {
  font-size: clamp(1.8rem, 3vw, 3.2rem);
  line-height: 1.35;
}
.network-setup-copy strong { color: #ffd34d; overflow-wrap: anywhere; }
.network-setup-overlay img {
  width: min(38vw, 38rem);
  aspect-ratio: 1;
  padding: 1rem;
  border-radius: 1.5rem;
  background: white;
}
