/* quiz/css/quiz.css — styles for index, host, and play pages */

/* ── Shared layout ──────────────────────────────────────────── */

.quiz-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.quiz-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  width: 100%;
}

.quiz-heading {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}
.quiz-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 24px;
}

/* ── Answer option colors ───────────────────────────────────── */

:root {
  --qa: #E53E3E;
  --qb: #3182CE;
  --qc: #2F9E44;
  --qd: #D4760A;
  --qa-light: #FEE2E2;
  --qb-light: #DBEAFE;
  --qc-light: #DCFCE7;
  --qd-light: #FEF3C7;
  --qa-icon: "▲";
  --qb-icon: "◆";
  --qc-icon: "●";
  --qd-icon: "■";
}

/* ── Pack browser tabs ──────────────────────────────────────── */

.quiz-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--toolbar-border);
  margin-bottom: 20px;
}
.quiz-tab {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.quiz-tab.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}
.quiz-tab-panel { display: none; }
.quiz-tab-panel.active { display: block; }

/* ── Pack grid ─────────────────────────────────────────────── */

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.pack-card {
  background: var(--surface);
  border: 2px solid var(--toolbar-border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  user-select: none;
}
.pack-card:hover { border-color: var(--purple-light); box-shadow: var(--shadow); }
.pack-card.selected { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-light); }
.pack-emoji { font-size: 32px; margin-bottom: 8px; }
.pack-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.pack-meta { font-size: 12px; color: var(--text-muted); }
.pack-meta span + span::before { content: ' · '; }
.pack-cat-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--purple-light);
  color: var(--purple);
}

/* ── Community controls ─────────────────────────────────────── */
.community-controls { display: flex; gap: 8px; margin-bottom: 16px; }
.community-search {
  flex: 1;
  box-sizing: border-box;
  padding: 9px 14px;
  border: 1.5px solid var(--toolbar-border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--btn-text);
  margin-bottom: 10px;
}
.community-search:focus { outline: none; border-color: var(--purple); }
.community-cat-select {
  padding: 9px 10px;
  border: 1.5px solid var(--toolbar-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--btn-text);
  cursor: pointer;
  white-space: nowrap;
}
.community-cat-select:focus { outline: none; border-color: var(--purple); }
.cat-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-pill {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--toolbar-border);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.cat-pill:hover { border-color: var(--purple); color: var(--purple); }
.cat-pill.active { background: var(--purple); border-color: var(--purple); color: #fff; }

.community-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 16px 0 8px;
}
.community-section-label:first-child { margin-top: 0; }
.community-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  padding: 0 8px;
}
.pack-spotlight {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 3px var(--purple-light);
}

.pack-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Built-in pagination ────────────────────────────────────── */
.pack-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 20px;
}
.pack-page-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid var(--btn-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--btn-text);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.pack-page-btn:hover:not(:disabled) { border-color: var(--purple); color: var(--purple); }
.pack-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.pack-page-label { font-size: 13px; color: var(--text-muted); font-weight: 600; min-width: 90px; text-align: center; }

/* ── Session config panel ───────────────────────────────────── */

.quiz-config {
  background: var(--surface);
  border: 1px solid var(--toolbar-border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}
.quiz-config h3 { margin: 0 0 16px; font-size: 15px; font-weight: 700; }
.quiz-config-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.quiz-config-field { flex: 1; min-width: 160px; }
.quiz-config-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.quiz-config-field input,
.quiz-config-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 14px;
  box-sizing: border-box;
}
.quiz-config-field input:focus,
.quiz-config-field select:focus { outline: 2px solid var(--purple); border-color: transparent; }

