/* ===================================================
   ELO CALCULATOR – v2.3.9 STABLE (Compact Fields All Devices)
=================================================== */
.internal-header {
    margin-bottom: 30px;
}

.internal-title-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.internal-subtitle {
    max-width: 640px;
    margin: 12px auto 0 auto;
    text-align: center;
    color: #6b7280;
    line-height: 1.6;
    font-size: 16px;
}

.seo-title {
    font-size: 18px;
    font-weight: 600;
    color: #e5e7eb; /* molto meglio del bianco */
    margin-top: 24px;
    margin-bottom: 6px;
}

.inline-link {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
}

.inline-link:hover {
    text-decoration: underline;
}

.elo-seo {
    margin-top: 60px;
    margin-left: auto;
    margin-right: auto;
    max-width: 680px;
    padding: 24px 28px;
    border-radius: 16px;

    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.05);

    font-size: 15px;
    line-height: 1.7;
    color: #374151;
}

.elo-seo p {
    margin-bottom: 14px;
}

.elo-seo .seo-title {
    color: #111827;
    font-size: 20px;
    margin-top: 20px;
}

#eloForm {
    max-width: 680px;
    margin: auto;
}

/* 🔥 Compatti su tutti i dispositivi */
#playerRating {
    max-width: 140px;
}

#kFactor {
    max-width: 260px;
    cursor: pointer;
}

#eloForm label,
#uscfForm label {
    margin-top: 10px;
    margin-bottom: 6px;
}

/* ================= BUTTONS ================= */

#eloForm button {
    font-size: 14px;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
    border: none;
}

#addOpponentBtn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

#eloForm button[type="submit"],
#uscfForm button[type="submit"] {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

#clearBtn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

#eloForm button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

/* ================= ROW GRID ================= */

.row-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px;
    gap: 12px;
    align-items: start;
    margin-bottom: 14px;
}

.field-group {
    display: flex;
    flex-direction: column;
}

.row-grid input,
.row-grid select {
    width: 100%;
    min-width: 0;
}

/*.removeBtn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 36px; /* Fix Android prima era 36
}*/

.removeBtn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    padding: 0;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    align-self: center;
    margin-top: 14px; /* compensa altezza label per allineare al centro dell'input */
}
/* ================= RESULTS CARD ================= */

/*.result-box {
    display: none;
    background: linear-gradient(90deg, #fff9db, #fff3b0);
    border: 1px solid #facc15;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.15);
    padding: 28px 24px;
    border-radius: 18px;
    margin-top: 30px;
    color: #111827;
}*/

.result-box {
    display: none;
    background: linear-gradient(90deg, #fff9db, #fff3b0);
    border: 1px solid #facc15;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.15);
    padding: 26px 22px;
    border-radius: 18px;
    margin-top: 30px;
    width: 100%;
    color: #111827;
}

.result-box table {
    width: 100%;
    border-collapse: collapse;
}

.result-box th,
.result-box td {
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
}

.result-box th {
    background: #f3f4f6;
    font-weight: 600;
}

.result-box th:nth-child(1),
.result-box td:nth-child(1) {
    text-align: center;
}

.result-box th:nth-child(n + 2),
.result-box td:nth-child(n + 2) {
    text-align: right;
}

/* ===== BADGES ===== */

.badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    display: inline-block;
    min-width: 60px;
    text-align: center;
}

.badge.win {
    background: #dcfce7;
    color: #047857;
}
.badge.loss {
    background: #fee2e2;
    color: #b91c1c;
}
.badge.draw {
    background: #f3f4f6;
    color: #374151;
}

.positive {
    color: #047857;
    font-weight: 600;
}
.negative {
    color: #b91c1c;
    font-weight: 600;
}

/* ================= SUMMARY ================= */

.elo-summary {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 2px solid #e5e7eb;
    display: grid;
    row-gap: 14px;
    font-size: 16px;
}

.elo-summary div {
    display: flex;
    justify-content: space-between;
}

@media (max-width: 480px) {
    .elo-summary div {
        align-items: flex-start;
    }

    .elo-summary span {
        max-width: 65%;
        line-height: 1.3;
    }

    .elo-summary strong {
        text-align: right;
        min-width: 70px;
    }
}

/* ===================================================
   MOBILE STACK (Pixel Perfect preserved)
=================================================== */

