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

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e8e8e8;
    --text: #111111;
    --text-1: #111111;
    --text-2: #666666;
    --text-3: #999999;
    --accent: #111111;
    --accent-soft: #f0f0f0;
    --green: #22c55e;
    --gold: #eab308;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.15s ease;
}

html, body {
    height: 100%;
    overscroll-behavior: none;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* Prevent double-tap zoom on all interactive elements */
button, a, [onclick] {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.app {
    max-width: 460px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    background: var(--surface);
    position: relative;
    overflow: hidden;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: absolute;
    inset: 0;
    background: var(--bg);
    z-index: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}
.screen.active {
    display: flex;
    position: relative;
    z-index: 2;
    animation: slideIn 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(18px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    padding-top: calc(14px + env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}
.btn-back {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text);
    padding: 8px;
    margin: -8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
.topbar-title {
    font-weight: 700;
    font-size: 0.9rem;
}
.badge {
    background: var(--text);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
}

/* ===== HOME ===== */
.home {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 24px;
    padding-top: calc(40px + env(safe-area-inset-top));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
    gap: 40px;
}
.brand {
    text-align: center;
}
.brand h1 {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -1px;
    color: var(--text);
}
.brand p {
    color: var(--text-3);
    font-size: 0.9rem;
    margin-top: 6px;
    font-weight: 500;
}

.credit-footer {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-3);
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    font-weight: 400;
    flex-shrink: 0;
    margin-top: auto;
}
.credit-footer strong { font-weight: 600; }
/* On screens with scroll content (players, tournament), keep it at natural flow */
#screen-players .credit-footer,
#screen-tournament .credit-footer { margin-top: 0; }

.home-options {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 320px;
}
.sport-pick {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.sport-pick:hover { border-color: var(--text); }
.sport-pick:active { transform: scale(0.95); border-color: var(--text); }
.sport-pick-icon {
    font-size: 2.4rem;
}
.sport-pick-name {
    font-weight: 700;
    font-size: 0.95rem;
}

/* ===== SCREEN BODY ===== */
.screen-body {
    flex: 1;
    padding: 20px 16px;
    min-height: 0;
}

/* ===== PILL GRID (futbol types) ===== */
.pill-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.pill {
    padding: 22px 0;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition), transform 0.1s;
    text-align: center;
    color: var(--text);
    min-height: 64px;
}
.pill:hover { border-color: var(--text); }
.pill:active { transform: scale(0.95); background: var(--accent-soft); }

/* ===== FORM STACK (padel config) ===== */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.field-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.field-card label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    margin-bottom: 16px;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}
.stepper-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}
.stepper-btn:hover { border-color: var(--text); }
.stepper-value {
    font-size: 2rem;
    font-weight: 900;
    min-width: 48px;
    text-align: center;
}

.toggle-row {
    display: flex;
    gap: 8px;
}
.toggle-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-2);
}
.toggle-btn:hover { border-color: var(--text-3); }
.toggle-btn.active {
    border-color: var(--text);
    color: var(--text);
    background: var(--accent-soft);
}

/* Alias for JS compatibility */
.points-btn { /* same as toggle-btn, handled by class */ }

/* ===== ACTION OPTIONS ===== */
.action-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}
.action-card:hover { border-color: var(--text); }
.action-card:active { transform: scale(0.98); }

.action-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    background: var(--accent-soft);
}
.action-icon-wrap.green { background: #ecfdf5; }
.action-icon-wrap.gold { background: #fefce8; }

.action-text h3 { font-size: 0.95rem; font-weight: 700; }
.action-text p { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; }
.action-arrow {
    margin-left: auto;
    color: var(--text-3);
    font-size: 1.2rem;
}

/* ===== CHOICE CARDS (mode) ===== */
.choice-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.choice-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}
.choice-card:hover { border-color: var(--text); }
.choice-card:active { transform: scale(0.98); }
.choice-emoji { font-size: 1.8rem; flex-shrink: 0; }
.choice-card strong { font-size: 0.95rem; display: block; }
.choice-card p { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; }

/* ===== FORMAT CARDS ===== */
.format-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 24px;
}
.format-card-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.format-info-btn {
    background: none;
    border: none;
    border-left: 2px solid var(--border);
    border-right: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
    padding: 8px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    border-radius: 0 0 var(--radius) var(--radius);
}
.format-info-btn:active, .format-info-btn.active {
    background: var(--accent-soft);
    color: var(--text-1);
}
.format-detail {
    background: var(--accent-soft);
    border: 2px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 14px 18px;
    font-size: 0.8rem;
    line-height: 1.7;
    color: var(--text-2);
}
.format-detail b { color: var(--text-1); }
.format-card-wrap .format-card {
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 1px solid var(--border);
}
.format-card-wrap .format-info-btn:last-of-type:not(.active) + .format-detail.hidden ~ * {
    border-radius: 0 0 var(--radius) var(--radius);
}
.format-card-wrap .format-detail.hidden + * { display: none; }
.format-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
}
.format-card:hover { border-color: var(--text); }
.format-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    background: var(--accent-soft);
}

