/* ================================
   Global reset & base
================================ */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  background: #f7f7f8;
  color: #1f2937;
}

button {
  font-size: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
}

.sidebar-separator {
  border: none;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent,
    rgba(255, 255, 255, 0.25),
    transparent
  );
  margin: 10px 0 10px 0;
}

.session-sidebar h2 {
  margin-top: 4px;
}

.session-meta .meta-label {
  white-space: nowrap;
}

input {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
}

.btn {
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn.primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  border: none;
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  border: none;
}

.btn.answer {
  margin-bottom: 10px;
  width: 100%;
}


/* ================================
   Landing page
================================ */
.landing-wrapper {
  min-height: 100svh;
  display: flex;
  background: #f7f7f8;
}

/* Left: hero */
.landing-hero {
  flex: 1;
  background: #3ba0ff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.landing-hero img {
  max-width: 420px;
  width: 100%;
  height: auto;
}

/* ================================
   Landing clarity helpers
================================ */

.landing-hint {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.landing-section {
  margin-top: 8px;
}

.landing-section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.landing-section-help {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 10px;
}


/* Right: form */
.landing-form-pane {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.landing-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 16px;
  padding: 10px 28px 28px 28px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.landing-card input + input {
  margin-top: 12px;
}

.landing-card button {
  width: 100%;
  margin-top: 16px;
}

.landing-divider {
  margin: 18px 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}

/* ================================
   Mobile hero reduction (landing)
================================ */
@media (max-width: 600px) {
  .landing-hero {
    padding: 20px 16px;
    min-height: 35svh;     /* was effectively much larger */
  }

  .landing-hero img {
    max-width: 240px;      /* was 420px */
  }

  .landing-form-pane {
    align-items: flex-start;
    padding-top: 12px;
  }

  .landing-card {
    margin-top: -24px;   /* slight overlap effect */
  }
}

/* ================================
   Join row (code + PIN)
================================ */
.join-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.join-row input {
  height: 48px;
  padding: 12px;
  line-height: 24px;
}

.join-row input + input {
  margin-top: 0; /* ← critical fix */
}

.join-row input[name="session_code"] {
  flex: 3;
  text-transform: uppercase;
}

.join-row input[name="pin"] {
  flex: 2;
  text-align: center;
}

/* ================================
   Action row (Join + Host)
================================ */
.action-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.action-row form {
  margin: 0;
}

.action-row button {
  margin-top: 0;
  height: 48px;
}

.action-row .primary {
  flex: 3;
}

.action-row .secondary {
  flex: 2;
}


/* ================================
   Mobile collapse (landing)
================================ */
@media (max-width: 900px) {
  .landing-wrapper {
    flex-direction: column;
  }

  .landing-hero {
    padding: 40px 24px;
  }

  .landing-form-pane {
    padding: 24px;
  }
}

/* ================================
   Session layout
================================ */
.session-shell {
  display: flex;
  height: 100svh;
}

/* Left panel */
.session-sidebar {
  width: 260px;
  background: #111827;
  color: #f9fafb;
  display: flex;
  flex-direction: column;
  padding: 16px;
  height: 100%;
}

.session-sidebar h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
}

.participant-list {
  flex: 1;
  overflow-y: auto;
}

.participant {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.08);
  font-size: 14px;
}

.answered-check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;

  opacity: 0;
  transform: scale(0.8);
  animation: answeredFadeIn 180ms ease-out forwards;
}

@keyframes answeredFadeIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.participant.host {
  font-weight: 600;
  background: rgba(37,99,235,0.35);
}

.participant-name {
  display: inline-flex;
  align-items: center;
}

.host-crown {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: middle;
}

.leave-btn {
  margin-top: auto;
}

.session-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.session-header {
  text-align: center;
  margin-bottom: 32px;
}