@media (max-width: 480px) {
    .result-box table,
    .result-box thead,
    .result-box tbody,
    .result-box th,
    .result-box td,
    .result-box tr {
        display: block;
        width: 100%;
    }

    .result-box thead {
        display: none;
    }

    .result-box tr {
        background: white;
        margin-bottom: 14px;
        padding: 14px;
        border-radius: 12px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    }

    .result-box td {
        border: none;
        padding: 6px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 14px;
    }

    .result-box td::before {
        font-weight: 600;
        color: #374151;
        margin-right: 8px;
    }

    .result-box td:nth-child(1)::before {
        content: "Game";
    }
    .result-box td:nth-child(2)::before {
        content: "Opponent";
    }
    .result-box td:nth-child(3)::before {
        content: "Result";
    }
    .result-box td:nth-child(4)::before {
        content: "Change";
    }

    .result-box td .badge {
        flex-shrink: 0;
        padding: 4px 6px;
        min-width: 44px;
        margin-right: -8px;
    }
}

#exportPdfBtn {
    margin: 30px auto 0;
    display: none;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
}
.pdf-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.pdf-modal {
    background: #fff;
    padding: 30px;
    border-radius: 18px;
    width: 100%;
    max-width: 420px;
}

@media (max-width: 480px) {
    .elo-summary {
        font-size: 14px;
        row-gap: 10px;
    }

    .elo-summary div {
        display: flex;
        justify-content: space-between;
        gap: 10px;
    }

    .elo-summary span {
        max-width: 60%;
    }
}

.after-result {
    display: none;
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
    color: #6b7280;
}

.result-box .gold {
    color: #b89600 !important;
    font-weight: 700;
    background: rgba(212, 175, 55, 0.2);
    padding: 2px 6px;
    border-radius: 6px;
}

.magnus-input {
    border: 2px solid #eab308 !important;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.8);
    background: linear-gradient(
        135deg,
        rgba(250, 204, 21, 0.15),
        rgba(255, 255, 255, 0)
    );
}

.seo-jump-wrapper {
    display: flex;
    justify-content: right;
    gap: 18px;
    margin-top: 18px;
    /* 🔥 QUESTO È IL FIX */
    margin-bottom: 28px;
}

.seo-jump {
    font-size: 14px;
    color: #6b7280;
    text-decoration: none;
    white-space: nowrap;
    display: inline-block;
}

.seo-jump:hover {
    text-decoration: underline;
}

/* MOBILE FIX */
@media (max-width: 480px) {
    .seo-jump-wrapper {
        flex-direction: column;
        align-items: right;
        gap: 6px;
    }

    .seo-jump {
        font-size: 13px;
    }
}

#gamesPlayed {
    width: 140px;
}

.seo-links {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* allinea a destra */
    gap: 6px;
}

/* Mobile */
@media (max-width: 768px) {
    .seo-links {
        align-items: flex-end;
        text-align: right;
        padding: 0 16px;
        margin-top: 20px;
    }
}
.k-help {
    margin-left: 6px;
    font-size: 12px;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.k-help:hover {
    text-decoration: underline;
}
.seo-intro {
    margin-top: 8px;
    font-size: 13px;
    color: #7c8796;
    line-height: 1.4;
    text-align: center;
}
.elo-note {
    margin: 4px 0; /* ↓ riduce spazio tra le righe */
    font-size: 12.5px;
    color: #6b7280;
    line-height: 1.35; /* leggermente più compatto */
}

/* ===================================================
   DARK MODE
=================================================== */

[data-theme="dark"] .result-box {
    background: linear-gradient(90deg, #1e2a44, #1e293b);
    border-color: #3b5299;
    color: var(--primary);
}

[data-theme="dark"] .result-box th {
    background: #334155;
    color: var(--primary);
}

[data-theme="dark"] .result-box td {
    border-bottom-color: #334155;
}

[data-theme="dark"] .result-box .gold {
    color: #facc15 !important;
    background: rgba(250, 204, 21, 0.15);
}

/* Mobile card mode in dark */
@media (max-width: 480px) {
    [data-theme="dark"] .result-box tr {
        background: #1e293b !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    }

    [data-theme="dark"] .result-box td::before {
        color: var(--text-label);
    }
}

[data-theme="dark"] .elo-summary {
    border-top-color: #334155;
}

[data-theme="dark"] .elo-seo {
    background: rgba(255, 255, 255, 0.03);
    border-color: #334155;
    color: var(--text-secondary);
}

[data-theme="dark"] .elo-seo .seo-title {
    color: var(--primary);
}

[data-theme="dark"] .internal-subtitle {
    color: var(--text-secondary);
}

[data-theme="dark"] .elo-note {
    color: var(--text-secondary);
}

[data-theme="dark"] .seo-intro {
    color: var(--text-secondary);
}

[data-theme="dark"] .pdf-modal {
    background: var(--card-bg);
    color: var(--primary);
}

[data-theme="dark"] .after-result a {
    color: var(--link-color);
}

[data-theme="dark"] .seo-jump {
    color: var(--text-secondary);
}

[data-theme="dark"] .k-help {
    color: var(--link-color);
}
