/* Competition hub */

:root {
    --comp-bg: #f0f3f8;
    --comp-surface: #fff;
    --comp-border: #e4e9f2;
    --comp-text: #1a2233;
    --comp-muted: #6b7a90;
    --comp-accent: #6d5ef7;
    --comp-accent-soft: #f0edff;
    --comp-green: #22a06b;
    --comp-radius: 14px;
    --comp-shadow: 0 8px 30px rgba(26, 34, 51, 0.06);
    --comp-media-h: clamp(200px, 22vw, 380px);
    --comp-media-h-stack: clamp(200px, 46vmin, 400px);
    --comp-header-h: 58px;
    --comp-guest-sim-h: clamp(420px, 62vh, 720px);
}

body.competition-app {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--comp-bg);
    color: var(--comp-text);
    min-height: 100dvh;
    padding: 0;
}

.comp-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 58px;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid var(--comp-border);
}

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

.comp-brand-icon { font-size: 22px; color: var(--comp-accent); }

.comp-brand-text {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--comp-text);
    text-decoration: none;
}

.comp-brand-text span { color: var(--comp-accent); }

.comp-topnav {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.comp-topnav-item {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--comp-muted);
    text-decoration: none;
}

.comp-topnav-item:hover { background: #f8fafc; color: var(--comp-text); }
.comp-topnav-item.active { background: var(--comp-accent-soft); color: var(--comp-accent); }

.comp-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.comp-user-pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--comp-accent-soft);
    color: var(--comp-accent);
}

.lang-switcher {
    display: flex;
    gap: 4px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--comp-border);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
}

.lang-btn {
    min-width: 36px;
    padding: 5px 10px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1.2;
}

.lang-btn:hover {
    background: #f1f5f9;
}

.comp-header .logout-btn,
.comp-header .lang-switcher {
    flex-shrink: 0;
    background: #fff;
    border-color: var(--comp-border);
    color: var(--comp-muted);
    box-shadow: none;
}

.comp-header .lang-btn.active {
    background: var(--comp-accent);
    color: #fff;
}

.comp-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.comp-hero {
    margin-bottom: 16px;
}

.comp-hero-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--comp-accent);
    margin-bottom: 6px;
}

.comp-hero-title {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 800;
}

.comp-hero-lead {
    margin: 0;
    color: var(--comp-muted);
    font-size: 15px;
    max-width: 560px;
}

.comp-queue-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    padding: 14px 16px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid var(--comp-border);
    border-radius: var(--comp-radius);
    box-shadow: var(--comp-shadow);
}

.comp-queue-banner--active {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.comp-queue-banner--queue {
    border-color: #fde68a;
    background: #fffbeb;
}

.comp-queue-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.comp-queue-pos { font-weight: 700; color: var(--comp-accent); }

body.competition-app.viewer-queued .comp-hero,
body.competition-app.viewer-queued .comp-grid {
    display: none;
}

body.competition-app.viewer-queued .comp-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - 58px);
    padding-top: 24px;
    padding-bottom: 32px;
}

body.competition-app.viewer-queued .comp-queue-banner {
    display: none;
}

body.competition-app.viewer-queued .comp-queue-screen {
    width: 100%;
    max-width: 440px;
}

.comp-idle-timer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--comp-muted);
    background: #f8fafc;
    border: 1px solid var(--comp-border);
    border-radius: 8px;
}

.comp-idle-timer strong {
    font-family: ui-monospace, monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--comp-text);
    font-variant-numeric: tabular-nums;
}

.comp-idle-timer strong.idle-countdown--urgent {
    color: #dc2626;
}

.comp-media-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
    align-items: stretch;
}

.comp-media-row > .comp-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-top: 0;
    padding: 0;
    overflow: hidden;
}

.comp-media-row > .comp-card .comp-card-head {
    padding: 14px 16px 10px;
    margin-bottom: 0;
}

.comp-simulator .comp-sim-ticker {
    margin: 0;
    padding: 10px 12px 12px;
    border-radius: 0;
    border-top: 1px solid var(--comp-border);
    min-height: 0;
}

