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

:root {
    --green-dark: #14532d;
    --green: #15803d;
    --green-light: #16a34a;
    --bg: #f1f5f3;
    --card: #ffffff;
    --text: #1c2b23;
    --muted: #6b7c72;
    --border: #e2e8e4;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .06);
}

body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.header {
    background: #111;
    color: #fff;
    padding: 2px 0;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header-inner h1 {
    justify-self: start;
    min-width: 0;
}

.header-inner .logo {
    grid-column: 2;
    justify-self: center;
}

.header-inner .btn {
    justify-self: end;
}

.header h1 {
    font-size: 1.5rem;
    letter-spacing: .3px;
}

.header-index {
    margin-bottom: 0;
}

/* Título debajo de la barra */
.page-title {
    text-align: center;
    padding: 14px 0 6px;
    margin-bottom: 20px;
}

.cartel {
    position: relative;
    display: inline-block;
    padding: 10px 34px 14px;
    border-radius: 8px;
    background: #0b0f14;
    border: 1px solid #2a333d;
    box-shadow:
        0 6px 18px rgba(0, 0, 0, .45),
        inset 0 2px 10px rgba(0, 0, 0, .7),
        inset 0 0 0 1px #3a4652;
    overflow: hidden;
}

.cartel-bg {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -90px;
    width: 70px;
    z-index: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .10), transparent);
    animation: cartel-move 3s linear infinite;
}

@keyframes cartel-move {
    from { left: -90px; }
    to { left: 110%; }
}

.cartel h1 {
    position: relative;
    z-index: 1;
    font-family: "Bitcount Single Ink", "Courier New", monospace;
    font-size: 2.4rem;
    line-height: 1.2;
    font-weight: 400;
    color: #ffffff;
    text-shadow: none;
    animation: cartel-flicker 5s linear infinite;
}

@keyframes cartel-flicker {
    0%, 100% { opacity: 1; }
    3% { opacity: .85; }
    6% { opacity: 1; }
    7% { opacity: .9; }
    8% { opacity: 1; }
    43% { opacity: 1; }
    44% { opacity: .82; }
    45% { opacity: 1; }
}

.cartel::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, .15) 0 1px,
        transparent 1px 3px
    );
}

.brand-title {
    font-size: 1.5rem;
    letter-spacing: .3px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.logo {
    width: 84px;
    height: 70px;
    object-fit: contain;
    flex-shrink: 0;
}

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

/* Cards */
.card {
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 24px;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    color: var(--green-dark);
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

@media (min-width: 720px) {
    .grid {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

/* Tabla de posiciones */
.table-wrap {
    overflow-x: auto;
}

table.standings {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

table.standings th,
table.standings td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

table.standings th {
    color: var(--muted);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    background: #fafcfa;
}

table.standings tbody tr:hover {
    background: #f7faf8;
}

table.standings td.team {
    text-align: left;
    font-weight: 600;
}

#tab-goleadores table.standings td.team {
    text-align: center;
    justify-content: center;
}

table.standings td.pos {
    font-weight: 700;
    color: #000;
}

table.standings td.pts {
    font-size: 1.05rem;
}

.chip {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    vertical-align: -2px;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, .15);
}

/* Partidos */
.matches {
    list-style: none;
}

.match {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

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

.match.pending {
    background: #fbfbf7;
    border-radius: 8px;
    margin: 4px 0;
    border: 1px dashed var(--border);
}

.team-name {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-name .chip {
    flex-shrink: 0;
}

.team-name.right {
    justify-content: flex-end;
    text-align: right;
}

.score {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    min-width: 70px;
    justify-content: center;
}

.score .dash {
    color: var(--muted);
}

.pending-label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--warning);
    font-weight: 700;
}

.match.final {
    background: linear-gradient(135deg, #fdf6d8, #f8ecc0);
    border: 1px solid #e6c95e;
    border-radius: 10px;
    margin: 6px 0;
    padding: 12px 10px;
}

.final-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .8px;
    background: #d4af37;
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
}

.final-icon {
    width: 16px;
    height: 16px;
}

.fecha-block {
    margin-bottom: 18px;
}

.fecha-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--heading);
    margin: 14px 0 6px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green);
}

.next-badge {
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #b7dfbd;
    padding: 2px 8px;
    border-radius: 999px;
}

.match-scorers {
    flex-basis: 100%;
    font-size: .82rem;
    color: var(--muted);
    padding-left: 22px;
    margin-top: 2px;
}

.fecha-chip {
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: #eef1f5;
    color: #44546a;
    border: 1px solid #d4dae3;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.fecha-add {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    font-weight: 600;
    margin: 6px 0;
}

.fecha-add input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.row-final td {
    background: #d4af37;
}

.row-final td.pos {
    background: #d4af37;
    color: #000;
}

.row-bottom td {
    background: rgba(220, 60, 60, .08);
}

.row-bottom td.pos {
    background: #dc3c3c;
    color: #000;
}

