:root {
    --ink: #17324d;
    --muted: #66788a;
    --line: #dfe6eb;
    --surface: #ffffff;
    --canvas: #f4f7f9;
    --teal: #008b83;
    --teal-dark: #007169;
    --coral: #f25f4b;
    --blue: #3178db;
    --yellow: #f3bc2f;
    --green: #35a36b;
    --shadow: 0 10px 30px rgba(23, 50, 77, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background: var(--canvas);
    font-family: "DM Sans", Arial, sans-serif;
}

button, input, select { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 238px;
    flex-direction: column;
    padding: 28px 18px 18px;
    color: #fff;
    background: var(--ink);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 10px 30px;
    color: #fff;
    font: 800 19px/1 "Manrope", sans-serif;
    text-decoration: none;
}

.brand > span:last-child span { color: #69d5cb; }
.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 7px;
    color: var(--ink);
    background: #69d5cb;
    font-size: 23px;
}

.main-nav { display: grid; gap: 7px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 7px;
    color: #bfcbd5;
    font-weight: 600;
    text-decoration: none;
}
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(105, 213, 203, .13); }
.nav-link.active { box-shadow: inset 3px 0 #69d5cb; }
.nav-icon { width: 22px; text-align: center; font-size: 20px; }

.sidebar-tip {
    margin: auto 5px 20px;
    padding: 18px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    background: rgba(255,255,255,.05);
}
.tip-icon { color: #f8cc57; font-size: 20px; }
.sidebar-tip strong { display: block; margin-top: 8px; font-size: 13px; }
.sidebar-tip p { margin: 6px 0 0; color: #bfcbd5; font-size: 12px; line-height: 1.5; }

.profile-button {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 11px 8px;
    border: 0;
    border-top: 1px solid rgba(255,255,255,.12);
    color: #fff;
    background: transparent;
    text-align: left;
}
.profile-button .avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: var(--coral); font-size: 12px; font-weight: 700; }
.profile-button strong, .profile-button small { display: block; }
.profile-button strong { font-size: 13px; }
.profile-button small { margin-top: 2px; color: #9fb0bf; font-size: 11px; }

.main-content { margin-left: 238px; padding: 38px clamp(24px, 4vw, 58px) 60px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; max-width: 1240px; margin: 0 auto 30px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 12px; font-weight: 800; letter-spacing: 0; }
h1 { margin: 0; max-width: 720px; font: 800 clamp(27px, 3vw, 40px)/1.12 "Manrope", sans-serif; }
.subtitle { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .join-button { min-height: 42px; border: 1px solid var(--line); background: #fff; }
.icon-button { width: 42px; border-radius: 7px; color: var(--coral); }
.join-button { padding: 0 16px; border-radius: 7px; color: var(--ink); font-weight: 700; }

.creator-layout { display: grid; grid-template-columns: minmax(460px, 1.05fr) minmax(420px, .95fr); gap: 24px; max-width: 1240px; margin: 0 auto; }
.creator-panel, .preview-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.creator-panel { padding: clamp(24px, 3vw, 36px); }

.section-heading { display: flex; align-items: center; gap: 14px; }
.section-heading.compact { margin-bottom: 22px; }
.step-number { display: grid; flex: 0 0 34px; height: 34px; place-items: center; border-radius: 7px; color: #fff; background: var(--teal); font-weight: 800; }
.step-number.coral { background: var(--coral); }
.section-heading h2 { margin: 0; font: 800 18px/1.3 "Manrope", sans-serif; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.source-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0 16px; }
.source-tab { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; text-align: left; }
.source-tab.active { border-color: var(--teal); background: #eefaf8; box-shadow: 0 0 0 1px var(--teal); }
.source-tab-icon { display: grid; flex: 0 0 42px; height: 42px; place-items: center; border-radius: 7px; font-size: 12px; font-weight: 800; }
.pdf-icon { color: #b8392d; background: #ffe6e1; }
.bible-icon { color: #986800; background: #fff1c7; font-size: 20px; }
.source-tab strong, .source-tab small { display: block; }
.source-tab strong { font-size: 14px; }
.source-tab small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.drop-zone { display: flex; min-height: 152px; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #a9b8c4; border-radius: 8px; background: #fafcfd; text-align: center; transition: .2s ease; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--teal); background: #f0fbfa; }
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.upload-icon { display: grid; width: 38px; height: 38px; margin-bottom: 9px; place-items: center; border-radius: 50%; color: var(--teal); background: #dff6f2; font-size: 23px; }
.drop-zone strong { font-size: 14px; }
.drop-zone > span:not(.upload-icon) { margin-top: 3px; color: var(--teal); font-size: 12px; }
.drop-zone small { margin-top: 8px; color: #8c9aa6; }
.source-panel.hidden { display: none; }
.source-panel select { width: 100%; margin-top: 7px; }

.divider { height: 1px; margin: 28px 0; background: var(--line); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-label { display: block; margin-bottom: 7px; color: var(--ink); font-size: 12px; font-weight: 700; }
select { width: 100%; height: 44px; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 18px 0 24px; padding: 14px 0; border-top: 1px solid #edf1f4; border-bottom: 1px solid #edf1f4; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { position: relative; flex: 0 0 42px; height: 24px; border-radius: 12px; background: #c7d2da; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.toggle-row input:checked + .toggle { background: var(--teal); }
.toggle-row input:checked + .toggle::after { transform: translateX(18px); }

.generate-button { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 0 18px; border: 0; border-radius: 7px; color: #fff; background: var(--teal); font-weight: 800; box-shadow: 0 8px 18px rgba(0, 139, 131, .22); }
.generate-button:hover { background: var(--teal-dark); }
.form-note { margin: 10px 0 0; color: #8a98a4; font-size: 11px; text-align: center; }

.preview-panel { align-self: start; overflow: hidden; background: var(--ink); color: #fff; }
.preview-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid rgba(255,255,255,.12); font-size: 11px; font-weight: 800; letter-spacing: 0; }
.status-pill { display: flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 12px; color: #c7d2da; background: rgba(255,255,255,.08); font-size: 10px; letter-spacing: 0; }
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); }
.question-preview { min-height: 414px; padding: 25px 22px; background: #fff; color: var(--ink); }
.question-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 700; }
.question-preview h3 { margin: 38px auto 8px; max-width: 400px; font: 800 24px/1.25 "Manrope", sans-serif; text-align: center; }
.question-preview > p { max-width: 390px; margin: 0 auto 34px; color: var(--muted); font-size: 13px; line-height: 1.45; text-align: center; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer-option { display: flex; min-height: 64px; align-items: center; gap: 9px; padding: 12px; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 700; }
.answer-option span { font-size: 18px; }
.answer-coral { background: var(--coral); }
.answer-blue { background: var(--blue); }
.answer-yellow { color: #4e3e0a; background: var(--yellow); }
.answer-green { background: var(--green); }

.team-strip { display: grid; grid-template-columns: repeat(3, 1fr); padding: 15px 18px; border-top: 1px solid rgba(255,255,255,.12); border-bottom: 1px solid rgba(255,255,255,.12); }
.team-strip > div { position: relative; display: grid; grid-template-columns: 9px 1fr; column-gap: 7px; padding: 0 9px; }
.team-strip > div + div { border-left: 1px solid rgba(255,255,255,.12); }
.team-dot { grid-row: 1 / 3; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; }
.coral-dot { background: var(--coral); }
.blue-dot { background: var(--blue); }
.yellow-dot { background: var(--yellow); }
.team-strip strong { font-size: 10px; }
.team-strip small { margin-top: 2px; color: #9fb0bf; font-size: 9px; }
.game-code-card { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; color: #aebcc8; font-size: 10px; letter-spacing: 0; }
.game-code-card strong { color: #fff; font-size: 11px; letter-spacing: 0; }

@media (max-width: 1040px) {
    .creator-layout { grid-template-columns: 1fr; }
    .preview-panel { width: 100%; }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: 100%; height: auto; padding: 16px; }
    .brand { padding-bottom: 14px; }
    .main-nav { grid-template-columns: repeat(4, 1fr); }
    .nav-link { justify-content: center; min-height: 42px; padding: 0 6px; font-size: 0; }
    .nav-icon { font-size: 20px; }
    .sidebar-tip, .profile-button { display: none; }
    .main-content { margin-left: 0; padding: 24px 16px 42px; }
    .topbar { display: block; }
    .top-actions { margin-top: 18px; }
    .join-button { flex: 1; }
    .creator-layout { display: block; }
    .preview-panel { margin-top: 18px; }
}

@media (max-width: 520px) {
    h1 { font-size: 28px; }
    .subtitle { font-size: 14px; }
    .source-tabs, .settings-grid, .answer-grid { grid-template-columns: 1fr; }
    .question-preview { min-height: 0; }
    .team-strip { grid-template-columns: 1fr; gap: 12px; }
    .team-strip > div + div { border-left: 0; }
    .game-code-card { align-items: flex-start; flex-direction: column; gap: 6px; }
}

.hidden { display: none !important; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(11, 30, 47, .72);
    backdrop-filter: blur(5px);
}
.modal {
    position: relative;
    width: min(460px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 34px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}
.modal h2 { margin: 0; font: 800 25px/1.25 "Manrope", sans-serif; }
.modal > p:not(.eyebrow) { color: var(--muted); }
.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: var(--ink);
    background: #edf2f5;
    font-size: 23px;
}
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 28px; font: 800 17px/1 "Manrope", sans-serif; }
.auth-brand > span:last-child { color: var(--teal); }
.auth-visual { width: 100%; height: 132px; margin: -8px 0 22px; object-fit: cover; border-radius: 7px; }
.auth-modal > p { margin: 8px 0 22px; font-size: 14px; }
.google-button {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid #cfd8df;
    border-radius: 7px;
    color: var(--ink);
    background: #fff;
    font-weight: 700;
    text-decoration: none;
}
.google-g { color: #4285f4; font: 800 18px/1 Arial, sans-serif; }
.auth-divider { position: relative; margin: 22px 0; border-top: 1px solid var(--line); text-align: center; }
.auth-divider span { position: relative; top: -10px; padding: 0 10px; color: #8997a3; background: #fff; font-size: 11px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 18px; padding: 4px; border-radius: 7px; background: #edf2f5; }
.auth-tabs button { min-height: 38px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.auth-tabs button.active { color: var(--ink); background: #fff; box-shadow: 0 2px 7px rgba(23,50,77,.1); }
.auth-form { display: grid; gap: 14px; }
.auth-form label { color: var(--ink); font-size: 12px; font-weight: 700; }
.auth-form input { width: 100%; height: 46px; margin-top: 6px; padding: 0 13px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; }
.auth-form input:focus, select:focus { outline: 2px solid rgba(0,139,131,.22); border-color: var(--teal); }
.text-button { width: 100%; margin-top: 14px; border: 0; color: #b33a30; background: transparent; font-weight: 700; }

.processing-modal { width: min(480px, 100%); padding: 48px 36px; text-align: center; }
.ai-loader { position: relative; display: grid; width: 76px; height: 76px; margin: 0 auto 24px; place-items: center; border: 2px solid #d9efed; border-radius: 50%; color: var(--teal); font-size: 30px; }
.ai-loader::after { content: ""; position: absolute; inset: -2px; border: 3px solid transparent; border-top-color: var(--teal); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.processing-modal > p:not(.eyebrow) { margin: 10px 0 22px; }
.progress-track { height: 7px; overflow: hidden; border-radius: 4px; background: #e6edf1; }
.progress-track span { display: block; width: 64%; height: 100%; border-radius: inherit; background: var(--teal); animation: progress 2.4s ease-in-out infinite alternate; }
@keyframes progress { from { transform: translateX(-45%); } to { transform: translateX(100%); } }

.wide-modal { width: min(900px, 100%); }
.result-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-right: 35px; }
.result-header p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.result-count { display: grid; flex: 0 0 88px; height: 72px; place-items: center; padding: 8px; border-radius: 7px; color: #fff; background: var(--teal); }
.result-count strong { font: 800 27px/1 "Manrope", sans-serif; }
.result-count span { font-size: 10px; }
.question-review { display: grid; gap: 10px; max-height: 430px; margin: 25px 0; overflow: auto; }
.review-item { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 7px; }
.review-number { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 6px; color: var(--teal); background: #e8f7f5; font-weight: 800; }
.review-item strong { display: block; font-size: 13px; }
.review-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.correct-badge { padding: 5px 8px; border-radius: 12px; color: #237047; background: #e5f6ed; font-size: 10px; font-weight: 800; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.secondary-button { min-height: 46px; padding: 0 18px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-weight: 700; }
.compact-button { width: auto; min-width: 190px; }

.library-list { display: grid; gap: 10px; margin-top: 24px; }
.library-item { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 7px; }
.library-icon { display: grid; width: 56px; height: 42px; place-items: center; border-radius: 7px; color: var(--teal); background: #e7f7f5; font-size: 11px; font-weight: 800; }
.library-item strong, .library-item small { display: block; }
.library-item small { margin-top: 4px; color: var(--muted); }
.library-item button { border: 0; color: var(--teal); background: transparent; font-weight: 800; }
.empty-state { padding: 50px 20px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; }

.code-input { font: 800 25px/1 "Manrope", sans-serif !important; letter-spacing: 0 !important; text-align: center; }
.join-modal { width: min(430px, 100%); }

.game-modal { width: min(1080px, 100%); padding: 0; overflow: hidden; color: #fff; background: var(--ink); }
.lobby-screen { min-height: min(720px, calc(100vh - 40px)); text-align: center; }
.lobby-top { display: flex; align-items: center; justify-content: space-between; padding: 20px 26px; border-bottom: 1px solid rgba(255,255,255,.12); color: #b9c8d3; font-size: 12px; }
.brand.inverse { padding: 0; }
.lobby-screen > p { margin: 55px 0 8px !important; color: #9eb0bf !important; font-size: 12px; font-weight: 800; letter-spacing: 0; }
.game-code { border: 0; color: #fff; background: transparent; font: 800 clamp(46px, 8vw, 78px)/1 "Manrope", sans-serif; letter-spacing: 0; }
.lobby-screen > h2 { margin: 20px 0 30px; color: #fff; }
.lobby-teams { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 14px; max-width: 850px; margin: 0 auto; padding: 0 26px; }
.lobby-team { min-height: 170px; padding: 18px; border: 1px solid rgba(255,255,255,.14); border-top: 5px solid var(--team-color); border-radius: 7px; background: rgba(255,255,255,.07); text-align: left; }
.lobby-team h3 { margin: 0 0 13px; font-size: 15px; }
.lobby-team p { margin: 5px 0; color: #c2ced7; font-size: 12px; }
.lobby-team .waiting { color: #8194a4; font-style: italic; }
.lobby-actions { display: flex; justify-content: center; gap: 12px; margin-top: 35px; padding: 0 24px 28px; }
.secondary-button.light { border-color: rgba(255,255,255,.25); color: #fff; background: transparent; }
.coral-button { background: var(--coral); box-shadow: 0 8px 18px rgba(242,95,75,.24); }
.coral-button:hover { background: #d94c3a; }

.play-screen { min-height: min(750px, calc(100vh - 40px)); }
.play-topbar { display: grid; grid-template-columns: 1fr 64px 1fr; align-items: center; padding: 16px 24px; border-bottom: 1px solid rgba(255,255,255,.12); font-weight: 700; }
.play-topbar > span:last-child { text-align: right; }
.timer { display: grid; width: 54px; height: 54px; place-items: center; border: 3px solid var(--yellow); border-radius: 50%; font: 800 21px/1 "Manrope", sans-serif; }
.play-content { min-height: 525px; padding: 34px clamp(20px, 7vw, 80px); background: #fff; color: var(--ink); text-align: center; }
.play-content h2 { max-width: 790px; margin: 12px auto 30px; font-size: clamp(22px, 3vw, 34px); }
.play-options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.play-option { display: grid; grid-template-columns: 48px 1fr; align-items: center; min-height: 90px; padding: 16px; border: 0; border-radius: 7px; color: #fff; text-align: left; font-weight: 700; transition: transform .15s ease, filter .15s ease; }
.play-option:hover { transform: translateY(-2px); filter: brightness(1.04); }
.play-option:disabled { cursor: default; opacity: .58; }
.play-option.correct { outline: 4px solid #17324d; opacity: 1; }
.play-symbol { display: grid; width: 38px; height: 38px; place-items: center; font-size: 21px; }
.answer-feedback { margin: 20px auto 0; max-width: 720px; padding: 15px; border-radius: 7px; background: #eef4f7; font-size: 13px; }
.answer-feedback strong { display: block; margin-bottom: 4px; font-size: 17px; }
.leaderboard-mini { display: flex; gap: 10px; justify-content: center; padding: 15px 20px; }
.score-chip { display: flex; gap: 10px; min-width: 150px; justify-content: space-between; padding: 9px 12px; border-left: 4px solid var(--team-color); background: rgba(255,255,255,.08); font-size: 12px; }
.next-button { position: absolute; right: 24px; bottom: 17px; min-height: 42px; padding: 0 16px; border: 0; border-radius: 7px; color: var(--ink); background: var(--yellow); font-weight: 800; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 200; max-width: min(380px, calc(100vw - 48px)); padding: 14px 18px; border-left: 4px solid var(--teal); border-radius: 6px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 13px; }
.toast.error { border-left-color: var(--coral); }

@media (max-width: 700px) {
    .modal { padding: 26px 20px; }
    .wide-modal { height: calc(100vh - 24px); max-height: none; }
    .result-header { padding-right: 25px; }
    .result-count { display: none; }
    .modal-actions { align-items: stretch; flex-direction: column; }
    .compact-button { width: 100%; }
    .lobby-screen, .game-modal { padding: 0; }
    .lobby-top > span:last-child { display: none; }
    .lobby-teams { grid-template-columns: 1fr; max-height: 320px; overflow: auto; }
    .game-code { letter-spacing: 0; }
    .play-options { grid-template-columns: 1fr; }
    .play-content { min-height: 0; padding: 25px 16px; }
    .play-option { min-height: 70px; }
    .leaderboard-mini { justify-content: flex-start; overflow: auto; }
    .next-button { position: static; width: calc(100% - 32px); margin: 0 16px 16px; }
}