.comp-cam-frame {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: var(--comp-media-h);
    border-radius: 0;
    overflow: hidden;
    background: #0f172a;
    border: none;
    border-top: 1px solid var(--comp-border);
}

.comp-cam-frame video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #0f172a;
}

.comp-cam-frame .media-stack,
.comp-cam-frame .video-container,
.comp-cam-frame .media-placeholder {
    position: absolute;
    inset: 0;
    margin: 0;
}

.comp-cam-frame .media-stack,
.comp-cam-frame .video-container {
    width: 100%;
    height: 100%;
}

.comp-cam-frame .media-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    background: #0f172a;
}

.comp-sim-view {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: var(--comp-media-h);
    background: #f1f5f9;
    border-radius: 0;
    overflow: hidden;
    border-top: 1px solid var(--comp-border);
}

/* Выравниваем высоту камеры с симулятором (у симулятора есть тикер снизу) */
.comp-media-row > .comp-camera::after {
    content: '';
    display: block;
    flex: 0 0 auto;
    min-height: 28px;
    border-top: 1px solid transparent;
}

.comp-sim-view .simulator-section,
.comp-sim-view .simulator-section.visible {
    display: flex !important;
    position: absolute;
    inset: 0;
}

.comp-sim-view .simulator-container {
    flex: 1;
    min-height: 0 !important;
    border-radius: 0;
}

.comp-sim-ticker {
    font-family: ui-monospace, monospace;
    font-size: 11px;
    color: var(--comp-muted);
    overflow-x: auto;
    white-space: nowrap;
    background: #f8fafc;
}

body.comp-guest .comp-sim-ticker {
    white-space: normal;
    padding: 10px 12px 14px;
    overflow: visible;
}

body.comp-guest .comp-sim-ticker:empty,
body.comp-guest .comp-sim-ticker[hidden] {
    display: none;
}

.comp-replay-paths {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comp-replay-path__label {
    display: block;
    margin-bottom: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--comp-muted);
}

.comp-replay-path__value {
    display: block;
    margin: 0;
    padding: 0;
    font-family: ui-monospace, monospace;
    font-size: 10px;
    line-height: 1.45;
    word-break: break-all;
    color: var(--comp-text);
}

.comp-sim-ticker .move-token {
    display: inline-block;
    margin-right: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--comp-accent-soft);
    color: var(--comp-accent);
}

.dash-live-badge {
    font-size: 11px;
    font-weight: 700;
    color: #e5484d;
}

.dash-live-badge::before { content: '● '; }

.dash-sync-badge {
    font-size: 12px;
    font-weight: 600;
    color: #22a06b;
}

.dash-sync-badge.busy { color: #d97706; }

.comp-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 400px);
    gap: 14px;
    align-items: start;
}

@media (max-width: 1024px) {
    .comp-media-row { grid-template-columns: 1fr; }
    .comp-cam-frame,
    .comp-sim-view { min-height: var(--comp-media-h-stack); }
    .comp-media-row > .comp-camera::after { display: none; }
}

@media (max-width: 900px) {
    .comp-grid { grid-template-columns: 1fr; }
    .comp-topnav { display: none; }
}

