/* VolatusTennis: estilos do site (antes inline no index.html) */
/* ==================== BASE ==================== */
:root {
    --bg: #0c0b14;
    --surface: #13111d;
    --surface-2: #1b1829;
    --line: #2a2640;
    --text: #f2f0fa;
    --muted: #a9a4c4;
    --accent: #a78bfa;
    --hard: #5b9cff;
    --clay: #e8884a;
    --grass: #5fcf80;
    --pos: #4ade80;
    --neg: #f87171;
}

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

@font-face {
    font-family: 'Sakana';
    src: url('../fonts/Sakana.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body {
    font-family: 'Sakana', sans-serif;
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
    background: var(--bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    font-family: 'Sakana', sans-serif;
}

h2 {
    color: #ffffff;
    margin: 30px 0 20px 0;
    font-size: 1.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

/* ==================== NAVEGAÇÃO ==================== */
.navbar {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    background: none;
    backdrop-filter: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 0 0 12px;
    justify-content: space-between;
}

.nav-tabs {
    display: flex;
    gap: 5px;
}

.nav-tab {
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 55px;
    padding: 0 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    font: 500 15px 'Sakana', sans-serif;
    color: var(--muted);
}

.nav-tab:hover {
    background: none;
    color: #fff;
    border-color: transparent;
    border-bottom-color: var(--line);
}

.nav-tab.active {
    background: none;
    box-shadow: none;
    color: #fff;
    border-color: transparent;
    border-bottom-color: var(--accent);
}

.nav-logo {
    font: 700 22px 'Sakana', sans-serif;
    letter-spacing: .03em;
    color: #fff;
}

.nav-logo span {
    color: var(--accent);
}

.flt:focus-visible,
.nav-tab:focus-visible,
.surface-tab:focus-visible,
.player-search-result:focus-visible,
.tab-content:focus-visible,
.tab-status-retry:focus-visible,
.clear-player-search:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==================== HISTÓRICO ==================== */
.tr-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.tr-filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 0.85rem;
}

.tr-filters select,
.tr-filters input[type="search"] {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

.tr-filters .tr-check {
    flex-direction: row;
    align-items: center;
    align-self: end;
    min-height: 40px;
    color: var(--text);
}

.tr-filters .tr-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.tr-filters select:focus-visible,
.tr-filters input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.tr-empty {
    color: var(--muted);
    padding: 24px 8px;
    text-align: center;
}

.tr-count {
    color: var(--muted);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.tr-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.tr-table {
    width: 100%;
    border-collapse: collapse;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 0.88rem;
    color: var(--text);
}

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

.tr-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.tr-table tbody tr:hover {
    background: var(--surface);
}

.tr-num,
.tr-nowrap {
    white-space: nowrap;
}

.tr-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tr-table .tr-ok {
    color: var(--pos);
}

.tr-table .tr-fail {
    color: var(--neg);
}

.tr-more {
    display: block;
    margin: 16px auto 0;
}

/* ==================== ESTADOS DE CARREGAMENTO / ERRO ==================== */
.tab-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 0 24px;
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    text-align: center;
    font-size: 0.95rem;
}

.tab-status[hidden] {
    display: none;
}

.tab-status.is-error {
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.5);
    background: rgba(248, 113, 113, 0.08);
}

.tab-status-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    animation: tabStatusSpin 0.8s linear infinite;
}

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

.tab-status-retry {
    min-height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.tab-status-retry:hover {
    background: rgba(167, 139, 250, 0.15);
}

/* Esqueleto dos valores enquanto os dados não chegam */
[aria-busy="true"] .stat-value {
    color: transparent;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.2s ease-in-out infinite;
}

@keyframes skeleton {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .tab-status-spinner,
    [aria-busy="true"] .stat-value {
        animation: none;
    }
}

/* ==================== SEPARADORES ==================== */
/* evita scroll horizontal momentâneo durante a animação de entrada dos separadores */
#conteudo {
    overflow-x: clip;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: tabEnter 0.4s ease both;
    will-change: opacity, transform;
}

@keyframes tabEnter {
    from { opacity: 0; transform: translateX(28px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==================== ESTATÍSTICAS E COMPONENTES PARTILHADOS ==================== */
.stats-header {
    color: #ffffff;
    text-align: left;
    margin: 32px 0 20px;
}

.stats-header h2 {
    margin: 0;
    font: 700 36px 'Sakana', sans-serif;
    color: var(--text);
}

.stat-positive {
    color: #00c853 !important;
}

.stat-negative {
    color: #ff5252 !important;
}

.accuracy-progress-card {
    margin: 0 0 20px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    font: 500 14px 'Sakana', sans-serif;
    color: var(--muted);
}

.progress-bar {
    width: 100%;
    border-radius: 999px;
    overflow: hidden;
    height: 10px;
    background: var(--line);
}

.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.8s ease-out;
    background: var(--accent);
    box-shadow: none;
}

.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    color: #ffffff;
    min-height: 240px;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}

.chart-card h3 {
    margin: 0 0 14px;
    font: 600 16px 'Sakana', sans-serif;
    color: var(--text);
}

.chart-card canvas {
    width: 100% !important;
    height: 200px !important;
    display: block;
    object-fit: contain;
}

.surface-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.surface-tab {
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: none;
    color: #cfcbe6;
    font: 500 14px 'Sakana', sans-serif;
    box-shadow: none;
}

.surface-tab:hover {
    background: none;
    border-color: var(--accent);
    color: #fff;
}

.surface-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #14101f;
    font-weight: 700;
    box-shadow: none;
}

.top10-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 10px;
    margin-top: 0;
}

