*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    background: #f5f0e8;
    color: #2c2416;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Navigation bar ─── */
.nav-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 56px;
    background: #3d5a3e;
    box-shadow: 0 2px 10px rgba(44, 36, 22, 0.18);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-weight: bold;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.nav-logo-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.lang-switcher {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 3px;
}

.lang-btn {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    font-family: inherit;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease;
}

.lang-btn.active,
.lang-btn:hover {
    background: #fff;
    color: #3d5a3e;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}

/* ─── Home hero ─── */
.hero {
    text-align: center;
    padding: 0.5rem 0 1.75rem;
}

.hero-badge {
    display: inline-block;
    background: #e8dcc4;
    color: #4a3728;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.85rem;
}

.hero-subtitle {
    margin: 0;
    color: #6b5d4d;
    font-style: italic;
    font-size: 1.05rem;
    max-width: 28rem;
    margin-inline: auto;
}

.card {
    background: #fff;
    border: 1px solid #ddd5c8;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(44, 36, 22, 0.06);
}

.card h2 {
    margin-top: 0;
    font-size: 1.5rem;
}

.progress-label {
    margin: 0 0 0.4rem;
    font-size: 0.9rem;
    color: #6b5d4d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-bar-container {
    background: #e8e0d4;
    border-radius: 4px;
    height: 6px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.progress-bar-fill {
    background: #3d5a3e;
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.event {
    margin: 0 0 1.5rem;
}

.event-title {
    font-size: 1.35rem;
    font-weight: bold;
    margin: 0 0 0.4rem;
    line-height: 1.4;
}

.event-desc {
    font-size: 1.05rem;
    font-weight: normal;
    margin: 0;
    line-height: 1.6;
    color: #4a3f35;
}

.start-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.guess-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.guess-form label {
    font-weight: bold;
}

.guess-form input[type="number"] {
    font-size: 1.25rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ccc4b8;
    border-radius: 4px;
    font-family: inherit;
    width: 100%;
    max-width: 200px;
}

.guess-form input[type="number"]::placeholder {
    color: #d8d4ce;
}

.era-options {
    border: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.era-legend {
    width: 100%;
    margin: 0 0 0.25rem;
    font-weight: bold;
    font-size: 0.95rem;
}

.era-option {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 1rem;
}

.era-option input[type="radio"] {
    accent-color: #3d5a3e;
}

.btn {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    font-size: 1rem;
    font-family: inherit;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    width: fit-content;
}

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

.btn-primary:hover {
    background: #2f4630;
}

.btn-secondary {
    background: #fff;
    color: #3d5a3e;
    border: 1px solid #3d5a3e;
}

.btn-secondary:hover {
    background: #eef3ee;
}

.btn-whatsapp {
    background: #25d366;
    color: #fff;
}

.btn-whatsapp:hover {
    background: #1daa53;
}

.result-grid-section {
    background: #faf7f2;
    border: 1px solid #ddd5c8;
    border-radius: 8px;
    padding: 1rem 1.1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.result-grid-title,
.share-title {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b5d4d;
}

.result-grid {
    --cell-size: 38px;
    display: grid;
    grid-template-columns: repeat(5, var(--cell-size));
    gap: calc(var(--cell-size) * 0.04);
    justify-content: center;
    margin: 0 auto;
    width: fit-content;
}

.result-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 4px;
    flex-shrink: 0;
}

.result-cell--exact {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #16a34a;
    color: #faf7f2;
    font-size: calc(var(--cell-size) * 0.95);
    font-weight: bold;
    line-height: 1;
    overflow: hidden;
}

.result-cell--zero {
    background: #eab308;
}

.result-cell--partial {
    background: #16a34a;
}

.share-section {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1.5rem;
}

.share-title {
    margin-bottom: 0.1rem;
}

.next-game-countdown {
    text-align: center;
    color: #6b5d4d;
    font-size: 0.95rem;
    margin: 0 0 1.25rem;
}

.stats-section {
    background: #faf7f2;
    border: 1px solid #ddd5c8;
    border-radius: 8px;
    padding: 1rem 1.1rem;
    margin-bottom: 1.5rem;
}

.stats-title {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b5d4d;
    text-align: center;
}

.stats-rank {
    text-align: center;
    font-weight: bold;
    margin: 0 0 0.75rem;
    color: #3d5a3e;
}

.stats-line {
    text-align: center;
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    color: #4a3f35;
}

.stats-subtitle {
    margin: 1rem 0 0.65rem;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b5d4d;
    text-align: center;
}

.dist-chart {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.dist-row {
    display: grid;
    grid-template-columns: 3.2rem 1fr;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.dist-row--user .dist-label {
    font-weight: bold;
    color: #3d5a3e;
}

.dist-row--user .dist-bar-fill {
    background: #3d5a3e;
}

.dist-label {
    text-align: right;
    color: #6b5d4d;
}

.dist-bar-track {
    background: #e8e0d4;
    border-radius: 3px;
    height: 14px;
    overflow: hidden;
}

.dist-bar-fill {
    background: #8faa90;
    height: 100%;
    border-radius: 3px;
    min-width: 2px;
}

.feedback {
    padding: 1rem 1.25rem;
    border-radius: 4px;
    margin-bottom: 1.25rem;
}

.feedback-correct {
    background: #e8f3e8;
    border: 1px solid #a8c9a8;
    color: #2a4a2a;
}

.feedback-wrong {
    background: #fbeaea;
    border: 1px solid #e0b4b4;
    color: #5c2a2a;
}

.feedback-error {
    background: #fff8e6;
    border: 1px solid #e6d49a;
    color: #5c4a1a;
}

.feedback p {
    margin: 0 0 0.5rem;
}

.correct-year {
    font-weight: bold;
}

.event-explanation {
    line-height: 1.6;
    color: #4a3f35;
}

.feedback p:last-child {
    margin-bottom: 0;
}

.accuracy-line {
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.answer-comment {
    margin-top: 0.5rem;
    font-style: italic;
    font-size: 0.95rem;
    opacity: 0.85;
}

.diff {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-top: 0.1rem;
}

.score {
    margin: 0 0 1.25rem;
    font-size: 1.1rem;
}

.final-score {
    font-size: 1.5rem;
    margin: 0 0 0.5rem;
}

.score-stars {
    letter-spacing: 0.05em;
}

.comment {
    font-style: italic;
    color: #6b5d4d;
    margin: 0 0 1.5rem;
    font-size: 1rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.results-table th,
.results-table td {
    padding: 0.6rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #e8e0d4;
}

.results-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b5d4d;
}

/* Numeric columns: fixed narrow width */
.results-table th:nth-child(2),
.results-table td:nth-child(2),
.results-table th:nth-child(3),
.results-table td:nth-child(3),
.results-table th:nth-child(4),
.results-table td:nth-child(4),
.results-table th:nth-child(5),
.results-table td:nth-child(5) {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

.row-correct td:last-child {
    color: #2a6a2a;
    font-weight: bold;
}

.row-wrong td:last-child {
    color: #8b2a2a;
    font-weight: bold;
}

@media (max-width: 600px) {
    .results-table {
        font-size: 0.8rem;
    }

    /* Hide the header row entirely on mobile */
    .results-table thead {
        display: none;
    }

    .results-table th,
    .results-table td {
        padding: 0.45rem 0.35rem;
    }
}

/* ─── Private analytics ─── */
body.analytics-layout .main-content {
    max-width: 960px;
}

.analytics-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.analytics-header h1,
.analytics-login h1 {
    margin: 0 0 0.25rem;
}

.muted {
    color: #6a5d4a;
    margin: 0;
}

.analytics-login-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1.25rem;
    max-width: 320px;
}

.analytics-login-form input {
    padding: 0.55rem 0.7rem;
    font: inherit;
    border: 1px solid #cbbda8;
    border-radius: 4px;
    background: #fff;
}

.error-msg {
    color: #8b2a2a;
    margin: 0.75rem 0 0;
}

.analytics-exports {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.analytics-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.analytics-kpi {
    background: #fff;
    border: 1px solid #ddd5c8;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.analytics-kpi-label {
    font-size: 0.8rem;
    color: #6a5d4a;
}

.analytics-kpi-value {
    font-size: 1.35rem;
    font-weight: bold;
    color: #3d5a3e;
}

.analytics-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.analytics-chart-card h2,
.analytics .card h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

.analytics .card {
    margin-bottom: 1rem;
}

.analytics-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.analytics-table-wrap {
    overflow-x: auto;
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.analytics-table th,
.analytics-table td {
    text-align: left;
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid #e5ddd0;
    white-space: nowrap;
}

.analytics-table th {
    color: #6a5d4a;
    font-weight: bold;
}

@media (max-width: 800px) {
    .analytics-charts,
    .analytics-split {
        grid-template-columns: 1fr;
    }

    .analytics-header {
        flex-direction: column;
    }
}

