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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #eef1f7;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem 2rem;
}

/* Top bar */
.top-bar {
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    font-size: 0.9rem;
}
.back-link {
    color: #555;
    text-decoration: none;
}
.back-link:hover { color: #3b82f6; }
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.user-name {
    font-weight: 600;
    color: #475569;
}
.logout-link {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
}
.logout-link:hover { color: #ef4444; }

/* Legacy back (auth pages) */
.back {
    align-self: flex-start;
    padding: 1rem 0;
    font-size: 0.9rem;
}
.back a {
    color: #555;
    text-decoration: none;
}
.back a:hover { color: #3b82f6; }

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 480px;
}
.hidden { display: none !important; }

/* Start screen */
#screen-start h1 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: #1e293b;
    text-align: center;
}
.intro {
    color: #64748b;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    text-align: center;
    line-height: 1.5;
}

/* Stats summary on start screen */
.stats-summary {
    background: #fff;
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    color: #475569;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    text-align: center;
}

/* Mode selection buttons */
.mode-buttons {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 320px;
}
.btn-mode {
    flex: 1;
    padding: 0.85rem 1rem;
    font-size: 1rem;
}

.start-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 10px;
    padding: 0.75rem 2rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: #3b82f6;
    color: #fff;
}
.btn-primary:hover { background: #2563eb; }

.btn-secondary {
    background: #e2e8f0;
    color: #334155;
}
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm {
    font-size: 0.85rem;
    padding: 0.5rem 1.25rem;
}

.btn-full {
    width: 100%;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #dde3ed;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.progress-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.status-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 1.25rem;
    font-weight: 500;
}

/* Game card */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
}

.flag {
    font-size: 5rem;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.country {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.question {
    color: #64748b;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

#answer-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.input {
    flex: 1;
    border: 2px solid #dde3ed;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font-size: 1.05rem;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}
.input:focus {
    border-color: #3b82f6;
}

/* Feedback */
.feedback {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
}
.feedback.correct {
    background: #dcfce7;
    color: #166534;
}
.feedback.wrong {
    background: #fee2e2;
    color: #991b1b;
}

/* Results screen */
#screen-results h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: #1e293b;
    text-align: center;
}

.results-score {
    font-size: 3rem;
    font-weight: 800;
    color: #3b82f6;
    margin: 0.75rem 0 1.5rem;
}

.results-list {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    background: #f8fafc;
}
.result-row.ok { background: #f0fdf4; }
.result-row.fail { background: #fef2f2; }

.result-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
}
.result-flag {
    font-size: 1.2rem;
    flex-shrink: 0;
}
.result-country {
    font-weight: 600;
    min-width: 100px;
}
.result-answer {
    color: #64748b;
    margin-left: auto;
    text-align: right;
}

/* ─── Auth pages ─── */
.auth-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 2rem 1.75rem;
    width: 100%;
    max-width: 380px;
    margin-top: 2rem;
}
.auth-box h1 {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 0.4rem;
    text-align: center;
}
.auth-subtitle {
    color: #64748b;
    font-size: 0.95rem;
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-align: center;
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.3rem;
}

/* ─── Progress screen ─── */
#screen-progress h2 {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 1rem;
}

/* Progress tabs */
.progress-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.btn-tab {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: #64748b;
    transition: all 0.15s;
}
.btn-tab:hover {
    border-color: #cbd5e1;
    color: #334155;
}
.btn-tab.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.progress-overview {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.overview-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    min-width: 90px;
}
.overview-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: #3b82f6;
}
.overview-label {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.progress-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}
.progress-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.prog-flag {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.prog-country {
    font-weight: 600;
    min-width: 85px;
    white-space: nowrap;
}
.prog-capital {
    color: #64748b;
    font-size: 0.85rem;
    min-width: 80px;
    white-space: nowrap;
}
.pbar {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    min-width: 40px;
}
.pbar-fill {
    height: 100%;
    border-radius: 4px;
    background: #ef4444;
    transition: width 0.3s ease;
}
.pbar-fill.pbar-good { background: #22c55e; }
.pbar-fill.pbar-mid { background: #f59e0b; }
.pbar-fill.pbar-low { background: #ef4444; }
.prog-stats {
    font-size: 0.8rem;
    color: #94a3b8;
    min-width: 70px;
    text-align: right;
    white-space: nowrap;
}

/* ─── Add user modal ─── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 1.75rem;
    width: 100%;
    max-width: 340px;
}
.modal-box h2 {
    font-size: 1.2rem;
    color: #1e293b;
    margin-bottom: 1rem;
}
.modal-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.modal-buttons .btn {
    flex: 1;
}

/* ─── Responsive ─── */
@media (max-width: 500px) {
    .progress-row {
        flex-wrap: wrap;
    }
    .pbar {
        order: 5;
        width: 100%;
        flex: none;
    }
    .prog-stats {
        order: 4;
        margin-left: auto;
    }
    .prog-capital {
        display: none;
    }
}