/* ===== PLAYER FORM ===== */
.players-body { display: flex; flex-direction: column; }
.player-form { margin-bottom: 16px; }
.input-row {
    display: flex;
    gap: 8px;
}
.input-row input {
    flex: 1;
    padding: 13px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; /* prevent iOS zoom */
    font-family: inherit;
    outline: none;
    background: var(--surface);
    transition: var(--transition);
    -webkit-appearance: none;
}
.input-row input:focus { border-color: var(--text); }
.input-row input::placeholder { color: var(--text-3); }

.btn-add {
    width: 48px;
    height: 48px;
    border: 2px solid var(--text);
    background: var(--text);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity var(--transition), transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-add:hover { opacity: 0.85; }
.btn-add:active { transform: scale(0.92); }

.skill-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
}
.skill-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
}
.stars-input { display: flex; gap: 4px; }
.star-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #ddd;
    transition: color 0.1s;
    padding: 2px;
}
.star-btn.active { color: var(--gold); }
.star-btn:hover { color: var(--gold); }

/* ===== PLAYER LIST ===== */
.player-list-wrap {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
.player-list { list-style: none; }
.reorder-btns {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-right: 6px;
    flex-shrink: 0;
}
.reorder-btn {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 0.55rem;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.1s;
}
.reorder-btn:hover:not(:disabled) { color: var(--text); }
.reorder-btn:disabled { opacity: 0.2; cursor: default; }
.reorder-btn:active:not(:disabled) { color: var(--text); }

.player-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 12px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: fadeIn 0.15s ease;
    min-height: 48px;
}
.player-info { display: flex; align-items: center; gap: 10px; }
.player-number {
    width: 26px; height: 26px;
    background: var(--text);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.player-name { font-weight: 600; font-size: 0.9rem; cursor: pointer; border-bottom: 1px dashed var(--border); }
.player-name:active { opacity: 0.6; }
.player-stars { color: var(--gold); font-size: 0.75rem; letter-spacing: 1px; }
.btn-remove {
    background: none; border: none;
    color: var(--text-3); font-size: 1.2rem;
    cursor: pointer; padding: 8px;
    margin: -8px -4px -8px 0;
    border-radius: 4px; transition: var(--transition);
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
}
.btn-remove:hover { color: #dc2626; background: #fef2f2; }
.btn-remove:active { color: #dc2626; }

/* ===== BOTTOM BAR ===== */
.bottom-bar {
    padding-top: 14px;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    margin-top: auto;
    flex-shrink: 0;
}
.helper-text {
    font-size: 0.8rem;
    color: var(--text-3);
    text-align: center;
    margin-bottom: 12px;
    min-height: 18px;
}
.bottom-buttons { display: flex; gap: 10px; }

/* ===== BUTTONS ===== */
.btn-main {
    flex: 1;
    padding: 15px 20px;
    background: var(--text);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity var(--transition), transform 0.1s;
    min-height: 52px;
}
.btn-main:hover:not(:disabled) { opacity: 0.85; }
.btn-main:active:not(:disabled) { transform: scale(0.97); }
.btn-main:disabled { opacity: 0.25; cursor: not-allowed; }

.btn-secondary {
    flex: 1;
    padding: 15px 20px;
    background: var(--surface);
    color: var(--text-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition), transform 0.1s;
    min-height: 52px;
}
.btn-secondary:hover { border-color: var(--text-3); }
.btn-secondary:active { transform: scale(0.97); }

/* Aliases for JS compatibility */
.btn.primary { /* same as btn-main */ }
.btn.ghost { /* same as btn-secondary */ }
.btn.outline { /* same as btn-secondary */ }
.full-width { width: 100%; flex: none; }
.hidden { display: none !important; }

/* ===== TEAMS RESULT ===== */
.teams-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    align-content: start;
}
.team-card {
    border-radius: var(--radius);
    padding: 16px;
    color: white;
    animation: teamPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes teamPop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.team-card h3 {
    font-size: 0.8rem;
    font-weight: 800;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.team-name-editable {
    cursor: pointer;
}
.team-name-pencil {
    font-size: 0.65rem;
    opacity: 0.5;
    cursor: pointer;
    margin-left: 2px;
    font-style: normal;
}
.team-name-input {
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 4px;
    color: white;
    font: inherit;
    font-weight: 800;
    font-size: 0.8rem;
    font-family: inherit;
    padding: 1px 6px;
    width: 110px;
    outline: none;
}
.team-avg {
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    padding: 2px 7px;
    border-radius: 8px;
    text-transform: none;
    letter-spacing: 0;
}
.team-card ol { list-style: none; counter-reset: tp; }
.team-card ol li {
    counter-increment: tp;
    padding: 4px 0;
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    font-weight: 500;
}
.team-card ol li:last-child { border-bottom: none; }
.team-card ol li::before {
    content: counter(tp);
    margin-right: 8px;
    opacity: 0.5;
    font-size: 0.7rem;
    font-weight: 700;
}
.team-player-stars { font-size: 0.65rem; opacity: 0.7; }
.suplentes-card { grid-column: 1 / -1; background: #888 !important; }

.result-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
    padding-top: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}
.result-bar .btn-wa {
    flex: 1 0 100%; /* WhatsApp always full width */
    order: 3;
}

/* ===== SCREEN BODY FLEX CHILDREN ===== */
#screen-teams-result .screen-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== TOURNAMENT ===== */
.tournament-body { padding: 0 !important; }

.tabs {
    display: flex;
    padding: 4px;
    margin: 12px 20px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
}
.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-3);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.tab.active {
    background: var(--text);
    color: white;
}

.tab-content {
    display: none;
    padding: 0 20px 20px;
    animation: fadeIn 0.18s ease;
}
.tab-content.active { display: block; }

.round-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
}
.round-btn {
    width: 44px; height: 44px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color var(--transition), transform 0.1s;
    color: var(--text);
}
.round-btn:hover { border-color: var(--text); }
.round-btn:active:not(:disabled) { transform: scale(0.92); }
.round-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.round-label { font-weight: 800; font-size: 0.9rem; min-width: 100px; text-align: center; }

/* ===== MATCHES ===== */
.matches-list { display: flex; flex-direction: column; gap: 10px; }
.match-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.match-card.played { border-color: var(--green); border-width: 2px; }

.match-header {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}
.match-teams { display: flex; align-items: center; gap: 8px; }
.match-team { flex: 1; text-align: center; }
.match-team-name { font-weight: 700; font-size: 0.85rem; }
.match-team-players { font-size: 0.7rem; color: var(--text-3); margin-top: 2px; }
.match-vs {
    font-weight: 800;
    color: var(--text-3);
    font-size: 0.7rem;
    padding: 3px 6px;
    background: var(--accent-soft);
    border-radius: 4px;
}

.match-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}
/* ===== SCORE +/- CONTROLS ===== */
.score-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
}
.score-adj {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text);
    flex-shrink: 0;
    transition: background 0.1s, transform 0.1s;
    line-height: 1;
}
.score-adj:active { transform: scale(0.88); background: var(--accent-soft); }

