:root {
  color-scheme: light;
  --ink: #070d2d;
  --muted: #62708f;
  --line: #e5e9f2;
  --soft: #f7f9fd;
  --brand: #ff5a1f;
  --brand-dark: #e8440a;
  --ok: #19b86a;
  --blue: #0b5aa8;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html {
  -webkit-user-select: none;
  user-select: none;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #fff 0%, #f4f7fb 48%, #fff2ec 100%);
}

[hidden] {
  display: none !important;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button, .primary, .ghost, .back-link, nav a {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
button:hover, .primary:hover, .ghost:hover, .back-link:hover, nav a:hover {
  transform: translateY(-1px);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  padding: 24px 18px;
  background: rgba(255,255,255,.92);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
  backdrop-filter: blur(16px);
  z-index: 10;
}

.brand, .sidebar a {
  color: inherit;
  text-decoration: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: end;
  gap: 4px;
}
.brand-mark span {
  width: 8px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #ff7a35, #ff4b12);
}
.brand-mark span:nth-child(1) { height: 14px; }
.brand-mark span:nth-child(2) { height: 24px; }
.brand-mark span:nth-child(3) { height: 31px; }
.brand-mark.small { transform: scale(.78); transform-origin: left center; }

nav { display: grid; gap: 8px; }
nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  color: #34415f;
  font-weight: 600;
}
nav a.active, nav a:hover {
  color: var(--brand-dark);
  background: #fff0e8;
}
.icon { width: 22px; text-align: center; }
.back-link {
  margin-top: auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  font-weight: 700;
}

.shell {
  margin-left: 260px;
  min-height: 100vh;
  padding: 26px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}
.menu-button {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  width: 42px;
  height: 42px;
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 4vw, 38px); }
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}
.primary, .ghost {
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  font-weight: 800;
}
.primary {
  color: #fff;
  background: linear-gradient(135deg, #ff7a35, #ff4b12);
  box-shadow: 0 14px 30px rgba(255, 86, 29, .22);
}
.ghost {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .06);
}
.wide { width: 100%; }

.view { display: none; }
.view.active { display: block; }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
}
.builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .8fr);
  gap: 22px;
}
.panel {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 24px;
  box-shadow: 0 18px 48px rgba(25, 35, 70, .08);
}
.privacy-shield {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  place-items: center;
  text-align: center;
  color: #fff;
  background: rgba(7, 13, 45, .92);
  backdrop-filter: blur(18px);
}
.privacy-shield.visible {
  display: grid;
}
.privacy-shield div {
  display: grid;
  gap: 8px;
  padding: 28px;
}
.privacy-shield strong {
  font-size: 28px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 18px;
}
.panel p { color: var(--muted); }
.status {
  white-space: nowrap;
  color: #0d7e49;
  background: #dff9ea;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
}
.status.warm { color: var(--brand-dark); background: #fff0e8; }

.projector {
  position: relative;
  overflow: hidden;
  min-height: 580px;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: clamp(22px, 4vw, 46px);
  background:
    radial-gradient(circle at 4% 18%, rgba(255, 88, 31, .18), transparent 30%),
    radial-gradient(circle at 97% 100%, rgba(255, 88, 31, .24), transparent 24%),
    linear-gradient(135deg, #fff 0%, #fff8f4 100%);
  text-align: center;
}
.projector-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.live-pill {
  margin-left: auto;
  color: var(--brand-dark);
  background: #fff0e8;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 800;
}
.projector h3 {
  margin: 34px 0 8px;
  font-size: clamp(42px, 8vw, 74px);
  letter-spacing: 0;
}
.projector h3::first-letter, .projector h3 span { color: var(--brand); }
.join-options {
  display: grid;
  grid-template-columns: 280px minmax(260px, 1fr);
  align-items: center;
  gap: 48px;
  max-width: 760px;
  margin: 26px auto;
}
.qr {
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 26px;
  border-radius: 18px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}
.qr div {
  min-height: 34px;
  background: #080d22;
  border-radius: 4px;
}
.qr div:nth-child(3n), .qr div:nth-child(5n) { background: var(--brand); }
.pin-card {
  text-align: left;
  display: grid;
  gap: 10px;
  padding: 26px;
  border-radius: 26px;
  background: rgba(255,255,255,.76);
  border: 1px solid var(--line);
}
.pin-card strong { color: var(--brand-dark); font-size: 26px; }
.pin-card button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 4px;
}
.pin-card small {
  color: var(--muted);
  line-height: 1.55;
}
.pin-card small a {
  color: var(--brand-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.copy-ok {
  display: inline-block;
  color: #0d7e49;
  margin-bottom: 4px;
}
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 820px;
  margin: 34px auto 0;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.82);
}
.steps span {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.steps b {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
}

.phone {
  max-width: 260px;
  margin: 16px auto 0;
  padding: 30px 18px;
  border: 10px solid #141923;
  border-radius: 34px;
  text-align: center;
  background: #fff8f4;
  box-shadow: 0 24px 50px rgba(0,0,0,.16);
}
.phone input, .settings-row input, .settings-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  background: #fff;
}
.quiz-form {
  display: grid;
  gap: 18px;
}
.quiz-form > input,
.participant-only input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: #fff;
}
.participant-hero {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: start center;
  padding-top: clamp(16px, 5vw, 72px);
}
.participant-card {
  width: min(100%, 760px);
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 5vw, 44px);
  background:
    radial-gradient(circle at 0 0, rgba(255, 90, 31, .14), transparent 30%),
    radial-gradient(circle at 100% 100%, rgba(11, 90, 168, .10), transparent 28%),
    rgba(255,255,255,.92);
}
.participant-logo {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  margin-bottom: 18px;
  background: #fff0e8;
}
.participant-card h2 {
  margin-bottom: 10px;
  font-size: clamp(34px, 6vw, 58px);
  letter-spacing: 0;
}
.join-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, .55fr) auto;
  gap: 12px;
  align-items: end;
  margin: 26px 0 18px;
}
.join-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.join-form input {
  margin-top: 8px;
  height: 54px;
  font-weight: 700;
  border-radius: 16px;
}
.security-note {
  padding: 12px 14px;
  border-radius: 12px;
  color: #7a3217;
  background: #fff0e8;
  font-size: 13px;
  font-weight: 700;
}
.participant-only fieldset,
.participant-card fieldset {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.participant-only legend,
.participant-card legend {
  padding: 0 8px;
  font-weight: 800;
}
.participant-only label,
.participant-card fieldset label {
  display: block;
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--soft);
}
.participant-card fieldset input {
  width: auto;
  margin-right: 8px;
}
.manager-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(100%, 520px);
  display: grid;
  gap: 16px;
  padding: clamp(28px, 5vw, 46px);
  background:
    radial-gradient(circle at 0 0, rgba(255, 90, 31, .16), transparent 30%),
    radial-gradient(circle at 100% 100%, rgba(11, 90, 168, .12), transparent 28%),
    rgba(255,255,255,.94);
}
.login-card h1 {
  font-size: clamp(32px, 7vw, 54px);
  line-height: 1.02;
}
.login-form {
  display: grid;
  gap: 14px;
}
.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.login-form input {
  width: 100%;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 16px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.login-error {
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 16px;
  color: #991b1b;
  background: #fff1f2;
  font-weight: 800;
}
.participant-link {
  color: var(--brand-dark);
  font-weight: 800;
  text-align: center;
}
.qr-box {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 280px);
  aspect-ratio: 1;
  border: 1px dashed #ffc4a9;
  border-radius: 28px;
  background: rgba(255,255,255,.82);
}
.qr-empty {
  max-width: 170px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}