.session-code-row {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.session-code {
  font-size: 16px;
  letter-spacing: 2px;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-pin {
  font-size: 16px;
  margin-top: 2px;
}

.session-content {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.random-number {
  font-size: 48px;
  margin-top: 24px;
}

/* ================================
   Mobile adjustments (session)
================================ */
@media (max-width: 768px) {

  .session-meta .meta-label {
    font-size: 11px;
    opacity: 0.8;
    letter-spacing: 0.4px;
  }

  .session-code {
    font-size: 13px;
    letter-spacing: 1px;
    overflow: visible;
    text-overflow: unset;
  }

  .share-btn {
    padding: 2px 6px;
    font-size: 13px;
  }

  .session-sidebar {
    width: 120px;
    padding: 8px;
  }

  .participant-list {
    display: block;
    max-height: 120px;
    overflow-y: auto;
  }

  .participant {
    font-size: 12px;
    padding: 6px 6px;
    text-align: center;
  }

  .leave-btn {
    width: 100%;
    font-size: 12px;
    padding: 6px;
  }

  .session-sidebar h2 {
    font-size: 12px;
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: 0.5px;
  }
}

@media (max-width: 360px) {
  .join-row {
    flex-direction: column;
  }

  .action-row {
    flex-direction: column;
  }
}

/* ================================
   Game UI
================================ */

.ui-status {
  font-size: 18px;
  margin-bottom: 20px;
  color: #374151;
}

.ui-question {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
}

.ui-answers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.ui-answers button {
  font-size: 18px;
}

.ui-cohorts {
  margin-top: 24px;
}

.cohort-group {
  margin-bottom: 16px;
}

.cohort-group h4 {
  margin-bottom: 8px;
}

.cohort-member {
  font-size: 14px;
  color: #374151;
}

.ui-host-controls {
  margin-top: 32px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.ui-host-controls button {
  min-width: 140px;
}


/* ================================
   Host pre-game controls (final)
================================ */

.host-setup {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  max-width: 420px;
  margin: 0 auto;
}

/* Section title */
.host-section-title {
  font-size: 18px;
  font-weight: 600;
  text-align: left;
  margin-bottom: 6px;
}

/* Topics */
.host-topics-group {
  width: 100%;
}

.host-topic-box {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  padding: 6px 0;
}

.host-topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 15px;
  cursor: pointer;
}

/* Topic checkbox sizing + spacing fix */
.host-topic-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  transform: none; /* cancel any global scaling */
}

/* Reduce space between checkbox and label */
.host-topic-item {
  gap: 8px; /* was effectively larger before */
}

.host-topic-item span {
  text-align: left;
}

.host-topic-item:hover {
  background: rgba(0,0,0,0.04);
}

/* Topic actions */
.host-topic-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

/* Config row: Rounds + Timer */
.host-config-row {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: space-between;
}

.host-setup-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.host-setup-group label {
  font-size: 14px;
  font-weight: 500;
}

.host-setup-group input,
.host-setup-group select {
  height: 46px;
  font-size: 16px;
  border-radius: 8px;
}

/* Start button */
.host-start-btn {
  width: 100%;
  height: 48px;
  font-size: 16px;
  font-weight: 600;
}

/* Mobile */
@media (max-width: 600px) {
  .host-config-row {
    flex-direction: row;
    justify-content: center;
    gap: 20px;
  }

  .host-setup-group {
    flex: 0 0 auto;
    align-items: center;
    text-align: center;
  }
}

/* --------------------------------
   Host config input sizing fix
-------------------------------- */

.host-setup-group input,
.host-setup-group select {
  width: auto;           /* cancel global 100% */
  max-width: 100px;      /* numeric control size */
}

@media (max-width: 600px) {
  .host-setup-group {
    align-items: center;
    text-align: center;
  }
}

/* --------------------------------
   Topic selector corrections
-------------------------------- */

/* Topics must be left-aligned */
.host-topics-group {
  align-items: stretch;   /* override center */
}

/* Header: stack title and buttons cleanly */
.host-topics-header {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

/* Topic list should be visually centered but not narrow */
.host-topic-box {
  margin: 0 auto;
  width: 100%;
  max-width: 360px;
}


.answer-progress {
  margin-top: 12px;
  font-size: 14px;
  opacity: 0.9;
}

.answer-progress-row {
  margin: 4px 0;
}
.answer-progress {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed rgba(0,0,0,0.15);
}

.share-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}

.audio-unlock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.audio-unlock-btn {
  font-size: 18px;
  padding: 14px 20px;
  border-radius: 8px;
  border: none;
  background: #2563eb;
  color: #fff;
}