@media (max-width: 640px) {
    .comp-header {
        height: auto;
        min-height: 52px;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    .comp-header-right { margin-left: auto; }

    .comp-main { padding: 14px 12px 28px; }

    .comp-hero-title { font-size: 22px; }

    .comp-hero-lead { font-size: 14px; }

    .comp-queue-banner {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
    }

    .comp-queue-actions {
        margin-left: 0;
        width: 100%;
    }

    .comp-queue-actions .btn-primary,
    .comp-queue-actions .btn-outline {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
    }

    .comp-media-row { gap: 12px; }

    .comp-cam-frame,
    .comp-sim-view { min-height: clamp(180px, 52vmin, 320px); }

    .comp-media-row > .comp-card .comp-card-head {
        padding: 12px 14px 8px;
        flex-wrap: wrap;
        gap: 6px;
    }

    .comp-card-title { font-size: 15px; }

    .comp-sim-ticker { font-size: 10px; }
}

.comp-card {
    background: var(--comp-surface);
    border: 1px solid var(--comp-border);
    border-radius: var(--comp-radius);
    box-shadow: var(--comp-shadow);
    padding: 16px;
}

.comp-card + .comp-card { margin-top: 14px; }

.comp-side .comp-card + .comp-card { margin-top: 14px; }

.comp-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.comp-card-title {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 700;
}

.comp-card-head .comp-card-title { margin-bottom: 0; }

.section-hint {
    font-size: 13px;
    color: var(--comp-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

.daily-challenge__date,
.daily-challenge__scramble {
    font-size: 13px;
    margin-bottom: 10px;
}

.daily-challenge__scramble {
    font-family: ui-monospace, monospace;
    word-break: break-word;
    padding: 10px;
    background: #f8fafc;
    border: 1px solid var(--comp-border);
    border-radius: 8px;
}

.path-input--area {
    width: 100%;
    padding: 10px;
    border: 1px solid #d0d8e6;
    border-radius: 10px;
    font-family: ui-monospace, monospace;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 10px;
}

.comp-btn-send {
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.daily-challenge__result {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
}

.daily-challenge__result--ok { background: #f0fdf4; color: #15803d; }
.daily-challenge__result--err { background: #fef2f2; color: #b91c1c; }

.comp-challenge-log {
    margin-top: 14px;
    padding: 10px 12px;
    max-height: 140px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.45;
    background: #fff;
    border: 1px solid #d0d8e6;
    border-radius: 10px;
    color: var(--comp-text);
}

.comp-challenge-log.empty-state {
    color: #4b5563;
}

.comp-challenge-log .log-entry { margin-bottom: 4px; }

.comp-challenge-log .log-time {
    color: #64748b;
    font-weight: 600;
}

.comp-challenge-log .response-success {
    color: #166534;
}

.comp-challenge-log .response-error {
    color: #b91c1c;
    font-weight: 600;
}

.comp-my-result .comp-card-head {
    margin-bottom: 4px;
}

.comp-reset-timer {
    font-family: ui-monospace, monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--comp-accent);
    padding: 4px 8px;
    background: var(--comp-accent-soft);
    border-radius: 8px;
}

.comp-reset-hint {
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--comp-muted);
}

.comp-my-result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.comp-my-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--comp-border);
    border-radius: 10px;
    font-size: 12px;
    color: var(--comp-muted);
}

.comp-my-stat strong {
    font-size: 14px;
    color: var(--comp-text);
}

.comp-header-login {
    padding: 6px 14px;
    font-size: 13px;
}

.comp-auth--overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
}

.comp-auth--overlay[hidden] {
    display: none !important;
}

.comp-auth--overlay .comp-auth-panel {
    width: min(100%, 400px);
    margin: 0;
    box-shadow: 0 24px 60px rgba(26, 34, 51, 0.2);
}

body.comp-guest .comp-participant-only {
    display: none !important;
}

/* Гость: симулятор слева, данные справа */
body.comp-guest .comp-main {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 400px);
    gap: 14px;
    align-items: start;
    max-width: 1400px;
}

body.comp-guest .comp-media-row,
body.comp-guest #compMediaRow[hidden] {
    grid-column: 1;
    grid-row: 1;
    display: grid !important;
    grid-template-columns: 1fr;
    margin-bottom: 0;
    position: sticky;
    top: calc(var(--comp-header-h) + 12px);
}

body.comp-guest .comp-simulator {
    min-height: var(--comp-guest-sim-h);
}

body.comp-guest .comp-sim-view {
    min-height: calc(var(--comp-guest-sim-h) - 120px);
}

body.comp-guest .comp-data-column {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

body.comp-guest .comp-date-bar {
    margin-bottom: 0;
}

body.comp-guest .comp-grid {
    grid-template-columns: 1fr;
    min-width: 0;
}

body.comp-guest .comp-public-side {
    display: grid;
    gap: 14px;
    min-width: 0;
}

@media (max-width: 1024px) {
    body.comp-guest .comp-main {
        grid-template-columns: 1fr;
        max-width: 1100px;
    }

    body.comp-guest .comp-media-row,
    body.comp-guest #compMediaRow[hidden] {
        grid-column: 1;
        grid-row: auto;
        position: static;
        margin-bottom: 14px;
    }

    body.comp-guest .comp-data-column {
        grid-column: 1;
        grid-row: auto;
    }

    body.comp-guest .comp-sim-view {
        min-height: var(--comp-media-h-stack);
    }

    body.comp-guest .comp-simulator {
        min-height: 0;
    }
}

