/*
 * Ikigai Combat — Telão de resultados ao vivo
 * Mesma linguagem visual do display de TV (broadcast).
 */

:root {
    --rl-bg-0: #070809;
    --rl-bg-1: #101214;
    --rl-bg-2: #171a1d;
    --rl-surface: rgba(22, 25, 28, 0.92);
    --rl-line: rgba(255, 255, 255, 0.08);
    --rl-text: #f4f5f6;
    --rl-muted: #9aa3ad;
    --rl-red: #d32f2f;
    --rl-red-deep: #9a1c1c;
    --rl-amber: #f0a500;
    --rl-live: #2ecc71;
    --rl-danger: #e74c3c;
    --rl-blue: #5dade2;

    --rl-font-display: 'Teko', 'Arial Narrow', sans-serif;
    --rl-font-ui: 'Barlow', 'Helvetica Neue', sans-serif;
    --rl-radius: 4px;
    --rl-gap: clamp(12px, 1.4vw, 24px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden],
.is-hidden {
    display: none !important;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: var(--rl-font-ui);
    color: var(--rl-text);
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(211, 47, 47, 0.18), transparent 55%),
        radial-gradient(ellipse 55% 40% at 100% 0%, rgba(240, 165, 0, 0.1), transparent 50%),
        linear-gradient(165deg, var(--rl-bg-0) 0%, var(--rl-bg-1) 45%, #0c0e10 100%);
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.035;
    background-image:
        repeating-linear-gradient(
            -18deg,
            transparent 0,
            transparent 11px,
            rgba(255, 255, 255, 0.55) 11px,
            rgba(255, 255, 255, 0.55) 12px
        );
    z-index: 0;
}

.rl-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 0;
    padding: var(--rl-gap);
    max-width: 1600px;
    margin: 0 auto;
}

/* Topbar */
.rl-topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: clamp(12px, 2vw, 28px);
    padding: 10px 4px 18px;
    border-bottom: 1px solid var(--rl-line);
}

.rl-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.rl-brand-mark {
    width: clamp(40px, 3.5vw, 52px);
    height: clamp(40px, 3.5vw, 52px);
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}

.rl-brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.05;
}

.rl-brand-name {
    font-family: var(--rl-font-display);
    font-size: clamp(1.35rem, 2.2vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rl-event-name {
    font-size: clamp(0.85rem, 1.1vw, 1.05rem);
    font-weight: 500;
    color: var(--rl-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 42vw;
}

.rl-title-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0.45em 1.1em;
    background: linear-gradient(135deg, var(--rl-red) 0%, var(--rl-red-deep) 100%);
    color: #fff;
    font-family: var(--rl-font-display);
    font-size: clamp(1.15rem, 1.8vw, 1.6rem);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: var(--rl-radius);
    box-shadow: 0 8px 24px rgba(211, 47, 47, 0.28);
}

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

.rl-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.4em 0.85em;
    background: rgba(46, 204, 113, 0.12);
    border: 1px solid rgba(46, 204, 113, 0.4);
    color: var(--rl-live);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: var(--rl-radius);
}

.rl-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rl-live);
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55);
    animation: livePing 2s ease-out infinite;
}

@keyframes livePing {
    0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55); }
    70% { box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

.rl-clock {
    font-family: var(--rl-font-display);
    font-size: clamp(1.5rem, 2.6vw, 2.4rem);
    font-weight: 600;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    padding: 0.15em 0.55em;
    background: var(--rl-bg-2);
    border: 1px solid var(--rl-line);
    border-radius: var(--rl-radius);
}

/* Stats */
.rl-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: var(--rl-gap) 0 0;
}

.rl-stat {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--rl-surface);
    border: 1px solid var(--rl-line);
    border-radius: var(--rl-radius);
    min-width: 180px;
}

.rl-stat i {
    color: var(--rl-amber);
    font-size: 1.1rem;
}

.rl-stat strong {
    display: block;
    font-family: var(--rl-font-display);
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.03em;
}

.rl-stat span {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rl-muted);
}

/* Stage / table */
.rl-stage {
    min-height: 0;
    padding: var(--rl-gap) 0;
}

.rl-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--rl-surface);
    border: 1px solid var(--rl-line);
    border-radius: var(--rl-radius);
    overflow: hidden;
    position: relative;
}

.rl-panel::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--rl-red);
}

.rl-panel-head {
    padding: clamp(16px, 2vw, 24px) clamp(18px, 2.2vw, 28px) 12px;
    border-bottom: 1px solid var(--rl-line);
}

.rl-panel-head h1 {
    font-family: var(--rl-font-display);
    font-size: clamp(1.5rem, 2.4vw, 2.1rem);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
}

.rl-panel-sub {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--rl-muted);
    font-weight: 500;
}

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

.rl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.85rem, 1.35vw, 1.05rem);
}

.rl-table thead tr {
    background: rgba(211, 47, 47, 0.16);
    border-bottom: 1px solid rgba(211, 47, 47, 0.35);
}

