/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #F2F2F7;
    --surface: #FFFFFF;
    --surface-2: #F2F2F7;
    --surface-3: #E5E5EA;
    --separator: rgba(60,60,67,0.12);
    --label: #000000;
    --label-2: rgba(60,60,67,0.6);
    --label-3: rgba(60,60,67,0.36);
    --label-4: rgba(60,60,67,0.18);
    --blue: #007AFF;
    --blue-light: rgba(0,122,255,0.1);
    --green: #34C759;
    --green-light: rgba(52,199,89,0.1);
    --orange: #FF9500;
    --orange-light: rgba(255,149,0,0.1);
    --red: #FF3B30;
    --red-light: rgba(255,59,48,0.1);
    --purple: #AF52DE;
    --yellow: #FFD60A;
    --tab-height: 83px;
    --safe-top: env(safe-area-inset-top, 44px);
    --nav-height: 52px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

html { font-size: 16px; }

body {
    font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--label);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ===== APP SHELL ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ===== iOS STATUS BAR AREA ===== */
.status-bar-spacer {
    height: var(--safe-top);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
}

/* ===== NAVIGATION BAR (iOS Large Title style) ===== */
.ios-nav {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 0.5px solid var(--separator);
    position: sticky;
    top: 0;
    z-index: 150;
    flex-shrink: 0;
}
.ios-nav-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 20px 12px;
    min-height: var(--nav-height);
    gap: 12px;
}
.ios-nav-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--label);
    flex: 1;
    text-align: center;
}
.ios-nav-large {
    padding: 0 20px 8px;
}
.ios-nav-large .large-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
}
.ios-nav-large .subtitle {
    font-size: 13px;
    color: var(--label-2);
    margin-top: 2px;
    letter-spacing: 0.1px;
}
.nav-action-btn {
    width: 34px; height: 34px;
    background: var(--blue-light);
    border: none;
    border-radius: 50%;
    color: var(--blue);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.nav-action-btn:active { opacity: 0.6; }

/* ===== SCROLL CONTENT ===== */
.scroll-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(var(--tab-height) + 16px);
}
.scroll-content::-webkit-scrollbar { display: none; }

/* ===== VIEWS ===== */
.view-section {
    display: none;
    animation: ios-slide-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.view-section.active { display: block; }
@keyframes ios-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== iOS GROUPED SECTIONS ===== */
.ios-section {
    margin: 20px 16px 0;
}
.ios-section:first-child { margin-top: 16px; }
.ios-section-header {
    font-size: 13px;
    font-weight: 400;
    color: var(--label-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px 8px;
}
.ios-list {
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.ios-list-item {
    display: flex;
    align-items: center;
    padding: 13px 16px;
    position: relative;
    gap: 14px;
    transition: background 0.12s;
}
.ios-list-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0; left: 56px; right: 0;
    height: 0.5px;
    background: var(--separator);
}
.ios-list-item:active { background: rgba(0,0,0,0.04); }
.ios-list-icon {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.icon-blue { background: var(--blue); }
.icon-green { background: var(--green); }
.icon-orange { background: var(--orange); }
.icon-purple { background: var(--purple); }
.icon-red { background: var(--red); }

.ios-list-content {
    flex: 1;
    min-width: 0;
}
.ios-list-label {
    font-size: 17px;
    font-weight: 400;
    color: var(--label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ios-list-detail {
    font-size: 13px;
    color: var(--label-2);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ios-list-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.ios-list-value {
    font-size: 15px;
    color: var(--label-2);
}
.ios-chevron {
    color: var(--label-3);
    font-size: 12px;
}
.ios-badge {
    background: var(--blue);
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 22px;
    text-align: center;
}
.badge-green { background: var(--green); }
.badge-orange { background: var(--orange); }
.badge-red { background: var(--red); }

/* ===== CARDS ===== */
.ios-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.ios-card-header {
    padding: 16px 16px 12px;
    border-bottom: 0.5px solid var(--separator);
}
.ios-card-body { padding: 0; }

/* ===== HERO CARD (Ranking / Score) ===== */
.hero-card {
    background: linear-gradient(145deg, #1a1a2e, #16213e, #0f3460);
    border-radius: var(--radius-xl);
    padding: 24px;
    margin: 16px;
    color: white;
    position: relative;
    overflow: hidden;
}
.hero-card::before {
    content: '⚽';
    position: absolute;
    right: -20px; top: -20px;
    font-size: 120px;
    opacity: 0.06;
    transform: rotate(-15deg);
}
.hero-eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 4px;
}
.hero-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}
.hero-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
}
.hero-stats {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-wrap: wrap;
}
.hero-stat-val {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--yellow);
}
.hero-stat-label {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
}

/* ===== TAB BAR ===== */
.ios-tab-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(248,248,248,0.94);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 0.5px solid var(--separator);
    display: flex;
    height: var(--tab-height);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 200;
}
.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 10px;
    cursor: pointer;
    gap: 4px;
    border: none;
    background: none;
    transition: opacity 0.15s;
}
.tab-item:active { opacity: 0.6; }
.tab-icon {
    font-size: 22px;
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.tab-item.active .tab-icon {
    transform: scale(1.15);
}
.tab-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--label-2);
    letter-spacing: 0.2px;
}
.tab-item.active .tab-label {
    color: var(--blue);
    font-weight: 600;
}
.tab-dot {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--blue);
    margin-top: 2px;
}