.player-card {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    grid-template-areas: "r n e" "r n l";
    align-items: center;
    column-gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    text-align: left;
    transition: border-color .2s;
}

.player-card:hover {
    background: var(--surface);
    border-color: #4a4470;
    transform: none;
    box-shadow: none;
}

.player-rank {
    grid-area: r;
    display: block;
    width: auto;
    height: auto;
    margin: 0;
    border-radius: 0;
    background: none;
    font: 700 20px 'Sakana', sans-serif;
    color: var(--muted);
}

.player-name-card {
    color: #ffffff;
    word-break: break-word;
    grid-area: n;
    margin: 0;
    font: 600 16px 'Sakana', sans-serif;
}

.player-elo {
    grid-area: e;
    text-align: right;
    font: 700 20px 'Sakana', sans-serif;
    color: #9078f1;
}

.player-elo-label {
    grid-area: l;
    margin: 0;
    text-align: right;
    font-size: 12px;
    color: var(--muted);
}

.section {
    border-radius: 12px;
    padding: 0;
    border: 0;
    background: none;
    margin-bottom: 32px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 20px 5px;
    border-radius: 12px;
    border: #764ba2 2px solid;
    text-align: center;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    color: #a466ea;
}

.stat-label {
    color: var(--muted);
    margin-top: 5px;
    margin-bottom: 5px;
}

.stats-header .subtitle {
    margin-top: 6px;
    font: 400 16px 'Sakana', sans-serif;
    color: var(--muted);
    opacity: 1;
}

#tab-estatisticas .stat-value.stat-positive {
    color: var(--pos) !important;
}

#tab-estatisticas .stat-value.stat-negative {
    color: var(--neg) !important;
}

.progress-header span:last-child {
    font: 700 28px 'Sakana', sans-serif;
    color: var(--text);
}

.section h2 {
    margin: 0 0 16px;
    font: 700 22px 'Sakana', sans-serif;
    color: var(--text);
}

.surface-tab::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
}

.surface-tab[data-surface="hard"]::before {
    background: var(--hard);
}

.surface-tab[data-surface="clay"]::before {
    background: var(--clay);
}

.surface-tab[data-surface="grass"]::before {
    background: var(--grass);
}

.surface-tab.active::before {
    box-shadow: 0 0 0 2px #14101f;
}

.player-card:nth-child(-n+3) .player-rank {
    color: var(--accent);
}

/* ==================== CLUSTERING ==================== */
.cluster-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: 12px;
    margin-bottom: 20px;
    text-align: left;
}

.cluster-meta-card {
    color: #ffffff;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.cluster-meta-card h3 {
    margin: 0 0 6px;
    font: 500 14px 'Sakana', sans-serif;
    color: var(--muted);
}

.cluster-meta-value {
    font: 700 28px 'Sakana', sans-serif;
    color: var(--text);
    overflow-wrap: anywhere;
}

.cluster-meta-subtitle {
    margin-top: 4px;
    font-size: 0.95em;
    color: var(--muted);
}

.cluster-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: 12px;
    margin-top: 0;
}

.cluster-card {
    color: #ffffff;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.cluster-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.cluster-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 999px;
    color: #ffffff;
    font-weight: bold;
    min-width: 40px;
    height: 40px;
    border: 1px solid var(--accent);
    background: #1f1a38;
    font-family: 'Sakana', sans-serif;
}

