/* perfil.css */
* { box-sizing: border-box; }

.perfil-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

.perfil-header {
    background: linear-gradient(135deg, #004D40, #00695C);
    color: white;
    border-radius: 12px;
    padding: 20px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.perfil-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.35);
    letter-spacing: -1px;
}

.perfil-nombre {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.perfil-meta {
    font-size: 0.88rem;
    opacity: 0.82;
}

.stats-grid {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 1fr 1fr 1fr;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 14px 6px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    border-top: 3px solid #004D40;
}

.stat-card.ganados  { border-top-color: #2e7d32; }
.stat-card.perdidos { border-top-color: #c62828; }
.stat-card.pct      { border-top-color: #1565c0; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #212121;
    line-height: 1;
}

.stat-label {
    font-size: 0.68rem;
    color: #757575;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.perfil-seccion {
    background: white;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.perfil-seccion h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #004D40;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.esca-row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.esca-row:last-child { border-bottom: none; }

.esca-posicion {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #004D40;
    color: white;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.esca-nombre { -webkit-box-flex: 1; -ms-flex: 1; flex: 1; font-weight: 500; color: #212121; font-size: 0.95rem; }
.esca-detalle { font-size: 0.82rem; color: #757575; white-space: nowrap; }

.match-row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #f0f0f0;
}

.match-row:last-child { border-bottom: none; }

.mr-badge {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.resultado-ganado .mr-badge  { background: #e8f5e9; color: #2e7d32; }
.resultado-perdido .mr-badge { background: #ffebee; color: #c62828; }

.mr-rival { -webkit-box-flex: 1; -ms-flex: 1; flex: 1; font-size: 0.9rem; color: #212121; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-rival a { color: inherit; text-decoration: none; }
.mr-rival a:hover { text-decoration: underline; color: #004D40; }

.mr-score { font-size: 0.85rem; color: #424242; white-space: nowrap; min-width: 70px; }
.mr-fecha  { font-size: 0.75rem; color: #9e9e9e; white-space: nowrap; text-align: right; }

.perfil-vacio { color: #9e9e9e; text-align: center; padding: 16px 0; font-size: 0.9rem; }

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .perfil-header { padding: 14px; gap: 12px; }
    .perfil-avatar { width: 50px; height: 50px; font-size: 18px; }
    .perfil-nombre { font-size: 1.15rem; }
    .mr-fecha { display: none; }
    .esca-detalle { display: none; }
}

/* --- Foto de perfil --- */
.perfil-avatar-wrap {
    position: relative;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.perfil-foto {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.5);
    display: block;
}

.perfil-foto-btn {
    position: absolute;
    bottom: 0;
    right: -4px;
    width: 22px;
    height: 22px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.perfil-foto-btn:hover { background: #fff; }

.perfil-foto-status {
    font-size: 0.78rem;
    margin-top: 4px;
    display: block;
}

.perfil-foto-status.loading { color: #fff; opacity: 0.8; }
.perfil-foto-status.ok      { color: #a5d6a7; }
.perfil-foto-status.error   { color: #ef9a9a; }

/* --- Head to head --- */
.h2h-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.h2h-table th {
    text-align: left;
    padding: 6px 8px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #757575;
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
}

.h2h-table th:not(:first-child) { text-align: center; }

.h2h-table td {
    padding: 8px 8px;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: middle;
}

.h2h-table td:not(:first-child) { text-align: center; }

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

.h2h-ganando { background: #f1f8e9; }
.h2h-perdiendo { background: #fff8f8; }

.h2h-rival a { color: #004D40; text-decoration: none; font-weight: 500; }
.h2h-rival a:hover { text-decoration: underline; }

.h2h-g { color: #2e7d32; font-weight: 600; }
.h2h-p { color: #c62828; font-weight: 600; }

@media (max-width: 480px) {
    .perfil-foto { width: 50px; height: 50px; }
    .h2h-table { font-size: 0.82rem; }
}