/* ===== PARTICIPANT CARDS ===== */
.participant-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.participant-list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 14px;
    position: relative;
    background: var(--surface);
    transition: background 0.12s;
    cursor: pointer;
}
.participant-list-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0; left: 62px; right: 0;
    height: 0.5px;
    background: var(--separator);
}
.participant-list-item:active { background: rgba(0,0,0,0.04); }
.p-avatar {
    width: 44px; height: 44px;
    background: var(--blue-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid transparent;
}
.p-avatar.active-user {
    border-color: var(--blue);
}
.p-avatar img {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.p-info { flex: 1; min-width: 0; }
.p-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.p-status {
    font-size: 13px;
    color: var(--label-2);
    margin-top: 1px;
}
.p-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
}
.icon-btn:active { opacity: 0.7; transform: scale(0.94); }
.btn-login { background: var(--blue-light); color: var(--blue); }
.btn-delete { background: var(--red-light); color: var(--red); }

/* ===== BUTTONS ===== */
.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.7; transform: scale(0.98); }
.btn-primary {
    background: var(--blue);
    color: white;
    border-radius: 14px;
    padding: 14px 24px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
    width: 100%;
}
.btn-primary-sm {
    background: var(--blue);
    color: white;
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 15px;
    font-weight: 600;
}
.btn-outline {
    background: transparent;
    color: var(--blue);
    border: 1.5px solid var(--blue);
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 15px;
    font-weight: 500;
}
.btn-destructive {
    background: var(--red-light);
    color: var(--red);
    border-radius: 14px;
    padding: 14px 24px;
    font-size: 17px;
    font-weight: 600;
    width: 100%;
}
.floating-btn {
    background: var(--blue);
    color: white;
    width: 56px; height: 56px;
    border-radius: 50%;
    font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0,122,255,0.4);
    border: none;
    cursor: pointer;
    position: fixed;
    bottom: calc(var(--tab-height) + 16px);
    right: 20px;
    z-index: 100;
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s;
}
.floating-btn:active { transform: scale(0.92); opacity: 0.85; }

/* ===== GROUP PILLS ===== */
.group-scroll {
    overflow-x: auto;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.group-scroll::-webkit-scrollbar { display: none; }
.group-pill {
    padding: 7px 18px;
    background: var(--surface);
    border: 1.5px solid var(--separator);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--label-2);
    flex-shrink: 0;
}
.group-pill.active {
    background: var(--label);
    color: white;
    border-color: var(--label);
}
.group-pill:active { opacity: 0.7; }

/* ===== MATCH ROWS ===== */
.match-card {
    background: var(--surface);
    margin: 0;
    padding: 14px 16px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}
