/* Reset & Base */
:root {
    --font-display: 'Source Sans 3', 'Segoe UI', sans-serif;
    --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
    --c-ink: #e6eaf2;
    --c-muted: #8b95a8;
    --c-accent: #3d7ea6;
    --c-accent-deep: #2a5f82;
    --c-blue-soft: #8eb6d4;
    --c-blue: #5b9fd4;
    --c-blue-deep: #1e4a6e;
    --c-ivory: #eef3f8;
    --c-ebony: #1c1f2a;
    --c-panel: #121824;
}

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

body {
    font-family: var(--font-body);
    background-color: #0f121c;
    color: var(--c-ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

html {
    scrollbar-gutter: stable;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* display:flex ci-dessus ne doit pas annuler hidden (sinon l’app apparaît sous le login) */
#appRoot[hidden],
.container[hidden] {
    display: none !important;
}

/* Écran login : rien d’autre n’est visible ni cliquable */
body.auth-locked {
    overflow: hidden !important;
    height: 100vh;
    height: 100dvh;
    background: #0b1018;
}

body.auth-locked > *:not(#authGate) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body.auth-locked #authGate {
    display: flex !important;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 30px;
    background: linear-gradient(135deg, #141a28 0%, #1a2740 55%, #1e3558 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid rgba(91, 159, 212, 0.18);
}

.header h1,
.header .app-title {
    font-size: 1.4rem;
    color: var(--c-ivory);
    margin: 0;
}

.clocks {
    display: none;
}

.clock {
    background: rgba(255,255,255,0.1);
    padding: 5px 20px;
    border-radius: 8px;
    text-align: center;
    min-width: 130px;
    border: 1px solid rgba(255,255,255,0.15);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.clock.active {
    border-color: rgba(233, 69, 96, 0.7);
    box-shadow: 0 0 0 1px rgba(233, 69, 96, 0.35);
}

.clock.unlimited .time {
    font-size: 1.15rem;
    letter-spacing: 0.02em;
}

.clock.white-clock {
    border-left: 3px solid #fff;
    border-right: 3px solid #fff;
}

.clock.black-clock {
    border-left: 3px solid #333;
    border-right: 3px solid #333;
}

.header .clock .player-name {
    font-size: 0.62rem;
    line-height: 1.15;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header .clock .time {
    font-size: 1.05rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.player-name {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 3px;
}

.time {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

:root {
    --board-size: 600px;
    --eval-col-width: 36px;
    --board-gap: 8px;
    --board-frame-width: calc(var(--eval-col-width) + var(--board-gap) + var(--board-size));
    --board-label-height: 2.35rem;
    --board-info-height: 2.35rem;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
    width: 100%;
}

.board-section {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.05);
    padding: 20px;
    border-radius: 12px;
    overflow: hidden;
}

/* Cadre fixe : barre éval + plateau (ne bouge pas avec le texte) */
.board-stage {
    width: var(--board-frame-width);
    max-width: 100%;
    margin: 0 auto;
    flex-shrink: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.board-with-eval {
    display: flex;
    gap: var(--board-gap);
    align-items: flex-start;
    width: 100%;
    max-width: var(--board-frame-width);
    flex-shrink: 0;
    box-sizing: border-box;
}

.eval-bar-column {
    width: var(--eval-col-width);
    min-width: var(--eval-col-width);
    max-width: var(--eval-col-width);
    flex: 0 0 var(--eval-col-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    overflow: hidden;
    box-sizing: border-box;
}

.eval-bar-pct {
    display: block;
    width: 100%;
    font-size: 0.55rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'Cascadia Mono', 'Source Sans 3', monospace;
    letter-spacing: 0;
    text-align: center;
    white-space: nowrap;
    color: #9aa3ad;
    line-height: 1;
}

.eval-bar-vertical {
    width: 28px;
    flex-shrink: 0;
    align-self: center;
    background: #333;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    border: 2px solid #000;
}

.eval-black-fill {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: #000;
    transition: height 0.4s ease;
}

.eval-white-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: #fff;
    transition: height 0.4s ease;
}

.eval-zero-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: #e94560;
    border-radius: 2px;
    top: 50%;
    z-index: 10;
    box-shadow: 0 0 6px rgba(233, 69, 96, 0.8);
}

.board-area {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 0 0 var(--board-size);
    width: var(--board-size);
    min-width: 0;
    max-width: var(--board-size);
    overflow: hidden;
    box-sizing: border-box;
}

.board-canvas-wrap {
    width: var(--board-size);
    height: var(--board-size);
    max-width: 100%;
    flex: 0 0 var(--board-size);
    flex-shrink: 0;
    position: relative;
    box-sizing: border-box;
}

#chessBoard {
    width: 100%;
    height: 100%;
    display: block;
    border: 3px solid #333;
    border-radius: 4px;
    cursor: pointer;
    background: #2d2d44;
    box-sizing: border-box;
    touch-action: manipulation;
}

.board-info {
    box-sizing: border-box;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: var(--board-info-height);
    min-height: var(--board-info-height);
    max-height: var(--board-info-height);
    margin-top: 10px;
    padding: 0 12px;
    font-size: 0.88rem;
    color: #c4ccd4;
    gap: 10px;
    flex-wrap: nowrap;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 6px;
}

.board-info #lastMove {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.board-info #turnIndicator {
    flex: 0 1 auto;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.replay-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(154, 208, 255, 0.08);
    border: 1px solid rgba(154, 208, 255, 0.28);
    border-radius: 8px;
    flex-shrink: 0;
    overflow: hidden;
}

.replay-bar[hidden] {
    display: none !important;
}

.replay-bar-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ad0ff;
}

.replay-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-replay {
    min-width: 2rem;
    height: 1.85rem;
    padding: 0 6px;
    font-size: 0.75rem;
    color: #e8eef4;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    cursor: pointer;
}

.btn-replay:hover {
    background: rgba(154, 208, 255, 0.25);
}

.btn-replay-play {
    min-width: 2.4rem;
    background: rgba(233, 69, 96, 0.35);
    border-color: rgba(233, 69, 96, 0.55);
}

.replay-progress {
    font-size: 0.78rem;
    color: #c8d4dc;
    font-variant-numeric: tabular-nums;
    min-width: 4.5rem;
}

.replay-speed {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: #aaa;
}

.replay-speed select {
    font-size: 0.75rem;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.35);
    color: #e8eef4;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.btn-replay-exit {
    margin-left: auto;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #e8eef4;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 5px;
    cursor: pointer;
}

.btn-replay-exit:hover {
    background: rgba(233, 69, 96, 0.3);
}

.label-check-suffix {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    pointer-events: none;
}

.label-check-suffix[hidden] {
    display: none !important;
}

.label-check-suffix .check-word {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0 2px;
    border-radius: 2px;
    margin-left: 1px;
    vertical-align: baseline;
}

.label-check-suffix .check-word.is-check {
    color: #1a1200;
    background: #ffb347;
}

.label-check-suffix .check-word.is-mate {
    color: #fff;
    background: #e94560;
}

.label-piece {
    flex-shrink: 0;
    line-height: 1;
}

.label-player {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.top-label,
.bottom-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.top-label-text,
.bottom-label-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

.board-elo-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    cursor: pointer;
}

.board-elo-wrap[hidden] {
    display: none !important;
}

.board-elo-caption {
    font-size: 0.65rem;
    font-weight: 600;
    color: #9ad0ff;
    letter-spacing: 0.04em;
}

.board-elo-select {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    width: calc(5ch + 1.1rem); /* 5 chiffres + flèche */
    max-width: calc(5ch + 1.1rem);
    padding: 1px 14px 1px 4px;
    border-radius: 4px;
    border: 1px solid rgba(154, 208, 255, 0.45);
    background: rgba(26, 35, 50, 0.9)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%239ad0ff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E")
        no-repeat right 4px center / 7px 4px;
    color: #e8eef4;
    font-size: 0.7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    line-height: 1.2;
    min-height: 0;
    height: auto;
}

.board-elo-select:hover,
.board-elo-select:focus {
    border-color: #9ad0ff;
    outline: none;
}

.player-label {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: var(--board-label-height);
    min-height: var(--board-label-height);
    max-height: var(--board-label-height);
    text-align: center;
    padding: 0 3.25rem 0 8px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 6px;
    margin: 5px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.label-center {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.top-label {
    background: rgba(0, 0, 0, 0.3);
    color: #aaa;
    border: 1px solid rgba(255,255,255,0.1);
}

.bottom-label {
    background: rgba(255, 255, 255, 0.1);
    color: #eee;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Sidebar */
.sidebar {
    width: 320px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 120px);
    scrollbar-gutter: stable;
}

.sidebar h2 {
    font-size: 1rem;
    margin: 0;
    color: #e94560;
    border: none;
    padding: 0;
    flex: 1 1 auto;
    white-space: nowrap;
}

.panel-head {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    margin-left: auto;
}

.btn-collapse {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #c8d4dc;
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.btn-collapse:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.collapsible-panel.is-collapsed .btn-collapse {
    transform: rotate(-90deg);
}

.collapsible-panel.is-collapsed .panel-head {
    margin-bottom: 0;
}

.collapsible-panel.is-collapsed .panel-body {
    display: none;
}

.panel-body {
    display: block;
}

/* Expérience moteur */
.experience-panel {
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(61, 126, 166, 0.12);
    border: 1px solid rgba(61, 126, 166, 0.35);
}

.exp-header-row {
    display: none; /* remplacé par .panel-head */
}

.btn-stats {
    flex: 0 0 auto;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #e8f4ff;
    background: rgba(61, 126, 166, 0.45);
    border: 1px solid rgba(154, 208, 255, 0.35);
    border-radius: 6px;
    cursor: pointer;
}

.btn-stats:hover {
    background: rgba(61, 126, 166, 0.7);
}

.exp-level-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #ddd;
}

.exp-bar {
    height: 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    margin-bottom: 10px;
}

.exp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3d7ea6, #5cdb95);
    transition: width 0.35s ease;
}

.exp-stats,
.exp-book {
    font-size: 0.8rem;
    color: #aaa;
    margin: 0 0 6px;
}

.exp-known-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    margin: 4px 0 2px;
}

.exp-eco-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0 2px;
}

.exp-eco-row .exp-known-label {
    margin: 0;
}

.btn-eco-ref {
    flex: 0 0 auto;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #e8f4ff;
    background: rgba(61, 126, 166, 0.4);
    border: 1px solid rgba(154, 208, 255, 0.35);
    border-radius: 5px;
    cursor: pointer;
}

.btn-eco-ref:hover {
    background: rgba(61, 126, 166, 0.7);
}

.exp-top-list.exp-known .exp-eco-item {
    cursor: pointer;
}

.exp-top-list.exp-known .exp-eco-item:hover {
    color: #e8f4ff;
    background: rgba(154, 208, 255, 0.08);
}

.exp-top-list.exp-known {
    max-height: 7.5rem;
    margin-bottom: 4px;
}

.exp-eco {
    color: #9ad0ff;
    font-family: ui-monospace, monospace;
    font-size: 0.68rem;
    margin-right: 4px;
}

.exp-ref-doc {
    font-size: 0.72rem;
    color: #888;
    margin: 0 0 8px;
}

.exp-ref-doc a {
    color: #9ad0ff;
}

.exp-top-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    max-height: 7.5rem;
    overflow-y: auto;
    font-size: 0.72rem;
    color: #b8c9d4;
}

.exp-top-list li {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    word-break: break-all;
}

.exp-top-list code {
    color: #9ad0ff;
    font-size: 0.7rem;
}

.exp-top-list .exp-empty {
    color: #777;
    border: none;
}

.exp-strategies {
    margin-bottom: 4px;
    max-height: 5.5rem;
}

.btn-train {
    width: 100%;
    margin-top: 8px;
    border: none;
    border-radius: 6px;
    padding: 9px 12px;
    background: #3d7ea6;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.btn-train:hover {
    background: #4f96c2;
}

.btn-train:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.exp-train-status {
    margin-top: 8px;
    font-size: 0.78rem;
    color: #9ad0ff;
}

/* Analyse IA */
.analysis-panel {
    margin-bottom: 20px;
}

.evaluation-bar {
    display: flex;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    margin: 10px 0;
    position: relative;
}

.eval-white, .eval-black {
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    transition: width 0.3s ease;
}

.eval-white {
    background: linear-gradient(90deg, #4a90d9, #6bb5ff);
    color: white;
}

.eval-black {
    background: linear-gradient(270deg, #4a90d9, #6bb5ff);
    color: white;
}

.eval-fill {
    width: 100%;
    height: 100%;
    position: relative;
}

.eval-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255,255,255,0.3);
    transition: width 0.3s ease;
}

.eval-value {
    position: absolute;
    font-size: 0.7rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'Cascadia Mono', 'Source Sans 3', monospace;
    min-width: 4ch;
    text-align: center;
}

.evaluation-text {
    text-align: center;
    color: #aaa;
    font-style: italic;
    margin-top: 5px;
}

/* Coach flottant (apprentissage) */
.coach-float {
    position: fixed;
    top: 100px;
    right: 28px;
    width: min(320px, calc(100vw - 32px));
    z-index: 1000;
    border-radius: 12px;
    background: linear-gradient(160deg, #1e2742 0%, #16213e 100%);
    border: 1px solid rgba(233, 69, 96, 0.45);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    user-select: none;
}

.coach-float[hidden] {
    display: none !important;
}

.coach-float.is-collapsed .coach-float-body {
    display: none;
}

.coach-float-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(233, 69, 96, 0.18);
    cursor: grab;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.coach-float-header:active {
    cursor: grabbing;
}

.coach-float-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #ff7a8f;
    letter-spacing: 0.01em;
}

.coach-float-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #eee;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.coach-float-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.coach-float-body {
    padding: 12px 14px 14px;
}

