:root {
  --ink: #17152b;
  --paper: #f7f5ef;
  --card: #fff;
  --violet: #7057e8;
  --violet-dark: #5139c8;
  --lime: #c8f44b;
  --coral: #ff795f;
  --muted: #777486;
  --line: #e7e3db;
  --shadow: 0 18px 50px rgba(27, 21, 63, .1);
  --radius: 22px;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; color: var(--ink); font-family: "DM Sans", sans-serif; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(112,87,232,.3); outline-offset: 2px; }
[hidden] { display: none !important; }
.ambient { position: fixed; border-radius: 50%; filter: blur(2px); pointer-events: none; opacity: .5; z-index: -1; }
.ambient-one { width: 360px; height: 360px; right: -180px; top: 25%; background: #ddd5ff; }
.ambient-two { width: 260px; height: 260px; left: -140px; bottom: -60px; background: #efffbf; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font: 800 20px "Syne", sans-serif; letter-spacing: -.7px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--ink); background: var(--lime); border-radius: 10px 4px 10px 4px; transform: rotate(-4deg); }
.auth-layout { display: grid; grid-template-columns: minmax(400px, .9fr) minmax(520px, 1.1fr); min-height: 100vh; }
.auth-story { color: #fff; background: var(--ink); padding: 44px clamp(38px, 6vw, 90px); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.auth-story::after { content: ""; position: absolute; width: 460px; height: 460px; border: 1px solid rgba(255,255,255,.12); border-radius: 45% 55% 63% 37%; right: -230px; bottom: -120px; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.02); }
.auth-story .brand { color: white; }
.story-copy { margin: auto 0; max-width: 590px; position: relative; z-index: 1; }
.eyebrow, .step { color: var(--violet); font-size: 11px; font-weight: 800; letter-spacing: 1.8px; margin: 0 0 14px; }
.story-copy .eyebrow { color: var(--lime); }
h1, h2, h3 { font-family: "Syne", sans-serif; margin-top: 0; }
h1 { font-size: clamp(52px, 6vw, 86px); line-height: .96; letter-spacing: -4px; margin-bottom: 28px; }
h1 em { color: var(--lime); font-style: normal; }
.story-copy > p:not(.eyebrow) { color: #c3c0d0; max-width: 510px; font-size: 18px; line-height: 1.7; }
.role-row { display: flex; align-items: center; gap: 13px; color: #aaa6b9; font-size: 10px; font-weight: 700; letter-spacing: 2px; margin-top: 45px; }
.role-row i { width: 34px; height: 1px; background: #4c4960; }
.auth-panel { padding: 36px clamp(24px, 7vw, 110px); display: grid; place-items: center; }
.auth-card { width: min(100%, 500px); }
.switcher { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; background: #ebe8e1; border-radius: 14px; padding: 5px; margin-bottom: 36px; }
.switcher button { padding: 11px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.switcher button.active { color: var(--ink); background: #fff; box-shadow: 0 2px 10px rgba(23,21,43,.07); }
.auth-form { display: grid; gap: 21px; }
h2 { font-size: 31px; line-height: 1.1; letter-spacing: -1.2px; margin-bottom: 0; }
h3 { letter-spacing: -.5px; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 12px; padding: 13px 14px; transition: border .2s, box-shadow .2s; }
input:hover, textarea:hover, select:hover { border-color: #c7c0d7; }
textarea { resize: vertical; min-height: 90px; }
.photo-heading { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.photo-heading small { color: var(--coral); text-transform: uppercase; font-size: 9px; letter-spacing: 1px; }
.camera-frame { background: #e9e6df; border-radius: 16px; height: 190px; overflow: hidden; position: relative; }
.camera-frame video, .camera-frame canvas { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.camera-frame canvas { display: none; }
#camera-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; font-size: 12px; }
#camera-placeholder span { font-size: 30px; color: #aaa6b0; }
.camera-actions { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 10px; }
.button { border: 0; border-radius: 12px; padding: 12px 17px; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s, opacity .15s; display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.button.primary { background: var(--violet); color: white; box-shadow: 0 8px 20px rgba(112,87,232,.23); }
.button.primary:hover { background: var(--violet-dark); }
.button.secondary { border: 1px solid var(--line); background: #fff; }
.button.danger { color: #a33c35; border: 1px solid #f0c9c5; background: #fff4f2; }
.button.participant { color: #fff; background: #2e8b7d; box-shadow: 0 7px 16px rgba(46,139,125,.18); }
.button.participant:hover { background: #237568; }
.button.danger:hover { background: #ffe8e4; }
.button.text-button { color: var(--violet); padding-inline: 10px; }
.button.wide { width: 100%; padding: 15px 20px; justify-content: space-between; }
.form-note { color: var(--muted); font-size: 11px; text-align: center; margin: -10px 0 0; }
.muted { color: var(--muted); line-height: 1.6; }
.toast { position: fixed; z-index: 50; left: 50%; top: 22px; transform: translate(-50%, -90px); opacity: 0; background: var(--ink); color: white; border-radius: 12px; padding: 12px 18px; box-shadow: var(--shadow); transition: .25s; font-size: 13px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #b43c39; }

.app-shell { min-height: 100vh; }
.topbar { height: 78px; padding: 0 clamp(20px, 5vw, 72px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: rgba(247,245,239,.9); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20; }
.main-nav { align-self: stretch; display: flex; gap: 30px; }
.main-nav button { position: relative; border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer; }
.main-nav button.active { color: var(--ink); }
.main-nav button.active::after { content: ""; position: absolute; height: 3px; background: var(--violet); border-radius: 3px 3px 0 0; left: 0; right: 0; bottom: 0; }
.player-menu { justify-self: end; display: flex; align-items: center; gap: 10px; }
.player-menu img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.player-menu div { display: grid; font-size: 12px; }
.player-menu small { color: var(--muted); text-transform: capitalize; }
.player-menu button { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.player-menu .return-admin { padding: 8px 11px; border-radius: 9px; background: #eee9ff; color: var(--violet); font-size: 11px; font-weight: 800; white-space: nowrap; }
.content { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 52px 0 80px; }
.page-heading { display: flex; justify-content: space-between; gap: 25px; align-items: end; margin-bottom: 28px; }
.page-heading h1 { font-size: clamp(34px, 5vw, 54px); letter-spacing: -2.5px; margin: 0 0 7px; }
.page-heading p { margin: 0; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 30px; padding: 7px 11px; color: #5e7720; background: #edf8cc; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #91be24; box-shadow: 0 0 0 4px rgba(145,190,36,.15); }
.pill.draft { color: #7a668e; background: #eee9f6; }
.pill.draft::before { background: #9374b1; }
.pill.scored { color: #387266; background: #dff3ef; }
.pill.scored::before { background: #3a9581; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(23,21,43,.04); padding: 26px; }
.hero-panel { background: var(--ink); color: white; border: 0; position: relative; overflow: hidden; padding: clamp(27px, 5vw, 52px); }
.hero-panel::after { content: "?"; font: 800 210px "Syne"; color: rgba(255,255,255,.035); position: absolute; right: 38px; top: -47px; }
.hero-panel .eyebrow { color: var(--lime); }
.hero-panel h2 { font-size: clamp(30px, 5vw, 50px); max-width: 780px; }
.hero-panel > p { color: #bbb8c9; font-size: 17px; line-height: 1.6; max-width: 720px; }
.progress-line { margin-top: 26px; display: flex; align-items: center; gap: 10px; color: #c5c1d3; font-size: 12px; }
.progress-line span { color: var(--lime); font-weight: 700; }
.game-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 24px; margin-top: 24px; align-items: start; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.answer-card { background: white; border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.answer-media { height: 180px; background: #ebe8e4; display: grid; place-items: center; }
.answer-media img { width: 100%; height: 100%; object-fit: cover; }
.answer-media audio { width: calc(100% - 25px); }
.audio-art { width: 100%; height: 100%; background: linear-gradient(135deg, #e4dcff, #f4f0ff); display: grid; place-items: center; }
.audio-art span { font-size: 45px; }
.answer-by { padding: 13px; display: flex; align-items: center; gap: 9px; }
.answer-by img { width: 31px; height: 31px; border-radius: 50%; object-fit: cover; }
.answer-by strong { font-size: 13px; }
.rank-panel { position: sticky; top: 100px; }
.rank-panel h3 { margin-bottom: 5px; }
.rank-panel > p { margin-top: 0; font-size: 12px; color: var(--muted); }
.rank-list { list-style: none; margin: 20px 0; padding: 0; display: grid; gap: 9px; counter-reset: rank; }
.rank-item { counter-increment: rank; display: grid; grid-template-columns: 26px 34px 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 13px; background: #fbfaf7; padding: 9px 10px; cursor: grab; transition: .15s; }
.rank-item::before { content: counter(rank); font: 800 13px "Syne"; color: var(--violet); text-align: center; }
.rank-item.dragging { opacity: .4; transform: scale(.98); }
.rank-item.drag-over { border-color: var(--violet); transform: translateY(2px); }
.rank-item img { width: 34px; height: 34px; object-fit: cover; border-radius: 9px; }
.rank-item strong { font-size: 12px; }
.drag-handle { color: #aaa5b1; letter-spacing: -2px; }
.rank-moves { display: flex; }
.rank-moves button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; }
.locked-list .rank-item { cursor: default; }
.empty-state { text-align: center; padding: 70px 25px; }
.empty-icon { margin: 0 auto 20px; width: 72px; height: 72px; border-radius: 23px; background: #eee9ff; color: var(--violet); display: grid; place-items: center; font-size: 31px; transform: rotate(-4deg); }
.empty-state p { color: var(--muted); max-width: 460px; margin-inline: auto; line-height: 1.6; }
.question-list, .stack { display: grid; gap: 14px; }
.question-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; }
.question-card h3 { margin: 0 0 6px; }
.question-card p { margin: 0; color: var(--muted); font-size: 13px; }
.question-meta { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.upload-box { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; display: block; }
.file-upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-upload-row input { width: auto; flex: 1; min-width: 210px; }
.audio-recorder { width: 100%; margin-top: 15px; padding: 16px; border: 1px solid #ddd5f5; border-radius: 15px; background: #f7f4ff; }
.recorder-heading { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 12px; font-size: 12px; }
.recorder-time { min-width: 51px; padding: 5px 8px; border-radius: 8px; background: var(--ink); color: #fff; font-variant-numeric: tabular-nums; text-align: center; }
.recorder-controls { display: flex; gap: 7px; flex-wrap: wrap; }
.recorder-controls .button { padding: 8px 11px; font-size: 11px; }
.record-button { color: #a12e2e; border: 1px solid #efcaca; background: #fff; }
.record-button:not(:disabled)::first-letter { color: #e03535; }
.recorder-status { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.media-preview { color: var(--violet); font-size: 12px; font-weight: 700; text-decoration: none; }
.scoreboard-tabs { width: min(100%, 420px); margin-bottom: 24px; }
.score-hero { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; background: var(--violet); color: white; }
.score-number { font: 800 56px "Syne"; }
.score-number small { font-size: 17px; opacity: .7; }
.score-hero p { margin: 4px 0; color: #dcd6ff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; padding: 0 13px 12px; }
td { border-top: 1px solid var(--line); padding: 14px 13px; font-size: 13px; }
td:last-child, th:last-child { text-align: right; }
.player-cell { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.player-cell img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.rank-number { font: 800 19px "Syne"; color: var(--muted); }
.rank-number.top { color: var(--violet); }
.points { font: 800 18px "Syne"; }
.admin-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; align-items: start; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.panel-title h3 { margin: 0; }
.user-row { display: grid; grid-template-columns: 38px 1fr 120px; gap: 11px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.user-row img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.user-row strong, .user-row small { display: block; }
.user-row small { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.user-row select { padding: 8px; font-size: 12px; }
.create-form { display: grid; gap: 13px; margin-bottom: 23px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.profile-panel { display: grid; grid-template-columns: 220px 1fr; gap: 34px; align-items: center; max-width: 780px; }
.profile-photo { width: 220px; height: 220px; border-radius: 28px; object-fit: cover; background: #e9e4f8; }
.profile-details h2 { margin: 16px 0 4px; }
.profile-details .upload-box { margin-top: 25px; }
.profile-picker { display: inline-flex; }
.profile-scores { max-width: 780px; margin-top: 24px; }
.profile-scores td:last-child { width: 130px; }
.mock-warning { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; margin-bottom: 24px; background: #f5f1ff; border-color: #ddd4ff; }
.mock-warning .empty-icon { margin: 0; }
.mock-warning h3 { margin: 0 0 8px; }
.mock-warning p { color: var(--muted); margin: 5px 0; line-height: 1.55; font-size: 13px; }
.mock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.mock-form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.mock-form .wide { grid-column: 1 / -1; margin-top: 5px; }
.mock-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mock-stats div { display: grid; gap: 3px; padding: 16px; background: #f8f6f1; border-radius: 13px; }
.mock-stats strong { font: 800 26px "Syne"; color: var(--violet); }
.mock-stats span { color: var(--muted); font-size: 11px; }
.mock-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.mock-workflow { margin-top: 24px; }
.mock-workflow .panel-title { align-items: end; }
.mock-workflow .panel-title h3 { margin-top: 0; }
.workflow-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.workflow-steps article { display: flex; flex-direction: column; align-items: flex-start; min-height: 235px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fbfaf7; }
.workflow-number { display: grid; place-items: center; width: 29px; height: 29px; margin-bottom: 16px; border-radius: 9px; background: var(--violet); color: #fff; font: 800 12px "Syne"; }
.workflow-steps h3 { margin: 0 0 8px; font-size: 16px; }
.workflow-steps p { flex: 1; color: var(--muted); font-size: 12px; line-height: 1.5; }
.workflow-steps .button { width: 100%; padding-inline: 10px; font-size: 11px; }
.workflow-actions { display: grid; width: 100%; gap: 7px; margin-top: auto; }
.users-panel details > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
.users-panel details > summary::-webkit-details-marker { display: none; }
.users-panel details > summary::after { content: "⌄"; color: var(--violet); font-size: 20px; transition: transform .2s; }
.users-panel details[open] > summary { margin-bottom: 18px; }
.users-panel details[open] > summary::after { transform: rotate(180deg); }
.user-search { margin-bottom: 12px; }
.user-search input { background: #f9f8f4; }
.inline-actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.loading { min-height: 50vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid #ded9e8; border-top-color: var(--violet); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 850px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { min-height: 360px; padding: 28px; }
  .story-copy { margin: 70px 0 20px; }
  h1 { font-size: 50px; letter-spacing: -2.5px; }
  .auth-panel { padding: 35px 20px 60px; }
  .topbar { height: auto; min-height: 72px; padding: 12px 20px; grid-template-columns: 1fr auto; }
  .topbar > .brand { font-size: 0; }
  .topbar > .brand .brand-mark { font-size: 20px; }
  .main-nav { grid-row: 2; grid-column: 1 / -1; height: 46px; justify-content: flex-start; gap: 24px; overflow-x: auto; }
  .player-menu div { display: none; }
  .content { padding-top: 34px; }
  .game-grid, .admin-grid { grid-template-columns: 1fr; }
  .workflow-steps { grid-template-columns: 1fr 1fr; }
  .rank-panel { position: static; }
  .answer-grid { grid-template-columns: 1fr; }
  .question-card { grid-template-columns: 1fr; }
  .question-card > .inline-actions { justify-content: flex-start; }
}
@media (max-width: 500px) {
  .story-copy > p:not(.eyebrow), .role-row { display: none; }
  .auth-story { min-height: 280px; }
  .auth-panel { place-items: start stretch; }
  .content { width: min(100% - 24px, 1180px); }
  .panel { padding: 19px; border-radius: 17px; }
  .hero-panel { padding: 25px 20px; }
  .page-heading { align-items: start; flex-direction: column; }
  .score-hero { grid-template-columns: 1fr; gap: 8px; }
  .profile-panel { grid-template-columns: 1fr; }
  .mock-warning, .mock-grid, .workflow-steps { grid-template-columns: 1fr; }
  .workflow-steps article { min-height: 0; }
  .mock-warning .empty-icon { display: none; }
  .profile-photo { width: 150px; height: 150px; }
  .user-row { grid-template-columns: 34px 1fr 105px; }
}
