:root {
    --bg: #0e1118;
    --card: rgba(255, 255, 255, 0.08);
    --card-strong: rgba(255, 255, 255, 0.13);
    --text: #f4f7fb;
    --muted: rgba(244, 247, 251, 0.62);
    --line: rgba(255, 255, 255, 0.14);
    --accent: #7c5cff;
    --accent2: #00d1ff;
    --danger: #ff4e6a;
    --ok: #2ee59d;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    --radius: 28px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 10% 5%, rgba(124, 92, 255, 0.34), transparent 34rem),
        radial-gradient(circle at 92% 8%, rgba(0, 209, 255, 0.20), transparent 32rem),
        linear-gradient(145deg, #0e1118 0%, #161b2a 100%);
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
    color: var(--text);
}

button:disabled {
    opacity: 0.45;
    cursor: default;
}

.app-shell {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0;
}

.app-shell.wide {
    width: min(1320px, calc(100% - 32px));
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.topbar h1,
.card h2,
.screen-shell h1 {
    margin: 0;
}

.top-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.eyebrow {
    color: var(--accent2);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.card {
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.grid-layout {
    display: grid;
    grid-template-columns: 0.85fr 1.15fr;
    gap: 18px;
}

.span-2 {
    grid-column: 1 / -1;
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--muted);
}

.label {
    display: block;
    margin: 18px 0 8px;
    color: var(--muted);
    font-size: 14px;
}

.input-row {
    display: flex;
    gap: 10px;
}

input,
select {
    width: 100%;
    min-height: 48px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

select option {
    color: #111827;
}

.primary,
.secondary,
.accent,
.danger,
.link-pill {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 16px;
    font-weight: 800;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
    white-space: nowrap;
}
#anonymousBtn{
    margin-top: 10px;
}
.primary {
    background: linear-gradient(135deg, var(--accent), #9f8cff);
}

.secondary,
.link-pill {
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid var(--line);
}

.accent {
    background: linear-gradient(135deg, #00b7ff, #7c5cff);
}

.accent.active {
    background: linear-gradient(135deg, #2ee59d, #00b7ff);
}

.danger {
    background: linear-gradient(135deg, var(--danger), #ff8c42);
}

.primary:hover,
.secondary:hover,
.accent:hover,
.danger:hover,
.link-pill:hover {
    transform: translateY(-1px);
}

.link-pill {
    display: inline-flex;
    align-items: center;
    color: var(--text);
    text-decoration: none;
}

.wide {
    width: 100%;
}

.login-panel {
    max-width: 620px;
    margin: 0 auto;
}

.check-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 14px 0 20px;
    color: var(--muted);
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.button-grid.two {
    margin-top: 10px;
}

.question-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.question-head h2 {
    line-height: 1.2;
}

.counter,
.screen-counter,
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.08);
    font-weight: 800;
}

.answers-grid {
    display: grid;
    gap: 12px;
}

.answer-btn,
.preview-answer {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 66px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    text-align: left;
    font-size: 18px;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.answer-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.12);
}

.answer-btn.selected {
    border-color: rgba(46, 229, 157, 0.75);
    background: rgba(46, 229, 157, 0.14);
}

.answer-btn.pulse {
    animation: pulse 0.45s ease;
}

.answer-number {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    font-weight: 900;
}

.actions-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 0;
    flex-wrap: wrap;
}

.results-panel {
    margin-top: 20px;
}

.results-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.results-title h2,
.results-title h3 {
    margin: 0;
}

.result-row {
    margin: 12px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.065);
}

.result-row.big {
    padding: 20px;
    border-radius: 24px;
}

.result-row.correct {
    border-color: rgba(46, 229, 157, 0.72);
    background: rgba(46, 229, 157, 0.10);
}

.result-meta {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.answer-label {
    font-weight: 850;
}

.answer-stat {
    color: var(--muted);
    white-space: nowrap;
}

.bar-wrap {
    position: relative;
    height: 15px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
}

.result-row.big .bar-wrap {
    height: 24px;
}

.bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width 0.8s cubic-bezier(.2, .8, .2, 1);
}

.target-line {
    position: absolute;
    top: -8px;
    bottom: -8px;
    width: 2px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

.answer-preview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.table-wrap {
    overflow: auto;
    max-height: 360px;
    border: 1px solid var(--line);
    border-radius: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

tr:last-child td {
    border-bottom: 0;
}

.screen-page {
    overflow: hidden;
}

.screen-shell {
    width: min(1280px, calc(100% - 60px));
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 0;
}

.screen-shell h1 {
    font-size: clamp(38px, 5vw, 76px);
    line-height: 1.05;
    margin-bottom: 16px;
}

.screen-counter {
    width: fit-content;
    margin-bottom: 28px;
}

.screen-waiting {
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 28px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.07);
    font-size: clamp(22px, 3vw, 38px);
}

.screen-page .results-title h2 {
    font-size: clamp(28px, 4vw, 48px);
}

.screen-page .answer-label {
    font-size: clamp(24px, 3vw, 42px);
}

.screen-page .answer-stat {
    font-size: clamp(20px, 2.5vw, 34px);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.985); }
    100% { transform: scale(1); }
}

@media (max-width: 860px) {
    .grid-layout,
    .answer-preview {
        grid-template-columns: 1fr;
    }

    .input-row,
    .topbar,
    .question-head,
    .results-title {
        flex-direction: column;
        align-items: stretch;
    }

    .button-grid {
        grid-template-columns: 1fr;
    }

    .app-shell {
        width: min(100% - 18px, 980px);
        padding: 16px 0;
    }

    .card {
        padding: 18px;
        border-radius: 22px;
    }
}


.soft-line {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 22px 0;
}

.small-note {
    font-size: 13px;
    line-height: 1.45;
}

.status-box {
    min-height: 42px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
}

.status-box.error {
    color: #ff9bad;
    border-color: rgba(255, 78, 106, 0.55);
    background: rgba(255, 78, 106, 0.10);
}

.editor-layout {
    grid-template-columns: 0.75fr 1.25fr;
}

.questions-editor {
    display: grid;
    gap: 16px;
}

.question-editor-item {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.065);
}

