* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #0b5ed7;
    --primary-dark: #083b8a;
    --bg: #edf3fb;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --success: #16a34a;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: linear-gradient(180deg, #edf3fb, #e3ecf8);
    color: var(--text);
}

/* HEADER FIJO */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: linear-gradient(135deg, #0b5ed7, #083b8a);
    color: white;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    padding: 14px 16px;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-logo {
    max-width: 220px;
    width: 100%;
    height: auto;
    display: block;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    font-weight: 700;
    background: rgba(255,255,255,0.12);
    padding: 10px 16px;
    border-radius: 14px;
}

.top-nav {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.top-nav a,
.top-nav button {
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.16);
    padding: 10px 16px;
    border-radius: 12px;
    color: white;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.top-nav a:hover,
.top-nav button:hover {
    background: rgba(255,255,255,0.24);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}

/* CONTAINER */
.container {
    max-width: 1100px;
    margin: 170px auto 130px;
    padding: 0 16px;
}

/* TEXTOS */
.loading-text,
.error-text {
    text-align: center;
    font-weight: 700;
    padding: 22px;
    border-radius: 16px;
    margin-top: 14px;
}

.loading-text {
    color: var(--muted);
    background: rgba(255,255,255,0.65);
}

.error-text {
    color: #b91c1c;
    background: #fee2e2;
}

.section-head {
    margin-bottom: 18px;
}

.section-head p {
    color: var(--muted);
    margin-top: 8px;
    line-height: 1.5;
}

/* GRUPOS */
.grupo {
    margin-bottom: 22px;
}

.grupo h3 {
    margin: 18px 0 12px;
    padding-left: 4px;
    font-weight: 900;
    font-size: 20px;
    color: var(--primary-dark);
    text-transform: capitalize;
}

/* CARD */
.match-card {
    background: var(--card);
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 16px;
    box-shadow: 0 8px 18px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(0,0,0,0.10);
}

/* LINEA PARTIDO */
.match-line {
    display: grid;
    grid-template-columns: 1fr 140px 1fr;
    align-items: center;
    gap: 10px;
    text-align: center;
    margin-bottom: 10px;
}

.team-left,
.team-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.team-left {
    justify-content: flex-end;
}

.team-right {
    justify-content: flex-start;
}

.team-left span,
.team-right span {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.2;
}

.bandera-img {
    width: 28px;
    height: 20px;
    object-fit: cover;
    border-radius: 4px;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
}

.bandera-code {
    min-width: 28px;
    height: 20px;
    padding: 0 6px;
    background: #e2e8f0;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* HORA */
.match-center .hora {
    display: inline-block;
    min-width: auto;
    padding: 0;
    font-size: 22px;
    font-weight: 900;
    border-radius: 0;
    color: #0f172a;
    background: transparent;
    box-shadow: none;
    line-height: 1.2;
}

/* INFO */
.match-info {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    margin: 12px 0 16px;
    line-height: 1.5;
}

/* BOTONERA */
.opciones {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.opt {
    padding: 16px 14px;
    border-radius: 14px;
    background: #eef2f7;
    text-align: center;
    font-weight: 800;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.opt input {
    display: none;
}

.opt:hover {
    transform: scale(1.02);
    border-color: rgba(11, 94, 215, 0.18);
}

.opt:has(input:checked) {
    background: #dbeafe;
    border: 2px solid var(--primary);
    color: var(--primary-dark);
}

.opt:has(input:disabled) {
    opacity: 0.75;
    cursor: not-allowed;
}

/* ESTADOS */
.guardado-chip {
    margin-top: 12px;
    background: #dcfce7;
    color: #166534;
    padding: 10px 12px;
    border-radius: 12px;
    text-align: center;
    font-weight: 800;
}

.resultado-final {
    margin-top: 12px;
    text-align: center;
    font-weight: 900;
    font-size: 22px;
    color: var(--primary-dark);
}

.cerrado {
    margin-top: 10px;
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 12px;
    text-align: center;
    font-weight: 800;
}

/* SAVE BAR */
.save-bar {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 12px;
    text-align: center;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    z-index: 50;
}

#btn-guardar {
    padding: 14px 30px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-weight: 900;
    cursor: pointer;
}

#btn-guardar:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: white;
    width: 100%;
    max-width: 460px;
    padding: 30px 24px;
    border-radius: 22px;
    text-align: center;
    animation: modalPop 0.3s ease;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

@keyframes modalPop {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-check {
    width: 76px;
    height: 76px;
    margin: 0 auto 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 900;
    color: #166534;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    animation: popCheck 0.45s ease;
}

@keyframes popCheck {
    0% { transform: scale(0.5) rotate(-12deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(3deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); }
}

.modal-box h3 {
    margin-bottom: 10px;
    font-size: 28px;
    font-weight: 900;
}

.modal-box p {
    color: #475569;
    font-size: 16px;
    line-height: 1.5;
}

.modal-actions {
    margin-top: 20px;
}

.modal-btn {
    margin-top: 10px;
    padding: 12px 22px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: white;
    font-weight: 900;
    cursor: pointer;
}

/* LOGIN */
.login-container {
    max-width: 420px;
    margin: 60px auto;
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    text-align: center;
}

.login-logo {
    width: 260px;
    margin-bottom: 20px;
}

.login-title {
    font-size: 26px;
    font-weight: 900;
    color: #0b5ed7;
    margin-bottom: 10px;
}

.login-sub {
    color: #64748b;
    margin-bottom: 25px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-form input {
    padding: 12px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    outline: none;
    font-size: 14px;
}

.login-form input:focus {
    border-color: #0b5ed7;
    box-shadow: 0 0 0 4px rgba(11, 94, 215, 0.10);
}

.login-btn {
    margin-top: 10px;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #0b5ed7, #083b8a);
    color: white;
    font-weight: 900;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(11, 94, 215, 0.18);
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.4);
    border-top: 3px solid white;
    border-radius: 50%;
    display: none;
    margin: auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.login-btn.loading .btn-text {
    display: none;
}

.login-btn.loading .btn-loader {
    display: block;
}

.login-btn.loading {
    cursor: not-allowed;
    opacity: 0.85;
}

.login-footer {
    margin-top: 18px;
    font-size: 14px;
}

.login-footer a {
    color: #0b5ed7;
    font-weight: bold;
    text-decoration: none;
}

/* ADMIN */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.admin-span-2 {
    grid-column: span 2;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    font-weight: 700;
    display: block;
    margin-bottom: 6px;
}

.input-group input,
.input-select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid #dbe4f0;
    background: #fff;
    outline: none;
}

.btn-save {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-weight: 900;
    cursor: pointer;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.admin-console {
    background: #0f172a;
    color: #22c55e;
    padding: 14px;
    border-radius: 12px;
    font-size: 12px;
    max-height: 300px;
    overflow: auto;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .main-header {
        padding: 12px 14px;
    }

    .header-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .header-left {
        justify-content: center;
    }

    .header-logo {
        max-width: 180px;
    }

    .header-right {
        align-items: center;
        width: 100%;
    }

    .user-info {
        justify-content: center;
        width: 100%;
    }

    .top-nav {
        justify-content: center;
        width: 100%;
    }

    .container {
        margin-top: 220px;
    }

    .match-line {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .team-left,
    .team-right {
        justify-content: center;
    }

    .opciones {
        grid-template-columns: 1fr;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-span-2 {
        grid-column: span 1;
    }

    .form-grid,
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
}