html,
body,
main {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

header {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background-color: var(--bleu);
    color: rgb(255, 255, 255);
    min-height: 64px;
    padding: 10px 230px;
    margin: auto;
    margin-top: 0px;
    width: 100%;
    position: relative;
    /* Paint the blue past body's 1440px max-width, to the edges of the window */
    border-image: linear-gradient(var(--bleu), var(--bleu)) fill 0 / 0 / 0 100vmax;
}

header h1,
header h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* White bubble with the logo, just left of the title */
.header-logo {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-right: 12px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.header-logo img {
    width: 34px;
    height: 34px;
}

header h1,
header h2 {
    margin: 0;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 26px;
    font-weight: 700;
}

/* ---------- Free play / Daily switch under the header ---------- */
.mode-tabs {
    display: flex;
    width: fit-content;
    max-width: calc(100% - 32px);
    margin: 20px auto;
    padding: 4px;
    gap: 4px;
    background: white;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(11, 40, 85, 0.1);
}

.mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 999px;
    color: var(--bleu);
    font-family: "IBM Plex Sans", Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.mode-tab:hover {
    background: rgb(from var(--bleu-clair) r g b / 15%);
}

.mode-tab[aria-current="page"] {
    background: var(--bleu);
    color: white;
}

.tab-badge {
    padding: 1px 7px;
    border-radius: 999px;
    background: rgb(from var(--bleu-clair) r g b / 15%);
    font-size: 12px;
}

.tab-badge.hidden {
    display: none;
}

/* Not played yet today: just a dot */
.tab-badge.is-new {
    width: 8px;
    height: 8px;
    padding: 0;
    background: var(--rouge);
}

.mode-tab[aria-current="page"] .tab-badge:not(.is-new) {
    background: rgb(255 255 255 / 20%);
}

@media (max-width: 420px) {
    .mode-tab {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* ---------- "?" bubble + How to play window (help.js) ---------- */
.mode-bar {
    position: relative;
    width: fit-content;
    max-width: calc(100% - 96px);
    margin: 20px auto;
}

.mode-bar .mode-tabs {
    max-width: 100%;
    margin: 0;
}

.help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    position: absolute;
    top: 50%;
    left: calc(100% + 10px);
    transform: translateY(-50%);
    padding: 0;
    border: 1px solid rgb(from var(--bleu-clair) r g b / 50%);
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(11, 40, 85, 0.1);
    color: var(--bleu);
    font-size: 13px;
    cursor: pointer;
}

.help-btn:hover {
    background: rgb(from var(--bleu-clair) r g b / 15%);
}

.help-dialog {
    box-sizing: border-box;
    width: min(520px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    padding: 0;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    color: #333;
    font-family: "IBM Plex Sans", Arial, sans-serif;
}

.help-dialog::backdrop {
    background: rgba(11, 40, 85, 0.4);
}

.help-body {
    padding: 22px 24px 24px;
}

.help-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.help-head h2 {
    margin: 0;
    color: var(--bleu-fonce);
    font-size: 22px;
}

.help-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--bleu);
    font-size: 18px;
    cursor: pointer;
}

.help-close:hover {
    background: rgb(from var(--bleu-clair) r g b / 15%);
}

.help-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0 6px;
    color: var(--bleu);
    font-size: 16px;
}

.help-section p {
    margin: 0 0 8px;
    font-size: 15px;
    line-height: 1.5;
}

.help-tip {
    display: flex;
    gap: 10px;
    margin: 18px 0 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgb(from var(--bleu-clair) r g b / 10%);
    color: var(--bleu-fonce);
    font-size: 14px;
    line-height: 1.5;
}

.help-tip i {
    margin-top: 3px;
    color: #c8960c;
}

@media (max-width: 820px) {
    .leaderboard-btn span {
        display: none;
    }

    header {
        padding-left: 160px;
        padding-right: 160px;
    }
}

.header-actions {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 5;
}

.leaderboard-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: none;
    border: 1px solid white;
    border-radius: 5px;
    color: white;
    font-family: "IBM Plex Sans", Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.leaderboard-btn:hover,
.leaderboard-btn[aria-expanded="true"] {
    background-color: rgba(255, 255, 255, 0.2);
}

h1, h4 {
    font-family: "IBM Plex Sans", sans-serif;
    font-weight: 700;
}

h4 {
    position: fixed;
    display: flex;
    margin-top: 180px;
}

body {
    max-width: 1440px;
    min-height: 100vh;
    margin: auto;
    background: var(--bleu-background);
    font-family: Arial, sans-serif;
    padding: 0;
}  

section {
    display: flex;
    justify-content: center;
    margin: auto;
}

/* ---------- Profile icon + dropdown (menu.js) ---------- */
.profile-menu {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
}

.profile-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    background: none;
    border: none;
    border-radius: 30px;
    color: white;
    font-size: 34px;
    cursor: pointer;
}

.profile-name {
    font-family: "IBM Plex Sans", Arial, sans-serif;
    font-size: 21px;
    font-weight: 700;
}

.profile-chevron {
    font-size: 12px;
}

.profile-icon:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.profile-dropdown {
    position: absolute;
    left: 0;
    top: calc(100% + 10px);
    min-width: 190px;
    padding: 6px 0;
    background: white;
    border: 1px solid var(--bleu);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-family: Arial, sans-serif;
    font-size: 15px;
    text-align: left;
}

