:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --panel: #fff;
    --text: #182230;
    --muted: #667085;
    --line: #d9e2ef;
    --primary: #2457d6;
    --primary-dark: #1d46ad;
    --success: #11845b;
    --soft: #f8fafc;
    --danger: #d92d20;
    --shadow: 0 18px 45px rgba(24, 34, 48, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: linear-gradient(180deg, #edf4ff 0, var(--bg) 340px);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
p { color: var(--muted); line-height: 1.55; }
input, button { font: inherit; }
input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
    background: white;
    color: var(--text);
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(36, 87, 214, .12); outline: none; }

.topbar {
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(14px);
}
.topbar.dark { background: rgba(11, 18, 32, .9); border-color: #344054; }
.nav {
    max-width: 1160px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; font-size: 20px; }
.brand::before {
    content: "MK";
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-size: 13px;
}
.nav-links, .quick-actions, .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.nav-links a, .quick-actions a { padding: 9px 12px; border-radius: 6px; color: var(--primary); font-weight: 800; }
.nav-links a:hover, .quick-actions a:hover { background: #edf4ff; }

.shell { max-width: 1160px; margin: 0 auto; padding: 32px 24px 56px; }
.panel, .page-head, .solo-question, .summary, .result-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
}
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 20px; margin-bottom: 20px; }
.hero-main { min-height: 280px; display: flex; flex-direction: column; justify-content: space-between; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
h1 { margin: 8px 0 10px; font-size: clamp(32px, 5vw, 54px); line-height: 1.02; }
h2 { margin: 0 0 16px; font-size: 21px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.stat strong { display: block; font-size: 22px; }
.stat span, .quiz-info span:last-child, .section-title span { color: var(--muted); font-size: 13px; }
.form-row, .join-card form, .question-form { display: grid; gap: 12px; }
.btn, .quick-actions .primary, .question-form button, .full-submit, .stage button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 800;
    cursor: pointer;
}
.btn.primary, .question-form button, .quick-actions .primary, .full-submit { background: var(--primary); color: white; }
.btn.primary:hover, .question-form button:hover, .full-submit:hover { background: var(--primary-dark); }
.btn.success { background: var(--success); color: white; }
.btn.secondary { background: white; border-color: var(--line); }
.btn:disabled { background: #98a2b3; cursor: default; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.section-title, .page-head, .summary { display: flex; justify-content: space-between; gap: 18px; align-items: center; flex-wrap: wrap; }
.quiz-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-top: 12px; background: var(--soft); }
.quiz-info strong { display: block; font-size: 18px; margin: 4px 0; }
.empty-state, .empty-note, .alert { border: 1px dashed #b9c9e6; border-radius: 8px; padding: 18px; background: var(--soft); }
.alert { color: var(--danger); border-color: #fecdca; background: #fff1f0; }

.editor-shell { max-width: 1120px; }
.layout { display: grid; grid-template-columns: minmax(320px, 390px) minmax(0, 1fr); gap: 20px; align-items: start; }
.sticky-form { position: sticky; top: 86px; }
label { display: block; font-weight: 800; color: var(--text); }
.answer-row { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 12px; align-items: end; }
.correct, .check-line { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.correct input, .check-line input { width: auto; }
.question-image { width: min(100%, 560px); max-height: 340px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: var(--soft); margin: 12px 0; }
.editor-tools { display: grid; gap: 12px; margin-bottom: 18px; }
.question-card { border: 1px solid var(--line); border-radius: 8px; background: var(--soft); margin-bottom: 14px; overflow: hidden; }
.question-card summary { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px 14px; padding: 18px; cursor: pointer; }
.question-card form { padding: 0 18px 18px; border-top: 1px solid var(--line); }
.question-number { color: var(--primary); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.question-title, .question-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.question-title { font-weight: 900; }
.question-meta { grid-column: 2; color: var(--muted); font-size: 13px; }

.solo-shell { max-width: 980px; }
.solo-question, .result-card, .summary { margin-bottom: 18px; }
.options, .answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option { display: flex; gap: 10px; align-items: center; min-height: 62px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); cursor: pointer; font-weight: 700; }
.option input { width: auto; }
.full-submit { width: 100%; font-size: 18px; }
.score { min-width: 150px; text-align: center; font-size: 52px; font-weight: 900; color: var(--primary); background: #edf4ff; border-radius: 8px; padding: 16px; }
.ok { border-left: 6px solid var(--success); }
.bad { border-left: 6px solid var(--danger); }

.host-page {
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(36, 87, 214, .28), transparent 380px), #101828;
    color: #f9fafb;
    padding-bottom: 48px;
}
.stage, .live-grid { max-width: 1120px; margin: 0 auto; padding: 28px 24px 0; }
.stage { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; }
.code-card, .live-panel { background: rgba(29, 41, 57, .92); border: 1px solid #344054; border-radius: 8px; padding: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, .24); }
.label { color: #cbd5e1; margin: 0 0 8px; }
.code { font-size: clamp(42px, 8vw, 68px); letter-spacing: 8px; font-weight: 900; }
.stage button { background: #22c55e; color: #052e16; }
.live-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.live-panel li { color: #cbd5e1; margin: 8px 0; }

.player-page { max-width: 900px; margin: 0 auto; padding: 28px 24px 48px; }
.question { font-size: clamp(28px, 5vw, 46px); font-weight: 900; margin: 10px 0 18px; line-height: 1.08; }
.room { display: inline-flex; color: var(--primary); background: #edf4ff; border-radius: 999px; padding: 8px 12px; font-weight: 900; margin: 0; }
.timer { color: var(--muted); margin-bottom: 14px; font-weight: 800; }
.answers button { min-height: 88px; padding: 18px; border: 0; border-radius: 8px; color: white; font-size: 18px; font-weight: 900; cursor: pointer; }
.answers button:nth-child(1) { background: #dc2626; }
.answers button:nth-child(2) { background: #2563eb; }
.answers button:nth-child(3) { background: #d97706; }
.answers button:nth-child(4) { background: #16a34a; }
.answers p { grid-column: 1 / -1; margin: 0; padding: 18px; border-radius: 8px; background: var(--soft); border: 1px solid var(--line); font-weight: 800; color: var(--text); }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 12px; background: #fff1f0; border-top: 1px solid #fecdca; color: #912018; z-index: 1000; }

@media (max-width: 920px) {
    .hero, .content-grid, .layout, .stage, .live-grid { grid-template-columns: 1fr; }
    .sticky-form { position: static; }
}
@media (max-width: 680px) {
    .quiz-row, .answer-row, .options, .answers, .question-card summary { grid-template-columns: 1fr; }
    .question-meta { grid-column: 1; }
    .actions .btn, .actions button { width: 100%; }
}
@media (max-width: 560px) {
    .shell, .player-page, .stage, .live-grid { padding-inline: 16px; }
    .nav { align-items: flex-start; flex-direction: column; padding-inline: 16px; }
    .panel, .page-head, .solo-question, .summary, .result-card, .code-card, .live-panel { padding: 18px; }
}
