:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-deep: #020617;
  --panel: rgba(30, 41, 59, 0.58);
  --panel-solid: #1e293b;
  --panel-soft: rgba(15, 23, 42, 0.62);
  --border: rgba(51, 65, 85, 0.82);
  --border-soft: rgba(51, 65, 85, 0.48);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --indigo: #4f46e5;
  --indigo-bright: #6366f1;
  --pink: #ec4899;
  --amber: #d97706;
  --green: #10b981;
  --red: #f43f5e;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.34);
  font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(79, 70, 229, 0.24), transparent 28rem),
    radial-gradient(circle at 86% 12%, rgba(236, 72, 153, 0.14), transparent 24rem),
    linear-gradient(180deg, #111827 0%, var(--bg) 42%, var(--bg-deep) 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.primary-button:disabled,
.secondary-button:disabled {
  background: rgba(51, 65, 85, 0.72);
  box-shadow: none;
  color: #94a3b8;
  opacity: 0.62;
  transform: none;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.topbar {
  border-bottom: 1px solid var(--border-soft);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(18px);
}

.topbar-inner,
.header,
.main,
.footer-inner {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
}

.live-label,
.room-pill,
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.1);
}

.mode-toggle {
  display: flex;
  gap: 8px;
}

.mode-toggle button,
.small-action {
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(51, 65, 85, 0.8);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
  transition: 160ms ease;
}

.mode-toggle button.active,
.small-action.active {
  background: var(--indigo);
  color: white;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 0 12px;
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: var(--indigo);
  box-shadow: 0 16px 34px rgba(79, 70, 229, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0;
}

.brand h1 span {
  color: #a5b4fc;
  font-weight: 500;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.room-code {
  color: #a5b4fc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
}

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

.profile-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.profile-name {
  font-size: 14px;
  font-weight: 800;
}

.profile-score {
  color: #818cf8;
  font-size: 12px;
  font-weight: 800;
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.9);
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 900;
}

.main {
  display: flex;
  flex: 1;
  align-items: center;
  padding: 28px 0;
}

.screen {
  width: 100%;
  min-width: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.join-panel {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 32px;
}

.centered-copy {
  text-align: center;
}

.centered-copy h2,
.waiting-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.12;
}

.centered-copy p,
.waiting-panel p,
.fineprint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.field-stack {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: rgba(2, 6, 23, 0.48);
  color: var(--text);
  padding: 14px 16px;
  transition: 160ms ease;
}

.field input:focus {
  border-color: var(--indigo-bright);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}

.field input.mono {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.role-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.52);
  color: var(--muted);
  padding: 12px;
  text-align: left;
}

.role-card strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.role-card span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.role-card.active {
  border-color: rgba(99, 102, 241, 0.88);
  background: rgba(79, 70, 229, 0.16);
}

.locked-role {
  border: 1px solid rgba(99, 102, 241, 0.5);
  border-radius: 12px;
  background: rgba(79, 70, 229, 0.14);
  padding: 14px 16px;
}

.locked-role span {
  display: block;
  color: #a5b4fc;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.locked-role strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 12px 18px;
  color: white;
  font-size: 14px;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.primary-button {
  background: var(--indigo);
  box-shadow: 0 16px 32px rgba(79, 70, 229, 0.22);
}

.primary-button:hover {
  background: var(--indigo-bright);
  transform: translateY(-1px);
}

.secondary-button {
  background: var(--amber);
}

.danger-button {
  border: 1px solid rgba(244, 63, 94, 0.3);
  background: rgba(244, 63, 94, 0.08);
  color: #fb7185;
}

.join-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  border-top: 1px solid var(--border-soft);
  padding-top: 20px;
  color: var(--muted);
  font-size: 12px;
}

.player-layout {
  width: min(720px, calc(100vw - 24px));
  max-width: 720px;
  margin: 0 auto;
}