.match-card:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0; left: 16px; right: 16px;
    height: 0.5px;
    background: var(--separator);
}
.team-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.team-col.away { align-items: center; }
.team-flag {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg);
    border: 2px solid var(--separator);
    flex-shrink: 0;
}
.team-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--label);
    text-align: center;
    line-height: 1.2;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.score-center {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.score-input {
    width: 52px; height: 52px;
    text-align: center;
    border: 2px solid var(--separator);
    border-radius: var(--radius-sm);
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: var(--surface);
    color: var(--label);
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s, background 0.15s;
}
.score-input:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--blue-light);
}
.score-input.admin-mode {
    border-color: var(--orange);
    background: var(--orange-light);
}
.score-input:disabled {
    background: var(--surface-2);
    color: var(--label-3);
    border-color: var(--label-4);
}
.score-sep {
    font-size: 20px;
    font-weight: 700;
    color: var(--label-3);
}
.lock-chip {
    font-size: 11px;
    font-weight: 600;
    color: var(--label-3);
    background: var(--surface-2);
    padding: 3px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ===== RANKING TABLE ===== */
.ranking-list { }
.ranking-row {
    display: flex;
    align-items: center;
    padding: 13px 16px;
    gap: 14px;
    background: var(--surface);
    position: relative;
}
.ranking-row:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0; left: 60px; right: 0;
    height: 0.5px;
    background: var(--separator);
}
.rank-pos {
    width: 28px;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--label-3);
    flex-shrink: 0;
}
.rank-pos.top-1 { color: #FFD700; }
.rank-pos.top-2 { color: #C0C0C0; }
.rank-pos.top-3 { color: #CD7F32; }
.rank-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--blue-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.rank-name {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rank-points {
    font-size: 20px;
    font-weight: 700;
    color: var(--blue);
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    text-align: right;
}
.pts-label { font-size: 11px; color: var(--label-3); font-weight: 500; }

/* ===== SYNC STATUS ===== */
.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--green);
    background: var(--green-light);
    padding: 4px 10px;
    border-radius: 20px;
}
.sync-badge.offline { color: var(--orange); background: var(--orange-light); }

/* ===== USER HEADER ===== */
.user-header {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    padding: 14px 16px;
    margin: 16px 16px 0;
    border-radius: var(--radius-lg);
}
.user-avatar-lg {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
}
.user-info-text { flex: 1; min-width: 0; }
.user-greeting {
    font-size: 13px;
    color: var(--label-2);
}
.user-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--label-2);
}
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--label); margin-bottom: 6px; }
.empty-text { font-size: 15px; color: var(--label-2); line-height: 1.4; }

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    top: calc(var(--safe-top) + 60px);
    left: 50%; transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: rgba(30,30,30,0.92);
    backdrop-filter: blur(16px);
    color: white;
    padding: 11px 20px;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 500;
    animation: toast-in 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
@keyframes toast-in {
    from { opacity: 0; transform: scale(0.88) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== LEGEND ===== */
.points-legend {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-2);
    flex-wrap: wrap;
}
.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--label-2);
    font-weight: 500;
}
.legend-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
}

/* ===== SCROLLBAR HIDE GLOBALLY ===== */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

/* ===== UTILITIES ===== */
.text-muted { color: var(--label-2); }
.fw-bold { font-weight: 700; }
.mt-0 { margin-top: 0 !important; }

/* Ocultar botón eliminar por defecto */
.btn-delete.hidden {
    display: none;
}
/* ===== ADMIN UNLOCK BUTTON ===== */
#btnSaveResults[style*="FF9500"],
.btn-unlock {
    background: var(--orange) !important;
}
 
/* Lock chip for admin read-only mode */
.lock-chip {
    background: rgba(255,149,0,0.12);
    color: var(--orange);
    border: 1px solid rgba(255,149,0,0.25);
}
/* Override for prediction locked chip (blue-gray) */
#predictionMatches .lock-chip {
    background: var(--surface-2);
    color: var(--label-3);
    border: none;
}