.cluster-style {
    text-align: right;
    font: 700 17px 'Sakana', sans-serif;
    color: var(--text);
}

.cluster-card small {
    color: var(--muted);
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(118, 75, 162, 0.18);
    border: 1px solid rgba(164, 102, 234, 0.25);
    color: #ffffff;
    font-size: 0.85em;
}

.cluster-toolbar {
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    max-width: 480px;
    margin-bottom: 16px;
}

.cluster-toolbar label {
    font: 500 14px 'Sakana', sans-serif;
    color: var(--muted);
}

.cluster-toolbar select {
    min-width: 0;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(118, 75, 162, 0.35);
    background: rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-family: 'Sakana', sans-serif;
}

.player-search-wrapper {
    position: relative;
    min-width: 0;
    width: min(450px, 100%);
}

#playerSearch {
    width: 100%;
    min-width: 0;
    outline: none;
    transition: all 0.25s ease;
    min-height: 44px;
    padding: 0 42px 0 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: 400 15px 'Sakana', sans-serif;
}

#playerSearch::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

#playerSearch:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, .2);
}

.clear-player-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: none;
}

.clear-player-search:hover {
    color: #ffffff;
}

.player-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.player-search-results.active {
    display: block;
}

.player-search-result {
    padding: 11px 15px;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: 'Sakana', sans-serif;
}

.player-search-result:hover,
.player-search-result.is-active {
    background: #26213a;
}

.player-search-result.is-active {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.player-search-result.all-players {
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--accent);
}

.player-search-no-results {
    padding: 13px 15px;
    color: rgba(255, 255, 255, 0.55);
}

.cluster-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    margin-bottom: 25px;
    gap: 16px;
}

.cluster-chart-grid .chart-card {
    min-height: 340px;
    max-height: 420px;
}

.cluster-chart-grid .chart-card.radar-card {
    min-height: 420px;
    max-height: 520px;
}

.cluster-chart-grid .chart-card canvas {
    height: 260px !important;
}

.cluster-chart-grid .chart-card.radar-card canvas {
    height: 340px !important;
}

.player-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 0 0 20px;
}

.player-summary-card {
    color: #ffffff;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.player-summary-card h4 {
    margin: 0 0 6px;
    font: 500 13px 'Sakana', sans-serif;
    color: var(--muted);
}

.player-summary-card .summary-value {
    font: 700 22px 'Sakana', sans-serif;
    color: var(--text);
}

#tab-estatisticas .stats-grid,
#tab-clustering .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

#tab-estatisticas .stat-card,
#tab-clustering .stat-card {
    display: flex;
    flex-direction: column-reverse;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    text-align: left;
}

#tab-estatisticas .stat-value,
#tab-clustering .stat-value {
    font: 700 28px 'Sakana', sans-serif;
    color: var(--text);
    overflow-wrap: anywhere;
}

#tab-clustering .stat-value {
    font-size: 24px;
}

#tab-estatisticas .stat-label,
#tab-clustering .stat-label {
    margin: 0;
    font: 500 12px 'Sakana', sans-serif;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}

.cluster-card .chip {
    border: 1px solid rgba(74, 222, 128, .35);
    background: var(--surface-2);
    color: var(--text);
    font: 13px 'Sakana', sans-serif;
}

.cluster-card .chip-list + .chip-list .chip {
    border-color: rgba(248, 113, 113, .35);
}

/* ==================== PREVISÕES ==================== */
.predictions-container {
    border-radius: 12px;
    border: #764ba2 2px solid;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.loading {
    text-align: center;
    padding: 30px;
    color: white;
    font-size: 1.2em;
}

#tab-previsoes header {
    text-align: left;
    margin: 32px 0 20px;
}

#tab-previsoes header h1 {
    font: 700 36px 'Sakana', sans-serif;
    margin: 0;
}

#tab-previsoes .subtitle {
    font: 400 16px 'Sakana', sans-serif;
    color: var(--muted);
    opacity: 1;
    margin-top: 6px;
}

#tab-previsoes .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

#tab-previsoes .stat-card:nth-child(3) {
    display: none;
}

#tab-previsoes .stat-card {
    display: flex;
    flex-direction: column-reverse;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    text-align: left;
}

#tab-previsoes .stat-value {
    font: 700 28px 'Sakana', sans-serif;
    color: var(--text);
}