.comp-replay-picker {
    display: flex;
    flex: 1 1 100%;
    gap: 8px;
    min-width: 0;
}

.comp-replay-select {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--comp-border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--comp-text);
    background: #fff;
}

.competition-app .dash-sync-badge {
    display: none !important;
}

.comp-simulator .comp-replay-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px 10px;
    border-top: 1px solid var(--comp-border);
    margin-top: 0;
}

.comp-try-solution {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--comp-border);
}

.comp-try-solution__label {
    font-size: 12px;
    font-weight: 700;
    color: var(--comp-text);
}

.comp-try-solution__hint {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--comp-muted);
}

.comp-try-solution__input {
    width: 100%;
    min-height: 52px;
    font-size: 12px;
    font-family: ui-monospace, monospace;
}

.comp-try-solution__btn {
    align-self: flex-start;
}

.comp-simulator .comp-replay-actions .btn-outline:not(.comp-replay-mine) {
    flex: 0 1 auto;
    min-width: 0;
    justify-content: center;
}

.comp-weekly-range {
    margin: -6px 0 10px;
    font-size: 12px;
    color: var(--comp-muted);
}

.comp-table-row--me {
    background: var(--comp-accent-soft);
}

.comp-table-row--me td {
    font-weight: 600;
}

.comp-you-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--comp-accent);
    background: #fff;
    border-radius: 999px;
    vertical-align: middle;
}

@media (max-width: 640px) {
    .comp-my-result-grid { grid-template-columns: 1fr; }
}

.comp-stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.comp-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 13px;
    color: var(--comp-muted);
}

.comp-stat strong { color: var(--comp-text); }

.comp-date-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--comp-surface, #fff);
    border: 1px solid var(--comp-border);
    border-radius: var(--comp-radius, 14px);
    box-shadow: 0 8px 24px rgba(26, 34, 51, 0.05);
}

.comp-date-bar__label {
    font-size: 13px;
    font-weight: 700;
    color: var(--comp-muted);
    letter-spacing: 0.02em;
}

.comp-date-bar__controls {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 240px;
    justify-content: flex-end;
}

.comp-date-nav {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--comp-border);
    border-radius: 10px;
    background: #fff;
    color: var(--comp-text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.comp-date-nav:hover:not(:disabled) {
    background: #f8fafc;
    border-color: var(--comp-border-strong, #d0d8e6);
}

.comp-date-nav:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.comp-date-select {
    flex: 1 1 180px;
    min-width: 0;
    max-width: 280px;
    padding: 8px 12px;
    border: 1px solid var(--comp-border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--comp-text);
    background: #fff;
}

.comp-table-wrap { overflow-x: auto; }

.comp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.comp-table th,
.comp-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--comp-border);
}

.comp-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--comp-muted);
}

.comp-table-empty {
    text-align: center;
    color: var(--comp-muted);
    padding: 20px !important;
}

.comp-rules-list {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: var(--comp-muted);
    line-height: 1.7;
}

.comp-soon .section-hint { margin-bottom: 0; }

.btn-primary {
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6d5ef7, #7c6df0);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.btn-success {
    background: linear-gradient(135deg, #15803d, #22c55e);
    color: #fff;
}

.btn-outline {
    padding: 10px 14px;
    border: 1px solid var(--comp-border);
    border-radius: 10px;
    background: #fff;
    font-weight: 600;
    cursor: pointer;
}

.btn-outline--danger { color: #e5484d; border-color: #fecaca; }
.btn-block { width: 100%; }

.comp-auth {
    margin-bottom: 16px;
}

.comp-auth-panel {
    background: #fff;
    border: 1px solid var(--comp-border);
    border-radius: var(--comp-radius);
    padding: 20px;
    box-shadow: var(--comp-shadow);
}

.comp-auth .auth-panel__input {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--comp-border);
    border-radius: 8px;
}

.comp-auth .auth-panel__submit {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: var(--comp-accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.comp-tech {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}