.checkbox-final {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 4px;
    cursor: pointer;
    font-size: .9rem;
}

.checkbox-final input {
    width: 18px;
    height: 18px;
    accent-color: #d4af37;
}

.vs {
    font-weight: 700;
    color: var(--muted);
}

/* Campeón y goleador */
.champions-banner {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.champ-card {
    flex: 1;
    min-width: 240px;
    background: linear-gradient(135deg, #fdf6d8, #f5e6a8);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(201, 160, 24, .25);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid #e6c95e;
    border-top: 4px solid #d4af37;
}

.champ-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.champ-label {
    display: block;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #8a6d1f;
    font-weight: 700;
}

.champ-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: #6b4f0a;
}

/* Card del campeón: brillo dorado y copa con rebote */
.champ-gold {
    position: relative;
    overflow: hidden;
    animation: champ-glow 2.5s ease-in-out infinite;
}

.champ-gold::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 50%;
    background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .75), rgba(255, 255, 255, 0));
    transform: translateX(-150%) skewX(-15deg);
    animation: champ-shimmer 3s ease-in-out .6s infinite;
    pointer-events: none;
}

.champ-gold .champ-icon {
    filter: drop-shadow(0 0 7px rgba(212, 175, 55, .75));
    animation: champ-bounce 2.2s ease-in-out infinite;
}

@keyframes champ-glow {
    0%, 100% {
        box-shadow: 0 4px 14px rgba(201, 160, 24, .25);
    }
    50% {
        box-shadow: 0 4px 24px rgba(212, 175, 55, .6);
    }
}

@keyframes champ-shimmer {
    0% {
        transform: translateX(-150%) skewX(-15deg);
    }
    100% {
        transform: translateX(320%) skewX(-15deg);
    }
}

@keyframes champ-bounce {
    0%, 100% {
        transform: translateY(0) rotate(0);
    }
    30% {
        transform: translateY(-6px) rotate(-5deg);
    }
    60% {
        transform: translateY(0) rotate(4deg);
    }
}

.badge {
    margin-left: 6px;
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

.label-icon {
    width: 18px;
    height: 18px;
    vertical-align: -3px;
    margin-right: 4px;
}

/* Pestañas */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.tab {
    font-family: inherit;
    padding: 10px 20px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: .95rem;
    color: var(--muted);
    transition: background .15s, color .15s;
}

.tab:hover {
    background: #eef4f0;
}

.tab.active {
    background: #111;
    color: #fff;
    border-color: #111;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Formularios */
.form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
    margin-top: 4px;
}

.form input,
.form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
}

.form input:focus,
.form select:focus {
    outline: 2px solid var(--green-light);
    outline-offset: 1px;
    border-color: var(--green-light);
}

.form input[type="color"] {
    height: 44px;
    padding: 4px;
    cursor: pointer;
}

.form-match .match-fields {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.form-match select {
    flex: 1;
    min-width: 130px;
}

.input-goal {
    width: 70px !important;
    text-align: center;
}

.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: filter .15s, transform .05s;
}

.btn:hover {
    filter: brightness(1.06);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: #111;
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, .6);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger-outline {
    background: transparent;
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, .6);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-small {
    padding: 5px 10px;
    font-size: .8rem;
}

/* Lista de equipos en admin */
.team-list {
    list-style: none;
}

.team-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.team-list li:last-child {
    border-bottom: none;
}

.team-list form {
    margin-left: auto;
}

.inline-form {
    display: inline;
}

/* Lista de partidos en admin */
.admin-matches {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-match-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}

.match-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.admin-match-item .score {
    flex: 0 0 auto;
}

.match-edit-form {
    width: 100%;
}

.match-toggle {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: .7rem;
    line-height: 1;
    transition: transform .2s, background .15s;
}

.match-toggle:hover {
    background: #eef4f0;
}

.admin-match-item.open .match-toggle {
    transform: rotate(180deg);
}

.admin-match-item .scorers,
.admin-match-item .match-actions {
    display: none;
}

.admin-match-item.open .scorers {
    display: grid;
}

.admin-match-item.open .match-actions {
    display: flex;
}

.scorers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.scorers input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .85rem;
    font-family: inherit;
    background: #fff;
}

.scorers input:focus {
    outline: 2px solid var(--green-light);
    outline-offset: 1px;
    border-color: var(--green-light);
}

@media (max-width: 600px) {
    .scorers {
        grid-template-columns: 1fr;
    }
}

.match-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* Alertas */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert-error {
    background: #fdecea;
    color: #b91c1c;
    border: 1px solid #f5c2c0;
}

.alert-success {
    background: #e7f6ec;
    color: #14532d;
    border: 1px solid #b7e3c6;
}

.muted {
    color: var(--muted);
    font-size: .9rem;
}

.small {
    font-size: .8rem;
}

.login-card {
    max-width: 420px;
    margin: 40px auto;
}