/* ===== RESTING CARD ===== */
.rest-card {
    border-style: dashed !important;
    background: var(--accent-soft) !important;
    opacity: 0.75;
}
.sub-card {
    border-color: #f59e0b !important;
    background: rgba(245,158,11,0.07) !important;
}
.sub-rotation-text {
    text-align: center;
    padding: 6px 0 2px;
    font-size: 0.85rem;
    color: var(--text-2);
    line-height: 1.7;
}
.sub-in { font-weight: 700; color: var(--green); }
.sub-out { font-weight: 700; color: #ef4444; }
.sub-team { font-size: 0.78rem; color: var(--text-3); display: block; margin-top: 2px; }

/* ===== PLAYER EMPTY STATE ===== */
.player-empty {
    text-align: center;
    color: var(--text-3);
    font-size: 0.85rem;
    padding: 32px 0;
    border: none !important;
    background: none !important;
    list-style: none;
}

/* ===== RESUME CARD (home) ===== */
.resume-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--surface);
    border: 2px solid var(--green);
    border-radius: var(--radius);
    cursor: pointer;
    width: 100%;
    max-width: 320px;
    text-align: left;
    transition: var(--transition);
    animation: fadeIn 0.3s ease;
}
.resume-card:active { transform: scale(0.97); }
.resume-icon { font-size: 1.4rem; flex-shrink: 0; }
.resume-text { display: flex; flex-direction: column; gap: 2px; }
.resume-text strong { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.resume-text span  { font-size: 0.75rem; color: var(--text-3); }

/* ===== HOME HISTORY ===== */
.home-history {
    width: 100%;
    margin-top: 24px;
}
.home-history-title {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    margin-bottom: 10px;
    text-align: left;
    padding-left: 2px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 6px;
}
.history-item-icon { font-size: 1.2rem; flex-shrink: 0; }
.history-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.history-item-info strong { font-size: 0.82rem; font-weight: 700; color: var(--text-1); }
.history-item-info span { font-size: 0.72rem; color: var(--text-3); }
.history-item-date { font-size: 0.7rem; color: var(--text-3); flex-shrink: 0; }

.match-score input {
    width: 60px; height: 50px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.3rem;
    font-weight: 800;
    font-family: inherit;
    outline: none;
    background: var(--surface);
    transition: var(--transition);
    -webkit-appearance: none;
    -moz-appearance: textfield;
}
.match-score input::-webkit-outer-spin-button,
.match-score input::-webkit-inner-spin-button { -webkit-appearance: none; }
.match-score input:focus { border-color: var(--text); }
.match-score-sep { font-weight: 800; color: var(--text-3); font-size: 1.1rem; }

.match-points-hint {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-3);
    margin-top: 6px;
}