.profile-dropdown.hidden {
    display: none;
}

.menu-user {
    margin: 0 0 6px;
    padding: 6px 14px 10px;
    border-bottom: 1px solid rgb(from var(--bleu-clair) r g b / 20%);
    color: #777;
    font-size: 13px;
}

.menu-user strong {
    color: var(--bleu);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    color: var(--bleu);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
}

.menu-item i {
    width: 16px;
    text-align: center;
}

.menu-item:hover {
    background: rgb(from var(--bleu-clair) r g b / 20%);
}

/* ---------- Phone ---------- */
@media (max-width: 600px) {
    /* Logo + title on the left, profile on the right */
    header {
        justify-content: flex-start;
        min-height: 60px;
        padding: 8px 64px 8px 12px;
    }

    header h1,
    header h2 {
        font-size: 20px;
    }

    .header-logo {
        width: 38px;
        height: 38px;
        margin-right: 8px;
    }

    .header-logo img {
        width: 28px;
        height: 28px;
    }

    /* Profile: just the round user icon on the right, the name is in the dropdown anyway */
    .profile-menu {
        left: auto;
        right: 10px;
    }

    .profile-dropdown {
        left: auto;
        right: 0;
    }

    .profile-icon {
        padding: 3px;
        font-size: 32px;
    }

    /* .profile-icon prefix so it wins over Font Awesome's own display rule */
    .profile-icon .profile-name,
    .profile-icon .profile-chevron {
        display: none;
    }

    /* "Daily challenge — 2026-10-27" doesn't fit, keep only "Daily challenge" */
    .title-date {
        display: none;
    }

    /* Leaderboard: out of the header, a floating bubble in the corner, daily page only */
    .header-actions {
        display: none;
    }

    .page-daily .header-actions {
        display: flex;
        position: fixed;
        top: auto;
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        transform: none;
    }


    .leaderboard-btn {
        justify-content: center;
        width: 52px;
        height: 52px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: var(--bleu-clair);
        box-shadow: 0 4px 12px rgba(11, 40, 85, 0.35);
        font-size: 20px;
    }

    .leaderboard-btn:hover,
    .leaderboard-btn[aria-expanded="true"] {
        background: rgb(from var(--bleu-clair) r g b / 80%);
    }

    /* No room to float the "?" outside the tabs: tabs and bubble share the row */
    .mode-bar {
        display: flex;
        align-items: center;
        gap: 8px;
        max-width: calc(100% - 24px);
        margin: 16px auto;
    }

    .mode-bar .mode-tabs {
        min-width: 0;
    }

    .help-btn {
        position: static;
        transform: none;
    }
}

@media (max-width: 380px) {
    .mode-tab {
        padding: 8px 11px;
    }

    .mode-tab > i {
        display: none;
    }

    .help-body {
        padding: 18px 18px 20px;
    }
}

/* ---------- Footer (same on every page) ---------- */
/* Pages with a footer are a full-height column, so the footer sits at the bottom even when the page is short */
body:has(> .site-footer) {
    display: flex;
    flex-direction: column;
}

/* No auto margins in the column: they would split the empty space with the footer.
   The section stays full width like before (its content is centered by its own flex) */
body:has(> .site-footer) > header {
    margin-bottom: 0;
}

body:has(> .site-footer) > section {
    margin: 0;
}

/* index.html: main grows with its content (explanation open, results...) instead of a fixed screen height,
   so the footer is always below it */
body:has(> .site-footer) > main {
    height: auto;
}

/* Keep some space above the footer when the page is long */
body > :has(+ .site-footer) {
    margin-bottom: 48px;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    box-sizing: border-box;
    width: 100%;
    margin-top: auto;
    padding: 18px 24px 24px;
    border-top: 1px solid rgb(from var(--bleu) r g b / 20%);
    color: rgb(from var(--bleu) r g b / 70%);
    font-family: "IBM Plex Sans", Arial, sans-serif;
    font-size: 13px;
}

.site-footer p {
    margin: 0;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
}

.site-footer a {
    color: inherit;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--bleu);
    text-decoration: underline;
}

@media (max-width: 600px) {
    .site-footer {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }

    .site-footer nav {
        justify-content: center;
    }
}

/* ---------- Text pages (privacy) ---------- */
.legal-page {
    box-sizing: border-box;
    width: 760px;
    max-width: 100%;
    margin-top: 30px;
    padding: 28px 32px 36px;
    background: white;
    border: 1px solid var(--bleu-clair);
    border-radius: 10px;
    color: #333;
    font-family: "IBM Plex Sans", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

.legal-page h1 {
    margin: 0;
    color: var(--bleu);
}

.legal-page h2 {
    margin: 28px 0 8px;
    color: var(--bleu);
    font-size: 1.25em;
}

.legal-page h3 {
    margin: 18px 0 4px;
    color: var(--bleu-peu-fonce);
    font-size: 1em;
}

.legal-page a {
    color: var(--bleu-clair);
}

.legal-updated {
    margin: 4px 0 20px;
    color: #777;
    font-size: 0.9em;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93em;
}

.legal-table th,
.legal-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgb(from var(--bleu) r g b / 15%);
    text-align: left;
    vertical-align: top;
}

.legal-table th {
    color: var(--bleu);
}

@media (max-width: 600px) {
    .legal-page {
        margin: 16px 12px 0;
        padding: 20px 18px 28px;
    }
}
