/* Relay (live quiz room) — host and participant screens. Light theme only. */

.rl-root {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 16px;
}

/* ---------- Action bar (desktop top bar) ---------- */

.rl-actionbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-radius: 16px;
    background: white;
    box-shadow: 0 4px 18px 0 rgba(31, 46, 70, 0.08);
}

.rl-actionbar__heading {
    min-width: 0;
}

.rl-actionbar__title {
    margin: 2px 0 0;
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 20px;
    color: var(--text-dark-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rl-actionbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* ---------- Two-column layout (lobby / dashboard row) ---------- */

.rl-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    align-items: start;
}

.rl-dash-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rl-card__caption {
    margin: 0 0 12px;
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-dark-color);
}

.rl-card__scorebox {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px;
    border-radius: 12px;
    background: var(--gray-100);
}

.rl-card__scorecap {
    font-family: var(--font-family);
    font-size: 12px;
    color: var(--gray-500);
}

/* ---------- Header ---------- */

.rl-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
}

.rl-header__heading {
    min-width: 0;
    text-align: center;
}

.rl-header__eyebrow {
    display: block;
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 12px;
    color: var(--blue-color);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.rl-header__title {
    margin: 0;
    text-align: center;
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 18px;
    color: var(--text-dark-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rl-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: none;
    background: var(--gray-200);
    color: var(--gray-800);
    cursor: pointer;
}

.rl-icon-btn--placeholder {
    background: transparent;
    cursor: default;
}

/* ---------- Panels (loading / status) ---------- */

.rl-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
}

.rl-panel__title {
    margin: 0;
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 18px;
    color: var(--text-dark-color);
}

.rl-panel__sub {
    margin: 0;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--gray-500);
}

.rl-error {
    margin: 0;
    font-family: var(--second-family);
    font-size: 12px;
    color: var(--red-color);
    text-align: center;
}

/* ---------- Lobby (host) ---------- */

.rl-lobby {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* Make the "Начать" button span the lobby card width. */
.rl-lobby .rl-btn--wide {
    margin-top: 8px;
}

.rl-lobby__cap {
    margin: 8px 0 0;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--gray-500);
}

.rl-code {
    margin: 0;
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 40px;
    letter-spacing: 6px;
    color: var(--text-dark-color);
}

.rl-qr {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 12px;
}

.rl-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--gray-300);
    background: white;
    cursor: pointer;
}

.rl-link__text {
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--gray-800);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rl-link__copy {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    color: var(--blue-color);
    flex-shrink: 0;
}

/* ---------- Participants ---------- */

.rl-participants {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.rl-participant {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--gray-100);
}

.rl-participant__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.rl-participant__name {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 15px;
    color: var(--text-dark-color);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rl-empty {
    margin: 0;
    text-align: center;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--gray-500);
}

/* ---------- Badges ---------- */

.rl-badge {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 8px;
    background: var(--gray-200);
    color: var(--gray-800);
    flex-shrink: 0;
}

.rl-badge--ok { background: #E6F9F2; color: #128C6B; }
.rl-badge--active { background: #E8F1FF; color: #2D6FD6; }
.rl-badge--done { background: #EFEAFE; color: #6B4DD6; }
.rl-badge--warn { background: #FFF4E5; color: #B8730C; }
.rl-badge--fail { background: #FDECE9; color: #C7402B; }

/* ---------- Dashboard (host) ---------- */

.rl-dashboard {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rl-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: white;
    box-shadow: 0 4px 18px 0 rgba(31, 46, 70, 0.08);
}

.rl-card__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rl-card__id {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.rl-card__score {
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 36px;
    line-height: 1;
    color: var(--text-dark-color);
}

.rl-current {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--gray-100);
}

.rl-current__pos {
    font-family: var(--font-family);
    font-size: 12px;
    color: var(--gray-500);
}

.rl-current__title {
    font-family: var(--third-family);
    font-weight: 600;
    font-size: 14px;
    color: var(--text-dark-color);
}

.rl-answered {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rl-answered__item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--gray-100);
    border-left: 4px solid var(--gray-300);
}

.rl-answered__item--ok { border-left-color: #1CCD9D; }
.rl-answered__item--wrong { border-left-color: #FF6951; }

.rl-answered__q {
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--gray-800);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rl-answered__a {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 14px;
    color: var(--text-dark-color);
    flex-shrink: 0;
    max-width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rl-result {
    padding: 10px 12px;
    border-radius: 12px;
    text-align: center;
}

.rl-result--ok { background: #E6F9F2; }
.rl-result--fail { background: #FDECE9; }

.rl-result__title {
    margin: 0;
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-dark-color);
}

.rl-result__sub {
    margin: 2px 0 0;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--gray-500);
}

/* ---------- Summary (host) ---------- */

.rl-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.rl-summary__title {
    margin: 0 0 8px;
    text-align: center;
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 22px;
    color: var(--text-dark-color);
}

.rl-summary__row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--gray-100);
}

.rl-summary__score {
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 16px;
    color: var(--gray-800);
}

.rl-summary__score--ok { color: #128C6B; }
.rl-summary__score--fail { color: #C7402B; }

/* ---------- Buttons ---------- */

.rl-btn {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    padding: 12px 18px;
    transition: opacity 120ms ease;
}

.rl-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.rl-btn--primary {
    background: var(--blue-color);
    color: white;
}

.rl-btn--ghost {
    background: var(--gray-200);
    color: var(--gray-800);
}

.rl-btn--danger {
    background: var(--red-color);
    color: white;
}

.rl-btn--wide {
    width: 100%;
}

.rl-btn--sm {
    font-size: 13px;
    padding: 8px 12px;
}

.rl-sticky {
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    background: linear-gradient(to top, var(--page-bg, #F4F7FB) 60%, transparent);
}

/* ---------- Confirm dialog ---------- */

.rl-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 30, 57, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.rl-confirm {
    background: white;
    border-radius: 20px;
    padding: 24px;
    max-width: 360px;
    width: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: center;
}

.rl-confirm__title {
    margin: 0;
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 18px;
    color: var(--text-dark-color);
}

.rl-confirm__sub {
    margin: 0;
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--gray-500);
}

.rl-confirm__actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.rl-confirm__actions .rl-btn {
    flex: 1;
}

/* ---------- Spinner ---------- */

.rl-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--blue-color);
    border-radius: 50%;
    animation: rl-spin 0.8s linear infinite;
}

@keyframes rl-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Mobile (collapse the 2-column layout to a stack) ---------- */

@media (max-width: 900px) {
    .rl-grid {
        grid-template-columns: 1fr;
    }

    .rl-actionbar {
        flex-wrap: wrap;
    }

    .rl-actionbar__heading {
        flex: 1 1 100%;
    }
}