.coach-steps {
    margin: 0 0 12px;
    padding-left: 1.2rem;
    color: #aab4c8;
    font-size: 0.78rem;
    line-height: 1.45;
}

.coach-steps li + li {
    margin-top: 2px;
}

.coach-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.coach-badge.excellent { background: #1b7a4a; color: #e8fff3; }
.coach-badge.good { background: #2d6a4f; color: #e8fff3; }
.coach-badge.inaccuracy { background: #8a6d1d; color: #fff8e1; }
.coach-badge.mistake { background: #a85a1a; color: #fff3e6; }
.coach-badge.blunder { background: #9b1c2e; color: #ffe8ec; }

.coach-message {
    color: #ddd;
    font-size: 0.88rem;
    line-height: 1.4;
    margin: 0 0 10px;
    user-select: text;
}

.coach-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-hint,
.btn-hint-clear,
.btn-undo,
.btn-pause {
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-hint {
    background: #3d7ea6;
    color: #fff;
}

.btn-hint:hover {
    background: #4f96c2;
}

.btn-hint:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-undo {
    background: #c47a1a;
    color: #fff;
}

.btn-undo:hover {
    background: #e0922a;
}

.btn-undo:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-pause {
    background: #3d5a80;
    color: #fff;
}

.btn-pause:hover {
    background: #4a6f9c;
}

.btn-pause.is-paused {
    background: #1b7a4a;
}

.btn-pause.is-paused:hover {
    background: #22965c;
}

.btn-hint-clear {
    background: rgba(255,255,255,0.12);
    color: #eee;
}

.btn-hint-clear:hover {
    background: rgba(255,255,255,0.2);
}

.coach-hint {
    margin: 10px 0 0;
    color: #9ad0ff;
    font-size: 0.85rem;
    line-height: 1.35;
    user-select: text;
}

@media (max-width: 700px) {
    .coach-float {
        top: auto;
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
    }
}

/* Historique des coups */
.moves-panel {
    margin-bottom: 20px;
}

.moves-list {
    max-height: 150px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.move-row {
    display: flex;
    padding: 3px 5px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.move-number {
    color: #888;
    width: 40px;
}

.move-san {
    flex: 1;
}

.move-jump {
    display: inline;
    padding: 0 2px;
    margin: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    border-radius: 3px;
}

.move-jump:hover {
    background: rgba(154, 208, 255, 0.15);
}

.move-jump.is-current {
    background: rgba(233, 69, 96, 0.35);
    box-shadow: 0 0 0 1px rgba(233, 69, 96, 0.5);
}

.move-jump.is-future {
    opacity: 0.45;
}

.move-ply.move-white {
    color: #f0f0f0;
}

.move-ply.move-black {
    color: #9ad0ff;
}

.move-arrow {
    color: #888;
    font-size: 0.72rem;
    margin-left: 2px;
}

.move-check {
    color: #ffb347;
    font-size: 0.75rem;
    font-style: italic;
    margin-left: 2px;
}

.move-check.mate {
    color: #ff6b81;
    font-weight: 600;
}

.move-capture {
    color: #e94560;
}

/* Gestion des parties */
.games-panel {
    margin-bottom: 20px;
}

.games-header-row {
    display: none; /* remplacé par .panel-head */
}

.btn-erase-all {
    flex: 0 0 auto;
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #ffc9d4;
    background: rgba(233, 69, 96, 0.2);
    border: 1px solid rgba(233, 69, 96, 0.45);
    border-radius: 6px;
    cursor: pointer;
    text-transform: lowercase;
    white-space: nowrap;
}

.btn-erase-all:hover {
    background: rgba(233, 69, 96, 0.45);
    color: #fff;
}

.btn-new-game {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    padding: 6px 8px;
    background: linear-gradient(135deg, #e94560, #c23152);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 0;
    white-space: nowrap;
}

.btn-new-game:hover {
    background: linear-gradient(135deg, #c23152, #a82447);
}

.btn-stop-game {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #e8eef2;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.btn-stop-game:hover:not(:disabled) {
    background: rgba(233, 69, 96, 0.25);
    border-color: rgba(233, 69, 96, 0.55);
}

.btn-stop-game:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-invite {
    flex: 1 1 auto;
    padding: 6px 8px;
    background: linear-gradient(135deg, #3d7ea6, #2a5f82);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.btn-invite:hover {
    background: linear-gradient(135deg, #2a5f82, #1e4a6e);
}

.plan-banner {
    margin: 0 0 10px;
    padding: 6px 10px;
    font-size: 0.78rem;
    color: #9ad0ff;
    background: rgba(91, 159, 212, 0.12);
    border: 1px solid rgba(91, 159, 212, 0.28);
    border-radius: 6px;
}

.invite-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

body.guest-mode .sidebar,
body.guest-mode .user-bar-actions {
    display: none !important;
}

.new-game-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
}

.game-controls-top {
    margin: 0 0 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.auto-ai-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    font-size: 0.72rem;
    color: #c8d4dc;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.auto-ai-check input {
    margin: 0;
    accent-color: #e94560;
}

.auto-ai-check.is-active span {
    color: #9ad0ff;
}

.games-list {
    list-style: none;
    max-height: 150px;
    overflow-y: auto;
}

.game-item {
    padding: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}

.game-item:hover {
    background: rgba(255,255,255,0.1);
}

.game-info {
    flex: 1;
    min-width: 0;
}

.game-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.btn-replay-game {
    background: rgba(154, 208, 255, 0.15);
    color: #9ad0ff;
    border: 1px solid rgba(154, 208, 255, 0.4);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-replay-game:hover {
    background: rgba(154, 208, 255, 0.35);
    color: #fff;
}

.btn-delete {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
    border: 1px solid rgba(233, 69, 96, 0.4);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete:hover {
    background: rgba(233, 69, 96, 0.5);
    color: #fff;
}

/* Paramètres */
.settings-panel {
    margin-bottom: 12px;
}

.sidebar-user-bar.user-bar {
    margin: 0;
    padding: 6px 8px;
    gap: 8px;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.sidebar-top-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    margin: 10px 0 12px;
    width: 100%;
    height: 0;
    opacity: 1;
}

.sidebar-user-bar #userBarLabel {
    font-size: 0.78rem;
    color: #c8d4dc;
}

.sidebar-user-bar .btn-user {
    padding: 2px 7px;
    font-size: 0.72rem;
    line-height: 1.1;
    border-radius: 4px;
}

.settings-panel .panel-head {
    margin-bottom: 6px;
    padding-bottom: 4px;
}

.settings-panel label {
    display: block;
    font-size: 0.72rem;
    color: #aaa;
    margin-top: 0;
    line-height: 1.2;
}

.settings-panel select {
    width: 100%;
    padding: 3px 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #eee;
    border-radius: 4px;
    margin-top: 0;
    font-size: 0.78rem;
    min-height: 26px;
    line-height: 1.2;
}

.settings-panel select option.elo-locked,
.settings-panel select option:disabled,
.board-elo-select option.elo-locked,
.board-elo-select option:disabled {
    color: #5a6470;
    background-color: #1e2430;
}

.settings-panel select.has-locked-options,
.board-elo-select.has-locked-options {
    color-scheme: dark;
}

.settings-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
    margin-top: 6px;
}

.settings-row .settings-field {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(3.4rem, auto) 1fr;
    align-items: center;
    gap: 2px 6px;
}

.settings-row .settings-field label {
    margin-top: 0;
    white-space: nowrap;
}

.settings-row .settings-field select {
    min-width: 0;
}

.settings-field--wide {
    grid-template-columns: 1fr !important;
}

.settings-field--wide label {
    margin-bottom: 1px;
}

.scoreboard {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 2px;
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
}

.scoreboard-side {
    flex: 1;
    min-width: 72px;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.scoreboard-label {
    font-size: 0.68rem;
    color: #9aa8b5;
}

.scoreboard-side strong {
    font-size: 0.95rem;
    color: #e8eef4;
    line-height: 1;
}

.scoreboard-unit {
    font-size: 0.62rem;
    color: #777;
}

.btn-reset-score {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #9ad0ff;
    border-radius: 5px;
    padding: 3px 6px;
    font-size: 0.65rem;
    cursor: pointer;
    white-space: nowrap;
}

.btn-reset-score:hover {
    background: rgba(154, 208, 255, 0.12);
}

#eloRow .settings-field[hidden] {
    display: none !important;
}

.btn-export {
    width: 100%;
    padding: 5px 8px;
    margin-top: 6px;
    background: rgba(74, 144, 217, 0.3);
    color: #6bb5ff;
    border: 1px solid #4a90d9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-export:hover {
    background: rgba(74, 144, 217, 0.5);
}

/* Footer */
.footer {
    text-align: center;
    padding: 15px;
    color: #666;
    font-size: 0.8rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer a,
.footer .linkish {
    color: #8eb8d8;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.footer a:hover,
.footer .linkish:hover {
    color: #b8d9f0;
}

/* Modale Règles FIDE */
.fide-modal[hidden] {
    display: none !important;
}

.fide-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.fide-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.fide-modal-panel {
    position: relative;
    z-index: 1;
    width: min(640px, 100%);
    max-height: min(85vh, 720px);
    display: flex;
    flex-direction: column;
    background: #1a2332;
    border: 1px solid rgba(142, 184, 216, 0.35);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    color: #e8eef4;
}

.fide-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.fide-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.fide-modal-close {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.fide-modal-close:hover {
    color: #fff;
}

.fide-modal-body {
    padding: 14px 16px 18px;
    overflow-y: auto;
    font-size: 0.88rem;
    line-height: 1.45;
}

.stats-modal-panel {
    max-width: 720px;
    width: min(92vw, 720px);
}

.eco-ref-modal-panel {
    max-width: 760px;
    width: min(94vw, 760px);
}

.eco-ref-intro {
    margin: 0 0 10px;
    color: #c8d4dc;
    font-size: 0.88rem;
    line-height: 1.45;
}

.eco-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(55vh, 480px);
    overflow-y: auto;
    padding-right: 4px;
}

.eco-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
}

.eco-card.is-focused {
    border-color: rgba(154, 208, 255, 0.65);
    box-shadow: 0 0 0 1px rgba(154, 208, 255, 0.25);
}

.eco-card-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}

.eco-card-code {
    flex: 0 0 auto;
    font-family: ui-monospace, monospace;
    font-size: 0.78rem;
    font-weight: 700;
    color: #9ad0ff;
    background: rgba(154, 208, 255, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
}

.eco-card-title {
    margin: 0;
    font-size: 0.95rem;
    color: #e8eef4;
    font-weight: 600;
}

.eco-card-notes {
    margin: 0 0 6px;
    font-size: 0.84rem;
    color: #c8d4dc;
    line-height: 1.4;
}

.eco-card-uci {
    margin: 0 0 4px;
    font-size: 0.75rem;
    color: #9aa8b5;
}

.eco-card-uci span {
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.68rem;
}

.eco-card-uci code {
    color: #9ad0ff;
    word-break: break-all;
}

.eco-card-source {
    margin: 0;
    font-size: 0.72rem;
    color: #888;
}

.stats-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-stats-reset {
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    background: #a82447;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.btn-stats-reset:hover {
    background: #c23152;
}

.stats-loading,
.stats-empty {
    color: #aaa;
    font-size: 0.9rem;
}

.stats-intro {
    margin: 0 0 14px;
    padding: 10px 12px;
    background: rgba(154, 208, 255, 0.08);
    border: 1px solid rgba(154, 208, 255, 0.22);
    border-radius: 8px;
    font-size: 0.84rem;
    color: #c8d4dc;
    line-height: 1.45;
}

.stats-intro p {
    margin: 0 0 6px;
}

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

.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stats-overview-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    text-align: center;
}

.stats-overview-label {
    font-size: 0.68rem;
    color: #9aa3ad;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stats-overview-item strong {
    font-size: 1.15rem;
    color: #e8eef4;
}

.stats-overview-sub {
    font-size: 0.72rem;
    color: #888;
}

.stats-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stats-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
}

.stats-card--white {
    border-color: rgba(232, 238, 242, 0.15);
}

.stats-card--black {
    border-color: rgba(90, 159, 212, 0.25);
}

.stats-card h3 {
    font-size: 0.88rem;
    margin: 0 0 10px;
    color: #9ad0ff;
    line-height: 1.3;
}

.stats-metrics {
    margin: 0;
    display: grid;
    gap: 6px;
}

.stats-metrics div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 0.82rem;
    color: #c8d4dc;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.stats-metrics div:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stats-metrics dt {
    margin: 0;
    font-weight: 500;
    color: #aaa;
}

.stats-metrics dd {
    margin: 0;
    text-align: right;
}

.stats-section-title {
    font-size: 0.92rem;
    color: #e8eef4;
    margin: 0 0 6px;
    font-weight: 600;
}

.stats-help {
    font-size: 0.78rem;
    color: #9aa3ad;
    margin: 0 0 10px;
    line-height: 1.4;
}

.stats-footnote {
    font-size: 0.75rem;
    color: #888;
    margin: 12px 0 0;
    line-height: 1.4;
    font-style: italic;
}

.stats-meta {
    font-size: 0.8rem;
    color: #aaa;
    margin: 0 0 12px;
}

.stats-chart-wrap {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 6px;
}

.stats-chart-y {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.62rem;
    color: #777;
    padding: 8px 0 18px;
    flex-shrink: 0;
    width: 2.2rem;
    text-align: right;
}

.stats-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 110px;
    padding: 8px 0 0;
    flex: 1;
    min-width: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    overflow-x: auto;
}

.stats-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.stats-bar-label {
    font-size: 0.58rem;
    color: #777;
    line-height: 1;
}

.stats-bar-group {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    min-width: 12px;
    height: 90px;
    gap: 2px;
}

.stats-bar {
    width: 6px;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
}

.stats-bar.white {
    background: #e8eef2;
}

.stats-bar.black {
    background: #5a9fd4;
}

.stats-chart-legend {
    display: flex;
    gap: 14px;
    font-size: 0.72rem;
    color: #aaa;
    margin-bottom: 14px;
}

.stats-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

.stats-legend-swatch.white { background: #e8eef2; }
.stats-legend-swatch.black { background: #5a9fd4; }

.stats-table-wrap {
    max-height: 220px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.stats-table th,
.stats-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}

.stats-table th {
    position: sticky;
    top: 0;
    background: #16213e;
    color: #9ad0ff;
    font-weight: 600;
}

.stats-table tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 560px) {
    .stats-summary {
        grid-template-columns: 1fr;
    }

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

.fide-doc-note {
    margin: 0 0 12px;
    color: #a8b8c8;
    font-size: 0.82rem;
}

.fide-doc-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0 0 16px;
    font-size: 0.8rem;
}

.fide-doc-links a {
    color: #9ad0ff;
}

.fide-rule {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.fide-rule:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.fide-rule h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    color: #dce8f2;
}

.fide-rule-meta {
    margin: 0 0 6px;
    font-size: 0.75rem;
    color: #8aa0b4;
}

.fide-rule p {
    margin: 0 0 4px;
    color: #c5d0da;
}

.fide-rule .fide-detail {
    color: #9aa8b5;
    font-size: 0.8rem;
}

.fide-badge {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.fide-badge-auto {
    background: rgba(92, 219, 149, 0.2);
    color: #5cdb95;
}

.fide-badge-claim {
    background: rgba(255, 193, 97, 0.2);
    color: #ffc161;
}

.fide-badge-win {
    background: rgba(154, 208, 255, 0.2);
    color: #9ad0ff;
}

.fide-section-title {
    margin: 14px 0 8px;
    font-size: 0.92rem;
    color: #9ad0ff;
    font-weight: 600;
}

.fide-quote {
    margin: 8px 0;
    padding: 8px 10px;
    border-left: 3px solid #3d7ea6;
    background: rgba(61, 126, 166, 0.12);
    border-radius: 0 6px 6px 0;
    color: #c8d6e2;
    font-size: 0.78rem;
    line-height: 1.4;
    font-style: italic;
}

.fide-quote p {
    margin: 0 0 6px;
    color: #c8d6e2;
}

.fide-quote footer {
    font-style: normal;
    font-size: 0.7rem;
    color: #8aa0b4;
}

.fide-ref-link {
    margin: 4px 0 0;
    font-size: 0.78rem;
}

.fide-ref-link a {
    color: #9ad0ff;
    word-break: break-all;
    text-decoration: underline;
}

.game-end-panel {
    max-width: 520px;
}

.game-end-result {
    font-size: 1.05rem;
    margin: 0 0 8px;
}

.game-end-wins {
    margin: 0 0 8px;
    color: #5cdb95;
    font-weight: 600;
}

.game-end-scoreline {
    margin: 0 0 10px;
    font-size: 0.9rem;
    color: #c5d0da;
}

.game-end-scoreline strong {
    color: #fff;
}

.game-end-label {
    margin: 0 0 8px;
    color: #9ad0ff;
    font-weight: 600;
}

.game-end-summary {
    margin: 0 0 8px;
    color: #c5d0da;
}

.game-end-source {
    margin: 0 0 6px;
    font-size: 0.8rem;
    color: #8aa0b4;
}

.game-end-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
}

.btn-fide-link {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 6px;
    background: #3d7ea6;
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 0.85rem;
}

.btn-fide-link:hover {
    background: #4f96c2;
}

.btn-fide-secondary {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: transparent;
    color: #ddd;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-fide-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.fide-loading,
.fide-error {
    color: #aaa;
}

/* Plateau verrouillé (attente IA / coup en cours) */
#chessBoard.board-busy {
    cursor: wait !important;
    opacity: 0.92;
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.35);
}

/* Auth / prod — login plein écran (masque tout le reste) */
.auth-gate {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 99999 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    background: #0b1018;
    background-image:
        radial-gradient(1000px 520px at 12% -8%, rgba(91, 159, 212, 0.16), transparent 55%),
        radial-gradient(900px 500px at 100% 110%, rgba(30, 74, 110, 0.35), transparent 50%),
        linear-gradient(165deg, #0b1018 0%, #121a28 48%, #152238 100%);
    overflow: auto;
}
.auth-gate::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
    pointer-events: none;
}
.auth-gate[hidden] { display: none !important; }

.auth-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    animation: authEnter 0.45s ease-out;
}
@keyframes authEnter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.auth-brand {
    text-align: center;
    position: relative;
}
.auth-board-glow {
    position: absolute;
    left: 50%;
    top: 40%;
    width: min(320px, 90vw);
    height: 90px;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse, rgba(91, 159, 212, 0.22), transparent 70%);
    filter: blur(12px);
    pointer-events: none;
}

/* Titre encadré : ♞♔  Nom  ♕♞ */
.brand-title {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.55rem 0.75rem;
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--c-ivory);
    line-height: 1.1;
}
.brand-title-text {
    font-size: clamp(1.45rem, 4.2vw, 1.9rem);
    font-weight: 600;
    background: linear-gradient(115deg, #dce8f4 0%, #7eb3d9 48%, #3d7ea6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.28));
}
.title-flank {
    display: inline-flex;
    align-items: center;
    gap: 0.18em;
    line-height: 1;
    user-select: none;
}
.title-flank .piece-knight,
.title-flank .piece-king,
.title-flank .piece-queen {
    font-size: clamp(1.45rem, 3.8vw, 1.85rem);
    line-height: 1;
}
.title-flank .piece-knight {
    color: var(--c-blue-soft);
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
}
.title-flank .piece-king {
    color: #f2f6fa;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}
.title-flank .piece-queen {
    color: #1a2433;
    text-shadow:
        0 0 0 #c5d6e8,
        1px 0 0 #dce8f4,
        -1px 0 0 #dce8f4,
        0 1px 0 #dce8f4,
        0 -1px 0 #dce8f4;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}
.title-flank-start {
    border-right: 1px solid rgba(126, 179, 217, 0.35);
    margin-right: 0.1rem;
    padding-right: 0.65rem;
}
.title-flank-end {
    padding-left: 0.65rem;
    border-left: 1px solid rgba(126, 179, 217, 0.35);
    margin-left: 0.1rem;
}

.brand-title-header {
    font-size: 1rem;
    gap: 0.35rem 0.45rem;
}
.brand-title-header .brand-title-text {
    font-size: clamp(1rem, 2.2vw, 1.3rem);
    font-weight: 600;
}
.brand-title-header .title-flank .piece-knight,
.brand-title-header .title-flank .piece-king,
.brand-title-header .title-flank .piece-queen {
    font-size: 1.15rem;
}
.brand-title-header .title-flank-start {
    padding-right: 0.4rem;
}
.brand-title-header .title-flank-end {
    padding-left: 0.4rem;
}

.auth-brand-sub {
    margin: 10px 0 0;
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--c-muted);
}

@media (max-width: 600px) {
    /* Titre header : une seule ligne sur Android */
    .brand-title-header {
        flex-direction: row;
        flex-wrap: nowrap;
        white-space: nowrap;
        gap: 0.2rem 0.28rem;
        justify-content: center;
        max-width: 100%;
        overflow: hidden;
    }
    .brand-title-header .brand-title-text {
        font-size: 0.88rem;
        flex-shrink: 1;
        min-width: 0;
    }
    .brand-title-header .title-flank .piece-knight,
    .brand-title-header .title-flank .piece-king,
    .brand-title-header .title-flank .piece-queen {
        font-size: 0.95rem;
    }
    .brand-title-header .title-flank-start,
    .brand-title-header .title-flank-end {
        padding: 0 0.28rem;
        margin: 0;
        flex-shrink: 0;
    }
}

.auth-card {
    width: 100%;
    background: rgba(28, 28, 48, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 28px 26px 22px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(10px);
}
.auth-panel[hidden] { display: none !important; }
.auth-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--c-ivory);
}
.auth-sub {
    color: #8b93a7;
    margin: 0 0 20px;
    font-size: 0.92rem;
    line-height: 1.4;
}
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 14px;
    padding: 0;
    border: none;
    background: none;
    color: #7d879c;
    font-size: 0.82rem;
    cursor: pointer;
}
.auth-back:hover { color: #c5cddd; }

.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9aa3b5;
    margin-top: 8px;
}
.auth-form input,
.admin-form-row input,
.admin-form-row select {
    background: rgba(12, 12, 24, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #eee;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-form input::placeholder { color: #5c6578; }
.auth-form input:focus {
    outline: none;
    border-color: rgba(233, 69, 96, 0.55);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}
.btn-auth-primary {
    margin-top: 18px;
    font-family: var(--font-body);
    background: linear-gradient(180deg, var(--c-accent) 0%, var(--c-accent-deep) 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px 16px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(42, 95, 130, 0.3);
    transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-auth-primary:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}
.btn-auth-primary:active { transform: translateY(0); }

.auth-foot {
    margin: 18px 0 0;
    text-align: center;
    font-size: 0.8rem;
    color: #6d768a;
}
.auth-foot[hidden] { display: none !important; }
.auth-link-quiet {
    display: inline;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    color: #9aa8c0;
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(154, 168, 192, 0.35);
    text-underline-offset: 3px;
}
.auth-link-quiet:hover {
    color: #d0d7e6;
    text-decoration-color: rgba(208, 215, 230, 0.55);
}

.auth-error {
    color: #ff8a80;
    font-size: 0.88rem;
    margin-top: 10px;
    line-height: 1.35;
}
.auth-ok {
    color: #7dcea0;
    font-size: 0.88rem;
    margin-top: 10px;
    line-height: 1.35;
}
.auth-hint {
    color: #9aa8b5;
    font-size: 0.85rem;
    margin: 0 0 8px;
    line-height: 1.35;
}

@media (max-width: 480px) {
    .auth-card { padding: 22px 18px 18px; border-radius: 14px; }
    .auth-mark { font-size: 2.4rem; }
    .auth-brand-name { font-size: 1.5rem; }
}
.admin-row-pending {
    background: rgba(233, 169, 69, 0.12);
}
.admin-row-banned {
    background: rgba(233, 69, 96, 0.15);
}
.admin-badge-pending {
    color: #e9a945;
    font-weight: 600;
    font-size: 0.85rem;
}
.admin-badge-banned {
    color: #ff8a80;
    font-weight: 700;
    font-size: 0.85rem;
}
.admin-badge-ok {
    color: #7dcea0;
    font-size: 0.85rem;
}
.btn-admin-validate {
    background: #1b7a4a !important;
    border-color: #22965c !important;
}
.btn-admin-ban {
    background: #8a3a20 !important;
    border-color: #a84828 !important;
    color: #fff !important;
}
.btn-admin-danger {
    background: #6b1f2a !important;
    border-color: #8a2835 !important;
    color: #fff !important;
}
.admin-section-title {
    margin: 22px 0 6px;
    font-size: 1rem;
    color: #dce8f2;
}
.admin-section-hint {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: #8aa0b4;
}
.admin-ip {
    color: #8aa0b4;
    font-family: ui-monospace, monospace;
}
.user-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    font-size: 0.85rem;
    color: #bbb;
}

.user-bar #userBarLabel {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-bar-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.btn-user {
    background: #24304a;
    color: #eee;
    border: 1px solid #3a4a6a;
    border-radius: 5px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 0.78rem;
    line-height: 1.15;
    min-height: 0;
}
.btn-user[hidden] {
    display: none !important;
}
.btn-user-danger { border-color: #6a3030; background: #3a2020; }
.admin-create-form { margin-bottom: 18px; }
.admin-create-form h3 { margin-bottom: 8px; font-size: 1rem; }
.admin-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.admin-users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-users-table th, .admin-users-table td {
    border-bottom: 1px solid #333;
    padding: 8px 6px;
    text-align: left;
    vertical-align: top;
}
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-actions button {
    background: #24304a;
    color: #eee;
    border: 1px solid #3a4a6a;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Responsive — tablette / téléphone (Android & co.) */
@media (max-width: 900px) {
    .container {
        padding: 10px;
        gap: 12px;
        max-width: 100%;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        width: 100%;
        max-height: none;
    }

    .board-stage {
        width: 100%;
        max-width: 100%;
    }

    .board-with-eval {
        width: 100%;
        max-width: 100%;
        align-items: flex-start;
    }

    .board-area {
        flex: 1 1 auto;
        width: auto;
        max-width: calc(100% - var(--eval-col-width) - var(--board-gap));
        min-width: 0;
    }

    .board-canvas-wrap {
        width: 100%;
        height: auto;
        flex: 0 0 auto;
        aspect-ratio: 1;
    }

    .eval-bar-column {
        width: 32px;
        min-width: 32px;
        max-width: 32px;
        flex: 0 0 32px;
    }

    .eval-bar-vertical {
        width: 18px;
    }

    .eval-bar-pct {
        font-size: 0.5rem;
    }

    #chessBoard {
        border-width: 3px;
    }

    .header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 8px 14px;
        justify-content: center;
    }

    .header h1 {
        order: -1;
        width: 100%;
        text-align: center;
        font-size: 1.15rem;
    }

    .clock {
        flex: 1 1 100px;
        min-width: 0;
        padding: 3px 6px;
        border-radius: 5px;
    }

    .clock .player-name {
        font-size: 0.58rem;
        margin-bottom: 0;
    }

    .clock .time {
        font-size: 0.85rem;
        font-weight: 600;
    }

    .clock.unlimited .time {
        font-size: 0.88rem;
    }

    .board-section {
        padding: 10px;
        width: 100%;
    }

    .player-label {
        padding: 6px 2.75rem 6px 4px;
        font-size: 0.85rem;
    }

    .label-check-suffix .check-word {
        font-size: 0.58rem;
        padding: 0 1px;
    }

    .board-info {
        height: 2.1rem;
        min-height: 2.1rem;
        max-height: 2.1rem;
        padding: 0 8px;
        font-size: 0.82rem;
        gap: 6px;
    }

    .board-info #turnIndicator {
        max-width: 46%;
    }

    .auth-card {
        width: calc(100% - 24px);
        margin: 12px;
        max-width: 420px;
    }

    /* Zoom iOS : champs auth uniquement (pas toute la sidebar) */
    .auth-form input,
    .auth-form button {
        font-size: 16px;
        min-height: 36px;
    }

    .settings-panel select {
        font-size: 0.78rem;
        min-height: 26px;
        padding: 3px 6px;
    }

    /* Tous les boutons UI : compacts sur Android */
    .sidebar button,
    .game-controls-top button,
    .btn-new-game,
    .btn-stop-game,
    .btn-export,
    .btn-train,
    .btn-stats,
    .btn-eco-ref,
    .btn-reset-score,
    .btn-erase-all,
    .btn-collapse,
    .btn-replay,
    .btn-replay-exit,
    .btn-hint,
    .btn-hint-clear,
    .btn-undo,
    .btn-pause,
    .btn-fide-secondary,
    .btn-stats-reset,
    .admin-actions button {
        font-size: 0.72rem !important;
        min-height: 0 !important;
        height: auto;
        padding: 4px 8px;
        line-height: 1.2;
        border-radius: 5px;
    }

    .btn-collapse {
        padding: 2px 6px !important;
        font-size: 0.7rem !important;
    }

    .auto-ai-check {
        font-size: 0.72rem;
        gap: 4px;
    }

    .auto-ai-check input {
        width: 14px;
        height: 14px;
        min-height: 0;
    }

    /* Compte utilisateur (en tête de sidebar) */
    .sidebar-user-bar.user-bar {
        gap: 6px;
        font-size: 0.68rem;
        padding: 5px 6px;
        margin: 0;
    }

    .sidebar-top-divider {
        margin: 8px 0 10px;
    }

    .sidebar-user-bar #userBarLabel {
        font-size: 0.68rem;
    }

    .sidebar-user-bar .btn-user {
        font-size: 0.65rem !important;
        padding: 2px 5px;
    }

    /* Barre utilisateur legacy (si présente) */
    .user-bar {
        align-items: center;
        gap: 6px;
        font-size: 0.72rem;
        width: 100%;
    }

    .user-bar #userBarLabel {
        text-align: left;
        line-height: 1.15;
    }

    .user-bar-actions {
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 4px;
        width: auto;
        flex-shrink: 0;
    }

    .user-bar .btn-user {
        font-size: 0.68rem !important;
        min-height: 0 !important;
        height: auto;
        padding: 2px 6px;
        border-radius: 4px;
        line-height: 1.1;
        flex: 0 1 auto;
        white-space: nowrap;
    }

    /* ELO plateau : compact (hors règle 44px des formulaires) */
    .board-elo-caption {
        font-size: 0.6rem;
    }

    .board-elo-select {
        font-size: 0.68rem !important;
        min-height: 0 !important;
        height: auto;
        width: calc(5ch + 1rem);
        max-width: calc(5ch + 1rem);
        padding: 1px 12px 1px 3px;
        line-height: 1.15;
    }

    .fide-modal-panel {
        width: calc(100vw - 20px);
        max-width: 100%;
        max-height: 90vh;
        overflow: auto;
        margin: 10px auto;
    }
}

@media (max-width: 600px) {
    body {
        /* barre d’adresse mobile */
        min-height: 100dvh;
    }

    .container {
        padding: 6px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        gap: 8px;
    }

    .header {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "title title"
            "white black";
        align-items: stretch;
        border-radius: 8px;
        padding: 5px 8px;
        gap: 4px;
    }

    .header h1,
    .header .app-title {
        grid-area: title;
        order: unset;
        width: 100%;
        font-size: 0.88rem;
        line-height: 1.15;
        justify-content: center;
        flex-wrap: nowrap;
        white-space: nowrap;
    }

    .header .white-clock {
        grid-area: white;
    }

    .header .black-clock {
        grid-area: black;
    }

    .clock {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
        padding: 2px 6px;
        min-height: 0;
        min-width: 0;
        width: 100%;
        flex: unset;
        border-left-width: 2px;
        border-right-width: 2px;
        gap: 4px;
    }

    .clock .player-name {
        margin-bottom: 0;
        font-size: 0.55rem;
        line-height: 1.15;
        max-width: 58%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .clock .time {
        font-size: 0.78rem;
        font-weight: 600;
        letter-spacing: 0;
        font-variant-numeric: tabular-nums;
    }

    .clock.unlimited .time {
        font-size: 0.8rem;
    }

    .board-section {
        padding: 6px;
        border-radius: 8px;
    }

    .board-stage {
        width: 100%;
    }

    .board-with-eval {
        gap: 4px;
        max-width: none;
    }

    .board-area {
        flex: 1 1 auto;
        width: auto;
        max-width: calc(100% - 28px - 4px);
    }

    .board-canvas-wrap {
        width: 100%;
        height: auto;
        flex: 0 0 auto;
        aspect-ratio: 1;
    }

    .eval-bar-column {
        width: 28px;
        min-width: 28px;
        max-width: 28px;
        flex: 0 0 28px;
        gap: 2px;
    }

    .eval-bar-vertical {
        width: 14px;
    }

    .eval-bar-pct {
        font-size: 0.45rem;
    }

    #chessBoard {
        border-width: 2px;
    }

    .top-label-text,
    .bottom-label-text {
        font-size: 0.8rem;
    }

    .board-elo-wrap {
        gap: 2px;
        transform: scale(0.82);
        transform-origin: left center;
    }

    .board-elo-caption {
        font-size: 0.55rem;
    }

    .board-elo-select {
        font-size: 0.62rem !important;
        font-weight: 600;
        min-height: 0 !important;
        height: auto;
        width: calc(5ch + 0.95rem);
        max-width: calc(5ch + 0.95rem);
        padding: 0 12px 0 3px;
        background-size: 6px 3px;
        background-position: right 3px center;
        line-height: 1.15;
    }

    /* Sélecteurs ELO config (sidebar) */
    .settings-panel select#difficultyWhite,
    .settings-panel select#difficultyBlack {
        font-size: 0.72rem !important;
        padding: 2px 4px;
        min-height: 24px !important;
        max-width: 5rem;
    }

    .settings-panel label,
    .settings-row {
        font-size: 0.68rem;
    }

    .settings-row .settings-field {
        grid-template-columns: minmax(2.8rem, auto) 1fr;
        gap: 2px 4px;
    }

    .scoreboard {
        padding: 4px 6px;
        margin: 4px 0 2px;
    }

    .scoreboard-side strong {
        font-size: 0.85rem;
    }

    .sidebar h2 {
        font-size: 0.92rem;
    }

    .game-controls-top {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 5px;
        padding: 6px;
        margin-bottom: 8px;
    }

    .game-controls-top button,
    .btn-new-game,
    .btn-stop-game {
        flex: 1 1 auto;
        min-height: 0 !important;
        font-size: 0.68rem !important;
        padding: 4px 6px !important;
        white-space: nowrap;
    }

    .moves-list {
        max-height: 120px;
        -webkit-overflow-scrolling: touch;
    }

    .coach-float {
        bottom: max(12px, env(safe-area-inset-bottom));
        left: 8px;
        right: 8px;
    }

    .scoreboard {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Très petits écrans */
@media (max-width: 380px) {
    .header h1,
    .header .app-title {
        font-size: 0.78rem;
    }

    .brand-title-header .brand-title-text {
        font-size: 0.78rem;
    }

    .brand-title-header .title-flank .piece-knight,
    .brand-title-header .title-flank .piece-king,
    .brand-title-header .title-flank .piece-queen {
        font-size: 0.85rem;
    }

    .user-bar .btn-user {
        font-size: 0.68rem !important;
        padding: 2px 6px;
    }
}