.btn-save-score {
    margin-top: 12px;
    width: 100%;
    padding: 12px;
    background: var(--text);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity var(--transition), transform 0.1s;
    min-height: 46px;
}
.btn-save-score:hover { opacity: 0.85; }
.btn-save-score:active { transform: scale(0.98); }

.btn-finish-tournament {
    background: var(--green) !important;
    color: #fff !important;
    font-weight: 700;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.btn-finish-tournament:active { transform: scale(0.97); }

.match-points-hint {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-3);
    margin: 4px 0 2px;
}

/* ===== STANDINGS TABLE ===== */
.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.standings-table thead th {
    padding: 10px 6px;
    text-align: left;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    border-bottom: 2px solid var(--border);
}
.standings-table thead th:first-child { padding-left: 12px; }
.standings-table thead th:not(:first-child):not(:nth-child(2)) { text-align: center; }
.standings-table tbody tr { transition: var(--transition); }
.standings-table tbody tr:hover { background: var(--accent-soft); }
.standings-table tbody td {
    padding: 10px 6px;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}
.standings-table tbody tr:last-child td { border-bottom: none; }
.standings-table tbody td:first-child { padding-left: 12px; font-weight: 800; width: 28px; }
.standings-table tbody td:not(:first-child):not(:nth-child(2)) { text-align: center; }
.standings-table tbody td:nth-child(2) { font-weight: 700; }
.standings-table tbody td:last-child { font-weight: 800; }
.standings-table tbody tr.top-1 td { background: #f0fdf4; }

/* Fewer games played highlight */
.pj-fewer { color: #e65100; font-weight: 700; background: #fff3e0; border-radius: 4px; padding: 2px 4px; }
.pj-diff { font-size: 0.7rem; color: #e65100; font-weight: 600; }

/* Compensation modal */
.comp-list { display: flex; flex-direction: column; gap: 8px; }
.comp-player {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff3e0; border: 1px solid #ffcc80; border-radius: 10px;
    padding: 10px 14px; gap: 8px;
}
.comp-name { font-weight: 700; flex: 1; }
.comp-detail { color: #e65100; font-size: 0.82rem; font-weight: 600; }
.comp-bonus { color: var(--green); font-weight: 800; font-size: 0.85rem; white-space: nowrap; }
.bonus-tag { font-size: 0.65rem; color: var(--green); font-weight: 700; background: #e8f5e9; border-radius: 4px; padding: 1px 4px; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 200;
    white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== POSITION SELECTOR ===== */
.position-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
}
.pos-btns { display: flex; gap: 6px; }
.pos-btn {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.pos-btn:hover { border-color: var(--text-3); }
.pos-btn.active { border-color: var(--text); background: white; }

.player-pos { font-size: 0.85rem; }

/* ===== LADO SELECTOR (PÁDEL) ===== */
.lado-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
}
.lado-btns { display: flex; gap: 6px; }
.lado-btn {
    padding: 7px 12px;
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: var(--surface);
    color: var(--text-2);
    transition: var(--transition);
}
.lado-btn.active {
    border-color: var(--text);
    color: var(--text);
    background: var(--accent-soft);
}
.lado-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--text-2);
}

/* ===== PRO BAR ===== */
.pro-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.pro-bar-label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.switch-btn {
    width: 44px; height: 24px;
    border-radius: 12px;
    border: none;
    background: var(--border);
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.switch-btn::after {
    content: '';
    position: absolute;
    left: 3px; top: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: white;
    transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch-btn.on { background: var(--text); }
.switch-btn.on::after { left: 23px; }

/* ===== WHATSAPP BUTTON ===== */
.btn-wa { background: #25d366 !important; }
.btn-wa:hover:not(:disabled) { background: #20b858 !important; opacity: 1 !important; }

/* ===== CELEBRATION OVERLAY ===== */
.celebration-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}
.celebration-overlay.hidden { display: none; }

#confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    top: -20px;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

.celebration-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: celebPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes celebPop {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.celebration-emoji {
    font-size: 4rem;
    margin-bottom: 8px;
    animation: bounce 1s ease infinite alternate;
}
@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}
.celebration-title {
    font-size: 1.3rem;
    font-weight: 900;
    margin-bottom: 20px;
    color: var(--text);
}
.celebration-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}
.podium-entry {
    flex: 1;
    max-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.podium-medal { font-size: 1.6rem; }
.podium-name {
    font-size: 0.75rem;
    font-weight: 700;
    word-break: break-word;
    max-width: 90px;
}
.podium-pts {
    font-size: 0.7rem;
    color: var(--text-3);
}
.podium-block {
    width: 100%;
    border-radius: 6px 6px 0 0;
    background: var(--accent-soft);
}
.podium-block.first  { height: 60px; background: #FEF9C3; }
.podium-block.second { height: 44px; background: #F1F5F9; }
.podium-block.third  { height: 32px; background: #FEF3C7; }

.celebration-btns { display: flex; gap: 10px; }
.celebration-stats { width: 100%; margin: 12px 0 4px; }
.celebration-stats-inner {
    background: var(--bg);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.stat-item {
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.5;
}
.stat-item strong { color: var(--text-1); }

/* ===== STANDINGS SHARE ===== */
.standings-share {
    padding: 16px 0 8px;
}
.standings-share .btn-wa {
    flex: none;
    width: 100%;
}

/* ===== BRACKET ===== */
.bracket {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    align-items: flex-start;
}
.bracket-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 130px;
    flex-shrink: 0;
}
.bracket-col-title {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    text-align: center;
    padding: 4px 0 6px;
}
.bracket-match {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.bracket-match.played { border-color: var(--green); }
.bracket-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    gap: 6px;
}
.bracket-team:last-child { border-bottom: none; }
.bracket-team.winner {
    font-weight: 800;
    color: var(--green);
    background: rgba(34,197,94,0.07);
}
[data-theme="dark"] .bracket-team.winner { background: rgba(34,197,94,0.12); }
.bracket-team-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bracket-score {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text-2);
    flex-shrink: 0;
}
.bracket-team.winner .bracket-score { color: var(--green); }

/* ===== PÁDEL PAREJAS ===== */
.pairs-hint {
    font-size: 0.75rem;
    color: var(--text-3);
    text-align: center;
    margin: 0 0 16px;
}
.pairs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 100px;
}
.pair-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
}
.pair-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.pair-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
}
.pair-sides { font-size: 0.7rem; color: var(--text-3); }
.pair-rename-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0 2px;
    opacity: 0.6;
}
.pair-rename-btn:active { opacity: 1; }
.pp-lado {
    font-size: 0.6rem;
    font-weight: 800;
    background: var(--accent-soft);
    border-radius: 4px;
    padding: 1px 4px;
    margin-right: 3px;
    vertical-align: middle;
}
.pair-players {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pair-player {
    flex: 1;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 10px 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-1);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    min-height: 44px;
}
.pair-player.selected {
    border-color: var(--green);
    background: rgba(34, 197, 94, 0.12);
    color: var(--green);
}
.pair-player.swap-target {
    border-color: #f59e0b;
    border-style: dashed;
}
.pair-slash {
    font-weight: 700;
    color: var(--text-3);
    font-size: 1rem;
    flex-shrink: 0;
}
.pair-odd {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-3);
    padding: 8px;
}
.pair-swap-hint {
    text-align: center;
    font-size: 0.75rem;
    color: #f59e0b;
    font-weight: 600;
    padding: 8px 0;
    animation: pulse 1s infinite alternate;
}
@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }

/* ===== MULTICOURT ===== */
.court-group {
    margin-bottom: 18px;
}
.court-group-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    padding: 0 0 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.court-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 7px;
    margin-bottom: 4px;
    letter-spacing: 0.4px;
    text-transform: none;
}
.match-card-court {
    padding-top: 6px;
}

