:root {
    --primary: #6c5ce7;
    --primary-dark: #5748d5;
    --primary-light: #9184f4;
    --primary-soft: #f0eeff;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --gold: #d8aa00;
    --silver: #9aa3af;
    --bronze: #b96c3a;

    --ink: #171923;
    --ink-soft: #353946;
    --muted: #707583;
    --muted-light: #979ba7;

    --background: #f6f7fc;
    --surface: rgba(255, 255, 255, .92);
    --surface-solid: #ffffff;
    --surface-soft: #f7f8fc;
    --line: #e6e8f0;

    --shadow-small:
        0 10px 30px rgba(27, 31, 51, .06);

    --shadow-medium:
        0 22px 60px rgba(27, 31, 51, .11);

    --shadow-large:
        0 35px 90px rgba(27, 31, 51, .16);

    --radius-small: 14px;
    --radius-medium: 22px;
    --radius-large: 30px;

    --font:
        "Plus Jakarta Sans",
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--ink);
    background: var(--background);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-background {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.app-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(105px);
    opacity: .17;
}

.app-orb-primary {
    width: 500px;
    height: 500px;
    top: -220px;
    right: -130px;
    background: var(--primary);
}

.app-orb-success {
    width: 430px;
    height: 430px;
    left: -180px;
    bottom: -200px;
    background: var(--success);
}

.app-grid {
    position: absolute;
    inset: 0;
    opacity: .22;
    background-image:
        linear-gradient(
            rgba(255, 255, 255, .38) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(255, 255, 255, .38) 1px,
            transparent 1px
        );
    background-size: 54px 54px;
    mask-image:
        linear-gradient(
            to bottom,
            rgba(0, 0, 0, .42),
            transparent 82%
        );
}

.app-header {
    min-height: 72px;
    padding:
        env(safe-area-inset-top)
        clamp(15px, 4vw, 64px)
        0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom:
        1px solid rgba(230, 232, 240, .86);
    background: rgba(255, 255, 255, .84);
    backdrop-filter: blur(22px);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.app-brand-icon {
    width: 36px;
    height: 36px;
    padding: 9px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    border-radius: 12px;
    color: #fff;
    background:
        linear-gradient(
            145deg,
            var(--primary),
            var(--primary-light)
        );
    box-shadow:
        0 10px 22px rgba(108, 92, 231, .25);
}

.app-brand-icon i {
    width: 4px;
    display: block;
    border-radius: 999px;
    background: currentColor;
}

.app-brand-icon i:nth-child(1) {
    height: 9px;
}

.app-brand-icon i:nth-child(2) {
    height: 17px;
}

.app-brand-icon i:nth-child(3) {
    height: 13px;
}

.app-brand-text {
    color: var(--ink);
    font-size: 1.22rem;
    font-weight: 800;
    letter-spacing: -.045em;
}

.app-brand-text span {
    color: var(--primary);
}

.app-navigation {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 22px);
}

.app-nav-link {
    color: var(--muted);
    font-size: .84rem;
    font-weight: 700;
    transition:
        color .18s ease,
        transform .18s ease;
}

.app-nav-link:hover {
    color: var(--primary);
    transform: translateY(-1px);
}

.app-user-chip {
    padding: 5px 11px 5px 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .75);
}

.app-user-avatar {
    width: 29px;
    height: 29px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background:
        linear-gradient(
            145deg,
            var(--primary),
            var(--primary-light)
        );
    font-size: .72rem;
    font-weight: 800;
}

.app-user-name {
    max-width: 150px;
    overflow: hidden;
    color: var(--ink-soft);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .78rem;
    font-weight: 700;
}

.app-logout-form {
    margin: 0;
}

.app-logout-button {
    border: 0;
    color: var(--danger);
    background: transparent;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 800;
}

.app-container {
    width:
        min(
            1480px,
            calc(100% - clamp(20px, 4vw, 64px))
        );
    margin: 0 auto;
    padding:
        clamp(24px, 4vw, 52px)
        0
        80px;
}

.app-footer {
    padding: 28px;
    display: grid;
    gap: 4px;
    color: var(--muted);
    text-align: center;
    font-size: .8rem;
}

.app-footer strong {
    color: var(--ink-soft);
}

.app-alert {
    margin-bottom: 20px;
    padding: 14px 17px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-small);
    font-size: .86rem;
    font-weight: 700;
    transition: .35s ease;
}

.app-alert span {
    width: 25px;
    height: 25px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 800;
}

.app-alert p {
    margin: 0;
}

.app-alert-error {
    color: #8d2329;
    background: #ffe8ea;
}

.app-alert-error span {
    background: var(--danger);
}

.app-alert-success {
    color: #08715a;
    background: #e1f9f2;
}

.app-alert-success span {
    background: var(--success);
}

.app-alert.is-hiding {
    opacity: 0;
    transform: translateY(-8px);
}

.glass-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-large);
    background: var(--surface);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-medium);
}