.login-card h2 {
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state h2 {
    margin-bottom: 8px;
}

.footer {
    text-align: center;
    color: var(--muted);
    padding: 20px 0 30px;
    font-size: .9rem;
    margin-top: auto;
}

.footer a {
    color: var(--green);
}

.footer-logo {
    display: block;
    max-width: 130px;
    margin: 12px auto 0;
    opacity: .85;
}

/* ===== Responsive / móvil ===== */
button,
a {
    touch-action: manipulation;
}

@media (max-width: 600px) {
    .container {
        padding: 0 12px;
    }

    .header {
        margin-bottom: 16px;
    }

    /* Header público: todo en una fila (logo centrado, título y botón a los costados) */
    .header-inner {
        grid-template-columns: 1fr auto 1fr;
        gap: 8px;
        padding: 4px 0;
    }

    .header-inner .logo {
        grid-column: 2;
        justify-self: center;
        width: 48px;
        height: 40px;
        margin-bottom: 0;
    }

    .header-inner h1 {
        grid-column: auto;
        grid-row: auto;
        justify-self: start;
        font-size: .95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-inner .btn {
        grid-column: auto;
        grid-row: auto;
        justify-self: end;
        padding: 7px 10px;
        font-size: .78rem;
        white-space: nowrap;
    }

    /* Header admin: apilado y centrado */
    .header-flex {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 8px 0;
    }

    .header-flex .brand {
        justify-content: center;
    }

    .brand .logo {
        width: 48px;
        height: 40px;
        margin-bottom: 0;
    }

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

    .header-actions .btn {
        padding: 8px 12px;
        font-size: .85rem;
    }

    .header h1,
    .brand-title {
        font-size: 1.15rem;
    }

    .page-title {
        padding: 10px 0 4px;
        margin-bottom: 14px;
    }

    .cartel {
        padding: 8px 18px 10px;
    }

    .cartel h1 {
        font-size: 2.4rem;
        color: #ffffff;
        text-shadow: none;
        font-weight: 400;
    }

    .card {
        padding: 16px;
        margin-bottom: 16px;
    }

    .tabs {
        gap: 6px;
    }

    .tab {
        flex: 1;
        padding: 10px 8px;
        font-size: .9rem;
    }

    .champions-banner {
        gap: 12px;
    }

    .champ-card {
        min-width: 100%;
        padding: 14px;
    }

    .champ-icon {
        width: 44px;
        height: 44px;
    }

    .champ-name {
        font-size: 1.1rem;
    }

    .match {
        gap: 8px;
        padding: 10px 4px;
    }

    .match.final {
        padding: 10px;
    }

    .team-name {
        font-size: .9rem;
    }

    .score {
        min-width: 60px;
    }

    .final-badge {
        width: 100%;
        justify-content: center;
    }

    /* Partido admin: apilado en columnas */
    .admin-match-item {
        padding: 10px;
    }

    .match-main {
        justify-content: center;
        gap: 8px;
    }

    .match-main .team-name {
        flex: 1 1 45%;
    }

    .match-main .score {
        order: 3;
        flex: 1 1 100%;
        min-width: 0;
    }

    .match-main .btn-primary {
        order: 4;
        flex: 1 1 100%;
    }

    .match-main .match-toggle {
        order: 5;
        width: 36px;
        height: 36px;
    }

    .match-actions {
        margin-left: 0;
        width: 100%;
        justify-content: stretch;
    }

    .match-actions .inline-form {
        flex: 1;
        display: block;
    }

    .match-actions .inline-form .btn {
        width: 100%;
    }

    /* Tabla de posiciones: más compacta, mantiene scroll horizontal */
    table.standings {
        font-size: .82rem;
    }

    table.standings th,
    table.standings td {
        padding: 8px 5px;
    }

    table.standings th {
        font-size: .68rem;
    }

    table.standings td.pts {
        font-size: .95rem;
    }

    .form-match .match-fields {
        gap: 6px;
    }

    .form-match select {
        min-width: 110px;
    }

    .input-goal {
        width: 56px !important;
    }

    .scorers input {
        font-size: .95rem;
    }

    .login-card {
        margin: 24px auto;
    }

    .timer-display {
        font-size: 4.5rem;
    }

    .timer-controls .btn {
        min-width: 0;
        flex: 1;
    }
}

/* Cronómetro de partido */
.timer-card {
    text-align: center;
    margin-bottom: 24px;
}

.timer-label {
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
}

.timer-display {
    font-family: 'Bitcount Single Ink', 'Inter', sans-serif;
    font-size: 4.5rem;
    font-weight: 400;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
    color: var(--heading);
    margin: 6px 0 12px;
}

.timer-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.timer-controls .btn {
    min-width: 110px;
}

.timer-card.timer-end .timer-display {
    color: #dc3c3c;
    animation: timer-flash 1s ease-in-out infinite;
}

.timer-card.timer-ten .timer-display {
    color: #dc3c3c;
}

@keyframes timer-flash {
    50% {
        opacity: .3;
    }
}

/* Confeti del campeón */
.confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
}
