:root {
  color-scheme: light;
  --ink: #182026;
  --muted: #60707f;
  --paper: #fbf9f4;
  --panel: #ffffff;
  --line: #d9e0e6;
  --blue: #2378d4;
  --cyan: #17a7b8;
  --coral: #e55c4a;
  --lime: #6aa84f;
  --violet: #7556d9;
  --shadow: 0 18px 50px rgba(24, 32, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(35, 120, 212, 0.10), transparent 32%),
    linear-gradient(240deg, rgba(229, 92, 74, 0.12), transparent 36%),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.button-link {
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  font-weight: 800;
}

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

.primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
}

.hero-grid {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.7fr);
  gap: 22px;
  align-items: center;
}

.compose-panel,
.preview-panel,
.join-panel,
.stage-card,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.compose-panel,
.join-panel {
  padding: clamp(20px, 4vw, 44px);
}

.preview-panel {
  min-height: 520px;
  display: grid;
  align-content: center;
  gap: 24px;
  padding: 24px;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 900;
}

.brand-row.compact {
  color: var(--ink);
}

.mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font-size: 0.86rem;
  letter-spacing: 0;
}

h1 {
  max-width: 820px;
  margin: 24px 0;
  font-size: clamp(2.2rem, 6vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.setup-screen {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 24px;
  align-content: start;
  padding-top: clamp(8px, 4vw, 44px);
}

.setup-header {
  display: grid;
  gap: 14px;
}

.setup-header h1 {
  max-width: 760px;
  margin: 10px 0 0;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
}

.setup-header p {
  max-width: 720px;
  margin: 0;
  font-size: 1.08rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.setup-card,
.format-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.setup-card {
  display: grid;
  gap: 16px;
  padding: clamp(18px, 3vw, 30px);
}

.format-card {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.format-card h2 {
  font-size: 1.18rem;
}

.format-card ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-weight: 700;
}

.format-card p {
  margin: 0;
}

.upload-box {
  min-height: 132px;
  place-items: center;
  border: 2px dashed #b8c8d8;
  border-radius: 8px;
  padding: 22px;
  color: var(--ink);
  background: #f6fbff;
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-box strong {
  font-size: 1.35rem;
}

.upload-box span {
  color: var(--muted);
  font-weight: 800;
}

.paste-panel {
  display: grid;
  gap: 10px;
}

.paste-panel summary {
  color: var(--blue);
  cursor: pointer;
  font-weight: 900;
}

.paste-panel textarea {
  margin-top: 12px;
  min-height: 190px;
}

.create-button {
  width: fit-content;
  justify-self: end;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.secondary-button {
  width: fit-content;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.google-login-panel {
  display: grid;
  gap: 8px;
  justify-items: stretch;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.setup-card .preview-panel {
  min-height: 0;
  align-content: start;
  padding: 16px;
  gap: 14px;
  box-shadow: none;
  overflow: visible;
}

.setup-card .empty-preview {
  min-height: 120px;
}

.preview-list {
  display: grid;
  gap: 12px;
  max-height: min(680px, 64vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 4px;
}

.preview-question {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.preview-question-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.preview-question-head span {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.danger-lite {
  color: #8d2b1d;
}

.preview-options {
  display: grid;
  gap: 8px;
}

.preview-option {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
}

.preview-option > span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #eef4f8;
  font-weight: 900;
}

.preview-option .correct-toggle {
  width: 22px;
  height: 22px;
  min-height: 0;
  accent-color: var(--blue);
}

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

.dashboard-screen {
  min-height: calc(100vh - 56px);
  display: grid;
  gap: 22px;
  align-content: start;
  padding-top: clamp(8px, 3vw, 34px);
}

.dashboard-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.split-header {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.dashboard-title {
  display: grid;
  gap: 8px;
}

.dashboard-title h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.4rem);
}

.dashboard-title p {
  margin: 0;
  font-size: 1.06rem;
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}

.quiz-card,
.empty-state,
.library-panel,
.library-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.quiz-card {
  min-height: 180px;
  display: grid;
  gap: 18px;
  align-content: space-between;
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.quiz-card h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.quiz-card > div {
  min-width: 0;
}

.quiz-card p {
  margin: 0;
}

.quiz-meta {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.quiz-card button {
  justify-self: start;
}

.empty-state {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 24px;
}

.empty-state h2 {
  font-size: 1.5rem;
}

.empty-state p {
  margin: 0;
}

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

.admin-side {
  display: grid;
  gap: 16px;
}

.library-panel {
  display: grid;
  gap: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.library-panel h2 {
  font-size: 1.18rem;
}

.security-panel button {
  justify-self: start;
}

.library-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  box-shadow: none;
}

.library-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.library-row span {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.library-row strong {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  justify-self: end;
  min-width: 0;
}

.library-row-actions button,
.library-row-actions .button-link {
  width: auto;
  min-width: 96px;
}

.quiz-detail-screen {
  max-width: 1480px;
  margin-inline: auto;
}

.quiz-editor-hero {
  display: grid;
  gap: 14px;
  align-items: start;
  margin: 28px 0 18px;
}

.title-edit-label {
  max-width: 860px;
  margin-top: 6px;
}

.title-edit-label input {
  min-height: 58px;
  font-size: clamp(1.45rem, 3vw, 2.7rem);
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-line {
  max-width: 820px;
  margin-top: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz-detail-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.quiz-detail-stats span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.quiz-detail-stats strong {
  color: var(--ink);
}

.quiz-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
}

.tab-row,
.editor-save-actions,
.preview-nav,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tab-button {
  width: auto;
  min-height: 42px;
  padding: 9px 14px;
  background: transparent;
}

.tab-button.active {
  border-color: rgba(35, 120, 212, 0.45);
  color: #174a82;
  background: rgba(35, 120, 212, 0.11);
}

.editor-save-actions button {
  width: auto;
  min-height: 42px;
}

.quiz-editor-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.editor-panel-head {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.editor-panel-head h2 {
  font-size: 1.4rem;
}

.compact-notice {
  padding: 9px 12px;
}

.editor-issues {
  display: grid;
  gap: 4px;
}

.editor-table-wrap {
  max-width: 100%;
  max-height: min(760px, 72vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  scrollbar-gutter: stable;
}

.quiz-editor-table {
  width: max-content;
  min-width: 1780px;
  table-layout: fixed;
  border-collapse: collapse;
  background: #fff;
}

.editor-col-number {
  width: 52px;
}

.editor-col-type {
  width: 112px;
}

.editor-col-question {
  width: 420px;
}

.editor-col-option {
  width: 180px;
}

.editor-col-correct {
  width: 150px;
}

.editor-col-small {
  width: 96px;
}

.editor-col-actions {
  width: 150px;
}

.quiz-editor-table th,
.quiz-editor-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.quiz-editor-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f8;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.quiz-editor-table tr.has-issue {
  background: rgba(229, 92, 74, 0.06);
}

.quiz-editor-table .row-number {
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.quiz-editor-table select,
.quiz-editor-table input,
.quiz-editor-table textarea {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 8px 9px;
  font-size: 0.95rem;
}

.quiz-editor-table textarea {
  min-width: 0;
  min-height: 86px;
  resize: vertical;
}

.correct-code-input {
  min-width: 0;
}

.empty-option-slot {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f7fafc;
  font-weight: 800;
}

.number-input {
  max-width: none;
}

.icon-text-button {
  width: auto;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.icon-text-button.danger {
  color: #8a2a1e;
}

.student-preview-panel {
  max-width: 980px;
}

.student-preview-card {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 30px);
  background: #fff;
}

.student-preview-card h2 {
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

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

.student-preview-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.student-preview-option > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #eef4f8;
  color: var(--muted);
  font-weight: 900;
}

.student-preview-option p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.08rem;
  font-weight: 800;
}

.student-preview-option strong,
.answer-key-row em {
  border-radius: 999px;
  padding: 4px 8px;
  color: #315f24;
  background: rgba(106, 168, 79, 0.18);
  font-style: normal;
  font-weight: 900;
}

.student-preview-option.correct {
  border-color: rgba(106, 168, 79, 0.58);
  background: rgba(106, 168, 79, 0.08);
}

.answer-key-list {
  display: grid;
  gap: 8px;
}

.answer-key-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(220px, auto);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.answer-key-row > span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #eef4f8;
  color: var(--muted);
  font-weight: 900;
}

.answer-key-row strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-key-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.answer-key-row em {
  justify-self: end;
  max-width: 460px;
  overflow-wrap: anywhere;
}

.live-room-panel .panel-title-row {
  align-items: start;
}

.live-room-panel .panel-title-row p {
  margin: 2px 0 0;
}

.inline-refresh {
  width: auto;
  min-height: 34px;
}

.live-room-row strong,
.live-room-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-room-row button {
  min-width: 78px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 260px;
  resize: vertical;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.93rem;
  line-height: 1.5;
}

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

.file-input input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-input span {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

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

.signal-card {
  aspect-ratio: 1;
  border: 5px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 16px 32px rgba(24, 32, 38, 0.18);
}

.cyan {
  background: var(--cyan);
}

.coral {
  background: var(--coral);
}

.lime {
  background: var(--lime);
}

.violet {
  background: var(--violet);
}

.mini-board {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.mini-board span,
.room-code span,
.muted {
  color: var(--muted);
}

.mini-board strong,
.room-code strong {
  font-size: 2rem;
  letter-spacing: 0;
}

.game-layout {
  display: grid;
  gap: 18px;
}

.topbar,
.player-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.topbar > div:first-child {
  flex: 1 1 auto;
}

.player-header > div:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.player-header small {
  color: var(--muted);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.room-code,
.score-pill {
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  background: #fff;
}

.player-count-card {
  min-width: 120px;
}

.host-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.host-stage > [data-host-stage] {
  min-width: 0;
}

.host-setup-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.host-setup-head {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.host-setup-head h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.host-timing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 10px;
}

.host-timing-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.timing-card-title,
.timing-card-meta {
  min-width: 0;
  overflow-wrap: anywhere;
}

.timing-card-title {
  color: var(--ink);
  font-weight: 900;
}

.timing-card-meta {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.timing-card-input {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: grid;
  gap: 2px;
  justify-items: center;
}

.timing-card-input input {
  width: 78px;
  min-height: 42px;
  padding: 8px;
  text-align: center;
}

.timing-card-input small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.stage-card {
  min-height: 520px;
  display: grid;
  gap: 24px;
  align-content: center;
  padding: clamp(18px, 4vw, 42px);
}

.stage-card.centered {
  justify-items: center;
  text-align: center;
}

.lobby-stage-card {
  min-height: 0;
  height: clamp(460px, calc(100vh - 270px), 680px);
  align-content: stretch;
  grid-template-rows: auto minmax(0, 1fr);
}

.lobby-stage-header {
  display: flex;
  gap: 18px;
  align-items: center;
}

.lobby-stage-header h2 {
  margin: 0;
}

.lobby-stage-header p {
  margin: 4px 0 0;
}

.lobby-quiz-name {
  display: block;
  max-width: min(760px, 70vw);
  margin-top: 4px;
  color: var(--ink);
  font-size: clamp(1.15rem, 2vw, 1.65rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.lobby-roster {
  min-height: 0;
  max-height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  scrollbar-gutter: stable;
}

.lobby-roster.empty {
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
}

.lobby-player-name {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lobby-player-name span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-player-name small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.lobby-player-name.active small {
  color: #4e8d35;
}

.lobby-player-name.disconnected {
  background: #f8fafc;
  color: #6b7280;
}

.recovery-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.recovery-panel summary {
  cursor: pointer;
  font-weight: 900;
}

.recovery-code-note,
.player-notice {
  max-width: 760px;
  margin: 10px auto;
}

.recovery-code-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.recovery-code-note strong {
  color: var(--ink);
  letter-spacing: 0.08em;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 18px;
}

.panel-block {
  display: grid;
  gap: 12px;
}

.panel-block h2 {
  font-size: 1.1rem;
}

.panel-block h3,
.player-leaderboard h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.panel-title-row > div {
  min-width: 0;
}

.count-pill {
  min-width: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--ink);
  background: #f6fbff;
  text-align: center;
  font-weight: 900;
}

.stat-panel {
  text-align: center;
}

.side-stat {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.side-stat strong {
  font-size: 2.8rem;
  line-height: 0.95;
}

.side-stat span {
  color: var(--muted);
  font-weight: 900;
}

.qr-panel {
  justify-items: center;
  text-align: center;
}

.qr-code {
  width: min(220px, 100%);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.qr-link {
  width: 100%;
}

.question-meta,
.answer-footer {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 900;
}

.answer-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-tile {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  text-align: center;
}

.summary-tile span {
  color: var(--muted);
  font-weight: 900;
}

.summary-tile strong {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 0.95;
}

.correct-count {
  border-color: rgba(106, 168, 79, 0.45);
  background: rgba(106, 168, 79, 0.10);
}

.wrong-count {
  border-color: rgba(229, 92, 74, 0.35);
  background: rgba(229, 92, 74, 0.08);
}

.missing-count {
  background: #f7fafc;
}

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

.answer-card {
  min-height: 112px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 0;
  padding: 16px;
  color: #fff;
  text-align: left;
  overflow-wrap: anywhere;
  box-shadow: 0 12px 26px rgba(24, 32, 38, 0.18);
}

.answer-card.correct {
  outline: 5px solid #172016;
}

.answer-card.selected {
  outline: 5px solid rgba(24, 32, 38, 0.78);
  box-shadow:
    0 0 0 7px rgba(255, 255, 255, 0.92),
    0 16px 34px rgba(24, 32, 38, 0.22);
}

.answer-grid.multi-select .answer-card {
  min-height: 104px;
}

.answer-letter {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.22);
}

.locked .answer-card:not(.correct) {
  filter: saturate(0.65);
}

.multi-submit-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.multi-submit-row span {
  color: var(--muted);
  font-weight: 900;
}

.multi-submit-row button {
  flex: 0 0 auto;
}

.answer-waiting {
  min-height: 230px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  border: 1px solid rgba(35, 120, 212, 0.18);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 34px);
  background:
    linear-gradient(135deg, rgba(35, 120, 212, 0.10), rgba(23, 167, 184, 0.06)),
    #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.66);
}

.waiting-ring {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #fff;
}

.waiting-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--blue), var(--cyan), rgba(35, 120, 212, 0.14), var(--blue));
  animation: waiting-spin 1.05s linear infinite;
}

.waiting-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
  z-index: 1;
}

.waiting-core {
  position: absolute;
  inset: 27px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 10px rgba(35, 120, 212, 0.12);
  animation: waiting-breathe 1.6s ease-in-out infinite;
  z-index: 2;
}

.waiting-core::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 10px;
  height: 18px;
  border-right: 4px solid #fff;
  border-bottom: 4px solid #fff;
  transform: translateX(-50%) rotate(40deg);
}

.waiting-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.waiting-copy strong {
  font-size: clamp(1.35rem, 4vw, 2.15rem);
  line-height: 1.05;
}

.waiting-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 800;
}

.waiting-dots {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
}

.waiting-dots span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  opacity: 0.35;
  animation: waiting-dot 1.2s ease-in-out infinite;
}

.waiting-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.waiting-dots span:nth-child(3) {
  animation-delay: 0.30s;
}

@keyframes waiting-spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes waiting-breathe {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.88);
  }
}

@keyframes waiting-dot {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.leaderboard {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard li,
.player-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

.leaderboard li span,
.player-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard li strong,
.player-row strong {
  flex: 0 0 auto;
}

.leaderboard.large li {
  padding: 16px 18px;
  font-size: clamp(1.05rem, 3vw, 1.5rem);
}

.player-list {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.player-list.expanded {
  max-height: min(420px, 50vh);
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  scrollbar-gutter: stable;
}

.player-list.expanded .player-row {
  min-height: 40px;
  padding-block: 8px;
}

.compact-button {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
}

.panel-title-row .compact-button,
.compact-button.inline-refresh {
  width: auto;
}

.small-note {
  margin: -4px 0 0;
  font-size: 0.88rem;
}

.control-bar {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.join-screen {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.join-panel {
  width: min(480px, 100%);
}

.player-game {
  min-height: calc(100vh - 56px);
  display: grid;
  gap: 18px;
  align-content: start;
}

.status-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--lime);
  box-shadow: 0 0 0 8px rgba(106, 168, 79, 0.18);
}

.lobby-count {
  display: grid;
  gap: 4px;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 26px;
  background: #fff;
}

.lobby-count strong {
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 0.9;
}

.lobby-count span {
  color: var(--muted);
  font-weight: 900;
}

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

.result-panel > div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.result-panel span {
  color: var(--muted);
  font-weight: 900;
}

.result-panel strong {
  font-size: clamp(1.35rem, 4vw, 2rem);
}

.result-panel p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.result-panel.good > div:first-child {
  border-color: rgba(106, 168, 79, 0.5);
  background: rgba(106, 168, 79, 0.10);
}

.result-panel.miss > div:first-child {
  border-color: rgba(229, 92, 74, 0.35);
  background: rgba(229, 92, 74, 0.08);
}

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

.error {
  border: 1px solid rgba(229, 92, 74, 0.35);
  border-radius: 8px;
  margin: 0;
  padding: 12px;
  color: #8a2a1e;
  background: rgba(229, 92, 74, 0.10);
  font-weight: 800;
}

.notice {
  border: 1px solid rgba(35, 120, 212, 0.28);
  border-radius: 8px;
  margin: 0;
  padding: 12px;
  color: #174a82;
  background: rgba(35, 120, 212, 0.10);
  font-weight: 800;
}

.live-status {
  margin: 0 0 12px;
}

.loaded-file {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 860px) {
  .hero-grid,
  .host-stage,
  .setup-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: auto;
  }

  .format-card {
    order: -1;
  }

  .side-panel {
    order: 2;
  }

  .topbar,
  .player-header,
  .dashboard-header,
  .split-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-actions {
    justify-content: flex-start;
  }

  .quiz-detail-stats {
    justify-content: flex-start;
    max-width: none;
  }

  .quiz-editor-toolbar,
  .editor-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .answer-key-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .answer-key-row em {
    grid-column: 2;
    justify-self: start;
  }

  .room-code,
  .score-pill {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .compose-panel,
  .join-panel,
  .stage-card {
    padding: 18px;
  }

  h1 {
    font-size: 2.45rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  .answer-grid {
    grid-template-columns: 1fr;
  }

  .answer-summary {
    grid-template-columns: 1fr;
  }

  .answer-card {
    min-height: 84px;
  }

  .multi-submit-row {
    display: grid;
  }

  .multi-submit-row button {
    width: 100%;
  }

  .host-setup-head,
  .host-timing-card {
    grid-template-columns: 1fr;
  }

  .host-setup-head {
    display: grid;
  }

  .timing-card-input {
    grid-row: auto;
    grid-column: 1;
    justify-items: stretch;
  }

  .timing-card-input input {
    width: 100%;
  }

  .answer-waiting {
    min-height: 210px;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .lobby-roster {
    grid-template-columns: 1fr;
  }

  .control-bar {
    flex-direction: column;
  }

  .result-panel {
    grid-template-columns: 1fr;
  }

  .library-row {
    grid-template-columns: 1fr;
  }

  .source-line {
    white-space: normal;
  }

  .title-edit-label input {
    min-height: 52px;
    font-size: 1.55rem;
  }

  .tab-row,
  .editor-save-actions,
  .preview-nav {
    display: grid;
  }

  .tab-row button,
  .editor-save-actions button,
  .preview-nav button {
    width: 100%;
  }

  .quiz-editor-panel {
    padding: 14px;
  }

  .student-preview-option {
    grid-template-columns: 1fr;
  }

  .student-preview-option > span {
    width: auto;
    height: auto;
    min-height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .waiting-ring,
  .waiting-ring::after,
  .waiting-core,
  .waiting-dots span {
    animation: none;
  }
}
