:root {
    --bg: #eff4fb;
    --bg-accent: #eaf1ff;
    --surface: rgba(255, 255, 255, 0.94);
    --surface-solid: #ffffff;
    --surface-muted: #f8fbff;

    --text: #182235;
    --text-soft: #5f6b7c;
    --text-inverse: #ffffff;

    --border: #dfe7f2;
    --border-strong: #cfd9e7;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;

    --success: #22c55e;
    --success-hover: #16a34a;

    --accent: #7c3aed;
    --accent-hover: #6d28d9;

    --danger: #dc2626;
    --danger-soft: #fee2e2;

    --answer-bg: #f8fbff;
    --answer-border: #d9e5f5;
    --answer-hover: #eef5ff;

    --answer-selected-bg: #2563eb;
    --answer-selected-border: #1d4ed8;
    --answer-selected-text: #ffffff;

    --answer-selected-alt-bg: #f59e0b;
    --answer-selected-alt-border: #d97706;
    --answer-selected-alt-text: #1f1300;

    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.16);

    --radius-xs: 10px;
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 24px;

    --transition: 0.18s ease;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
            radial-gradient(circle at top left, #ffffff 0%, var(--bg-accent) 32%, var(--bg) 100%);
}

/* Общие заголовки */
h1,
h2,
h3 {
    margin: 0;
    color: var(--text);
}

h2 {
    width: 100%;
    max-width: 1100px;
    margin-bottom: 20px;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* ---------- АДМИНКА ---------- */

form {
    width: 100%;
    max-width: 1100px;
}

.create-test {
    margin: 0 0 24px;
    padding: 14px 22px;
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--success), #4ade80);
    color: var(--text-inverse);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.create-test:hover {
    background: linear-gradient(135deg, var(--success-hover), #22c55e);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.create-test:active {
    transform: translateY(0);
}

.test-list {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.test-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.test-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 18px 20px;
    cursor: pointer;
}

.test-main-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.test-id {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.test-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.test-link {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition);
}

.test-link:hover {
    color: var(--primary);
}

.qr-container {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    min-width: 72px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.qr-container:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-sm);
    border-color: var(--border-strong);
}

.qr-code {
    width: 60px;
    height: 60px;
}

.results {
    display: none;
    width: 100%;
    padding: 0 20px 18px 20px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, #fcfdff 0%, #f8fbff 100%);
}

.results-inner {
    padding-top: 14px;
}

.result-item {
    margin: 0 0 10px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-soft);
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.result-item:last-child {
    margin-bottom: 0;
}

/* ---------- СТРАНИЦА ТЕСТА ---------- */

.test-page {
    width: 100%;
    max-width: 980px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.test-page-header {
    width: 100%;
    display: flex;
    justify-content: center;
}

.test-id-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.10);
    border: 1px solid rgba(37, 99, 235, 0.18);
    color: var(--primary);
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-align: center;
}