.rl-table th {
    padding: clamp(10px, 1.4vw, 16px) clamp(10px, 1.6vw, 18px);
    text-align: left;
    font-weight: 700;
    font-size: clamp(0.62rem, 1vw, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--rl-muted);
    white-space: nowrap;
}

.rl-table td {
    padding: clamp(12px, 1.4vw, 18px) clamp(10px, 1.6vw, 18px);
    border-bottom: 1px solid var(--rl-line);
    vertical-align: middle;
}

.rl-table tbody tr:last-child td {
    border-bottom: none;
}

.rl-table tbody tr {
    transition: background 0.2s ease;
}

.rl-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.rl-table tbody tr.new-row {
    animation: newRow 0.9s ease-out forwards;
}

@keyframes newRow {
    0% {
        opacity: 0;
        background: rgba(46, 204, 113, 0.22);
        transform: translateY(-6px);
    }
    60% { background: rgba(46, 204, 113, 0.1); }
    100% {
        opacity: 1;
        background: transparent;
        transform: translateY(0);
    }
}

.seq-num {
    color: var(--rl-muted);
    font-family: var(--rl-font-display);
    font-size: 1.15em;
    font-weight: 600;
    min-width: 28px;
}

.winner-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 700;
}

.winner-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--rl-radius);
    background: linear-gradient(135deg, #1e8f4f, var(--rl-live));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    flex-shrink: 0;
    color: #fff;
}

.winner-name {
    font-family: var(--rl-font-display);
    font-size: clamp(1.15rem, 1.8vw, 1.55rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--rl-live);
    line-height: 1;
}

.loser-cell {
    color: var(--rl-muted);
    font-weight: 600;
    font-size: 0.95em;
}

.tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: clamp(0.62rem, 1vw, 0.75rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.28em 0.7em;
    border-radius: var(--rl-radius);
    white-space: nowrap;
}

.tipo-pontos {
    background: rgba(41, 128, 185, 0.22);
    color: #7fc3f8;
    border: 1px solid rgba(41, 128, 185, 0.4);
}

.tipo-finalizacao {
    background: rgba(211, 47, 47, 0.22);
    color: #ff9d8f;
    border: 1px solid rgba(211, 47, 47, 0.4);
}

.tipo-wo {
    background: rgba(240, 165, 0, 0.2);
    color: #ffd080;
    border: 1px solid rgba(240, 165, 0, 0.4);
}

.tipo-default {
    background: rgba(255, 255, 255, 0.06);
    color: var(--rl-muted);
    border: 1px solid var(--rl-line);
}

.area-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(211, 47, 47, 0.14);
    border: 1px solid rgba(211, 47, 47, 0.35);
    border-radius: var(--rl-radius);
    padding: 0.25em 0.65em;
    font-size: 0.82em;
    font-weight: 700;
    color: #ffc9c9;
    white-space: nowrap;
}

.cat-text {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.92em;
    font-weight: 500;
}

.time-text {
    font-family: var(--rl-font-display);
    font-size: 1.2em;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--rl-amber);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.rl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 220px;
    color: var(--rl-muted);
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.rl-empty i {
    font-size: 2.2rem;
    opacity: 0.7;
}

.rl-empty p {
    font-size: 1.05rem;
    font-weight: 500;
}

.loading-spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--rl-red);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

/* Footer */
.rl-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 4px 4px;
    border-top: 1px solid var(--rl-line);
    color: var(--rl-muted);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.footer-info {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.footer-update {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--rl-muted);
}

.connection-status[data-state='online'] .status-indicator {
    background: var(--rl-live);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.2);
}

.connection-status[data-state='offline'] .status-indicator {
    background: var(--rl-danger);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

.connection-status[data-state='connecting'] .status-indicator {
    background: var(--rl-amber);
    animation: statusBlink 1.2s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* Mobile cards */
@media (max-width: 720px) {
    .rl-topbar {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            'brand meta'
            'title title';
    }

    .rl-brand { grid-area: brand; }
    .rl-topbar-meta { grid-area: meta; }
    .rl-title-pill { grid-area: title; justify-self: start; }

    .rl-event-name { max-width: 55vw; }

    .rl-table,
    .rl-table thead,
    .rl-table tbody,
    .rl-table th,
    .rl-table td,
    .rl-table tr {
        display: block;
    }

    .rl-table thead {
        display: none;
    }

    .rl-table tbody tr {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--rl-line);
        border-radius: var(--rl-radius);
        margin: 0 12px 12px;
        padding: 0.9rem 1rem;
    }

    .rl-table tbody tr:first-child {
        margin-top: 12px;
    }

    .rl-table tbody tr.new-row {
        border-color: rgba(46, 204, 113, 0.4);
    }

    .rl-table td {
        padding: 0.3rem 0;
        border: none;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .rl-table td::before {
        content: attr(data-label);
        font-size: 0.62rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--rl-muted);
        min-width: 72px;
        flex-shrink: 0;
        font-weight: 700;
    }

    .rl-table td.td-seq {
        display: none;
    }
}

@media (max-width: 480px) {
    .rl-topbar-meta {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }

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