/* ===== HISTORIAL ===== */
.history-section {
    margin-bottom: 20px;
}
.history-round-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-3);
    padding: 0 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.history-match {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.82rem;
}
.history-match.played { border-color: var(--green); }
.history-team {
    flex: 1;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-team.right { text-align: right; }
.history-score {
    font-weight: 800;
    font-size: 0.85rem;
    white-space: nowrap;
    color: var(--text-2);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}
.history-match.played .history-score { color: var(--text); }

/* ===== TEAM NAME EDIT IN TOURNAMENT ===== */
.tname-edit {
    cursor: pointer;
    border-bottom: 1px dashed var(--text-3);
}
.tname-edit:hover { color: var(--text); }

/* ===== STANDINGS SCROLL ===== */
.standings-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 320px) {
    .teams-grid { grid-template-columns: 1fr; }
    .home-options { flex-direction: column; }
}

/* ===== LIVE MATCH OVERLAY ===== */
.lm-overlay {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: flex-end;
    padding: 0;
}
.lm-overlay.hidden { display: none; }
.lm-card {
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 24px 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    animation: slideUp 0.3s cubic-bezier(0.25,0.46,0.45,0.94);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.lm-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.lm-sport-label { font-size: 0.8rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }
.lm-close { background: none; border: none; font-size: 1.4rem; color: var(--text-3); cursor: pointer; padding: 4px; }
.lm-timer-wrap { text-align: center; margin-bottom: 24px; }
.lm-timer { font-size: 3.5rem; font-weight: 900; letter-spacing: -2px; color: var(--text); font-variant-numeric: tabular-nums; }
.lm-timer-btns { display: flex; gap: 10px; margin-top: 12px; }
.lm-btn-pause {
    flex: 1; padding: 12px; border: 2px solid var(--border); background: var(--surface);
    border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 700; font-family: inherit;
    cursor: pointer; color: var(--text); transition: var(--transition);
}
.lm-btn-pause:active { background: var(--accent-soft); }
.lm-btn-finish {
    flex: 1; padding: 12px; border: none; background: var(--green);
    border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 700; font-family: inherit;
    cursor: pointer; color: white; transition: var(--transition);
}
.lm-btn-finish:active { opacity: 0.85; }
.lm-scoreboard { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.lm-team-col { flex: 1; text-align: center; }
.lm-team-name { font-size: 0.82rem; font-weight: 700; margin-bottom: 10px; }
.lm-score-ctrl { display: flex; align-items: center; justify-content: center; gap: 10px; }
.lm-score { font-size: 2.8rem; font-weight: 900; min-width: 48px; font-variant-numeric: tabular-nums; }
.lm-adj {
    width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--border);
    background: var(--surface); font-size: 1.5rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; color: var(--text);
    transition: background 0.1s, transform 0.1s;
}
.lm-adj:active { transform: scale(0.88); background: var(--accent-soft); }
.lm-sep { font-size: 2rem; font-weight: 900; color: var(--text-3); }
.lm-elapsed-label { text-align: center; font-size: 0.8rem; color: var(--green); font-weight: 600; min-height: 20px; }
.btn-live-match {
    margin-top: 8px; width: 100%; padding: 10px; background: var(--accent-soft);
    color: var(--text); border: 1px solid var(--border); border-radius: 8px;
    font-size: 0.82rem; font-weight: 600; font-family: inherit; cursor: pointer;
    transition: background var(--transition);
}
.btn-live-match:active { background: var(--border); }