.quiz-container {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.question-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px 20px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.question-number {
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.question {
    font-size: 32px;
    line-height: 1.35;
    font-weight: 800;
    color: var(--text);
    word-break: break-word;
}

.answers {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.answ_button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    padding: 20px 22px;
    border: 2px solid var(--answer-border);
    border-radius: 18px;
    background: var(--answer-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    transition:
            transform var(--transition),
            box-shadow var(--transition),
            background var(--transition),
            border-color var(--transition),
            color var(--transition);
}

.answ_button:hover {
    background: var(--answer-hover);
    border-color: #b9d1f7;
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.answ_button:active {
    transform: translateY(0);
}

.answer-index {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e7efff;
    color: var(--primary);
    font-size: 18px;
    font-weight: 800;
}

.answer-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.selected-answer {
    background: linear-gradient(135deg, var(--answer-selected-bg), #3b82f6) !important;
    border-color: var(--answer-selected-border) !important;
    color: var(--answer-selected-text) !important;
    font-weight: 800 !important;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.26) !important;
}

.selected-answer .answer-index {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

.quiz-actions {
    display: flex;
    gap: 14px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.nav-button {
    min-height: 60px;
    padding: 16px 24px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), opacity var(--transition);
    box-shadow: var(--shadow-sm);
}

.nav-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.nav-button:active {
    transform: translateY(0);
}

.nav-button-back {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #ffffff;
}

.nav-button-back:hover {
    background: linear-gradient(135deg, var(--accent-hover), #7c3aed);
}

.nav-button-next {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: #ffffff;
}

.nav-button-next:hover {
    background: linear-gradient(135deg, var(--primary-hover), #2563eb);
}

.nav-button-finish {
    background: linear-gradient(135deg, var(--success), #4ade80);
    color: #ffffff;
}

.nav-button-finish:hover {
    background: linear-gradient(135deg, var(--success-hover), #22c55e);
}

.nav-button-disabled,
.nav-button:disabled {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    color: #ffffff;
    cursor: not-allowed;
    opacity: 0.92;
    box-shadow: none;
    transform: none;
}

/* ---------- РЕГИСТРАЦИЯ ---------- */

.registration-form {
    width: 100%;
    max-width: 420px;
    text-align: center;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.registration-form h2 {
    max-width: none;
    margin-bottom: 18px;
    font-size: 24px;
}

.registration-form input,
.registration-form select {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: #ffffff;
    color: var(--text);
    outline: none;
    display: block;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.registration-form input:focus,
.registration-form select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.registration-form button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--success), #4ade80);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    display: block;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.registration-form button:hover {
    background: linear-gradient(135deg, var(--success-hover), #22c55e);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ---------- ТАБЛИЦЫ ---------- */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f8fafc;
    font-weight: 800;
    color: var(--text);
}

td {
    color: var(--text-soft);
}

tr:last-child td {
    border-bottom: none;
}

.title {
    text-align: center;
    font-weight: 800;
    font-size: 20px;
    color: var(--text);
}

/* ---------- МОДАЛКА QR ---------- */

.qr-modal {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.40);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 999;
    animation: fadeIn 0.2s ease;
}

.qr-modal-content {
    width: 100%;
    max-width: min(92vw, 360px);
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

#qrModalCode {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#qrModalCode canvas,
#qrModalCode img {
    max-width: 100%;
    height: auto !important;
}

#qrModalCode canvas {
    width: 220px !important;
    height: 220px !important;
}

/* ---------- ПЛАНШЕТЫ ---------- */

@media (max-width: 1024px) {
    body {
        padding: 22px 16px;
    }

    h2 {
        font-size: 28px;
        margin-bottom: 16px;
    }

    .test-header {
        padding: 16px 18px;
    }

    .test-name {
        font-size: 18px;
    }

    .qr-container {
        width: 68px;
        height: 68px;
        min-width: 68px;
    }

    .qr-code {
        width: 54px;
        height: 54px;
    }

    .results {
        padding: 0 18px 18px 18px;
    }

    .quiz-container {
        padding: 24px;
        border-radius: 22px;
    }

    .question-card {
        padding: 20px 18px;
    }

    .question-number {
        font-size: 15px;
    }

    .question {
        font-size: 28px;
    }

    .answ_button {
        font-size: 22px;
        padding: 18px 20px;
        border-radius: 16px;
    }

    .answer-index {
        width: 40px;
        height: 40px;
        font-size: 17px;
    }

    .nav-button {
        min-height: 56px;
        font-size: 18px;
        padding: 15px 22px;
    }
}

/* ---------- МОБИЛЬНЫЕ ---------- */

@media (max-width: 768px) {
    body {
        padding: 16px 12px;
    }

    h2 {
        font-size: 24px;
        line-height: 1.2;
        margin-bottom: 14px;
    }

    .create-test {
        width: 100%;
        padding: 14px 16px;
        font-size: 15px;
    }

    .test-list {
        gap: 12px;
    }

    .test-item {
        border-radius: 14px;
    }

    .test-header {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
        gap: 12px;
    }

    .test-id {
        font-size: 13px;
    }

    .test-name {
        font-size: 17px;
    }

    .qr-container {
        align-self: center;
        width: 76px;
        height: 76px;
        min-width: 76px;
    }

    .qr-code {
        width: 60px;
        height: 60px;
    }

    .results {
        padding: 0 14px 14px 14px;
    }

    .results-inner {
        padding-top: 12px;
    }

    .result-item {
        font-size: 14px;
        padding: 10px 12px;
        border-radius: 10px;
    }

    .test-page {
        gap: 14px;
    }

    .test-id-badge {
        width: 100%;
        font-size: 15px;
        padding: 10px 14px;
        border-radius: 14px;
    }

    .quiz-container {
        padding: 16px;
        gap: 16px;
        border-radius: 18px;
    }

    .question-card {
        padding: 16px 14px;
        border-radius: 14px;
    }

    .question-number {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .question {
        font-size: 24px;
        line-height: 1.32;
    }

    .answers {
        gap: 12px;
    }

    .answ_button {
        font-size: 19px;
        line-height: 1.35;
        padding: 16px;
        gap: 12px;
        border-radius: 14px;
    }

    .answer-index {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .quiz-actions {
        flex-direction: column;
        gap: 12px;
        margin-top: 2px;
    }

    .nav-button {
        width: 100%;
        min-height: 54px;
        font-size: 17px;
        padding: 14px 16px;
        border-radius: 14px;
    }

    .registration-form {
        max-width: 100%;
        padding: 18px 14px;
        border-radius: 14px;
    }

    .registration-form h2 {
        font-size: 22px;
    }

    .registration-form input,
    .registration-form select,
    .registration-form button {
        font-size: 15px;
        padding: 12px;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        border-radius: 12px;
    }

    th,
    td {
        padding: 10px 8px;
        font-size: 14px;
    }

    .title {
        font-size: 18px;
    }
}

/* ---------- МАЛЕНЬКИЕ ЭКРАНЫ ---------- */

@media (max-width: 480px) {
    body {
        padding: 12px 10px;
    }

    h2 {
        font-size: 22px;
    }

    .test-header {
        padding: 12px;
        gap: 10px;
    }

    .test-name {
        font-size: 16px;
    }

    .qr-container {
        width: 72px;
        height: 72px;
    }

    .qr-code {
        width: 56px;
        height: 56px;
    }

    .results {
        padding: 0 12px 12px 12px;
    }

    .result-item {
        font-size: 13px;
        padding: 9px 10px;
    }

    .quiz-container {
        padding: 12px;
    }

    .question-card {
        padding: 14px 12px;
    }

    .question-number {
        font-size: 13px;
    }

    .question {
        font-size: 21px;
    }

    .answ_button {
        font-size: 17px;
        padding: 14px 12px;
        gap: 10px;
    }

    .answer-index {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .nav-button {
        min-height: 50px;
        font-size: 16px;
        padding: 13px 14px;
    }

    .qr-modal-content {
        padding: 14px;
        border-radius: 16px;
    }

    #qrModalCode canvas {
        width: min(78vw, 240px) !important;
        height: min(78vw, 240px) !important;
    }
}

@media (min-width: 1200px) {
    .question {
        font-size: 36px;
    }

    .answ_button {
        font-size: 26px;
        padding: 22px 24px;
    }

    .nav-button {
        font-size: 21px;
    }
}

/* ---------- АНИМАЦИИ ---------- */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.92);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}