#tab-previsoes .stat-label {
    font: 500 12px 'Sakana', sans-serif;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0;
}

#tab-previsoes .predictions-container {
    border: 0;
    padding: 0;
    box-shadow: none;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.flt {
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: none;
    color: #cfcbe6;
    font: 500 14px 'Sakana', sans-serif;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}

.flt:hover {
    border-color: var(--accent);
}

.flt.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #14101f;
    font-weight: 700;
}

#predictions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
    gap: 16px;
}

#predictions.loading {
    display: block;
    color: var(--muted);
}

#predictions > .mx-empty {
    grid-column: 1 / -1;
    padding: 40px 0;
    text-align: center;
    color: var(--muted);
    font-family: 'Sakana', sans-serif;
}

.mx {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    font-family: 'Sakana', sans-serif;
    transition: border-color .2s;
}

.mx:hover {
    border-color: #4a4470;
}

.mx-m {
    font-size: 12px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}

.mx-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.mx-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
}

.mx-conf b {
    font: 700 26px 'Sakana', sans-serif;
}

.mx-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.mx-p {
    min-width: 0;
    padding: 14px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--surface-2);
}

.mx-p.win {
    border-color: var(--accent);
    background: #1f1a38;
}

.mx-p .tag {
    min-height: 1.2em;
    color: var(--accent);
}

.mx-p .n {
    margin: 2px 0 6px;
    font: 600 18px 'Sakana', sans-serif;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.mx-p.win .n {
    color: #fff;
    font-weight: 700;
}

.mx-bar {
    display: flex;
    height: 10px;
    margin-top: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--line);
}

.mx-bar i {
    display: block;
    background: #4a4470;
}

.mx-bar i.w {
    background: var(--accent);
}

.mx-bar-l {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.mx-tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.mx-t {
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.mx-t b {
    display: block;
    margin-top: 4px;
    font: 600 18px 'Sakana', sans-serif;
    color: var(--text);
    overflow-wrap: anywhere;
}

.mx-t b.sm {
    font-size: 14px;
}

.mx-t b.pos {
    color: var(--pos);
}

.mx-t b.neg {
    color: var(--neg);
}

.mx-t b.zero {
    color: #ab4545;
}

.mx-note {
    margin: 14px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}

.mx-foot {
    margin: 24px 0 0;
    font: 13px 'Sakana', sans-serif;
    color: var(--muted);
}

/* ==================== ECRÃ DE LOADING ==================== */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background: radial-gradient(60% 50% at 50% 42%, rgba(167, 139, 250, 0.16), transparent 70%), #0c0b14;
    font-family: 'Sakana', sans-serif;
}

.loading-screen.is-hidden {
    pointer-events: none;
    animation: radialWipe 0.45s cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    padding: 0 20px;
    color: #ffffff;
    text-align: center;
}

.loading-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.loading-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.45));
    opacity: 0;
    transform: scale(0.6);
    animation: logoIntro 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.loading-content h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 2.8rem);
    letter-spacing: 0.03em;
    color: #ffffff;
    opacity: 0;
    transform: translateX(-24px);
    animation: textSlideIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

.loading-content h1 span {
    color: #a78bfa;
}

.loading-court {
    position: relative;
    width: 60px;
    height: 72px;
    opacity: 0;
    animation: fadeIn 0.4s ease 0.7s forwards;
}

.loading-court::after {
    content: '';
    position: absolute;
    left: -40px;
    right: -40px;
    bottom: 3px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #2a2640 30%, #2a2640 70%, transparent);
}

.loading-ball {
    position: absolute;
    left: 50%;
    bottom: 12px;
    width: 30px;
    height: 30px;
    margin-left: -15px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #d9ff5e, #a4d400 70%);
    overflow: hidden;
    animation: ballBounce 0.8s cubic-bezier(0.5, 0, 1, 0.5) 0.7s infinite alternate;
}

.loading-ball::before,
.loading-ball::after {
    content: '';
    position: absolute;
    top: -25%;
    width: 150%;
    height: 150%;
    border: 2px solid rgba(255, 255, 255, 0.65);
    border-radius: 50%;
}

.loading-ball::before {
    left: -95%;
}

.loading-ball::after {
    left: 45%;
}

.loading-shadow {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 30px;
    height: 7px;
    margin-left: -15px;
    border-radius: 50%;
    background: rgba(167, 139, 250, 0.4);
    animation: shadowBounce 0.8s cubic-bezier(0.5, 0, 1, 0.5) 0.7s infinite alternate;
}