.waiting-panel {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.results-panel {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.results-hero h2 {
  margin: 4px 0 6px;
  font-size: 30px;
}

.results-hero p:not(.admin-title) {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.result-list,
.admin-results,
.response-table {
  display: grid;
  gap: 12px;
}

.result-row,
.admin-result-block {
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.38);
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
}

.result-row.correct,
.response-row.correct {
  border-color: rgba(16, 185, 129, 0.34);
  background: rgba(16, 185, 129, 0.1);
}

.result-row.incorrect,
.response-row.incorrect {
  border-color: rgba(100, 116, 139, 0.5);
}

.result-kicker,
.result-answer {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.result-kicker {
  margin-bottom: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-row strong,
.admin-result-heading strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.result-answer {
  margin-top: 6px;
}

.result-status {
  display: grid;
  flex: 0 0 auto;
  min-width: 48px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.18);
  color: #c4b5fd;
  font-size: 14px;
  font-weight: 900;
}

.admin-result-block {
  padding: 16px;
}

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

.response-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(51, 65, 85, 0.56);
  border-radius: 12px;
  padding: 10px 12px;
}

.player-list {
  display: grid;
  gap: 10px;
}

.question-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.timer-track {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: rgba(51, 65, 85, 0.66);
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--indigo-bright));
  transition: width 600ms linear;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timer-text {
  color: #f472b6;
}

.question-card h2 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.24;
  overflow-wrap: anywhere;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.option-button {
  display: flex;
  min-width: 0;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 2px solid rgba(30, 41, 59, 0.96);
  border-radius: 16px;
  background: rgba(30, 41, 59, 0.82);
  color: var(--text);
  padding: 18px;
  text-align: left;
  transition: 160ms ease;
}

.option-button:hover {
  border-color: rgba(100, 116, 139, 0.88);
  background: rgba(51, 65, 85, 0.72);
}

.option-button.selected {
  border-color: var(--indigo-bright);
  background: rgba(79, 70, 229, 0.15);
}

.option-button.correct {
  border-color: rgba(16, 185, 129, 0.82);
  background: rgba(16, 185, 129, 0.14);
}

.option-button.incorrect {
  border-color: rgba(244, 63, 94, 0.74);
  background: rgba(244, 63, 94, 0.11);
}

.option-label {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: rgba(100, 116, 139, 0.32);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 900;
}

.option-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.option-text {
  min-width: 0;
  color: #e2e8f0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.radio {
  display: grid;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.selected .radio,
.correct .radio {
  border-color: var(--indigo-bright);
  background: var(--indigo);
}

.answer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.32);
  padding: 16px 18px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(99, 102, 241, 0.28);
  border-top-color: var(--indigo-bright);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.hidden {
  display: none !important;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 20px;
}

.admin-card {
  padding: 24px;
}

.admin-header,
.control-row,
.standing-row,
.submission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.admin-title {
  margin: 0;
  color: #818cf8;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.admin-header h2 {
  margin: 5px 0 0;
  font-size: 27px;
}

.state-pill {
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: 9px;
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.question-preview {
  margin: 22px 0;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 18px;
}

.eyeline {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.question-preview p:not(.eyeline) {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.45;
}

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

.preview-option {
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.48);
  padding: 11px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
}

.preview-option.correct {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
}

.meter {
  overflow: hidden;
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.78);
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--indigo-bright);
  transition: width 220ms ease;
}

.control-row {
  flex-wrap: wrap;
}

.control-copy h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.control-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.standings {
  padding: 22px;
}

.standings h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
  font-size: 19px;
}

.standings h3 span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.standing-list {
  display: grid;
  max-height: 470px;
  gap: 10px;
  overflow: auto;
  padding-right: 3px;
}

.standing-row {
  border: 1px solid rgba(30, 41, 59, 0.78);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.36);
  padding: 11px;
}

.standing-row.me {
  border-color: rgba(99, 102, 241, 0.38);
  background: rgba(49, 46, 129, 0.26);
}

.person {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.rank {
  width: 24px;
  color: var(--muted-2);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.person .avatar {
  width: 34px;
  height: 34px;
  border: 0;
  background: rgba(79, 70, 229, 0.16);
}

.person-name {
  overflow: hidden;
  max-width: 180px;
  color: #e2e8f0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 900;
}

.person-meta {
  color: #818cf8;
  font-size: 11px;
  font-weight: 800;
}

.answered-label {
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 900;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

.footer {
  border-top: 1px solid rgba(30, 41, 59, 0.78);
  background: rgba(2, 6, 23, 0.7);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  border: 1px solid rgba(244, 63, 94, 0.34);
  border-radius: 12px;
  background: rgba(127, 29, 29, 0.94);
  color: white;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 800;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 820px) {
  .topbar-inner,
  .header,
  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile {
    width: 100%;
    justify-content: space-between;
  }

  .profile-meta {
    align-items: flex-start;
  }

  .admin-grid,
  .options-grid,
  .preview-options {
    grid-template-columns: 1fr;
  }

  .main {
    align-items: flex-start;
  }

  .answer-footer,
  .control-row,
  .result-row,
  .admin-result-heading,
  .admin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .answer-footer .primary-button,
  .control-actions,
  .control-actions button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .topbar-inner,
  .header,
  .main,
  .footer-inner {
    width: min(1120px, calc(100% - 24px));
    max-width: calc(100% - 24px);
  }

  .app-shell,
  .screen,
  .player-layout,
  .question-card,
  .options-grid,
  .answer-footer,
  .option-button {
    max-width: 100%;
  }

  .player-layout {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .question-card,
  .option-button,
  .answer-footer {
    width: 100%;
  }

  .question-card h2 {
    width: 320px;
    max-width: 100%;
    font-size: 18px;
    line-height: 1.35;
    overflow-wrap: normal;
    word-break: normal;
  }

  .mode-toggle,
  .role-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .mode-toggle {
    display: grid;
  }

  .join-panel,
  .question-card,
  .admin-card,
  .standings {
    padding: 20px;
  }

  .question-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}
