@import url("https://cdn.jsdelivr.net/npm/computer-modern@0.1.3/cmu-serif.css");

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: "CMU Serif", serif;
    background: #151820;
    color: #f5f5f7;
}

button, input, p, h1 {
    font-family: "CMU Serif", serif;
}

[hidden] { display: none !important; }

/* ---------- barre du haut ---------- */

.topbar {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid #343a4d;
    position: sticky;
    top: 0;
    background: #151820;
    z-index: 5;
}

.brand {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
}

.nav-links { display: flex; height: 100%; }

button.nav {
    background: transparent;
    color: #9299aa;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0 18px;
    font-size: 16px;
    font-weight: 400;
    height: 100%;
}

button.nav:hover { color: #f5f5f7; }
button.nav.on { color: #f5f5f7; border-bottom-color: #f5f5f7; }

/* ---------- mise en page 3 colonnes ---------- */

.container {
    height: calc(100dvh - 52px);
    overflow: hidden;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 300px;
    align-items: stretch;
}

.main-col {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px 16px;
}

.side {
    min-height: 0;
    overflow: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-self: stretch;
}

.side.left { border-right: 1px solid #343a4d; grid-column: 1; }
.side.right { border-left: 1px solid #343a4d; grid-column: 3; }
.main-col { grid-column: 2; }
#page-settings { grid-column: 1 / -1; max-width: 640px; justify-self: center; width: 100%; justify-content: flex-start; overflow-y: auto; padding-top: 28px; }
#page-account { grid-column: 1 / -1; max-width: 560px; justify-self: center; width: 100%; justify-content: flex-start; overflow-y: auto; }

.muted { color: #8a92a6; font-size: 14px; }

/* ---------- panneaux repliables ---------- */

.panel { border: 1px solid #343a4d; }

.panel-head {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    color: #9099ac;
    border: none;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
}

#streak { font-size: 20px; line-height: 1.7; white-space: nowrap; }
.panel-head span:first-child { white-space: nowrap; }

.panel-head:hover { color: #f5f5f7; }
.chev { transition: transform 0.15s; }
.panel.collapsed .chev { transform: rotate(-90deg); }
.panel.collapsed .panel-body { display: none; }
.panel-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }

.equation-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 24px;
}

.label {
    color: #9099ac;
    font-size: 14px;
}

#equation, #p-equation, #d-equation, #e1-equation, #m-equation, #t-equation, #c-equation, #sm-equation {
    font-size: clamp(16px, 2.5vw, 25px);
    color: #ffffff;
    max-width: 100%;
    overflow-x: auto;
}

/* ---------- réponse ---------- */

.answer-card {
    width: min(640px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.answer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    font-size: 20px;
}

#answer, #p-answer, #d-answer, #e1-answer, #t-answer, #c-answer, #sm-answer {
    flex: 1;
    min-width: 0;
    background: #1d2130;
    color: #f5f5f7;
    border: 1px solid #343a4d;
    padding: 10px 12px;
    font-size: 18px;
    outline: none;
}

#answer:focus, #p-answer:focus, #d-answer:focus, #e1-answer:focus, #t-answer:focus, #c-answer:focus, #sm-answer:focus {
    border-color: #f5f5f7;
}

.preview {
    min-height: 2em;
    font-size: 18px;
    overflow-x: auto;
    max-width: 100%;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: 100%;
}

button.key {
    padding: 8px 4px;
    font-size: 15px;
    font-weight: 400;
    background: #1d2130;
    color: #f5f5f7;
    border: 1px solid #343a4d;
}

button.key:hover {
    border-color: #f5f5f7;
}

.buttons {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

button {
    border: 1px solid #f5f5f7;
    padding: 10px 17px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: #f5f5f7;
    color: #151820;
}

button.secondary {
    background: transparent;
    color: #f5f5f7;
    border-color: #343a4d;
}

button.secondary:hover {
    border-color: #f5f5f7;
}

button:active {
    transform: scale(0.97);
}

.feedback {
    min-height: 1.4em;
    font-size: 16px;
}

.feedback.ok { color: #6fd08c; }
.feedback.ko { color: #ff7b7b; }

.solution {
    border-top: 1px solid #343a4d;
    padding-top: 10px;
    width: 100%;
    font-size: 18px;
    overflow-x: auto;
}

.sol-title {
    color: #9099ac;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.sol-regime {
    color: #9299aa;
    font-size: 15px;
    margin: 4px 0;
}

/* ---------- panneau latéral ---------- */

.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #343a4d;
    border: 1px solid #343a4d;
}

.stat {
    background: #151820;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 26px;
}

.stat-label {
    color: #9099ac;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
}



/* ---------- compte + classement ---------- */

.account {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    text-align: left;
}

.board { display: flex; flex-direction: column; gap: 8px; }
.acc-sep { margin-top: 14px; }
.acc-total { font-size: 28px; }
.account button { padding: 10px; }

.account input {
    background: #1d2130;
    color: #f5f5f7;
    border: 1px solid #343a4d;
    padding: 8px 10px;
    font-size: 16px;   /* 16 px : évite le zoom automatique sur iOS */
    outline: none;
}

.account input:focus { border-color: #f5f5f7; }
.acc-buttons { display: flex; gap: 6px; }
.acc-buttons button { flex: 1; padding: 8px; font-size: 15px; }
.acc-name { font-size: 18px; }
.acc-msg { color: #ff7b7b; font-size: 13px; min-height: 1em; }

.board-tabs { display: flex; gap: 4px; }

.tab {
    flex: 1;
    padding: 6px;
    font-size: 14px;
    font-weight: 400;
    background: transparent;
    color: #9299aa;
    border: 1px solid #343a4d;
}

.tab.on { color: #f5f5f7; border-color: #f5f5f7; }

.board-list {
    list-style: none;
    counter-reset: rank;
    font-size: 15px;
}

.board-list li {
    counter-increment: rank;
    display: flex;
    justify-content: space-between;
    padding: 5px 8px;
    border: 1px solid #343a4d;
    margin-top: -1px;
}

.board-list li::before {
    content: counter(rank) ".";
    color: #8a92a6;
    width: 2em;
}

.board-list li span:first-child { flex: 1; }
.board-list li.me { border-color: #f5f5f7; }
.board-list li.empty { color: #8a92a6; }
.board-list li.empty::before { content: ""; width: 0; }

/* pas de barre de défilement verticale dans les blocs de la colonne centrale :
   ils gardent leur taille naturelle au lieu de se comprimer */
#equation, #p-equation, #d-equation, #e1-equation, #m-equation, #t-equation, #c-equation, #sm-equation, .solution, .preview, .equation-card, .answer-card {
    flex-shrink: 0;
    overflow-y: hidden;
}

/* ---------- pages : tout se pilote avec body[data-page] ---------- */

.mobile-only { display: none; }

.page { display: none; }

body[data-page="ed"] #page-ed,
body[data-page="ed1"] #page-ed1,
body[data-page="prim"] #page-prim,
body[data-page="deriv"] #page-deriv,
body[data-page="mat"] #page-mat,
body[data-page="trig"] #page-trig,
body[data-page="cplx"] #page-cplx,
body[data-page="sum"] #page-sum,
body[data-page="lobby"] #page-lobby,
body[data-page="duel"] #page-duel, body[data-page="daily"] #page-daily,
body[data-page="groups"] #page-groups,
body[data-page="select"] #page-select,
body[data-page="group"] #page-group,
body[data-page="login"] #page-login,
body[data-page="admin"] #page-admin,
body[data-page="account"] #page-account,
body[data-page="settings"] #page-settings { display: flex; }

/* la page Connexion n'a pas les colonnes classement / session */
body[data-page="account"] #left,
body[data-page="account"] #right,
body[data-page="settings"] #left,
body[data-page="settings"] #right,
body[data-page="lobby"] #left,
body[data-page="lobby"] #right,
body[data-page="duel"] #left, body[data-page="daily"] #left,
body[data-page="duel"] #right, body[data-page="daily"] #right,
body[data-page="groups"] #left,
body[data-page="groups"] #right,
body[data-page="select"] #left,
body[data-page="select"] #right,
body[data-page="group"] #left,
body[data-page="group"] #right,
body[data-page="login"] #left,
body[data-page="login"] #right,
body[data-page="board"] #right,
body[data-page="admin"] #left,
body[data-page="admin"] #right { display: none; }


/* ---------- solution affichée : le reste monte ou disparaît ---------- */

.solved .toolbar,
.solved .preview { display: none; }
.solved .equation-card { padding: 8px; gap: 8px; }
.solved .answer-card { gap: 6px; }
.solved .solution { font-size: 16px; padding-top: 6px; }
.solved .katex-display { margin: 0.3em 0; }
.solved .sol-title { display: none; }

.board-list li { padding: 4px 8px; }
.panel-body .muted { font-size: 13px; }

/* écrans peu hauts */
@media (max-height: 700px) {
    .side { padding: 10px; gap: 8px; }
    .stat { padding: 6px 10px; font-size: 22px; }
        .panel-head { padding: 7px 10px; }
    .panel-body { padding: 0 10px 8px; gap: 6px; }
    .equation-card { padding: 10px; gap: 10px; }
    #equation, #p-equation, #d-equation, #e1-equation, #m-equation, #t-equation, #c-equation, #sm-equation { font-size: clamp(15px, 2.2vw, 22px); }
    .preview { min-height: 1.4em; }
    button.key { padding: 5px 4px; }
    button { padding: 8px 14px; }
}

/* ---------- petits écrans : une page à la fois, sans défilement ---------- */

@media (max-width: 1000px) {
    .container { grid-template-columns: minmax(0, 1fr); }
    .main-col, #page-account, #page-settings, #page-admin, #page-lobby, #page-select, #page-duel, #page-daily, #page-login, #page-groups, #page-group, .side { grid-column: 1; grid-row: 1; }
    .side.left, .side.right { border: none; width: 100%; }
    .mobile-only { display: block; }
    .topbar { padding: 0 10px; }
    .nav-links { width: 100%; justify-content: space-around; }
    button.nav { padding: 0 8px; font-size: 15px; }

    body[data-page="ed"] #left,
    body[data-page="ed"] #right,
    body[data-page="ed1"] #left,
    body[data-page="ed1"] #right,
    body[data-page="prim"] #left,
    body[data-page="prim"] #right,
    body[data-page="deriv"] #left,
    body[data-page="deriv"] #right,
    body[data-page="mat"] #left,
    body[data-page="mat"] #right,
    body[data-page="trig"] #left,
    body[data-page="trig"] #right,
    body[data-page="cplx"] #left,
    body[data-page="cplx"] #right,
    body[data-page="sum"] #left,
    body[data-page="sum"] #right { display: none; }

    body[data-page="board"] #right,
    body[data-page="board"] #page-ed,
    body[data-page="board"] #page-ed1,
    body[data-page="board"] #page-prim,
    body[data-page="board"] #page-deriv,
    body[data-page="board"] #page-mat,
    body[data-page="board"] #page-trig,
    body[data-page="board"] #page-cplx,
    body[data-page="board"] #page-sum,
    body[data-page="board"] #page-admin,
    body[data-page="board"] #page-lobby,
    body[data-page="board"] #page-duel,
    body[data-page="board"] #page-daily,
    body[data-page="board"] #page-groups,
    body[data-page="board"] #page-select,
    body[data-page="board"] #page-settings,
    body[data-page="board"] #page-group,
    body[data-page="board"] #page-login { display: none; }
}

.acc-actions { display: flex; justify-content: space-between; gap: 10px; }

/* ---------- page Matrices : grille de réponse ---------- */

.m-grid {
    display: grid;
    gap: 6px;
    justify-content: center;
}

.m-cell { display: flex; align-items: center; gap: 6px; font-size: 18px; }

.m-cell input {
    width: 100%;
    min-width: 0;
    text-align: center;
    background: #1d2130;
    color: #f5f5f7;
    border: 1px solid #343a4d;
    padding: 10px 4px;
    font-size: 18px;
    outline: none;
}

.m-cell input:focus { border-color: #f5f5f7; }

.m-steps { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; font-size: 14px; margin-bottom: 6px; }
.m-step { display: flex; flex-direction: column; align-items: center; color: #9099ac; }
.m-step .katex { font-size: 1em; }

/* ---------- accessibilité ---------- */

.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid #f5f5f7; outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline-offset: 0; }

button, .key, .nav { touch-action: manipulation; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    button:active { transform: none; }
}


/* ---------- filtres du classement ---------- */

.board-filters { display: flex; flex-direction: column; gap: 6px; }
.board-filters select {
    width: 100%;
    background: #1d2130;
    color: #f5f5f7;
    border: 1px solid #343a4d;
    padding: 6px 8px;
    font-size: 14px;
    font-family: inherit;
}

/* ---------- statistiques (page Profil) ---------- */

.stats-box { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; margin-top: 18px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.stats-table th, .stats-table td { border: 1px solid #343a4d; padding: 5px 10px; text-align: right; font-weight: 400; }
.stats-table th:first-child { text-align: left; }
.stats-table thead th { color: #9099ac; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.stats-list th { color: #9099ac; }

.toast {
    position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
    background: #f5f5f7; color: #151820; padding: 10px 16px; font-size: 16px; font-weight: 600;
    z-index: 20; max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- touches − / ⌫ de la grille de matrices ---------- */

.m-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: min(240px, 100%); }
.solved .m-keys { display: none; }

@media (max-width: 1000px) {
    .stats-table { font-size: 13px; }
    .stats-table th, .stats-table td { padding: 5px 6px; }
    button.nav { padding: 0 5px; font-size: 14px; }
}

html { scrollbar-color: #343a4d #151820; }

@media (max-width: 1000px) {
    .nav-links { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
    .nav-links::-webkit-scrollbar { display: none; }
    button.nav { white-space: nowrap; flex: 0 0 auto; padding: 0 10px; }
}

/* ---------- panneau Niveau ---------- */

.lv-cat { color: #9099ac; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }
.lv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lv-num { font-size: 24px; }
.xpbar { height: 8px; border: 1px solid #343a4d; background: #151820; }
.xpbar > div { height: 100%; width: 0; background: #f5f5f7; transition: width 0.3s; }

/* ---------- bandeau de niveau (téléphone) ---------- */

.lv-strip { display: none; }

@media (max-width: 1000px) {
    body[data-page="ed"] .lv-strip, body[data-page="ed1"] .lv-strip, body[data-page="prim"] .lv-strip,
    body[data-page="deriv"] .lv-strip, body[data-page="mat"] .lv-strip, body[data-page="trig"] .lv-strip, body[data-page="cplx"] .lv-strip, body[data-page="sum"] .lv-strip {
        display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px;
        border-bottom: 1px solid #343a4d; font-size: 13px; color: #9099ac; white-space: nowrap;
    }
    .lv-strip #lvs-lv { color: #f5f5f7; }
    .lv-strip .xpbar { flex: 1; height: 6px; }
    body[data-page="ed"] .container, body[data-page="ed1"] .container, body[data-page="prim"] .container,
    body[data-page="deriv"] .container, body[data-page="mat"] .container, body[data-page="trig"] .container, body[data-page="cplx"] .container, body[data-page="sum"] .container { height: calc(100dvh - 82px); }
}

/* ---------- classement : le bas du cadre reste visible ---------- */

.side { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #343a4d transparent; }
.side .panel { flex-shrink: 0; }
.board-filters select { padding: 4px 6px; font-size: 13px; }
.board-filters { gap: 4px; }
.side.left { gap: 10px; padding-bottom: 20px; }

/* ---------- tableaux de stats sans bordures ---------- */

.stats-table { border-collapse: separate; border-spacing: 0 2px; }
.stats-table th, .stats-table td { border: none; padding: 6px 12px; background: #1a1e2a; }
.stats-table thead th { background: transparent; padding-bottom: 4px; }
.stats-list th { background: #1a1e2a; }
.stats-table tbody tr:hover th, .stats-table tbody tr:hover td { background: #20263a; }

/* ---------- page Paramètres ---------- */

#page-admin { grid-column: 1 / -1; max-width: 640px; justify-self: center; width: 100%; justify-content: flex-start; overflow-y: auto; }
.admin-box { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.adm-head { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.adm-head select { background: #1d2130; color: #f5f5f7; border: 1px solid #343a4d; padding: 4px 8px; font-size: 14px; font-family: inherit; }
.adm-chart { width: 100%; height: auto; margin: 6px 0 0; }
.adm-legend { display: flex; gap: 8px; align-items: center; }
.sw { display: inline-block; width: 10px; height: 10px; margin-left: 10px; }
.sw-a { background: #f5f5f7; margin-left: 0; }
.sw-b { background: #6d7487; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.adm-head .sol-title { margin: 0; }
.adm-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.adm-tile { background: #1a1e2a; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.adm-tile strong { font-size: 24px; font-weight: normal; font-variant-numeric: tabular-nums; }
.adm-tile span { color: #8a92a6; font-size: 13px; }
.adm-hit:hover { fill: rgba(245, 245, 247, 0.07); }
.adm-scroll { max-height: 420px; overflow: auto; }
.adm-logrow { cursor: pointer; }
.adm-logrow.open th, .adm-logrow.open td { background: #20263a; }
.adm-table tr.adm-ex td, .adm-table tr.adm-ex:hover td { background: #151820; border: 1px solid #343a4d; padding: 12px; text-align: center; white-space: normal; }
.adm-ex .adm-tex { font-size: 20px; overflow-x: auto; padding: 8px 0 4px; }
.adm-ex p { text-align: left; font-size: 13px; }
.adm-ratio { display: block; position: relative; width: 70px; height: 8px; background: #20263a; margin-left: auto; }
.adm-ratio i { display: block; height: 100%; background: #6d7487; }
.adm-ratio::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: #f5f5f7; }
.adm-odd .adm-ratio i { background: #f5f5f7; }
.adm-table td.adm-diag { color: #8a92a6; white-space: normal; text-align: left; font-size: 13px; padding-top: 0; }
.adm-odd td.adm-diag { color: #ffb86b; }
#admin .hist-cats li { grid-template-columns: 9em 1fr 5em; }
.adm-scroll .adm-table { width: 100%; }
.adm-scroll thead th { position: sticky; top: 0; background: #151820; }
@media (max-width: 560px) { .adm-tiles { grid-template-columns: repeat(2, 1fr); } }
button.danger { background: transparent; color: #ff7b7b; border-color: #ff7b7b; }
button.danger:hover { background: #ff7b7b; color: #151820; }

/* ---------- classements : même style que les statistiques (sans cadres) ---------- */

.side.left .panel { border: none; }
.side.left .panel-head { padding: 0 0 6px; color: #9099ac; }
.side.left .panel-body { padding: 0; gap: 0; }
.side.left .board-list li {
    border: none; margin-top: 0; margin-bottom: 2px;
    background: #1a1e2a; padding: 6px 10px; font-size: 14px;
}
.side.left .board-list li::before { width: 1.6em; }
.side.left .board-list li:hover { background: #20263a; }
.side.left .board-list li.me { background: #2a3045; color: #ffffff; }
.side.left .board-list li.me::before { color: #f5f5f7; }
.side.left .board-list li.empty { background: transparent; padding-left: 0; }
.side.left { gap: 14px; }
.board-filters select { border-color: transparent; background: #1a1e2a; }
.board-filters select:hover { background: #20263a; }

/* page Matrices : pas de barres de défilement visibles */
#page-mat, #page-mat * { scrollbar-width: none; }
#page-mat *::-webkit-scrollbar { display: none; }

/* page Matrices : aucun défilement (le contenu se réduit au lieu de déborder) */
/* (seuls les conteneurs sont concernés : KaTeX a besoin que ses éléments internes débordent de leur boîte) */
#page-mat, #page-mat .equation-card, #page-mat .answer-card, #page-mat #m-equation, #page-mat .solution, #page-mat .m-steps { overflow: hidden; }
#page-mat #m-equation { font-size: clamp(12px, 2.2vw, 22px); }
#page-mat .m-steps { font-size: clamp(10px, 1.6vw, 14px); }
#page-mat .m-step .katex { font-size: 0.9em; }
@media (max-width: 1000px) {
    #page-mat #m-equation { font-size: clamp(11px, 3.4vw, 18px); }
}

/* statistiques : tiennent dans l'écran d'un téléphone */
.stats-box, .stats-table { max-width: 100%; }
#page-account { overflow-x: hidden; }
@media (max-width: 1000px) {
    #page-account { padding: 12px 10px; }
    .stats-table { table-layout: fixed; font-size: 13px; }
    .stats-table th, .stats-table td { padding: 6px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .stats-table th:first-child { width: 34%; }
    .stats-table thead th { font-size: 9px; letter-spacing: 0; text-transform: uppercase; white-space: normal; }
}

/* statistiques par catégorie : une ligne par catégorie, sans tableau (rien ne déborde) */
.cat-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; background: #1a1e2a; padding: 8px 12px; }
.cat-row:hover { background: #20263a; }
.cat-name { color: #f5f5f7; }
.cat-lv { text-align: right; }
.cat-detail { grid-column: 1 / -1; color: #9099ac; font-size: 13px; }

/* ---------- XP en jeu : la part de barre clignote en sinusoïde ---------- */

.xpbar { display: flex; }
.xpbar > div { height: 100%; flex: none; }
.xp-ghost { background: #f5f5f7; opacity: 0.6; animation: xp-pulse 4s cubic-bezier(0.37, 0, 0.63, 1) infinite; }
.xp-gain { color: #f5f5f7; font-size: 13px; animation: xp-pulse 4s cubic-bezier(0.37, 0, 0.63, 1) infinite; }
@keyframes xp-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.9; } }
.lv-strip .xp-gain { font-size: 12px; }

/* ---------- accueil ---------- */

#page-lobby, #page-select, #page-duel, #page-daily, #page-login, #page-groups, #page-group { grid-column: 1 / -1; width: 100%; justify-self: center; justify-content: center; overflow-y: auto; }
.home { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 22px; }
.home-title { font-size: clamp(34px, 7vw, 58px); font-weight: 600; line-height: 1.1; text-align: center; }
.home-title { font-size: clamp(19px, 4.2vw, 36px); width: min(94vw, 660px); align-self: center; text-wrap: balance; }
.home-login { margin-top: -10px; }
button.link { background: none; border: none; color: #9099ac; font-size: 15px; font-weight: 400; padding: 0; text-decoration: underline; cursor: pointer; }
button.link:hover { color: #f5f5f7; }
.home-modes { display: flex; flex-direction: column; gap: 10px; width: 100%; }
button.mode-btn {
    width: 100%; padding: 16px; font-size: 20px; font-weight: 400; letter-spacing: 1px;
    background: #1a1e2a; color: #f5f5f7; border: 1px solid #343a4d;
}
button.mode-btn:hover { border-color: #f5f5f7; }
button.mode-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.home-ranking { background: none; border: none; padding: 6px 0; width: 100%; color: inherit; font-weight: 400; text-align: left; cursor: pointer; }
.home-list { list-style: none; counter-reset: rank; font-size: 14px; color: #8a92a6; }
.home-list li { counter-increment: rank; display: flex; justify-content: space-between; padding: 3px 4px; }
.home-list li::before { content: counter(rank) "."; width: 2em; color: #6d7487; }
.home-list li span:first-child { flex: 1; }
.home-list li.me { color: #f5f5f7; }
.home-list li.empty::before { content: ""; width: 0; }
.home-ranking:hover .home-list { color: #f5f5f7; }

/* ---------- page du duel ---------- */

.duel-page { width: min(460px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: left; padding: 8px 0 24px; }
.page-title { font-size: 34px; font-weight: 600; }
.duel-page h2 { font-size: 16px; font-weight: 400; color: #9099ac; letter-spacing: 2px; text-transform: uppercase; margin-top: 10px; }
.dl-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.dl-row label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; font-size: 13px; color: #9099ac; }
.dl-row select, .dl-row input {
    background: #1a1e2a; color: #f5f5f7; border: 1px solid #343a4d; padding: 11px 12px;
    font-size: 16px; font-family: inherit; min-width: 0;
}
.dl-row input { width: 130px; flex: none; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-size: 20px; }
.dl-row .dl-join { flex: 1; width: auto; }

/* ---------- barre du haut : accueil à gauche, onglets du mode classé ---------- */

.home-link { height: 100%; padding: 0 18px 0 0; font-size: 18px; font-weight: 600; letter-spacing: 1px; color: #f5f5f7; flex: none; }
body[data-page="lobby"] .nav-links, body[data-page="duel"] .nav-links, body[data-page="daily"] .nav-links, body[data-page="login"] .nav-links, body[data-page="groups"] .nav-links, body[data-page="select"] .nav-links, body[data-page="group"] .nav-links, body[data-page="settings"] .nav-links, body[data-mode="duel"] .nav-links { display: none; }
/* entraînement : seulement les catégories */
body[data-mode="train"] .nav.ranked-only { display: none; }
.topbar { justify-content: flex-start; }
.topbar .nav-links { margin-left: auto; }

/* ---------- page Classement (accessible depuis l'accueil) ---------- */

body[data-page="board"] #left { grid-column: 1 / -1; justify-self: center; width: min(560px, 100%); border: none; align-self: start; overflow-y: auto; }
/* ---------- barre du mode de jeu ---------- */

.mode-bar { display: flex; align-items: center; gap: 12px; height: 34px; padding: 0 16px; border-bottom: 1px solid #343a4d; font-size: 14px; color: #9099ac; white-space: nowrap; overflow: hidden; }
.mode-bar #mb-text { flex: 1; color: #f5f5f7; overflow: hidden; text-overflow: ellipsis; }
.mode-bar button { padding: 3px 10px; font-size: 13px; }
.mode-bar select { padding: 2px 6px; font-size: 13px; }
body:not([data-mode="ranked"]) .container { height: calc(100dvh - 86px); }
body:not([data-mode="ranked"]) .lv-strip { display: none !important; }

/* ---------- fenêtre centrale ---------- */

.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(21, 24, 32, 0.94); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay-box { background: #1a1e2a; padding: 24px; width: min(440px, 100%); text-align: center; display: flex; flex-direction: column; gap: 10px; }
.overlay-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.ov-big { font-size: 44px; line-height: 1.1; }
.ov-code { font-size: 54px; letter-spacing: 10px; padding-left: 10px; }
.ov-link { font-size: 13px; color: #9099ac; word-break: break-all; }
#lb-msg:empty, .lobby-account .acc-msg:empty { display: none; }

@media (max-width: 1000px) {
    .topbar .nav-links { width: auto; flex: 1; min-width: 0; margin-left: 0; }
    .home-link { padding-right: 12px; font-size: 16px; }
}
button.home-link { color: #f5f5f7; padding: 0 18px 0 0; }
button.home-link:hover { color: #ffffff; }
.dl-row:has(#dl-code) { align-items: stretch; }
.dl-row #dl-code { padding: 0 12px; }

.login-box { width: min(420px, 100%); text-align: left; }

/* duel : uniquement l'exercice (pas de colonnes de niveau, de série ni de classement) */
body[data-mode="duel"] #left, body[data-mode="duel"] #right, body[data-mode="train"] #left, body[data-mode="train"] #right { display: none; }
body[data-mode="duel"] .container, body[data-mode="train"] .container { grid-template-columns: minmax(0, 1fr); }
body[data-mode="duel"] .main-col, body[data-mode="train"] .main-col { grid-column: 1; }

/* ---------- direction sobre : gros titres, peu de cadres ---------- */

.panel { border: none; }
.side-title { font-size: 12px; font-weight: 400; color: #9099ac; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 8px; }
.side .panel-body { padding: 0; gap: 10px; }
.side { gap: 26px; }
.side.right .stat-row { background: none; border: none; display: flex; gap: 40px; }
.side.right .stat { background: none; padding: 0; font-size: 34px; gap: 2px; }
.side.right .stat-label { font-size: 11px; }
.lv-cat { font-size: 12px; }
.lv-num { font-size: 36px; line-height: 1.1; }
.xpbar { border: none; background: #20263a; height: 6px; }
.board-title { display: none; margin-bottom: 4px; }
body[data-page="board"] .board-title { display: block; }
/* les filtres du classement ne sont que sur la page Classement */
.board-filters { display: none; }
body[data-page="board"] .board-filters { display: flex; }
.page-title { font-size: clamp(32px, 6vw, 46px); font-weight: 600; line-height: 1.1; }
.account .page-title, .admin-box .page-title, .login-box .page-title { margin-bottom: 8px; }

.side.left, .side.right { border: none; }
#page-account, #page-admin { padding-top: 28px; }

/* lignes verticales qui séparent l'exercice du classement (gauche) et du niveau (droite) */
.side.left { border-right: 1px solid #343a4d; }
.side.right { border-left: 1px solid #343a4d; }
body[data-page="board"] #left { border: none; }

/* ---------- panneau de niveau : lisible d'un coup d'œil ---------- */

.side.right .panel-body { gap: 8px; }
.lv-cat { font-size: 13px; color: #b4bbcc; letter-spacing: 2px; }
.lv-num { font-size: 46px; line-height: 1.05; font-weight: 600; color: #ffffff; margin-bottom: 4px; }
.side.right .xpbar { height: 12px; background: #2a3045; }
.lv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.lv-xp { font-size: 17px; color: #e6e9f0; }
.side.right .xp-gain { font-size: 17px; font-weight: 600; color: #ffffff; }
.lv-tier { font-size: 15px; color: #b4bbcc; margin-top: 4px; }
.side.right .stat { font-size: 40px; color: #ffffff; }
.side.right .stat-label { font-size: 13px; color: #b4bbcc; letter-spacing: 2px; }
.side.right .panel + .panel { margin-top: 10px; }
.side.right #streak, .side.right #timer { font-size: 40px; line-height: 1.1; }

/* ---------- chargement des classements : motif gris en attendant le serveur ---------- */

li.skeleton { align-items: center; }
li.skeleton span { display: block; height: 11px; background: #2a3045; animation: skeleton-pulse 1.6s ease-in-out infinite alternate; }
li.skeleton span:first-child { width: 42%; }
li.skeleton span:last-child { width: 16%; }
@keyframes skeleton-pulse { from { opacity: 0.35; } to { opacity: 0.9; } }

/* ---------- fondu des colonnes latérales (ordinateur) ----------
   Les colonnes restent affichées et s'estompent (opacité) quand la page n'en a pas besoin :
   on passe du mode classé à l'accueil, à la connexion, etc. avec un fondu au lieu d'une disparition. */

.container { position: relative; }
@media (min-width: 1001px) {
    .main-col { grid-row: 1; }
    #left, #right { display: flex !important; grid-row: 1; transition: opacity 0.45s ease, visibility 0.45s; }
    body[data-page="lobby"] #left, body[data-page="lobby"] #right,
    body[data-page="duel"] #left, body[data-page="daily"] #left, body[data-page="duel"] #right, body[data-page="daily"] #right,
    body[data-page="groups"] #left, body[data-page="groups"] #right,
    body[data-page="select"] #left, body[data-page="select"] #right,
    body[data-page="group"] #left, body[data-page="group"] #right,
    body[data-page="login"] #left, body[data-page="login"] #right,
    body[data-page="account"] #left, body[data-page="account"] #right,
    body[data-page="settings"] #left, body[data-page="settings"] #right,
    body[data-page="admin"] #left, body[data-page="admin"] #right,
    body[data-page="board"] #right { opacity: 0; visibility: hidden; pointer-events: none; }
    /* pendant un duel : pas de colonnes du tout */
    body[data-mode="duel"] #left, body[data-mode="duel"] #right, body[data-mode="train"] #left, body[data-mode="train"] #right { display: none !important; }
}

/* la colonne de gauche change de place sur la page Classement : pas de fondu depuis ou vers cette page (sinon elle « saute » avant de s'estomper) */
@media (min-width: 1001px) {
    body[data-page="board"] #left, body[data-prev="board"] #left { transition: none; }
}

.mode-bar select { background: #151820; color: #f5f5f7; border: 1px solid #343a4d; padding: 2px 8px; font-size: 13px; font-family: inherit; }

/* pas de petite ligne d'indication (catégorie, niveau, difficulté) au-dessus de l'énoncé */
#label, #e1-label, #p-label, #d-label, #m-label, #t-label, #c-label, #sm-label { display: none; }

/* barre du haut : onglets sur une seule ligne, qui défilent si l'écran est trop étroit (Paramètres reste accessible) */
.topbar .nav-links { flex: 1; min-width: 0; margin-left: 0; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
.topbar .nav-links::-webkit-scrollbar { display: none; }
.topbar .nav-links > :first-child { margin-left: auto; }
.topbar .nav-links button.nav { white-space: nowrap; flex: none; padding: 0 12px; font-size: 15px; }
@media (min-width: 1500px) { .topbar .nav-links button.nav { padding: 0 16px; font-size: 16px; } }

/* classements : une seule ligne par joueur, le pseudo est coupé (…) s'il est trop long */
.board-list li, .home-list li { gap: 8px; align-items: baseline; }
.board-list li span:first-child, .home-list li span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li span:last-child, .home-list li span:last-child { flex: none; white-space: nowrap; }
.board-list li::before, .home-list li::before { flex: none; }

/* ---------- groupes ---------- */

#page-groups, #page-group { justify-content: flex-start; padding-top: 28px; }
.gp-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
button.gp-item { width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; background: #1a1e2a; border: none; color: #f5f5f7; font-size: 17px; font-weight: 400; text-align: left; }
button.gp-item:hover { background: #20263a; }
.gp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gp-meta { color: #9099ac; font-size: 14px; white-space: nowrap; }
.gp-empty { color: #8a92a6; padding: 6px 0; }
.dl-row input.gp-input { width: auto; flex: 1 1 200px; text-transform: none; letter-spacing: 0; text-align: left; font-size: 16px; }
.dl-row input:disabled, .dl-row .mode-btn:disabled { opacity: 0.4; }

.group-page { width: min(1000px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: left; padding-bottom: 24px; }
.group-page > button.link { align-self: flex-start; }
.g-invite { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.g-invite b { font-size: 22px; letter-spacing: 4px; }
.g-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 28px; margin-top: 8px; }
.g-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.g-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.g-filters select, .gc-form input { background: #1a1e2a; color: #f5f5f7; border: 1px solid transparent; padding: 8px 10px; font-size: 14px; font-family: inherit; min-width: 0; }
.g-board { list-style: none; display: flex; flex-direction: column; gap: 2px; counter-reset: rank; }
.g-board li { counter-increment: rank; display: flex; align-items: baseline; gap: 8px; background: #1a1e2a; padding: 7px 10px; font-size: 15px; }
.g-board li::before { content: counter(rank) "."; width: 1.8em; color: #6d7487; flex: none; }
.g-board li.me { background: #2a3045; color: #ffffff; }
.gb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gb-name em { font-style: normal; color: #8a92a6; font-size: 12px; margin-left: 4px; }
.gb-val { flex: none; white-space: nowrap; color: #c4cad8; }
.gb-kick, .gc-del { background: none; border: none; color: #8a92a6; font-size: 16px; padding: 0 4px; font-weight: 400; cursor: pointer; }
.gb-kick:hover, .gc-del:hover { color: #ff7b7b; }
.gc-list { height: min(52dvh, 460px); overflow-y: auto; background: #1a1e2a; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; scrollbar-width: thin; scrollbar-color: #343a4d transparent; }
.gc-msg { display: flex; align-items: baseline; gap: 8px; font-size: 15px; line-height: 1.35; }
.gc-name { flex: none; color: #9099ac; max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-msg.mine .gc-name { color: #f5f5f7; }
.gc-body { flex: 1; min-width: 0; overflow-wrap: anywhere; color: #e6e9f0; }
.gc-time { flex: none; color: #6d7487; font-size: 12px; }
.gc-form { display: flex; gap: 6px; }
.gc-form input { flex: 1; font-size: 16px; }
.gc-form button { padding: 8px 16px; }
@media (max-width: 800px) {
    .g-cols { grid-template-columns: minmax(0, 1fr); gap: 22px; }
    .gc-list { height: 46dvh; }
}

/* tag de groupe devant le pseudo : [2/3] Martin */
.bd-tag { font-style: normal; color: #9099ac; }
.g-tag { font-style: normal; color: #9099ac; font-size: 0.6em; vertical-align: middle; }
.dl-row input.gp-tag { width: 76px; flex: none; text-transform: none; letter-spacing: 1px; text-align: center; font-size: 16px; }
.gp-hint { margin-top: -4px; }

/* groupes : liste de tous les groupes, accès, demandes */
.gp-row { display: flex; align-items: center; gap: 12px; background: #1a1e2a; padding: 8px 12px; font-size: 16px; }
.gp-row .gp-name { flex: 1; }
.gp-row .gp-meta { flex: none; }
button.gp-act { flex: none; padding: 6px 12px; font-size: 14px; font-weight: 400; background: transparent; color: #f5f5f7; border: 1px solid #343a4d; }
button.gp-act:hover:not([disabled]) { border-color: #f5f5f7; }
button.gp-act:disabled { opacity: 0.35; cursor: not-allowed; }
.gp-search, .gp-select { background: #1a1e2a; color: #f5f5f7; border: 1px solid transparent; padding: 10px 12px; font-size: 16px; font-family: inherit; min-width: 0; width: 100%; }
.dl-row select.gp-select { flex: 1 1 220px; }
.g-reqs li { align-items: center; }
.g-reqs button { padding: 4px 12px; font-size: 14px; }
.g-reqs .gp-empty { background: transparent; }
.g-reqs li::before { content: none; width: 0; }

/* ---------- réglages : clavier, raccourcis, abréviations ---------- */

.settings-page { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; padding-bottom: 28px; }
.settings-page h2 { font-size: 15px; font-weight: 400; color: #9099ac; letter-spacing: 2px; text-transform: uppercase; margin-top: 16px; }
.settings-page code { background: #1a1e2a; padding: 1px 5px; font-size: 14px; color: #e6e9f0; }
.st-check { display: flex; align-items: baseline; gap: 10px; font-size: 16px; }
.st-check input { width: 18px; height: 18px; accent-color: #f5f5f7; align-self: center; flex: none; }
.st-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.st-file { display: inline-block; padding: 10px 17px; font-size: 16px; font-weight: 600; cursor: pointer; background: transparent; color: #f5f5f7; border: 1px solid #343a4d; }
.st-file:hover { border-color: #f5f5f7; }
.st-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.st-list li { display: flex; align-items: center; gap: 10px; background: #1a1e2a; padding: 6px 10px; }
.st-op { width: 5.5em; flex: none; font-size: 16px; }
.st-combo { flex: 1; color: #c4cad8; font-size: 15px; min-width: 0; }
.st-combo.empty { color: #6d7487; }
.st-combo.wait { color: #f5f5f7; }
.st-list button { padding: 4px 10px; font-size: 14px; font-weight: 400; }
textarea.st-snip { width: 100%; background: #1a1e2a; color: #f5f5f7; border: 1px solid transparent; padding: 10px 12px; font-size: 14px; line-height: 1.5; font-family: "DejaVu Sans Mono", "Fira Code", monospace; resize: vertical; tab-size: 4; }
textarea.st-snip:focus { border-color: #f5f5f7; outline: none; }
textarea.st-snip.drag { border-color: #6fd08c; }
.acc-links { margin-top: 10px; }

/* clavier à l'écran masqué (ordinateur seulement) */
@media (hover: hover) and (pointer: fine) {
    body.no-kbd .toolbar, body.no-kbd .m-keys { display: none; }
}

/* page Classement : défilement vertical possible, sans barre visible */
body[data-page="board"] #left { align-self: stretch; min-height: 0; overflow-y: auto; scrollbar-width: none; padding-bottom: 40px; }
body[data-page="board"] #left::-webkit-scrollbar { display: none; }


/* « Accueil » : soulignement centré sous le mot (marges égales de chaque côté) */
button.home-link { padding: 0 12px; margin-left: -12px; }
@media (max-width: 1000px) { .home-link { padding: 0 8px; margin-left: -8px; } }

/* classement des clans : visible seulement sur la page Classement */
.board-clans-panel { display: none; }
body[data-page="board"] .board-clans-panel { display: block; }
.gp-top li { counter-increment: rank; }

/* clan : pastille de nouveaux messages (permanente tant qu'il y en a) et vue complète en superposition */
.clan-dock {
    position: fixed; left: 16px; bottom: 16px; z-index: 15; max-width: calc(100vw - 32px);
    padding: 8px 14px; font-size: 14px; font-weight: 400; cursor: pointer;
    background: #1a1e2a; color: #c4cad8; border: 1px solid #343a4d;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.clan-dock:hover { border-color: #f5f5f7; color: #f5f5f7; }
.clan-dock.unread { background: #f5f5f7; color: #151820; border-color: #f5f5f7; font-weight: 600; }
@media (max-width: 1000px) {
    .clan-dock { left: 12px; right: 12px; bottom: 12px; text-align: center; max-width: none; }
    .clan-dock:not(.unread) { display: none; }
}
#g-close { display: none; }
body.clan-overlay { overflow: hidden; }
body.clan-overlay #page-group {
    display: flex; position: fixed; inset: 0; z-index: 25; background: #151820;
    overflow-y: auto; justify-content: flex-start; align-items: center; padding: 20px 16px 28px;
}
body.clan-overlay #g-back { display: none; }
body.clan-overlay #g-close { display: inline-block; align-self: flex-start; }
body.clan-overlay .toast { z-index: 40; }

/* page Classement : toute la zone défile à la molette (même souris sur les côtés) ; le contenu reste centré */
body[data-page="board"] #left {
    width: 100%; justify-self: stretch;
    padding-left: max(16px, calc((100% - 560px) / 2)); padding-right: max(16px, calc((100% - 560px) / 2));
}

/* boutons « retirer » / « supprimer » en texte (pas de pictogramme) */
.gb-kick, .gc-del { font-size: 12px !important; letter-spacing: 0.5px; padding: 0 6px !important; }

.st-back { align-self: flex-start; }

/* clan sous le niveau (mode classé) : même DA que Niveau, ancré en bas à droite de la colonne */
@media (min-width: 1001px) {
    .side.right { display: flex; }
    #right .panel.clan-card { margin-top: auto; }
    .clan-card[hidden] { display: none; }
    .clan-dock { display: none !important; }
}
.clan-open { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 0; background: none; border: none; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.clan-card .lv-num { font-size: 34px; margin-bottom: 0; }
.clan-card .lv-cat { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clan-open:hover .lv-cat { color: #ffffff; }
.clan-card.unread .lv-cat::after { content: " · nouveau message"; color: #ffffff; font-weight: 600; }
.cc-msgs { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; font-size: 14px; color: #9099ac; }
.cc-msgs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-msgs b { font-weight: 400; color: #c4cad8; }
.gp-rank { flex: none; color: #c4cad8; font-size: 14px; min-width: 2.2em; text-align: right; }



/* accueil : tient dans l'écran sans défilement, texte « écrit au clavier » */
.home-title .ghost { visibility: hidden; }
.home-title .caret { display: inline-block; width: 2px; height: 0.9em; margin: 0 1px; background: #f5f5f7; vertical-align: -0.08em; animation: caret-blink 0.8s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
.home { gap: 16px; }
.home-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.home-modes #home-ranked { grid-column: 1 / -1; }
.home-modes button.mode-btn { padding: 12px; font-size: 18px; }
.home-ranking { padding: 0; }
.home-list li { padding: 2px 4px; }
@media (max-height: 640px) { .home { gap: 10px; } .home-modes button.mode-btn { padding: 9px; } .home-list li { padding: 1px 4px; font-size: 13px; } }
.home-title { margin-bottom: 8px; }

/* accueil : le classement a un fond, comme les boutons mais plus discret */
.home-ranking { background: #1a1e2a; padding: 8px 10px; }
.home-ranking:hover { background: #20263a; }
.home-list li { padding: 2px 4px; }

/* accueil : boutons empilés, phrase pas plus large que les boutons */
.home-modes { display: flex; flex-direction: column; gap: 8px; }
.home-modes #home-ranked { grid-column: auto; }
.home-modes button.mode-btn { padding: 10px; font-size: 18px; }
.home-title { width: 100%; font-size: clamp(18px, 3vw, 23px); }
@media (max-height: 640px) { .home-modes button.mode-btn { padding: 7px; } }



/* accueil : grand titre */
.home { width: min(540px, 100%); }
.home-title { font-size: clamp(28px, 6vw, 42px); line-height: 1.12; }
.home-login { margin-top: -8px; }
.home-login button.link { font-size: 18px; }
@media (max-height: 640px) { .home { gap: 8px; } .home-title { font-size: clamp(26px, 5vw, 36px); } .home-modes button.mode-btn { padding: 6px; } }

/* accueil : boutons plus grands */
.home-modes button.mode-btn { padding: 14px; font-size: 22px; }
@media (max-height: 760px) { .home-modes button.mode-btn { padding: 10px; font-size: 21px; } }
@media (max-height: 640px) { .home-modes button.mode-btn { padding: 8px; font-size: 20px; } }

/* podium : une simple couche de couleur très légère par-dessus le fond habituel de la ligne ; le pseudo reste blanc */
.board-list li:nth-child(1):not(.empty), .home-list li:nth-child(1):not(.empty), .g-board li:nth-child(1):not(.empty) { background-image: linear-gradient(rgba(227, 199, 102, 0.13), rgba(227, 199, 102, 0.13)); }
.board-list li:nth-child(2):not(.empty), .home-list li:nth-child(2):not(.empty), .g-board li:nth-child(2):not(.empty) { background-image: linear-gradient(rgba(190, 198, 215, 0.12), rgba(190, 198, 215, 0.12)); }
.board-list li:nth-child(3):not(.empty), .home-list li:nth-child(3):not(.empty), .g-board li:nth-child(3):not(.empty) { background-image: linear-gradient(rgba(201, 141, 90, 0.14), rgba(201, 141, 90, 0.14)); }
.board-list li:nth-child(-n+3):not(.empty), .home-list li:nth-child(-n+3):not(.empty), .g-board li:nth-child(-n+3):not(.empty) { color: #f5f5f7; }
.board-list li:nth-child(-n+3):not(.empty)::before, .home-list li:nth-child(-n+3):not(.empty)::before, .g-board li:nth-child(-n+3):not(.empty)::before { color: #c4cad8; }

/* accueil : classement avec un espace entre les joueurs, survol discret */
.home-list li { background-color: #20263a; margin-bottom: 3px; padding: 3px 8px; }
.home-list li.empty { background: none; }
.home-ranking:hover { background: #1d2230; }
.home-ranking:hover .home-list { color: #8a92a6; }

/* accueil : boutons plus hauts et moins larges */
.home { width: min(440px, 100%); }
.home-modes, .home-ranking { width: min(360px, 100%); }
.home-modes button.mode-btn { padding: 20px 14px; font-size: 22px; }
@media (max-height: 800px) { .home-modes button.mode-btn { padding: 11px 12px; font-size: 21px; } .home { gap: 12px; } }
@media (max-height: 680px) { .home-modes button.mode-btn { padding: 8px 12px; font-size: 20px; } }

/* accueil : chargement, puis tout apparaît d'un coup */
.home { position: relative; }
.home-wait { position: absolute; top: 40%; left: 0; right: 0; text-align: center; color: #9099ac; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; animation: skeleton-pulse 0.9s ease-in-out infinite alternate; }
body.home-ready .home-wait { display: none; }
body:not(.home-ready) .home > :not(.home-wait) { visibility: hidden; }
body.home-ready .home-modes, body.home-ready .home-ranking { animation: home-in 0.4s ease both; }
@keyframes home-in { from { opacity: 0; } to { opacity: 1; } }
.home-title { width: min(540px, 94vw); }

/* accueil : bloc plus large */
.home { width: min(640px, 100%); }
.home-modes, .home-ranking { width: min(480px, 100%); }
.home-title { width: min(640px, 94vw); }

/* accueil : classement très sobre, sans fond */
.home-ranking, .home-ranking:hover { background: none; padding: 0; }
.home-list li, .home-list li:nth-child(-n+3):not(.empty) { background: none; background-image: none; padding: 3px 4px; }
.home-list li:nth-child(-n+3):not(.empty) { color: #c4cad8; }
.home-list li:nth-child(-n+3):not(.empty)::before { color: #8a92a6; }
.home-ranking:hover .home-list { color: #8a92a6; }

/* accueil : podium en couleur sur le texte (pas de fond) */
.home-list li:nth-child(1):not(.empty) { color: #e3c766; }
.home-list li:nth-child(2):not(.empty) { color: #b4bccd; }
.home-list li:nth-child(3):not(.empty) { color: #c98d5a; }
.home-list li:nth-child(-n+3):not(.empty)::before { color: inherit; }
.home-ranking:hover .home-list li:nth-child(1):not(.empty) { color: #e3c766; }
.home-ranking:hover .home-list li:nth-child(2):not(.empty) { color: #b4bccd; }
.home-ranking:hover .home-list li:nth-child(3):not(.empty) { color: #c98d5a; }

/* accueil : léger survol sur le classement */
.home-ranking { transition: background 0.15s; }
.home-ranking:hover { background: rgba(255, 255, 255, 0.04); }
.home-ranking:hover .home-list li:nth-child(n+4) { color: #a9b0c2; }

/* accueil : Classé en pleine largeur, puis les quatre autres boutons en 2 x 2 */
.home-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.home-modes #home-ranked { grid-column: 1 / -1; }
.home-title { margin-bottom: 12px; }

/* podium sur tous les classements : couleur du texte, pas de fond */
.board-list li:nth-child(-n+3):not(.empty), .g-board li:nth-child(-n+3):not(.empty) { background-image: none; }
.board-list li:nth-child(1):not(.empty), .g-board li:nth-child(1):not(.empty) { color: #e3c766; }
.board-list li:nth-child(2):not(.empty), .g-board li:nth-child(2):not(.empty) { color: #b4bccd; }
.board-list li:nth-child(3):not(.empty), .g-board li:nth-child(3):not(.empty) { color: #c98d5a; }
.board-list li:nth-child(-n+3):not(.empty)::before, .g-board li:nth-child(-n+3):not(.empty)::before { color: inherit; }
.board-list li:nth-child(-n+3) .gb-val, .g-board li:nth-child(-n+3) .gb-val { color: inherit; }

/* fiche du clan : plus lisible */
.g-sub { color: #9099ac; font-size: 16px; margin-top: -4px; }
.g-invite-box { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: #1a1e2a; }
.g-invite { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.g-label { color: #9099ac; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }
.g-options summary { cursor: pointer; color: #9099ac; font-size: 15px; }
.g-options summary:hover, .g-options[open] summary { color: #f5f5f7; }
.g-opts { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-top: 8px; }
.g-note { color: #8a92a6; font-size: 14px; margin-top: -4px; }
.gc-list:empty::before { content: "Aucun message pour l'instant. Écris le premier."; color: #8a92a6; font-size: 15px; }
.gc-list { height: min(40dvh, 400px); }

/* invitation reçue par lien */
.gp-invite { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; background: #1a1e2a; border: 1px solid #343a4d; }
.gp-invite p { font-size: 18px; }
.gp-invite-actions { display: flex; align-items: center; gap: 18px; }
.gp-invite button.mode-btn { width: auto; padding: 10px 22px; font-size: 18px; }

/* Mes exercices (page Paramètres) */
.hist { padding-top: 8px; }
.hist .page-title { margin-top: 18px; }
.hist-cats { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.hist-cats li { display: grid; grid-template-columns: 9em 1fr 3em; gap: 4px 10px; align-items: center; font-size: 15px; }
.hc-bar { height: 8px; background: #20263a; }
.hc-bar i { display: block; height: 100%; background: #f5f5f7; }
.hc-val { text-align: right; }
.hc-meta { grid-column: 2 / -1; color: #8a92a6; font-size: 13px; }
.hist-log { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.hist-row { width: 100%; display: grid; grid-template-columns: 8.5em 1fr; gap: 2px 12px; text-align: left; padding: 8px 12px; background: #1a1e2a; border: none; color: #f5f5f7; font-size: 15px; font-weight: 400; }
.hist-row:hover, .hist-log li.open .hist-row { background: #20263a; }
.hr-when { color: #9099ac; }
.hr-meta { grid-column: 2; color: #8a92a6; font-size: 13px; }
.hist-ex { background: #151820; border: 1px solid #343a4d; padding: 16px; overflow-x: auto; text-align: center; font-size: 22px; }

/* carte du clan (mode classé) : trois chiffres, dernier message, survol */
.clan-card .clan-open { padding: 10px 12px; margin: 0 -12px; width: calc(100% + 24px); gap: 10px; transition: background 0.15s; }
.clan-card .clan-open:hover { background: #1a1e2a; }
.cc-stats { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 10px; }
.cc-stat { display: flex; flex-direction: column; gap: 2px; }
.cc-lab { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #9099ac; }
.cc-val { font-size: 30px; line-height: 1.1; font-weight: 600; color: #ffffff; }
.cc-last { font-size: 14px; color: #9099ac; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-last b { color: #ffffff; font-weight: 600; }
.clan-card.unread .cc-last { color: #e6e9f0; }
.clan-card.unread .lv-cat::after { content: none; }

/* interface du clan : survols */
.gp-row:hover, .g-board li:not(.empty):not(.gp-empty):hover { background: #20263a; }
.g-board li.me:hover { background: #343c58; }
.gc-msg:hover { background: rgba(255, 255, 255, 0.04); }
.g-invite-box:hover { background: #1d2232; }
#g-send:hover, .gp-invite button.mode-btn:hover { background: #ffffff; border-color: #ffffff; color: #151820; }
.gp-invite button.mode-btn:hover { background: #20263a; border-color: #f5f5f7; color: #f5f5f7; }
.gp-search:hover, .gp-select:hover, .g-filters select:hover, .gc-form input:hover { background: #20263a; }
.gp-search:focus, .gp-select:focus, .gc-form input:focus { background: #20263a; outline: 1px solid #5a6278; }
.gp-act:hover:not([disabled]) { background: #20263a; }
#g-close:hover, #g-back:hover { color: #ffffff; }
.g-opts button:hover, .g-invite button:hover { color: #ffffff; }
.g-reqs button:hover { filter: brightness(1.2); }

/* page Classement : Plus d'XP, Meilleur clan, puis Meilleure vitesse */
body[data-page="board"] #left .panel:nth-of-type(2) { order: 1; }
body[data-page="board"] #left .board-clans-panel { order: 2; }
body[data-page="board"] #left .panel:nth-of-type(1) { order: 3; }

/* accueil : numéro du raccourci clavier, discret, à droite du bouton */
.home-modes button.mode-btn { position: relative; }
.home-modes button.mode-btn::after { content: attr(data-key); position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 14px; color: #6d7487; }
@media (hover: none) { .home-modes button.mode-btn::after { content: none; } }

/* Profil : un clic sur une statistique déroule la comparaison avec les autres joueurs */
.stat-click { cursor: pointer; }
.stat-click:hover th, .stat-click:hover td, .stat-click.open th, .stat-click.open td { background: #20263a; }
.stat-click:focus-visible { outline: 1px solid #5a6278; }
.stat-detail > td { background: #151820 !important; padding: 14px 12px 18px !important; text-align: center !important; }
.stat-detail .sol-title { margin: 0 0 6px; }
.radar { width: min(420px, 100%); height: auto; display: block; margin: 0 auto; }
.radar-legend { display: flex; justify-content: center; gap: 22px; font-size: 14px; color: #c4cad8; margin: 4px 0; }
.radar-legend i { display: inline-block; width: 18px; height: 10px; margin-right: 8px; vertical-align: middle; }
.lg-me { background: rgba(245, 245, 247, 0.4); border: 2px solid #f5f5f7; }
.lg-avg { background: rgba(109, 116, 135, 0.5); border: 1.5px solid #9099ac; }
.radar-verdict { font-size: 15px; color: #e6e9f0; margin-bottom: 10px; }
.radar-table { max-width: 420px; margin: 0 auto; }
.radar-table td, .radar-table th { background: #1a1e2a; }
.radar-table th:first-child { text-align: left; }

/* page de choix de la catégorie (Classé) */
#page-select { justify-content: center; }
.select-box { width: min(640px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: left; }
.select-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
/* défis du jour : résumé sur l'accueil (bouton), détail sur la page Défis */
button.home-daily { width: min(480px, 100%); display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; padding: 10px 14px;
    background: #1a1e2a; border: 1px solid transparent; color: #f5f5f7; font-weight: 400; font-size: 16px; text-align: left; }
button.home-daily:hover { background: #20263a; border-color: #343a4d; }
.home-daily .hd-title { color: #9099ac; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
.home-daily .hd-info { color: #8a92a6; font-size: 14px; }
.home-daily .hd-bars { flex-basis: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.home-daily .hd-bars .dy-bar { height: 5px; }
body.home-ready .home-daily { animation: home-in 0.4s ease both; }
.daily-page .daily { padding: 14px 16px; }
.daily-page .dy-list { gap: 10px; }
.daily-page .dy-list li { grid-template-columns: 1fr 2.6em; }
.daily-page .dy-list .dy-name { grid-column: 1 / -1; }
.daily-page .dy-list .dy-xp { grid-column: 1 / -1; text-align: left; }
.dy-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dy-stats div { background: #1a1e2a; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.dy-stats strong { font-size: 24px; font-weight: normal; font-variant-numeric: tabular-nums; }
.dy-stats span { color: #8a92a6; font-size: 13px; }
.dy-hist { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.dy-hist i { display: block; aspect-ratio: 1; background: #20263a; }
.dy-hist i[data-n="1"] { background: #4a5166; }
.dy-hist i[data-n="2"] { background: #8a92a6; }
.dy-hist i[data-n="3"] { background: #f5f5f7; }
.dy-hist-ends { display: flex; justify-content: space-between; color: #8a92a6; font-size: 13px; }
.daily { background: #1a1e2a; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.dy-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dy-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.dy-list li { display: grid; grid-template-columns: 1fr 90px 2.6em 11em; gap: 4px 10px; align-items: center; font-size: 15px; }
.dy-bar { height: 8px; background: #20263a; }
.dy-bar i { display: block; height: 100%; background: #f5f5f7; }
.dy-val { text-align: right; font-variant-numeric: tabular-nums; }
.dy-xp { text-align: right; color: #8a92a6; font-size: 13px; }
.dy-list li.done .dy-name, .dy-list li.done .dy-val { color: #8a92a6; }
.dy-list li.done .dy-bar i { background: #6d7487; }
.dy-note { font-size: 13px; }
@media (max-width: 520px) {
    .dy-list li { grid-template-columns: 1fr 2.6em; }
    .dy-list .dy-name { grid-column: 1 / -1; }
    .dy-list .dy-xp { grid-column: 1 / -1; text-align: left; }
}
button.sel-btn { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px 18px; background: #1a1e2a; color: #f5f5f7; border: 1px solid #343a4d; font-weight: 400; text-align: left; }
button.sel-btn:hover { border-color: #f5f5f7; background: #20263a; }
.sel-name { font-size: 22px; }
.sel-lv { font-size: 15px; color: #9099ac; }
button.sel-btn.last .sel-lv::after { content: " · dernière catégorie"; }
button.sel-btn::after { content: attr(data-key); position: absolute; right: 14px; top: 14px; font-size: 14px; color: #6d7487; }
@media (hover: none) { button.sel-btn::after { content: none; } }
@media (max-width: 520px) { .select-cats { grid-template-columns: 1fr; } }

/* choix de la catégorie : le niveau en grand */
.sel-name { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: #b4bbcc; }
.sel-lv { font-size: 38px; line-height: 1.05; font-weight: 600; color: #ffffff; }
button.sel-btn { gap: 6px; padding: 16px 18px 18px; }
button.sel-btn.last .sel-lv::after { content: none; }
button.sel-btn.last .sel-name::after { content: " · dernière"; color: #6d7487; }
.sel-bar { width: 100%; height: 6px; background: #2a3045; margin-top: 4px; }
.sel-bar i { display: block; height: 100%; background: #f5f5f7; }

/* choix de la catégorie : une colonne, boutons moins hauts (nom à gauche, niveau à droite) */
.select-cats { grid-template-columns: 1fr; gap: 6px; }
button.sel-btn { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 10px 18px 12px; }
.sel-name { font-size: 15px; }
.sel-lv { font-size: 26px; text-align: right; }
.sel-bar { grid-column: 1 / -1; margin-top: 2px; height: 5px; }
button.sel-btn::after { top: 50%; transform: translateY(-50%); right: auto; left: -26px; }
@media (max-width: 520px) { button.sel-btn::after { content: none; } }

/* choix de la catégorie : la catégorie d'abord, le niveau plus discret */
.sel-name { font-size: 24px; letter-spacing: 0; text-transform: none; color: #ffffff; }
.sel-lv { font-size: 16px; font-weight: 400; color: #9099ac; }
button.sel-btn { padding: 12px 18px 12px; }
.sel-bar { height: 4px; }
button.sel-btn.last .sel-name::after { font-size: 14px; }

.select-cats.train .sel-btn { grid-template-columns: 1fr; padding: 14px 18px; }
.select-cats.train .sel-bar, .select-cats.train .sel-lv { display: none; }

/* choix de la catégorie : glisser-déposer et focus clavier */
.select-cats { user-select: none; -webkit-user-select: none; }
button.sel-btn { -webkit-touch-callout: none; transition: transform 0.12s, border-color 0.15s, background 0.15s; }
button.sel-btn:focus-visible { border-color: #f5f5f7; background: #20263a; outline: none; }
.select-cats.sorting { cursor: grabbing; }
button.sel-btn.dragging { border-color: #f5f5f7; background: #2a3045; transform: scale(1.02); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); z-index: 2; }