.loading-status {
    margin: 0;
    min-height: 1.2em;
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    color: #a9a4c4;
    opacity: 0;
    animation: fadeIn 0.5s ease 0.9s forwards;
}

.loading-status::after {
    content: '';
    display: inline-block;
    width: 1.2em;
    text-align: left;
    animation: loadingDots 1.4s steps(4, end) infinite;
}

@keyframes logoIntro {
    from { opacity: 0; transform: scale(0.6); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes textSlideIn {
    from { opacity: 0; transform: translateX(-24px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes textSlideInUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

@keyframes ballBounce {
    from { transform: translateY(-34px) rotate(0deg); }
    to { transform: translateY(0) rotate(160deg); }
}

@keyframes shadowBounce {
    from { transform: scale(0.55); opacity: 0.25; }
    to { transform: scale(1); opacity: 0.7; }
}

@keyframes loadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

@keyframes radialWipe {
    from { opacity: 1; clip-path: circle(150% at 50% 50%); visibility: visible; }
    to { opacity: 0; clip-path: circle(0% at 50% 50%); visibility: hidden; }
}

/* ==================== RESPONSIVO E ACESSIBILIDADE ==================== */
@media (max-width: 768px) {
    .cluster-toolbar {
        align-items: stretch;
        flex-direction: column;
        max-width: none;
    }

    .player-search-wrapper {
        width: 100%;
        min-width: 0;
    }

    #playerSearch {
        min-width: 0;
    }

    h1 {
        font-size: 2em;
    }

    .chip-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .flt {
        flex: none;
    }

    #tab-previsoes header h1 {
        font-size: 28px;
    }

    .stats-header h2 {
        font-size: 28px;
    }
}

@media (max-width: 720px) {
    .navbar {
        flex-direction: column;
        justify-content: center;
        gap: 6px;
    }

    .nav-tabs {
        width: 100%;
        gap: 6px;
    }

    .nav-tab {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 0;
        padding: 0 10px;
        font-size: 13px;
    }
}

/* Telemóvel: 4 separadores numa linha ficam colados → grelha 2×2 com alvos de 44px */
@media (max-width: 480px) {
    .nav-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding-top: 4px;
    }

    .nav-tab {
        min-height: 44px;
        padding: 0 8px;
        justify-content: center;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: var(--surface);
        font-size: 13px;
        letter-spacing: 0.02em;
    }

    .nav-tab:hover {
        border-color: var(--line);
        border-bottom-color: var(--line);
        background: var(--surface-2);
    }

    .nav-tab.active {
        border-color: var(--accent);
        border-bottom-color: var(--accent);
        background: rgba(167, 139, 250, 0.14);
    }
}

@media (max-width: 480px) {
    .loading-brand {
        flex-direction: column;
        gap: 12px;
    }

    .loading-content h1 {
        font-size: clamp(1.8rem, 9vw, 2.4rem);
        transform: translateY(18px);
        animation-name: textSlideInUp;
    }
}

@media (max-width: 380px) {
    .nav-logo {
        font-size: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tab-content.active {
        animation: none;
    }

    .loading-content h1,
    .loading-logo,
    .loading-court,
    .loading-ball,
    .loading-shadow,
    .loading-status,
    .loading-status::after {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* ==================== APP (PWA): instalar, Telegram, avisos ==================== */
.nav-brand {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
}

.app-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.app-actions:not(:has(> :not([hidden]))) {
    display: none;
}

.app-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font: 500 13px 'Sakana', sans-serif;
    text-decoration: none;
    cursor: pointer;
}

.app-action[hidden] {
    display: none;
}

.app-action:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

.app-action:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.app-action-telegram {
    border-color: rgba(42, 171, 238, 0.6);
}

.app-banner {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.app-banner[hidden] {
    display: none;
}

.app-banner-update {
    border-color: var(--accent);
}

.ios-dialog {
    max-width: min(420px, calc(100% - 32px));
    margin: auto;
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.ios-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.ios-dialog h2 {
    font: 700 20px 'Sakana', sans-serif;
    margin-bottom: 16px;
}

.ios-dialog ol {
    padding-left: 20px;
    line-height: 1.6;
}

.ios-dialog li + li {
    margin-top: 8px;
}

.ios-dialog-note {
    margin: 16px 0;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 720px) {
    .nav-brand {
        flex-direction: column;
        gap: 10px;
    }

    .app-actions {
        justify-content: center;
    }
}