.question-editor-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.question-number {
    font-weight: 900;
    color: var(--accent2);
}

.question-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.small {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 13px;
}

textarea {
    width: 100%;
    min-height: 52px;
    resize: vertical;
    padding: 14px 15px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    font: inherit;
}

.answers-editor {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.answer-edit-row {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 10px;
    align-items: center;
}

.answer-edit-row span {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    font-weight: 900;
}

.question-options {
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 12px;
    margin-top: 14px;
}

.question-options label {
    color: var(--muted);
    font-size: 13px;
}

.question-options select,
.question-options input {
    margin-top: 7px;
}

@media (max-width: 860px) {
    .editor-layout,
    .question-options {
        grid-template-columns: 1fr;
    }

    .question-editor-head {
        align-items: stretch;
        flex-direction: column;
    }
}


/* Animated statistics update */
.result-row {
    transition:
        background 0.28s ease,
        border-color 0.28s ease,
        transform 0.28s ease,
        opacity 0.28s ease;
}

.result-row.row-appear {
    animation: rowAppear 0.42s ease both;
}

.result-row.row-leave {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
}

.result-row.stat-bump {
    animation: statBump 0.48s ease;
}

.result-row.stat-bump .answer-stat {
    animation: numberFlash 0.52s ease;
}

.result-row.stat-bump .bar {
    filter: brightness(1.16);
}

.bar {
    will-change: width, filter;
    transition:
        width 0.82s cubic-bezier(.2, .85, .2, 1),
        filter 0.42s ease;
}

.answer-stat,
.badge {
    will-change: transform;
}

.badge.badge-bump {
    animation: badgeBump 0.42s ease;
}

@keyframes rowAppear {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes statBump {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(124, 92, 255, 0);
    }
    35% {
        transform: scale(1.012);
        box-shadow: 0 0 26px rgba(124, 92, 255, 0.18);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(124, 92, 255, 0);
    }
}

@keyframes numberFlash {
    0% {
        color: var(--muted);
        transform: scale(1);
    }
    35% {
        color: #ffffff;
        transform: scale(1.08);
    }
    100% {
        color: var(--muted);
        transform: scale(1);
    }
}

@keyframes badgeBump {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}
