: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; }
html { scroll-behavior: smooth; }
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; }
.home-shell { padding-top: 24px; }
.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; }
.home-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(340px, .7fr);
    gap: 20px;
    align-items: stretch;
    margin-bottom: 20px;
}
.home-intro {
    background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px 30px;
    box-shadow: var(--shadow);
}
.home-intro h1 {
    max-width: 680px;
    font-size: clamp(34px, 4.6vw, 52px);
}
.home-intro p {
    max-width: 720px;
    margin-bottom: 20px;
}
.create-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.scroll-target { scroll-margin-top: 96px; }
.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, .live-action, .menu-return {
    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; }
.form-error {
    margin: 12px 0 0;
    color: var(--danger);
    font-weight: 800;
}

.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-action {
    background: #22c55e;
    color: #052e16;
    box-shadow: 0 14px 28px rgba(34, 197, 94, .2);
}
.live-action.inline {
    width: fit-content;
    margin: 0 0 18px;
}
.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; }
.menu-return {
    margin: 0 0 18px;
    background: var(--primary);
    color: white;
    font-weight: 900;
}
.clock {
    display: inline-grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    margin: 0 0 16px;
    padding: 10px 14px 10px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}
.clock-face {
    display: grid;
    place-items: center;
    width: 64px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 0 75%, #d9e2ef 75% 100%);
    color: white;
    font-size: 26px;
    font-weight: 900;
    box-shadow: inset 0 0 0 6px rgba(255,255,255,.24);
}
.clock-label {
    color: var(--muted);
    font-weight: 900;
    line-height: 1.2;
}
.clock.danger .clock-face {
    background: conic-gradient(#dc2626 0 75%, #fee2e2 75% 100%);
    animation: pulse-clock .7s ease-in-out infinite;
}
.clock.ended {
    border-color: #fecdca;
    background: #fff1f0;
}
.clock.ended .clock-face {
    background: #111827;
}
.host-clock {
    background: rgba(15, 23, 42, .82);
    border-color: #344054;
}
.host-clock .clock-label { color: #cbd5e1; }
.time-expired {
    position: relative;
    box-shadow: 0 18px 45px rgba(217, 45, 32, .18);
}
.time-expired::after {
    content: "Tiempo agotado";
    position: absolute;
    top: 18px;
    right: 18px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #111827;
    color: white;
    font-weight: 900;
    font-size: 13px;
}
.answers button { min-height: 88px; padding: 18px; border: 0; border-radius: 8px; color: white; font-size: 18px; font-weight: 900; cursor: pointer; }
.answers button:disabled { opacity: .5; cursor: default; }
.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); }

.confetti-burst {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 40;
}
.confetti-burst span {
    position: absolute;
    left: calc(50% - 5px);
    top: 32%;
    width: 10px;
    height: 18px;
    border-radius: 2px;
    background: hsl(calc(var(--i) * 47), 82%, 55%);
    transform: rotate(calc(var(--i) * 18deg));
    animation: confetti-fall 1.45s cubic-bezier(.15,.75,.35,1) forwards;
    animation-delay: calc((var(--i) % 7) * 28ms);
}
.bomb-effect {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    z-index: 45;
}
.answer-effect {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    z-index: 46;
}
.answer-effect span {
    display: grid;
    place-items: center;
    width: 142px;
    aspect-ratio: 1;
    border-radius: 50%;
    color: white;
    font-size: 52px;
    font-weight: 900;
    line-height: 1;
    animation: answer-pop 1.05s ease-out forwards;
}
.correct-answer span {
    background: #16a34a;
    box-shadow: 0 0 0 18px rgba(22, 163, 74, .16), 0 0 80px rgba(22, 163, 74, .42);
}
.wrong-answer span {
    background: #dc2626;
    box-shadow: 0 0 0 18px rgba(220, 38, 38, .16), 0 0 80px rgba(220, 38, 38, .42);
}
.bomb-core {
    width: 96px;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 28%, #fef3c7 0 10%, transparent 11%),
        radial-gradient(circle, #111827 0 48%, #020617 49% 100%);
    box-shadow: 0 0 0 16px rgba(220, 38, 38, .16), 0 0 70px rgba(220, 38, 38, .45);
    animation: bomb-pop .9s ease-out forwards;
}
.blast-ring {
    position: absolute;
    width: 120px;
    aspect-ratio: 1;
    border: 10px solid rgba(248, 113, 113, .9);
    border-radius: 50%;
    animation: blast-ring 1s ease-out forwards;
}
.host-bomb .bomb-core { box-shadow: 0 0 0 16px rgba(248, 113, 113, .22), 0 0 90px rgba(248, 113, 113, .55); }
.screen-shake { animation: screen-shake .35s linear 2; }

@keyframes pulse-clock {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
@keyframes confetti-fall {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(0deg) scale(.8);
    }
    12% { opacity: 1; }
    100% {
        opacity: 0;
        transform:
            translate(
                calc((var(--i) - 14) * 26px),
                calc(260px + (var(--i) % 6) * 34px)
            )
            rotate(calc(220deg + var(--i) * 31deg))
            scale(1);
    }
}
@keyframes bomb-pop {
    0% { transform: scale(.65); opacity: 0; }
    35% { transform: scale(1.18); opacity: 1; }
    100% { transform: scale(.9); opacity: 0; }
}
@keyframes answer-pop {
    0% { transform: scale(.55) rotate(-8deg); opacity: 0; }
    25% { transform: scale(1.12) rotate(3deg); opacity: 1; }
    70% { transform: scale(1) rotate(0); opacity: 1; }
    100% { transform: scale(.9); opacity: 0; }
}
@keyframes blast-ring {
    0% { transform: scale(.3); opacity: .9; }
    100% { transform: scale(4.2); opacity: 0; }
}
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-7px, 3px); }
    40% { transform: translate(6px, -3px); }
    60% { transform: translate(-4px, -2px); }
    80% { transform: translate(4px, 2px); }
}

#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, .home-dashboard, .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; }
}