.eyebrow,
.section-label,
.badge {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.btn,
.button {
    min-height: 48px;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    font-size: .86rem;
    font-weight: 800;
    transition:
        transform .16s ease,
        box-shadow .16s ease,
        opacity .16s ease;
}

.btn:hover,
.button:hover {
    transform: translateY(-2px);
}

.btn.is-pressed,
.button.is-pressed,
.app-nav-link.is-pressed {
    transform: translateY(1px) scale(.99);
}

.btn.primary,
.button-primary {
    color: #fff;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--primary-light)
        );
    box-shadow:
        0 14px 28px rgba(108, 92, 231, .24);
}

.btn.soft,
.button-secondary {
    color: var(--primary);
    background: var(--primary-soft);
}

.btn.danger,
.button-danger {
    color: #fff;
    background: var(--danger);
}

.btn.ghost,
.button-ghost {
    color: var(--ink-soft);
    background: #fff;
    border: 1px solid var(--line);
}

.btn.full,
.button-full {
    width: 100%;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--ink-soft);
    font-size: .82rem;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid var(--line);
    border-radius: 13px;
    outline: none;
    color: var(--ink);
    background: #fff;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow:
        0 0 0 4px rgba(108, 92, 231, .10);
}

.auth,
.join-shell {
    min-height: 620px;
    display: grid;
    grid-template-columns:
        minmax(0, 1.1fr)
        minmax(360px, .9fr);
    align-items: center;
    gap: clamp(32px, 6vw, 80px);
}

.auth-copy h1,
.join-copy h1 {
    margin: 18px 0;
    font-size:
        clamp(3rem, 7vw, 5.8rem);
    line-height: .96;
    letter-spacing: -.07em;
}

.auth-copy h1 em {
    display: block;
    color: var(--primary);
    font-style: normal;
}

.auth-copy p,
.join-copy p {
    max-width: 650px;
    color: var(--muted);
    font-size: 1.06rem;
    line-height: 1.7;
}

.auth-card,
.join-card,
.panel,
.editor {
    padding: 28px;
}

.auth-card h2 {
    margin: 14px 0 24px;
    font-size: 2rem;
}

.demo-access {
    display: block;
    margin-top: 15px;
    padding: 14px;
    border-radius: 14px;
    color: var(--muted);
    background: var(--surface-soft);
}

.floating-cards {
    margin-top: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.floating-cards div {
    padding: 13px 16px;
    border-radius: 15px;
    background: #fff;
    box-shadow: var(--shadow-small);
    font-weight: 700;
}

.page-head {
    margin-bottom: 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.page-head h1 {
    margin: 14px 0 7px;
    font-size:
        clamp(2.3rem, 5vw, 4.3rem);
    letter-spacing: -.055em;
}

.page-head p {
    margin: 0;
    color: var(--muted);
}

.metric-grid {
    margin-bottom: 22px;
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.metric-grid article {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #fff;
    box-shadow: var(--shadow-small);
}

.metric-grid span,
.metric-grid strong {
    display: block;
}

.metric-grid span {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
}

.metric-grid strong {
    margin-top: 7px;
    font-size: 2.2rem;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.panel h2 {
    margin: 10px 0 18px;
}

.quiz-row,
.history-row,
.rank-row {
    margin-bottom: 9px;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-radius: 15px;
    background: var(--surface-soft);
}

.empty {
    padding: 28px;
    border-radius: 16px;
    color: var(--muted);
    background: var(--surface-soft);
    text-align: center;
}

.editor-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.editor-meta .wide {
    grid-column: 1 / -1;
}

.question-editor {
    margin: 18px 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface-soft);
}

.question-editor header {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
}

.question-settings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.option {
    margin-bottom: 10px;
    display: grid;
    grid-template-columns:
        44px 1fr 90px 30px;
    align-items: center;
    gap: 10px;
}

.correct {
    margin: 0;
    position: relative;
}

.correct input {
    position: absolute;
    opacity: 0;
}

.correct span {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #858a98;
    background: #e8eaf0;
    cursor: pointer;
}

.correct input:checked + span {
    color: #08765f;
    background: #d9f7ef;
}

@media (max-width: 920px) {
    .app-container {
        width: min(100% - 24px, 1480px);
    }

    .auth,
    .join-shell,
    .split {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 680px) {
    .app-header {
        min-height: 64px;
        padding-left: 14px;
        padding-right: 14px;
    }

    .app-navigation {
        gap: 10px;
    }

    .app-navigation
    .app-nav-link:not(.app-nav-join),
    .app-user-name {
        display: none;
    }

    .app-user-chip {
        padding-right: 5px;
    }

    .app-container {
        width: min(100% - 18px, 1480px);
        padding-top: 22px;
    }

    .metric-grid,
    .editor-meta,
    .question-settings {
        grid-template-columns: 1fr;
    }

    .option {
        grid-template-columns:
            42px 1fr 28px;
    }

    .option small {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
