@import url('https://fonts.googleapis.com/css2?family=Lora:wght@600;700&display=swap');

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #faf4ea;
    min-height: 100vh;
    padding: 20px;
    color: #2d2016;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-family: 'Lora', Georgia, serif;
    font-size: 2.5rem;
    color: #c96a2a;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: #7a6651;
    opacity: 0.9;
}

.nav-link {
    color: #c96a2a;
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-link:hover {
    color: #9b5418;
    text-decoration: underline;
}

section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(120, 60, 10, 0.08);
    border: 1px solid #f0e6d8;
}

h2 {
    font-family: 'Lora', Georgia, serif;
    margin-bottom: 20px;
    color: #c96a2a;
    font-size: 1.5rem;
}

/* ── Stats Section ────────────────────────────────────────────── */
.stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.player-stats {
    background: linear-gradient(135deg, #fdf8f2 0%, #f0dfd0 100%);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e8d8c4;
}

.player-heading {
    margin-bottom: 15px;
    color: #c96a2a;
    font-family: 'Lora', Georgia, serif;
    font-size: 1.3rem;
    min-height: 1.6rem;
}

.player-heading.loading {
    color: #bbb;
    font-style: italic;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(120, 60, 10, 0.1);
    color: #4a3324;
}

.stat-row.total {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid #c96a2a;
    border-bottom: none;
    font-weight: bold;
}

.stat-value {
    font-weight: bold;
    color: #9b5418;
}

/* ── Form Section ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #4a3324;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e8d8c4;
    border-radius: 8px;
    /* 16px prevents iOS Safari from zooming on focus */
    font-size: 16px;
    transition: border-color 0.3s;
    background: white;
    color: #2d2016;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #c96a2a;
}

.player-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #c96a2a 0%, #e8a042 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 106, 42, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ── Filter Buttons ───────────────────────────────────────────── */
.filter-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: 2px solid #c96a2a;
    background: white;
    color: #c96a2a;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    min-height: 44px;
}

.filter-btn:hover {
    background: #fdf0e4;
}

.filter-btn.active {
    background: #c96a2a;
    color: white;
}

/* ── Game History ─────────────────────────────────────────────── */
.game-history {
    display: grid;
    gap: 15px;
    min-height: 40px;
}

.game-history.loading::after {
    content: "Loading…";
    display: block;
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

.game-card {
    background: linear-gradient(135deg, #fdf8f2 0%, #f0dfd0 100%);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #c96a2a;
    border: 1px solid #e8d8c4;
    border-left: 4px solid #c96a2a;
}

.game-card.scrabble {
    border-left-color: #e8a042;
}

.game-card.gin-rummy {
    border-left-color: #5ba89a;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 4px;
}

.game-type {
    font-weight: bold;
    color: #c96a2a;
    font-size: 1.1rem;
}

.game-date {
    font-size: 0.9rem;
    color: #7a6651;
}

.game-scores {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 15px;
    align-items: center;
    margin-bottom: 12px;
}

.player-info {
    text-align: center;
}

.player-name {
    font-weight: bold;
    margin-bottom: 5px;
    color: #4a3324;
}

.player-score {
    font-size: 1.8rem;
    font-weight: 700;
    color: #9b5418;
    font-family: 'Lora', Georgia, serif;
}

.player-info.winner .player-name::after {
    content: " 🏆";
}

.vs {
    font-weight: bold;
    color: #b8a090;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.05em;
}

/* ── Card actions (delete / confirm) ─────────────────────────── */
.card-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.delete-btn {
    padding: 8px 16px;
    background: transparent;
    color: #b04040;
    border: 1.5px solid #e0a0a0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, border-color 0.2s;
    min-height: 44px;
    min-width: 44px;
}

.delete-btn:hover {
    background: #fff0f0;
    border-color: #c05050;
}

.confirm-label {
    font-size: 0.9rem;
    color: #4a3324;
    font-weight: 600;
}

.confirm-yes,
.confirm-no {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 44px;
}

.confirm-yes {
    background: #c05050;
    color: white;
}

.confirm-yes:hover {
    background: #a03030;
}

.confirm-no {
    background: #f0e6d8;
    color: #4a3324;
}

.confirm-no:hover {
    background: #e0d0c0;
}

/* ── Photo ────────────────────────────────────────────────────── */
.photo-file-input {
    display: none;
}

.photo-thumb {
    display: block;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 10px;
    cursor: pointer;
}

.photo-btn {
    padding: 8px 14px;
    background: transparent;
    color: #7a6651;
    border: 1.5px solid #e8d8c4;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
    min-height: 44px;
}

.photo-btn:hover {
    background: #fdf0e4;
}

/* ── Toast Notification ───────────────────────────────────────── */
#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #3d2b1a;
    color: white;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1000;
    min-width: 220px;
    max-width: 90vw;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

#toast.success {
    background: #4a7a40;
}

#toast.error {
    background: #8b2020;
}

/* ── Login Overlay ────────────────────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #c96a2a 0%, #e8a042 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.login-overlay.hidden {
    display: none;
}

.login-box {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(80, 30, 0, 0.25);
}

.login-box h1 {
    font-family: 'Lora', Georgia, serif;
    text-align: center;
    color: #c96a2a;
    font-size: 1.8rem;
    margin-bottom: 30px;
}

.login-error {
    color: #8b2020;
    font-size: 0.9rem;
    margin-bottom: 10px;
    min-height: 1.2em;
    text-align: center;
}

/* ── Mobile Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .player-inputs {
        grid-template-columns: 1fr;
    }

    section {
        padding: 20px;
    }

    .game-scores {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .player-info {
        flex: 1;
    }

    .vs {
        flex: 0 0 auto;
        font-size: 0.9rem;
    }

    .player-score {
        font-size: 1.4rem;
    }

    .card-actions {
        flex-wrap: wrap;
    }

    .delete-btn {
        width: 100%;
        margin-top: 6px;
        font-size: 1rem;
    }

    .confirm-yes,
    .confirm-no {
        flex: 1;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    section {
        padding: 15px;
    }

    h2 {
        font-size: 1.3rem;
    }
}

/* ── Summary section ─────────────────────────────────────────────── */
.summary-section {
    background: white;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(120, 60, 10, 0.08);
    border: 1px solid #f0e6d8;
}

.streak-banner {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1rem;
    color: #4a3324;
}
.streak-banner.streak-liz  { color: #c0405a; }
.streak-banner.streak-sean { color: #3a6a9a; }

.h2h-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.h2h-table th,
.h2h-table td {
    padding: 0.4rem 0.75rem;
    text-align: center;
    color: #4a3324;
}
.h2h-table th:first-child,
.h2h-table td:first-child {
    text-align: left;
    color: #7a6651;
}
.h2h-table thead th      { font-weight: 700; border-bottom: 2px solid #e8d8c4; color: #c96a2a; }
.h2h-table .h2h-total td { font-weight: 700; border-top: 2px solid #e8d8c4; }
