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

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

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

/* ---------- 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-primary);
}

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

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

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

.rl-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: none;
    background: var(--surface-sunken);
    color: var(--text-primary);
    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;
}

/* The code entry keeps the page gutters on phones; the panel adds no side padding of its own. */
@media (max-width: 767.98px) {
    .rl-panel {
        padding: 32px 0;
    }
}

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

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

.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(--text-secondary);
}

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

.rl-qr {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-raised);
    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(--surface-sunken);
    background: var(--surface-raised);
    cursor: pointer;
}

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

.rl-link__copy {
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 13px;
    color: var(--accent-action);
    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(--surface-sunken);
}

.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-primary);
    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(--text-secondary);
}

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

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

.rl-badge--ok { background: var(--success-soft); color: var(--success); }
.rl-badge--active { background: var(--info-soft); color: var(--info); }
.rl-badge--done { background: #EFEAFE; color: #6B4DD6; }
.rl-badge--warn { background: var(--warning-soft); color: var(--warning); }
.rl-badge--fail { background: var(--danger-soft); color: var(--danger); }

/* ---------- 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: var(--surface-raised);
    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-primary);
}

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

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

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

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

.rl-answered__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surface-sunken);
    border-left: 4px solid var(--surface-sunken);
}

.rl-answered__item--ok { border-left-color: var(--green-500); }
.rl-answered__item--wrong { border-left-color: var(--red-500); }

/* Correctness is also shown as a glyph, not by color alone. */
.rl-answered__mark {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

.rl-answered__item--ok .rl-answered__mark { color: var(--green-500); background: var(--green-100); }
.rl-answered__item--wrong .rl-answered__mark { color: var(--red-500); background: var(--red-100); }

.rl-answered__q {
    font-family: var(--font-family);
    font-size: 14px;
    color: var(--text-primary);
    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-primary);
    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-primary);
}

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

/* ---------- 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-primary);
}

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

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

.rl-summary__score--ok { color: var(--success); }
.rl-summary__score--fail { color: var(--danger); }

/* ---------- 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(--accent-action);
    color: white;
}

.rl-btn--ghost {
    background: var(--surface-sunken);
    color: var(--text-primary);
}

.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(--surface) 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: var(--z-modal);
}

.rl-confirm {
    background: var(--surface-raised);
    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-primary);
}

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

.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(--surface-sunken);
    border-top-color: var(--accent-action);
    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;
    }

}