.btn-launch {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn-launch:hover { background: var(--purple-dark); }
.btn-launch:disabled { background: var(--btn-border); cursor: not-allowed; }

/* ── My packs section ───────────────────────────────────────── */

.my-packs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.btn-new-pack {
  padding: 8px 16px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-new-pack:hover { background: var(--purple-dark); }

.my-pack-list { display: flex; flex-direction: column; gap: 10px; }
.my-pack-row {
  background: var(--surface);
  border: 1px solid var(--toolbar-border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.my-pack-row-emoji { font-size: 22px; flex-shrink: 0; }
.my-pack-row-info { flex: 1; min-width: 0; }
.my-pack-row-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.my-pack-row-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.my-pack-row-meta span + span::before { content: ' · '; }
.my-pack-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-sm {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-text);
  transition: background .12s;
}
.btn-sm:hover { background: var(--btn-hover); }
.btn-sm.danger { border-color: #fca5a5; color: #dc2626; }
.btn-sm.danger:hover { background: #fee2e2; }
.btn-sm.success { border-color: #86efac; color: #15803d; }
.btn-sm.success:hover { background: #dcfce7; }
.badge-public {
  display: inline-block;
  background: var(--qc-light);
  color: var(--qc);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
  margin-left: 4px;
}
.badge-pending-review {
  display: inline-block;
  background: #fff3cd; color: #78500a;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .04em;
  vertical-align: middle; margin-left: 4px;
}

/* ── Pack editor modal ──────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 5000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 680px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  position: relative;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px;
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
}
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 14px;
  box-sizing: border-box;
  font-family: inherit;
}
.form-textarea { resize: vertical; min-height: 70px; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: 2px solid var(--purple); border-color: transparent; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.form-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--purple); }

/* ── Question editor ─────────────────────────────────────────── */

.q-editor-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; max-height: 300px; overflow-y: auto; }
.q-editor-row {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color .12s;
}
.q-editor-row:hover { border-color: var(--purple-light); }
.q-editor-row.editing { border-color: var(--purple); background: var(--surface-2); }
.q-editor-num { font-size: 12px; color: var(--text-muted); font-weight: 700; flex-shrink: 0; width: 24px; }
.q-editor-text { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-editor-badge { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.q-editor-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; flex-shrink: 0; padding: 2px 6px; border-radius: 4px; }
.q-editor-del:hover { background: #fee2e2; color: #dc2626; }

.q-edit-form {
  border: 2px solid var(--purple);
  border-radius: 10px;
  padding: 16px;
  margin-top: 12px;
  background: var(--surface-2);
}
.q-edit-form .form-group { margin-bottom: 10px; }
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.option-row { display: flex; flex-direction: column; gap: 4px; }
.option-label-row { display: flex; align-items: center; gap: 6px; }
.option-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.option-label-text { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.correct-radio { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.correct-radio input { accent-color: var(--purple); }

.q-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn-primary-sm {
  padding: 8px 18px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary-sm:hover { background: var(--purple-dark); }
.btn-cancel-sm {
  padding: 8px 14px;
  background: none;
  border: 1px solid var(--btn-border);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.add-q-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 2px dashed var(--btn-border);
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
  justify-content: center;
  transition: border-color .12s, color .12s;
}
.add-q-btn:hover { border-color: var(--purple-light); color: var(--purple); }

.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; border-top: 1px solid var(--toolbar-border); padding-top: 16px; }
.btn-modal-save {
  padding: 10px 24px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-modal-save:hover { background: var(--purple-dark); }
.btn-modal-cancel {
  padding: 10px 18px;
  background: none;
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

/* ── Host view ───────────────────────────────────────────────── */

.host-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.host-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--toolbar-border);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.host-topbar-title { font-size: 15px; font-weight: 700; }
.host-session-code {
  font-size: 13px;
  color: var(--text-muted);
}
.host-session-code strong {
  color: var(--purple);
  font-size: 15px;
  letter-spacing: .08em;
}
.host-q-label { font-size: 13px; font-weight: 700; color: var(--purple); }
.host-player-count { font-size: 13px; color: var(--text-muted); margin-left: auto; }
.host-topbar-close {
  background: none;
  border: 1px solid var(--btn-border);
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

.host-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* ── Lobby (waiting room) ──────────────────────────────────── */

.host-lobby {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
.lobby-code-display {
  background: var(--surface);
  border: 2px solid var(--toolbar-border);
  border-radius: 20px;
  padding: 32px 48px;
  margin-bottom: 32px;
}
.lobby-join-url {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.lobby-code {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: .15em;
  color: var(--purple);
  font-family: monospace;
}
.lobby-players {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}
.lobby-names {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
  min-height: 20px;
  max-width: 500px;
}
.btn-start-quiz {
  padding: 16px 40px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-start-quiz:hover { background: var(--purple-dark); transform: scale(1.02); }
.btn-start-quiz:disabled { background: var(--btn-border); cursor: not-allowed; transform: none; }

/* ── Host question view ─────────────────────────────────────── */

.host-q-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.host-progress-bar {
  height: 6px;
  background: var(--toolbar-border);
}
.host-progress-fill {
  height: 100%;
  background: var(--purple);
  transition: width .5s linear;
}
.host-q-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 40px 20px;
}
.host-q-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.host-timer {
  font-size: 32px;
  font-weight: 900;
  font-family: monospace;
  color: var(--purple);
}
.host-timer.urgent { color: #E53E3E; }
.host-q-text {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 32px;
  flex: 1;
}
.host-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.host-option {
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.host-option-shape { font-size: 18px; flex-shrink: 0; }
.host-option-text { flex: 1; }
.host-option:nth-child(1) { background: var(--qa); }
.host-option:nth-child(2) { background: var(--qb); }
.host-option:nth-child(3) { background: var(--qc); }
.host-option:nth-child(4) { background: var(--qd); }

.host-answer-count {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 16px;
}

/* ── Host answer reveal ─────────────────────────────────────── */

.host-answer-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 40px 20px;
}
.host-answer-q {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}
.host-answer-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.host-answer-opt {
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  opacity: .4;
  transition: opacity .3s;
}
.host-answer-opt.correct { opacity: 1; }
.host-answer-opt:nth-child(1) { background: var(--qa); color: #fff; }
.host-answer-opt:nth-child(2) { background: var(--qb); color: #fff; }
.host-answer-opt:nth-child(3) { background: var(--qc); color: #fff; }
.host-answer-opt:nth-child(4) { background: var(--qd); color: #fff; }
.host-answer-opt .answer-count-badge {
  margin-left: auto;
  background: rgba(255,255,255,.25);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 13px;
}

.host-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 120px;
  margin-bottom: 24px;
}
.host-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.host-bar-fill { width: 100%; border-radius: 6px 6px 0 0; transition: height .5s; min-height: 4px; }
.host-bar-label { font-size: 11px; font-weight: 700; color: var(--text-muted); }
.host-bar-count { font-size: 13px; font-weight: 700; }
.host-bar-col:nth-child(1) .host-bar-fill { background: var(--qa); }
.host-bar-col:nth-child(2) .host-bar-fill { background: var(--qb); }
.host-bar-col:nth-child(3) .host-bar-fill { background: var(--qc); }
.host-bar-col:nth-child(4) .host-bar-fill { background: var(--qd); }

.host-leaderboard { }
.host-leaderboard h3 { font-size: 14px; font-weight: 700; color: var(--text-muted); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--toolbar-border); font-size: 14px; }
.lb-rank { width: 24px; text-align: center; font-weight: 700; color: var(--text-muted); }
.lb-rank.top3 { color: #D69E2E; }
.lb-name { flex: 1; font-weight: 600; }
.lb-score { font-weight: 700; color: var(--purple); }

.host-controls {
  display: flex;
  gap: 10px;
  padding: 16px 40px 24px;
  border-top: 1px solid var(--toolbar-border);
  justify-content: flex-end;
}
.btn-host-action {
  padding: 12px 28px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn-host-action:hover { background: var(--purple-dark); }
.btn-host-action.secondary { background: var(--btn-bg); color: var(--btn-text); border: 1px solid var(--btn-border); }
.btn-host-action.secondary:hover { background: var(--btn-hover); }
.btn-host-action.danger { background: #E53E3E; }
.btn-host-action.danger:hover { background: #C53030; }

/* ── Ended screen ───────────────────────────────────────────── */

.host-ended {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 40px 24px;
  text-align: center;
}
.host-ended h2 { font-size: 28px; font-weight: 900; margin-bottom: 32px; }
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}
.podium-place { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.podium-name { font-size: 14px; font-weight: 700; max-width: 100px; word-break: break-word; }
.podium-score { font-size: 12px; color: var(--text-muted); }
.podium-block { border-radius: 8px 8px 0 0; width: 80px; }
.podium-place.p1 .podium-block { height: 120px; background: #D69E2E; }
.podium-place.p2 .podium-block { height: 90px; background: #A0AEC0; }
.podium-place.p3 .podium-block { height: 70px; background: #C05621; }
.podium-medal { font-size: 28px; }
.podium-medal-avatar { font-size: 36px; line-height: 1; margin-bottom: 2px; }

/* ── Play page ───────────────────────────────────────────────── */

.play-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.play-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Join screen */
.play-join {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 24px;
  text-align: center;
}
.play-join h1 { font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.play-join p { color: var(--text-muted); margin-bottom: 32px; }
.play-join-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.play-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--btn-border);
  border-radius: 10px;
  font-size: 18px;
  background: var(--surface);
  color: var(--btn-text);
  text-align: center;
  font-weight: 700;
  letter-spacing: .05em;
  box-sizing: border-box;
}
.play-input:focus { outline: 2px solid var(--purple); border-color: transparent; }
.play-input::placeholder { font-weight: 400; letter-spacing: 0; }
.btn-play-join {
  width: 100%;
  padding: 16px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.btn-play-join:hover { background: var(--purple-dark); }
.play-err { color: #E53E3E; font-size: 14px; font-weight: 600; min-height: 20px; }

/* Player lobby */
.play-lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 24px;
  text-align: center;
}
.play-lobby-name { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.play-lobby-wait { font-size: 15px; color: var(--text-muted); }
.play-lobby-count { font-size: 40px; font-weight: 900; color: var(--purple); margin: 16px 0 4px; }
.play-lobby-label { font-size: 13px; color: var(--text-muted); }

/* Question view */
.play-q-view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.play-progress { height: 6px; background: var(--toolbar-border); }
.play-progress-fill { height: 100%; background: var(--purple); transition: width .5s linear; }
.play-q-header {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.play-q-num { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.play-timer-wrap { display: flex; align-items: center; gap: 6px; }
.play-timer { font-size: 22px; font-weight: 900; font-family: monospace; color: var(--purple); }
.play-timer.urgent { color: #E53E3E; }
.play-score { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.play-q-text {
  padding: 12px 20px 20px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  flex: 1;
}
.play-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 14px 20px;
}
.play-option-btn {
  border: none;
  border-radius: 12px;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  min-height: 100px;
}
.play-option-btn .opt-shape { font-size: 22px; }
.play-option-btn:nth-child(1) { background: var(--qa); }
.play-option-btn:nth-child(2) { background: var(--qb); }
.play-option-btn:nth-child(3) { background: var(--qc); }
.play-option-btn:nth-child(4) { background: var(--qd); }
.play-option-btn:hover { opacity: .88; transform: scale(1.02); }
.play-option-btn:active { transform: scale(.97); }
.play-option-btn:disabled { cursor: default; transform: none; }
.play-answered-msg {
  text-align: center;
  padding: 32px 24px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Answer reveal */
.play-answer-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 24px;
  text-align: center;
  min-height: 100%;
  gap: 16px;
}
.play-result-icon { font-size: 64px; }
.play-result-text { font-size: 22px; font-weight: 900; }
.play-result-text.correct { color: var(--qc); }
.play-result-text.wrong { color: var(--qa); }
.play-result-text.noans { color: var(--text-muted); }
.play-correct-answer {
  background: var(--surface);
  border: 2px solid var(--qc);
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
}
.play-result-score { font-size: 16px; color: var(--text-muted); }
.play-result-score strong { color: var(--purple); font-size: 20px; }
.play-waiting { font-size: 14px; color: var(--text-muted); }

/* Ended / Leaderboard */
.play-ended {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  text-align: center;
  min-height: 100%;
}
.play-ended h2 { font-size: 26px; font-weight: 900; margin-bottom: 6px; }
.play-final-score { font-size: 18px; color: var(--text-muted); margin-bottom: 32px; }
.play-final-score strong { color: var(--purple); font-size: 24px; }
.play-lb { width: 100%; max-width: 360px; }
.play-lb-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--toolbar-border); font-size: 15px; }
.play-lb-rank { width: 28px; text-align: center; font-weight: 900; color: var(--text-muted); }
.play-lb-rank.gold { color: #D69E2E; font-size: 18px; }
.play-lb-rank.silver { color: #718096; font-size: 16px; }
.play-lb-rank.bronze { color: #C05621; font-size: 14px; }
.play-lb-name { flex: 1; font-weight: 600; }
.play-lb-me { color: var(--purple); }
.play-lb-score { font-weight: 700; color: var(--purple); }
.play-again-btn {
  margin-top: 32px;
  padding: 14px 32px;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.play-again-btn:hover { background: var(--purple-dark); }

/* ── Login required banner ──────────────────────────────────── */

.login-required {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.login-required a { color: var(--purple); font-weight: 600; text-decoration: none; }

/* ── Pack groups ─────────────────────────────────────────────── */

.group-pills-wrap { margin-bottom: 16px; }
.group-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.group-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--toolbar-border);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.group-pill:hover { border-color: var(--purple); color: var(--purple); }
.group-pill.active { background: var(--purple); border-color: var(--purple); color: #fff; }

.group-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.group-join-input { width: 120px !important; }

.group-info-box {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--toolbar-border);
  border-radius: 10px;
  font-size: 13px;
}
.group-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.group-code {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  font-family: monospace;
  color: var(--purple);
}
.group-member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--toolbar-border);
  font-size: 13px;
}
.group-member-row:last-child { border-bottom: none; }
.group-member-name { flex: 1; }

/* ── Pack share panel (My Packs → Share button) ─────────────── */

.btn-sm.active-share { border-color: #86efac; color: #15803d; background: #dcfce7; }
.btn-sm.active-share:hover { background: #bbf7d0; }

.pack-share-panel {
  flex: 0 0 100%;
  padding: 10px 12px;
  background: var(--bg-muted, #f4f3ee);
  border-radius: 8px; display: flex; flex-direction: column; gap: 6px;
}
.pack-share-group-row { display: flex; align-items: center; gap: 10px; }
.pack-share-group-name { flex: 1; font-size: 13px; }
.pack-share-empty { font-size: 13px; color: var(--text-muted); }

/* ── Utility ────────────────────────────────────────────────── */

.hidden { display: none !important; }
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid var(--toolbar-border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Emoji picker ───────────────────────────────────────────── */

.emoji-field-group { position: relative; }

.emoji-pick-btn {
  width: 100%;
  height: 52px;
  font-size: 28px;
  border: 2px solid var(--toolbar-border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .12s;
  font-family: inherit;
}
.emoji-pick-btn:hover { border-color: var(--purple); }

.emoji-picker-panel {
  position: absolute;
  z-index: 200;
  background: var(--surface);
  border: 1.5px solid var(--toolbar-border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  width: 284px;
}
.emoji-picker-search {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1.5px solid var(--toolbar-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--btn-text);
  margin-bottom: 8px;
}
.emoji-picker-search:focus { outline: none; border-color: var(--purple); }
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}
.emoji-picker-grid button {
  font-size: 22px;
  padding: 5px 2px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  transition: background .1s;
}
.emoji-picker-grid button:hover { background: var(--surface-2); }

@media (max-width: 600px) {
  .host-q-main, .host-answer-view { padding: 20px 20px 16px; }
  .host-q-text { font-size: 20px; }
  .host-options-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .host-controls { padding: 12px 20px 20px; }
  .play-options { gap: 8px; padding: 0 10px 16px; }
  .play-option-btn { min-height: 80px; font-size: 13px; padding: 14px 10px; }
  .play-q-text { font-size: 17px; }
}