.qr-img {
  width: min(100%, 280px);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 18px;
  background: #fff;
  display: none;
}
.qr-img.ready {
  display: block;
}
.qr-img.ready + .qr-empty {
  display: none;
}
.code-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  background: #fff;
  display: grid;
  gap: 4px;
}
.code-box strong { font-size: 30px; }

.dropzone {
  border: 2px dashed #ff8b5a;
  border-radius: 24px;
  padding: 34px;
  display: flex;
  align-items: center;
  gap: 24px;
  background: #fff8f4;
}
.pdf-icon {
  width: 74px;
  height: 74px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
  font-weight: 900;
}
.settings-row {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 120px 150px minmax(180px, 1fr) auto;
  gap: 14px;
  align-items: end;
}
.settings-row label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.settings-row input, .settings-row select { margin-top: 8px; }

.questions-list {
  display: grid;
  gap: 10px;
}
.questions-list article, .leaderboard div {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.questions-list b, .leaderboard b {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff0e8;
  color: var(--brand-dark);
}
.questions-list em {
  color: var(--brand-dark);
  background: #fff0e8;
  padding: 6px 10px;
  border-radius: 999px;
  font-style: normal;
  font-weight: 800;
}
.questions-list.full { margin-top: 18px; }
.leaderboard {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

body.menu-open .sidebar { transform: translateX(0); }

body.embed-mode {
  min-height: auto;
  background: linear-gradient(135deg, #f8fbff 0%, #fff 54%, #fff3ed 100%);
}

body.embed-mode .privacy-shield,
body.embed-mode .sidebar,
body.embed-mode .topbar {
  display: none;
}

body.embed-mode .shell {
  margin-left: 0;
  min-height: auto;
  padding: 0;
}

body.embed-mode .view.active {
  min-height: 100vh;
}

body.embed-mode .builder-grid,
body.embed-mode .content-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

body.embed-mode .panel {
  border-radius: 22px;
  box-shadow: none;
}

body.embed-mode .projector {
  min-height: 520px;
}

body.embed-mode .qr-box {
  overflow: hidden;
}

@media (max-width: 1160px) {
  .content-grid, .builder-grid { grid-template-columns: 1fr; }
  .side-panel { order: -1; }
}

@media (max-width: 880px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .shell {
    margin-left: 0;
    padding: 18px;
  }
  .menu-button { display: inline-grid; place-items: center; }
  .topbar { align-items: start; }
  .top-actions { gap: 8px; }
  .ghost { display: none; }
  .join-options, .steps, .settings-row {
    grid-template-columns: 1fr;
  }
  .join-form {
    grid-template-columns: 1fr;
  }
  .projector { min-height: auto; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .top-actions {
    width: 100%;
    margin-left: 0;
  }
  .primary, .ghost { padding: 12px 14px; }
  .avatar { margin-left: auto; }
  .projector-brand { flex-wrap: wrap; }
  .live-pill { margin-left: 0; }
  .dropzone {
    padding: 22px;
    flex-direction: column;
    align-items: start;
  }
  .panel { padding: 18px; }
}

@media print {
  body * {
    visibility: hidden !important;
  }
  body::before {
    content: "Printing is disabled for this protected quiz.";
    visibility: visible;
    display: grid;
    place-items: center;
    min-height: 100vh;
    font: 700 24px Inter, sans-serif;
  }
}
