@font-face {
    font-family: 'BeyondWonderland';
    src: url('../assets/fonts/beyond-wonderland.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'MagicSchool';
    src: url('../assets/fonts/magic-school-one.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Junicode';
    src: url('../assets/fonts/junicode.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Junicode';
    src: url('../assets/fonts/junicode-italic.ttf') format('truetype');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'Junicode';
    src: url('../assets/fonts/junicode-bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

:root {
    --bg:           #1a1a2e;
    --bg-card:      #1f1f38;
    --bg-active:    #252545;
    --bg-chip:      #2a2a4a;
    --bg-btn:       #33336a;
    --bg-btn-hover: #44448a;
    --border:       #333355;
    --border-sub:   #444466;
    --border-btn:   #6666aa;
    --accent:       #8888cc;
    --text:         #cccccc;
    --text-bright:  #ffffff;
    --text-btn:     #ccccff;
}

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

body {
    background-color: var(--bg);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: sans-serif;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    padding: 20px 16px;
}

/* ============================================================
   ÉCRAN D'ACCUEIL
   ============================================================ */

#home-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg);
}

/* Bloc titre + crédit + règles (haut de page) */
#home-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

#home-title {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 700;
    color: #e07820;
    text-align: center;
    margin-top: 20px;
    letter-spacing: 0.05em;
    text-shadow:
        0 0 18px rgba(224, 120, 32, 0.55),
        0 2px 6px rgba(0, 0, 0, 0.6);
}

#home-credit {
    font-style: italic;
    color: #7a7a8a;
    font-size: 0.82rem;
    align-self: flex-end;
    margin-top: 4px;
    letter-spacing: 0.02em;
}

/* Boutons principaux — centrés verticalement dans l'écran */
#home-buttons {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

#btn-rules {
    background: transparent;
    border: none;
    color: #afafaf;
    font-family: 'Cormorant Garamond', 'Palatino Linotype', serif;
    font-style: italic;
    font-size: clamp(1rem, 2.8vw, 1.4rem);
    cursor: pointer;
    letter-spacing: 0.04em;
    padding: 4px 0;
    transition: color 0.2s, text-shadow 0.2s;
}
#btn-resume {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1rem, 3vw, 2rem);
    font-weight: 700;
    text-transform: lowercase;
    background: transparent;
    border: none;
    color: #e07820;
    cursor: pointer;
    letter-spacing: 0.05em;
    padding: 4px 0;
    transition: color 0.2s, text-shadow 0.2s;
    outline: none;
    text-shadow: 0 0 10px rgba(224, 120, 32, 0.30);
}
#btn-resume:hover {
    color: #ffaa44;
    text-shadow: 0 0 18px rgba(255, 170, 68, 0.55);
}

#btn-local,
#btn-online,
#btn-ai,
#btn-alpharogue,
#btn-ladder {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1rem, 3vw, 2rem);
    font-weight: 700;
    text-transform: lowercase;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    letter-spacing: 0.05em;
    padding: 4px 0;
    transition: color 0.2s, text-shadow 0.2s;
    outline: none;
    white-space: nowrap;
}

#btn-rules:hover,
#btn-local:hover,
#btn-online:hover,
#btn-alpharogue:hover,
#btn-ladder:hover {
    color: #e07820;
    text-shadow: 0 0 14px rgba(224, 120, 32, 0.45);
}

#btn-ai:disabled {
    color: #555566;
    cursor: default;
    opacity: 1; /* neutralise l'atténuation navigateur */
}

/* Séparé du groupe pour passer après :disabled dans la cascade */
#btn-ai:not(:disabled):hover {
    color: #e07820;
    text-shadow: 0 0 14px rgba(224, 120, 32, 0.45);
}

/* Ligne titre + icône paramètres */
#home-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Bouton Paramètres — icône roue dentée à droite du titre */
#btn-settings {
    background: transparent;
    border: none;
    color: #555577;
    font-size: clamp(1.3rem, 3.5vw, 2rem);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.2s, transform 0.3s;
}

#btn-settings:hover {
    color: #e07820;
    transform: rotate(45deg);
}

/* ============================================================
   ÉCRAN DES RÈGLES
   ============================================================ */

#rules-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg);
    padding: 24px 32px;
    overflow: hidden;
}

#rules-center {
    display: flex;
    position: relative;
    width: 100%;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    overflow: hidden;
}
#rules-title-row {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    position: relative;
}
#rules-title {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 700;
    color: #e07820;
    text-align: center;
    margin-top: 20px;
    letter-spacing: 0.05em;
    text-shadow:
        0 0 18px rgba(224, 120, 32, 0.55),
        0 2px 6px rgba(0, 0, 0, 0.6);
}
#rules-scrollable {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    scrollbar-color: rgb(231, 116, 8) #1a1a2e;
    scrollbar-width: thin;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding-bottom: 40px;
}

#rules-description-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
    width: 80%;
}

#rules-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    width: 80%;
}

#rules-content p {
    font-family: 'Junicode', serif;
    font-size: clamp(0.88rem, 1.8vw, 1.02rem);
    color: #b08a62;
    text-align: justify;
    line-height: 1.7;
    margin: 0;
}

#rules-content p:first-child {
    font-style: italic;
    color: #c49a72;
}
.rules-description-card-body {
    background: var(--bg-card);
    border-radius: 8px;
    display: flex;
    padding: 16px;
    padding-top: 28px;
    flex-direction: row;
    gap: 12px;
    align-items: center;
    position: relative;
}
.rules-description-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 8px 16px;
    flex-direction: column;
    gap: 4px;
    display: flex;
    flex: 1;
}
.rules-description-card-icon {
    background: var(--bg);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 110px;
    height: 110px;
}

.rules-piece-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(255, 200, 80, 0.25));
}
.rules-title {
    font-family: 'Metamorphous', cursive; /* alt: 'Uncial Antiqua' */
    font-size: clamp(1.05rem, 2.4vw, 1.35rem);
    color: var(--text);
    margin: 0 0 4px;
    text-align: left;
    line-height: 1.35;
    letter-spacing: 0.02em;
}

.rules-description {
    font-family: 'Junicode', serif;
    font-size: clamp(0.70rem, 1.5vw, 0.82rem);
    color: var(--text);
    text-align: left;
    line-height: 1.4;
    margin: 0;
}

.rules-exemple {
    color: rgba(130, 120, 170, 0.55);
    font-style: italic;
    font-size: clamp(0.70rem, 1.5vw, 0.82rem);
    text-align: center;
    line-height: 1.7;
    letter-spacing: 0.01em;
}

/* ── Diagrammes de mouvement ───────────────────────────────── */
.rules-diagram-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 4px 12px;
    background: none;
    border: 1px solid rgba(224, 120, 32, 0.35);
    border-radius: 4px;
    color: rgba(224, 120, 32, 0.75);
    font-family: 'Metamorphous', cursive;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.rules-diagram-toggle:hover {
    background: rgba(224, 120, 32, 0.08);
    border-color: rgba(224, 120, 32, 0.6);
    color: #e07820;
}
.rules-diagram-toggle.active {
    background: rgba(224, 120, 32, 0.12);
    border-color: #e07820;
    color: #e07820;
}
.rules-diagram-section {
    display: none;
}
.rules-diagram-row {
    margin-top: 14px;
    margin-bottom: 4px;
}
.rules-diagram-label {
    font-family: 'Metamorphous', cursive;
    font-size: 0.68rem;
    color: #e07820;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}
.rules-diagram-panels {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}
.rules-diagram-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.rules-diagram-panel-title {
    font-family: 'Junicode', serif;
    font-size: 0.60rem;
    color: rgba(180, 155, 115, 0.80);
    text-align: center;
}

/* ── Badge valeur ──────────────────────────────────────────── */
.rules-value-badge {
    position: absolute;
    top: 7px;
    right: 10px;
    font-family: 'MagicSchool', cursive;
    font-size: clamp(0.92rem, 2vw, 1.12rem);
    color: #e07408;
    background: rgba(224, 116, 8, 0.12);
    border: 1px solid rgba(224, 116, 8, 0.35);
    border-radius: 4px;
    padding: 2px 8px;
    letter-spacing: 0.03em;
}

/* ── Barre de filtre Pièces Spéciales ──────────────────────── */
#rules-filter-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 16px;
    margin-bottom: 4px;
}

.rules-filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.rules-filter-label input[type="checkbox"] {
    display: none;
}

.rules-filter-track {
    display: inline-block;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--bg-chip);
    border: 1px solid var(--border-btn);
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.rules-filter-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    transition: transform 0.2s;
}

.rules-filter-label input[type="checkbox"]:checked ~ .rules-filter-track {
    background: rgba(224, 116, 8, 0.3);
    border-color: #e07408;
}

.rules-filter-label input[type="checkbox"]:checked ~ .rules-filter-track::after {
    transform: translateX(16px);
    background: #e07408;
}

.rules-filter-text {
    font-family: 'Junicode', serif;
    font-size: clamp(0.70rem, 1.4vw, 0.80rem);
    color: var(--text);
}

#btn-rules-back {
    position: absolute;
    top: 16px;
    right: 20px;
}

/* ============================================================
   ÉCRAN DE SAISIE DU NOM
   ============================================================ */

#name-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    background-color: var(--bg);
}

#name-title {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1.2rem, 4vw, 2.2rem);
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.06em;
}

#name-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

#name-input {
    background: var(--bg-active);
    border: 1px solid var(--border-sub);
    border-radius: 6px;
    color: var(--text-bright);
    font-size: 1.1rem;
    padding: 10px 16px;
    outline: none;
    width: min(260px, calc(100vw - 120px));
    transition: border-color 0.15s;
    letter-spacing: 0.03em;
    font-family: sans-serif;
}

#name-input:focus {
    border-color: var(--accent);
}

#name-confirm-btn {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
    border-radius: 6px;
    padding: 10px 22px;
    font-size: 1rem;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

#name-confirm-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

/* ============================================================
   ÉCRAN DES PARAMÈTRES
   ============================================================ */

#settings-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 32px;
    background-color: var(--bg);
    padding: 24px 32px;
    overflow-y: auto;
}

#settings-header {
    display: flex   ;
    align-items: center;
    justify-content: center;
    position: relative;
}

#settings-header h2 {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1.5rem, 6vw, 3rem);
    font-weight: 700;
    color: #e07820;
    text-align: center;
    margin-top: 20px;
    letter-spacing: 0.05em;
    text-shadow:
        0 0 18px rgba(224, 120, 32, 0.55),
        0 2px 6px rgba(0, 0, 0, 0.6);
}

.settings-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.settings-section-title {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Profil d'échiquier sélectionné */
.profile-card.selected button {
    border-color: var(--accent);
    background: #2a2a5a;
    color: var(--text-bright);
}

/* --- Profil des pièces --- */

#piece-profile-list {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.piece-profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.piece-profile-card.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.piece-profile-card button {
    background: var(--bg-chip);
    color: var(--text);
    border: 1px solid var(--border-sub);
    border-radius: 8px;
    padding: 14px 32px;
    font-size: 1rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    width: 100%;
}

.piece-profile-card:not(.disabled) button:hover {
    background: #3a3a6a;
    border-color: var(--accent);
}

.piece-profile-card.selected button {
    border-color: var(--accent);
    background: #2a2a5a;
    color: var(--text-bright);
}

/* Aperçu des pièces */
.piece-preview {
    display: flex;
    gap: 4px;
    align-items: center;
}

.piece-preview-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.piece-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: bold;
    font-family: sans-serif;
    flex-shrink: 0;
}

.piece-circle.white {
    background: rgba(255, 255, 255, 0.92);
    color: #333333;
    border: 1.5px solid #888888;
}

.piece-circle.black {
    background: rgba(25, 25, 25, 0.92);
    color: #eeeeee;
    border: 1.5px solid #cccccc;
}

#board-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    width: fit-content;
}

#game-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
}

#game-move-counter {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: var(--text-muted, #888);
    pointer-events: none;
}

/* Dans le game-header, le bouton est en flux normal (pas de label centré à préserver) */
#game-header .quit-btn {
    position: static;
}

/* --- Barres joueurs --- */

.player-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--bg-card);
    /* width:0 + min-width:100% : ne contribue PAS à la largeur intrinsèque de
       #board-container (fit-content), donc seul le canvas la détermine.
       La barre prend ensuite toute cette largeur sans jamais l'élargir. */
    width: 0;
    min-width: 100%;
    overflow: hidden;
}

.player-bar.active {
    background: var(--bg-active);
}

/* Ligne principale : indicateur + nom + score */
.player-bar-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.player-name {
    color: var(--text);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* En mode IA : le nom peut passer sur plusieurs lignes (la barre grandit en hauteur) */
#board-container.vs-ai .player-name {
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: clip;
}

.player-bar.active .player-name {
    color: var(--text-bright);
    font-weight: 600;
}

/* Avantage matériel — inline après les pièces capturées */
.player-score {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    padding-left: 2px;
    align-self: center;
    flex-shrink: 0;
}

.player-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-sub);
    flex-shrink: 0;
}

.player-bar.active .player-indicator {
    background: var(--accent);
}

/* Pièces capturées */
.player-captures {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding-left: 20px; /* aligne avec le nom (après l'indicateur) */
    min-height: 0;
}

.player-captures:empty {
    display: none;
}

.captured-piece-img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    opacity: 0.80;
}

/* Échec : barre du joueur en danger passe au rouge */
.player-bar.in-check {
    background: rgba(180, 40, 40, 0.30);
    border: 1px solid rgba(255, 80, 80, 0.50);
}

.player-bar.in-check .player-name {
    color: #ff9999;
    font-weight: 600;
}

.player-bar.in-check .player-indicator {
    background: #ff5555;
    box-shadow: 0 0 6px #ff5555;
}

/* Bandeau statut de jeu (échec, nulle…) */
#game-status {
    display: none;
    width: 100%;
    text-align: center;
    padding: 5px 0;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    color: #ff9999;
    background: rgba(180, 40, 40, 0.18);
    border-radius: 4px;
    animation: pulse-check 1.4s ease-in-out infinite;
}

#game-status.visible {
    display: block;
}

/* Bannière de déconnexion adverse */
#disconnect-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 7px 12px;
    box-sizing: border-box;
    background: rgba(180, 100, 20, 0.22);
    border: 1px solid rgba(240, 150, 40, 0.50);
    border-radius: 4px;
    color: #f0b060;
    font-size: 0.88rem;
}

#disconnect-text {
    flex: 1;
}

#disconnect-claim-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    background: rgba(220, 100, 30, 0.30);
    border: 1px solid rgba(240, 130, 40, 0.60);
    border-radius: 4px;
    color: #f0b060;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s;
}

#disconnect-claim-btn:hover {
    background: rgba(220, 100, 30, 0.55);
}

@keyframes pulse-check {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

#board-canvas-wrap {
    position: relative; /* ancre pour le picker absolu */
    line-height: 0;     /* supprime l'espace résiduel sous le canvas inline */
    flex-shrink: 0;
}

#board-canvas {
    display: block;
}

/* --- Panneau fin de partie --- */

#game-over-panel {
    display: none; /* flex via JS */
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(15, 15, 35, 0.92);
    border: 1px solid var(--border-btn);
    border-radius: 6px;
    width: 100%;
}

#game-over-text {
    color: var(--text-bright);
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.03em;
}

#game-over-code,
#game-over-code-dynamic,
#game-over-code-normal-diff,
#game-over-code-hard-diff,
#game-over-code-impossible-diff,
#game-over-code-final {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: rgba(30, 60, 30, 0.55);
    border: 1px solid rgba(100, 200, 80, 0.35);
    border-radius: 6px;
    width: 100%;
}

.game-over-code-label {
    font-size: 0.82rem;
    color: #a0d090;
    letter-spacing: 0.03em;
    text-align: center;
}

.game-over-code-value {
    font-size: clamp(0.9rem, 3.5vw, 1.4rem);
    font-weight: bold;
    color: #c8f0a0;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(160, 255, 100, 0.55);
}

/* ─── Section de sauvegarde post-partie ─── */
#game-over-save {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 10px 0 4px;
    border-top: 1px solid rgba(212,165,32,0.18);
    margin-top: 4px;
}
.go-save-title {
    font-size: 0.78rem;
    color: rgba(212,165,32,0.70);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
}
.go-save-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(212,165,32,0.18);
    border-radius: 6px;
    padding: 8px 10px;
}
.go-save-player-name {
    font-size: 0.82rem;
    color: #c8c0b0;
    font-weight: 600;
}
.go-save-pieces {
    font-size: 0.72rem;
    color: rgba(180,175,160,0.65);
    line-height: 1.4;
}
.go-save-row {
    display: flex;
    gap: 6px;
}
.go-save-row input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(212,165,32,0.3);
    border-radius: 4px;
    color: #e0d8c8;
    font-size: 0.8rem;
    padding: 4px 8px;
    outline: none;
}
.go-save-row input:focus { border-color: rgba(212,165,32,0.65); }
.go-save-btn {
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid rgba(212,165,32,0.4);
    background: rgba(212,165,32,0.1);
    color: #d4a520;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
}
.go-save-btn:hover { background: rgba(212,165,32,0.22); }
.go-save-skip-btn {
    background: none;
    border: none;
    color: rgba(180,175,160,0.45);
    font-size: 0.72rem;
    cursor: pointer;
    text-align: center;
    padding: 2px 0;
}
.go-save-skip-btn:hover { color: rgba(180,175,160,0.75); }
.go-save-done {
    font-size: 0.75rem;
    color: rgba(212,165,32,0.70);
    text-align: center;
    font-style: italic;
}

#badge-btn {
    padding: 8px 20px;
    border-radius: 5px;
    border: 1px solid rgba(212, 165, 32, 0.55);
    background: rgba(212, 165, 32, 0.12);
    color: #d4a520;
    font-size: 0.9rem;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 0.18s, border-color 0.18s;
    width: 100%;
}
#badge-btn:hover {
    background: rgba(212, 165, 32, 0.22);
    border-color: rgba(212, 165, 32, 0.85);
}

/* Animation de mise en valeur du bouton badge à l'apparition */
@keyframes badge-pulse-anim {
    0%   { box-shadow: 0 0  0   0   rgba(212,165,32,0.00); transform: scale(1.00); }
    25%  { box-shadow: 0 0 14px 4px rgba(212,165,32,0.65); transform: scale(1.04); }
    55%  { box-shadow: 0 0 22px 6px rgba(212,165,32,0.45); transform: scale(1.02); }
    80%  { box-shadow: 0 0 10px 3px rgba(212,165,32,0.30); transform: scale(1.01); }
    100% { box-shadow: 0 0  6px 2px rgba(212,165,32,0.20); transform: scale(1.00); }
}
#badge-btn.badge-pulse {
    animation: badge-pulse-anim 1.6s ease-out forwards;
}

#game-over-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

#replay-start-btn,
#home-btn {
    border-radius: 5px;
    padding: 7px 20px;
    font-size: 0.88rem;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: background 0.18s, border-color 0.18s;
}

#replay-start-btn {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
}

#replay-start-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

#home-btn {
    background: transparent;
    color: #8888aa;
    border: 1px solid #444466;
}

#home-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-color: #666688;
}

/* --- Barre de navigation replay --- */

#replay-nav {
    display: none; /* flex via JS */
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 6px 0;
    width: 100%;
}

#replay-counter {
    color: var(--accent);
    font-size: 0.85rem;
    min-width: 120px;
    text-align: center;
    letter-spacing: 0.03em;
}

#replay-prev,
#replay-next,
#replay-exit {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1.6;
}

#replay-prev:hover,
#replay-next:hover {
    background: var(--bg-btn-hover);
}

#replay-exit {
    padding: 4px 10px;
    color: #aaaaaa;
    border-color: #555577;
}

#replay-exit:hover {
    background: #3a2a2a;
    color: #ffaaaa;
    border-color: #885555;
}

#replay-prev:disabled,
#replay-next:disabled {
    opacity: 0.35;
    cursor: default;
}

/* --- Écran de draft --- */

#draft-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    gap: 20px;
}

#draft-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#draft-turn-label {
    color: var(--text-bright);
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

#draft-explanation {
    color: #aaaacc;
    font-size: 0.82rem;
    text-align: center;
    line-height: 1.5;
    margin: 0;
    padding: 0 8px;
}

#draft-layout {
    display: grid;
    grid-template-columns: 1fr 200px 1fr;
    gap: 16px;
    align-items: start;
}

/* Armées joueurs */

.draft-army {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
}

.draft-army.active {
    opacity: 1;
    border-color: var(--accent);
}

.draft-army.done {
    opacity: 0.4;
}

.draft-army-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.draft-army-name {
    color: var(--text-bright);
    font-size: 0.95rem;
    font-weight: 600;
    flex: 1;
}

.draft-army-budget {
    color: var(--accent);
    font-size: 0.85rem;
}

.draft-army-count {
    color: #888888;
    font-size: 0.8rem;
}

.draft-army-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.draft-piece-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-chip);
    color: var(--text);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.78rem;
    border: 1px solid var(--border-sub);
}

.draft-chip-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.draft-piece-chip.king {
    border-color: var(--accent);
    color: #aaaaee;
}

.draft-done-tag {
    color: #666688;
    font-size: 0.78rem;
    text-align: center;
    font-style: italic;
}

.draft-finish-btn {
    margin-top: 8px;
    width: 100%;
    padding: 7px 12px;
    background: linear-gradient(135deg, #2a6e2a, #1e4e1e);
    border: 1px solid rgba(80, 200, 80, 0.45);
    border-radius: 6px;
    color: #a0f0a0;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s;
}
.draft-finish-btn:hover {
    background: linear-gradient(135deg, #348034, #255225);
    border-color: rgba(80, 200, 80, 0.75);
}

/* Catalogue central */

#draft-center {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#draft-replay-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: var(--bg-active);
    border: 1px solid #555588;
    border-radius: 6px;
    padding: 8px 10px;
}

#draft-replay-banner:empty {
    display: none;
}

.replay-label {
    color: #aaaacc;
    font-size: 0.82rem;
}

#draft-catalog {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.draft-catalog-item {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    gap: 8px;
    transition: border-color 0.15s;
}

.draft-catalog-item:not(.disabled):hover {
    border-color: var(--border-btn);
}

.draft-catalog-item.disabled {
    opacity: 0.35;
}

.catalog-label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    color: var(--text);
    font-size: 0.9rem;
}

.catalog-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.catalog-value {
    color: var(--accent);
    font-size: 0.82rem;
    min-width: 36px;
    text-align: right;
}

.catalog-buy-btn {
    background: var(--bg-btn);
    color: var(--text-bright);
    border: none;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s;
}

.catalog-buy-btn:hover:not(:disabled) {
    background: #5555aa;
}

.catalog-buy-btn:disabled {
    background: #222233;
    cursor: default;
}

/* --- Boutons secondaires (styles partagés) --- */

.replay-btn,
.save-btn {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.replay-btn:hover,
.save-btn:hover {
    background: var(--bg-btn-hover);
}

.replay-btn {
    padding: 3px 10px;
    font-size: 0.82rem;
}

.save-btn {
    padding: 6px 14px;
    font-size: 0.88rem;
    white-space: nowrap;
}

.save-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* --- Écran de sauvegarde du draft --- */

#save-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
    max-width: 600px;
}

#save-title {
    color: var(--text);
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

#save-players {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.save-player-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.save-player-name {
    color: var(--text-bright);
    font-size: 0.95rem;
    font-weight: 600;
}

.save-player-pieces {
    color: #888899;
    font-size: 0.8rem;
    line-height: 1.5;
}

.save-player-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.save-player-row input {
    flex: 1;
    background: var(--bg-active);
    border: 1px solid var(--border-sub);
    border-radius: 4px;
    color: var(--text);
    padding: 6px 10px;
    font-size: 0.88rem;
    outline: none;
}

.save-player-row input:focus {
    border-color: var(--accent);
}

.save-skip-btn {
    background: none;
    border: none;
    color: #666688;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.save-skip-btn:hover {
    color: #9999bb;
}

.save-done-label {
    color: #6688aa;
    font-size: 0.82rem;
    font-style: italic;
}

#save-launch-btn {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
    border-radius: 8px;
    padding: 12px 32px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    display: none;
}

#save-launch-btn.visible {
    display: block;
}

#save-launch-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

/* --- Écran d'attente adversaire (mode en ligne, après placement) --- */

#placement-wait-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    width: 100%;
    min-height: 50vh;
}

/* --- Écran de placement --- */

#placement-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    gap: 20px;
}

#placement-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#placement-turn-label {
    color: var(--text-bright);
    font-size: 1.3rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* --- Sélecteur de promotion --- */

#promotion-picker {
    /* Overlay flottant centré sur le canvas */
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    z-index: 10;

    display: none; /* flex via JS */
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(15, 15, 35, 0.95);
    border: 1px solid var(--border-btn);
    border-radius: 6px;
}

.promotion-label {
    color: var(--text-bright);
    font-size: 0.95rem;
    text-align: center;
    letter-spacing: 0.03em;
}

.promotion-btns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.promotion-btn {
    padding: 8px 22px;
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: background 0.18s, border-color 0.18s;
}

.promotion-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

/* Bouton Quitter (draft + placement) */
.quit-btn {
    position: absolute;
    right: 0;
    padding: 6px 14px;
    background: transparent;
    color: var(--text-muted, #888);
    border: 1px solid var(--text-muted, #888);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.quit-btn:hover {
    color: #e05555;
    border-color: #e05555;
    background: rgba(224, 85, 85, 0.08);
}

#placement-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: center;
}

#placement-canvas {
    display: block;
    flex-shrink: 0;
}

.placement-army {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
    flex: 0 0 160px;
}

.placement-army.active {
    opacity: 1;
    border-color: var(--accent);
}

.placement-army-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.placement-army-name {
    color: var(--text-bright);
    font-size: 0.95rem;
    font-weight: 600;
    flex: 1;
}

.placement-army-progress {
    color: var(--accent);
    font-size: 0.85rem;
}

.placement-piece-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.placement-piece-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-chip);
    color: var(--text);
    border: 1px solid var(--border-sub);
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.85rem;
    cursor: default;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.placement-army.active .placement-piece-chip {
    cursor: pointer;
}

.placement-army.active .placement-piece-chip:hover {
    border-color: var(--border-btn);
}

.placement-piece-chip.selected {
    border-color: var(--accent);
    border-left: 3px solid var(--accent);
    background: #2a2a5a;
    color: var(--text-bright);
    box-shadow: 0 0 6px rgba(100, 120, 255, 0.35);
}

/* Ghost cursor — pièce transparente qui suit la souris pendant le placement */
#placement-ghost {
    position: fixed;
    width: 64px;
    height: 64px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    display: none;
}

.placement-count-badge {
    color: var(--accent);
    font-size: 0.78rem;
    margin-left: auto;
}

.placement-done-tag {
    color: #666688;
    font-size: 0.78rem;
    text-align: center;
    font-style: italic;
}

/* --- Panneau confirmation reprise de pièce (placement non-secret) --- */

#placement-takeback-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(15, 15, 35, 0.92);
    border: 1px solid var(--border-btn);
    border-radius: 6px;
    width: 100%;
}

#placement-takeback-text {
    color: var(--text);
    font-size: 0.9rem;
    text-align: center;
    letter-spacing: 0.02em;
}

#placement-takeback-actions {
    display: flex;
    gap: 10px;
}

#placement-takeback-yes,
#placement-takeback-no {
    border-radius: 5px;
    padding: 7px 20px;
    font-size: 0.88rem;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: background 0.15s, border-color 0.15s;
}

#placement-takeback-yes {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
}

#placement-takeback-yes:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

#placement-takeback-no {
    background: transparent;
    color: #8888aa;
    border: 1px solid #444466;
}

#placement-takeback-no:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-color: #666688;
}

/* --- Écran de sélection de profil --- */

#profile-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

#profile-screen h1 {
    color: var(--text);
    font-size: 1.6rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

#profile-list {
    display: flex;
    gap: 32px;
}

.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.profile-card button {
    background: var(--bg-chip);
    color: var(--text);
    border: 1px solid var(--border-sub);
    border-radius: 8px;
    padding: 14px 32px;
    font-size: 1rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    width: 100%;
}

.profile-card button:hover {
    background: #3a3a6a;
    border-color: var(--accent);
}

.profile-swatches {
    display: flex;
    gap: 8px;
}

.swatch {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.15);
}

/* ============================================================
   TOGGLE PARAMÈTRES
   ============================================================ */

.settings-toggle-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.settings-toggle-label {
    color: var(--text);
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.toggle-btn {
    position: relative;
    width: 48px;
    height: 26px;
    border-radius: 13px;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    background: var(--border-sub);
    transition: background 0.25s;
    padding: 0;
}

.toggle-btn.on {
    background: var(--accent);
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    transition: transform 0.25s;
    pointer-events: none;
}

.toggle-btn.on .toggle-thumb {
    transform: translateX(22px);
}

/* ============================================================
   ANIMATIONS PARTIE — BASCULE DU PLATEAU
   ============================================================ */

@keyframes board-flip {
    0%   { transform: perspective(800px) rotateX(0deg);  }
    50%  { transform: perspective(800px) rotateX(90deg); }
    100% { transform: perspective(800px) rotateX(0deg);  }
}

#board-canvas.board-flipping {
    animation: board-flip 1s ease-in-out;
}

@keyframes name-pulse {
    0%   { font-size: 0.95rem; font-weight: 400; }
    45%  { font-size: 1.45rem; font-weight: 700; color: var(--text-bright); }
    100% { font-size: 0.95rem; font-weight: 400; }
}

.player-name.name-pulse {
    animation: name-pulse 0.75s ease-in-out;
    display: inline-block;
}

/* ── Bulle de bande dessinée E4D3 ────────────────────────── */
.e4d3-bubble {
    position: relative;
    display: none;
    background: #ffffff;
    color: #1a1a2e;
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    font-style: italic;
    line-height: 1.35;
    padding: 5px 10px;
    border-radius: 10px;
    border: 1.5px solid #c8922a;
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    /* queue pointant à gauche vers le nom */
    margin-left: 10px;
}
.e4d3-bubble::before,
.e4d3-bubble::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    pointer-events: none;
}
.e4d3-bubble::before {
    left: -13px;
    border-right-color: #c8922a;
}
.e4d3-bubble::after {
    left: -10px;
    border-right-color: #ffffff;
}
.e4d3-bubble.visible {
    display: block;
    animation: e4d3-pop-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.e4d3-bubble.hiding {
    display: block;
    animation: e4d3-fade-out 0.35s ease-in forwards;
}
@keyframes e4d3-pop-in {
    from { opacity: 0; transform: scale(0.6) translateX(-8px); }
    to   { opacity: 1; transform: scale(1)   translateX(0);    }
}
@keyframes e4d3-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ---- Draft ≤ 600px : catalogue pleine largeur en haut, armées côte à côte en dessous ---- */
@media (max-width: 600px) {
    #draft-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "catalog catalog"
            "army0   army1";
        gap: 12px;
    }

    #draft-center { grid-area: catalog; }
    #draft-army-0 { grid-area: army0; }
    #draft-army-1 { grid-area: army1; }

    /* Armées plus compactes */
    .draft-army { padding: 10px; gap: 8px; }

    /* Catalogue plus compact */
    .draft-catalog-item { padding: 6px 8px; gap: 6px; }
    .catalog-label { font-size: 0.85rem; }
}

/* ---- Placement ≤ 1050px : canvas en haut, armées côte à côte en dessous ---- */
@media (max-width: 1050px) {
    #placement-layout {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    #placement-canvas {
        order: 1;
    }

    .placement-army {
        flex: 1 1 160px;
        max-width: 280px;
        order: 2;
    }
}

/* ---- Partie en cours ≤ 380px : compteur replay plus compact ---- */
@media (max-width: 380px) {
    #replay-counter {
        min-width: 80px;
        font-size: 0.78rem;
    }

    #replay-prev,
    #replay-next,
    #replay-exit {
        padding: 4px 8px;
    }
}

/* ============================================================
   ÉCRAN LOBBY EN LIGNE
   ============================================================ */

#online-lobby-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    gap: 32px;
    padding: 40px 24px;
    overflow-y: auto;
}

.lobby-title {
    font-family: 'Cinzel Decorative', serif;
    color: var(--accent);
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: 400;
    letter-spacing: 0.06em;
}

#lobby-sections {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
    flex-wrap: wrap;
    justify-content: center;
}

.lobby-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 180px;
}

.lobby-section h3 {
    color: var(--text-bright);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.lobby-hint {
    color: #777799;
    font-size: 0.78rem;
    text-align: center;
    max-width: 200px;
    line-height: 1.4;
}

.lobby-divider {
    color: #444466;
    font-size: 0.9rem;
    padding-top: 32px;
}

#lobby-create-btn,
#lobby-join-btn {
    padding: 10px 28px;
    background: var(--bg-btn);
    border: 1px solid var(--border-btn);
    border-radius: 8px;
    color: var(--text-btn);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

#lobby-create-btn:hover,
#lobby-join-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

#lobby-create-btn:disabled,
#lobby-join-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

#lobby-code-input {
    width: 140px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-bright);
    font-size: 1.2rem;
    letter-spacing: 0.18em;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.15s;
}

#lobby-code-input:focus {
    border-color: var(--accent);
}

#lobby-waiting {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#lobby-waiting-host,
#lobby-waiting-guest {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#lobby-share-btn {
    font-size: 0.95rem;
    padding: 8px 20px;
    background: transparent;
    border: 1px solid #e07820;
    color: #e07820;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

#lobby-share-btn:hover {
    background: #e07820;
    color: #000;
}

#lobby-room-code {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-family: 'Courier New', monospace;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: #e07820;
    text-shadow: 0 0 18px rgba(224, 120, 32, 0.45);
    user-select: all;
}

.lobby-spin-msg {
    color: #6666aa;
}

/* Message d'attente dans le catalogue de draft (mode en ligne) */
.draft-waiting-msg {
    color: rgba(200, 155, 60, 0.75);
    font-style: italic;
    text-align: center;
    padding: 2.5rem 1rem;
    font-size: 0.9rem;
}

/* Spinner tournant */
.lobby-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #333355;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: lobby-spin 0.9s linear infinite;
}

@keyframes lobby-spin {
    to { transform: rotate(360deg); }
}

#lobby-error-msg {
    color: #e05555;
    font-size: 0.85rem;
    background: rgba(200, 50, 50, 0.1);
    border: 1px solid rgba(200, 50, 50, 0.3);
    border-radius: 6px;
    padding: 8px 16px;
    text-align: center;
}

/* Repositionner le bouton retour en haut à droite */
#online-lobby-screen > .quit-btn {
    position: absolute;
    top: 16px;
    right: 20px;
}

/* ============================================================
   ÉCRAN DE PASSATION (placement secret en local)
   ============================================================ */

#handover-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background-color: var(--bg);
}

#handover-subtitle {
    color: #7a7a8a;
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#handover-name {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1.4rem, 5vw, 2.4rem);
    font-weight: 700;
    color: #e07820;
    letter-spacing: 0.06em;
    text-shadow: 0 0 18px rgba(224, 120, 32, 0.40);
}

#handover-hint {
    color: #7a7a9a;
    font-size: 0.85rem;
    text-align: center;
    letter-spacing: 0.02em;
}

#handover-btn {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
    border-radius: 8px;
    padding: 12px 40px;
    font-size: 1rem;
    cursor: pointer;
    letter-spacing: 0.04em;
    margin-top: 12px;
    transition: background 0.2s, border-color 0.2s;
}

#handover-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

/* ============================================================
   PANNEAUX DE CITATIONS (grands écrans uniquement)
   ============================================================ */

.game-quote-panel {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    /* largeur définie dynamiquement par _repositionQuotes() */
    padding: 0 12px;
    pointer-events: none;
    user-select: none;
    display: none; /* masqué par défaut */
    box-sizing: border-box;
}

/* Visible uniquement pendant la partie (classe .shown) ET sur grand écran */
@media (min-width: 1280px) {
    .game-quote-panel.shown { display: block; }
}

#game-quote-left  { text-align: right; }
#game-quote-right { text-align: left;  }

.game-quote-text {
    color: rgba(130, 120, 170, 0.55);
    font-style: italic;
    font-size: 0.78rem;
    line-height: 1.7;
    letter-spacing: 0.01em;
}

.game-quote-author {
    color: rgba(100, 90, 140, 0.45);
    font-size: 0.68rem;
    margin-top: 10px;
    letter-spacing: 0.03em;
}

/* Petite ligne décorative côté échiquier */
#game-quote-left  .game-quote-text { border-right: 1px solid rgba(100, 90, 150, 0.18); padding-right: 10px; }
#game-quote-right .game-quote-text { border-left:  1px solid rgba(100, 90, 150, 0.18); padding-left:  10px; }

/* ============================================================
   CHIPS DE SÉLECTION (paramètres temporisation)
   ============================================================ */

.settings-label-row {
    margin-top: 6px;
    text-align: center;
}

.settings-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin: 6px 0 10px;
}

.settings-slider-icon {
    font-size: 1.1rem;
}

#slider-volume {
    -webkit-appearance: none;
    appearance: none;
    width: 180px;
    height: 6px;
    border-radius: 3px;
    background: #444;
    outline: none;
    cursor: pointer;
}

#slider-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e07820;
    cursor: pointer;
}

#slider-volume::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e07820;
    cursor: pointer;
    border: none;
}

.settings-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chip {
    background: var(--bg-chip);
    color: var(--text);
    border: 1px solid var(--border-sub);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    letter-spacing: 0.02em;
}

.chip:hover {
    border-color: var(--border-btn);
    background: #3a3a6a;
}

.chip.selected {
    background: #2a2a5a;
    border-color: var(--accent);
    color: var(--text-bright);
}

/* ============================================================
   TIMER JOUEUR (barre d'état)
   ============================================================ */

.player-timer {
    display: none;
    margin-left: auto;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    min-width: 52px;
    text-align: right;
    flex-shrink: 0;
}

.player-timer.visible {
    display: inline-block;
}

.player-timer.timer-warning {
    color: #e07820;
}

.player-timer.timer-critical {
    color: #e05050;
    animation: timer-blink 0.8s ease-in-out infinite;
}

@keyframes timer-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ============================================================
   BOUTONS ABANDON / PROPOSER NULLE
   ============================================================ */

#game-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.game-action-btn {
    background: transparent;
    color: #888899;
    border: 1px solid #444466;
    border-radius: 6px;
    padding: 7px 20px;
    font-size: 0.85rem;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

#abandon-btn:hover {
    color: #ff7777;
    border-color: #aa4444;
    background: rgba(200, 60, 60, 0.10);
}

#draw-btn:hover {
    color: #aaaaee;
    border-color: #6666aa;
    background: rgba(100, 100, 200, 0.10);
}

.game-action-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* ============================================================
   PANNEAU D'OFFRE DE NULLE
   ============================================================ */

#draw-offer-panel {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 15, 35, 0.92);
    border: 1px solid var(--border-btn);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#draw-offer-text {
    color: var(--text);
    font-size: 0.9rem;
    text-align: center;
    letter-spacing: 0.02em;
}

#draw-offer-actions {
    display: flex;
    gap: 10px;
}

#draw-accept-btn,
#draw-decline-btn {
    border-radius: 5px;
    padding: 7px 20px;
    font-size: 0.88rem;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: background 0.15s, border-color 0.15s;
}

#draw-accept-btn {
    background: var(--bg-btn);
    color: var(--text-btn);
    border: 1px solid var(--border-btn);
}

#draw-accept-btn:hover {
    background: var(--bg-btn-hover);
    border-color: var(--accent);
}

#draw-decline-btn {
    background: transparent;
    color: #8888aa;
    border: 1px solid #444466;
}

#draw-decline-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-color: #666688;
}

/* ======================================================
   ÉCRAN L'AVENTURE (IA)
   ====================================================== */

#adventure-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg);
    padding: 28px 32px;
    overflow-y: auto;
}

#adventure-header {
    display: flex;
    position: relative;
    width: 100%;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 40px;
}

#adventure-title {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1.5rem, 6vw, 3rem);
    font-weight: 700;
    color: #e07820;
    text-align: center;
    letter-spacing: 0.06em;
}

#adventure-back-btn {
    position: absolute;
    right: 0;
}

#adventure-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    width: 100%;
}

.adventure-level-title {
    font-family: 'MagicSchool', cursive;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: #b08a62;
    letter-spacing: 0.15em;
    text-align: center;
    margin: 0;
}

.adventure-opponents {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    justify-content: center;
}

/* ── Carte adversaire — style Vignette fondue ─────────── */
.ai-opponent-card {
    position: relative;
    width: 200px;
    height: 260px;
    border: 2px solid rgba(176, 138, 98, 0.40);
    border-radius: 14px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.22s, box-shadow 0.22s, transform 0.18s;
    outline: none;
    background: #ebebeb; /* correspond au fond du PNG */
}

.ai-opponent-card:hover {
    border-color: #e07820;
    box-shadow: 0 0 26px rgba(224, 120, 32, 0.35), 0 4px 18px rgba(0,0,0,0.55);
    transform: translateY(-4px);
}

/* Image plein cadre */
.ai-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center 20%;
    display: block;
}

/* Gradient sombre sur le bas — assombrit l'image sous le nom */
.ai-opponent-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
        transparent 35%,
        rgba(10, 10, 20, 0.55) 65%,
        rgba(10, 10, 20, 0.90) 100%);
    pointer-events: none;
}

/* Nom en overlay, centré en bas */
.ai-card-name {
    position: absolute;
    bottom: 18px;
    left: 0;
    right: 0;
    z-index: 2;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: clamp(1.1rem, 2.5vw, 1.45rem);
    color: #e07820;
    text-align: center;
    letter-spacing: 0.12em;
    text-shadow: 0 0 12px rgba(224, 120, 32, 0.55), 0 1px 6px rgba(0,0,0,0.9);
}

/* ── Carte boss verrouillée ───────────────────────────── */
.ai-card-bw {
    filter: grayscale(100%);
}

.ai-card-locked {
    cursor: not-allowed;
    opacity: 0.72;
}

.ai-card-locked:hover {
    border-color: rgba(176, 138, 98, 0.40) !important;
    box-shadow: none !important;
    transform: none !important;
}

/* ── Panneau de déverrouillage Level 2 ───────────────── */
[id^="lvl"][id$="-lock-panel"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 300px;
    text-align: center;
}

.lvl2-lock-msg {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 0.88rem;
    color: #888;
    margin: 0;
    line-height: 1.4;
}

.lvl2-code-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lvl2-code-row input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(176,138,98,0.35);
    border-radius: 6px;
    color: #e8e0d0;
    padding: 6px 12px;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    outline: none;
}

.lvl2-code-row input:focus {
    border-color: rgba(224, 120, 32, 0.6);
}

.lvl2-code-row button {
    background: #2a2a3e;
    border: 1.5px solid #555;
    color: #ccc;
    font-size: 1rem;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s;
}

.lvl2-code-row button:hover {
    border-color: #e07820;
    color: #e07820;
}

.lvl2-code-error {
    color: #e04040;
    font-size: 0.78rem;
    margin: 0;
}

/* ============================================================
   AI CARD — meilleur score communautaire
   ============================================================ */
.ai-card-best {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    z-index: 2;
    font-size: 0.65rem;
    color: rgba(212, 165, 32, 0.80);
    text-align: center;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* ============================================================
   RÉCAPITULATIF VICTOIRE ALPHAROGUE
   ============================================================ */

#alpharogue-victory-summary {
    margin: 1rem 0 0.5rem;
    border: 1px solid rgba(224, 120, 32, 0.25);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    background: rgba(20, 18, 40, 0.6);
    max-width: 480px;
    width: 100%;
}

.ars-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 0.8rem;
    color: #e07820;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    text-align: center;
}

.ars-player-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
}

.ars-player-name {
    font-family: 'Orbitron', monospace;
    font-size: 0.68rem;
    color: #888;
    min-width: 88px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.ars-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    flex: 1;
}

.ars-chip {
    display: inline-flex;
    position: relative;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.ars-chip img {
    width: 100%;
    height: 100%;
    display: block;
}

.ars-chip-lost img {
    opacity: 0.35;
}

/* Trait rouge diagonal sur les pièces perdues */
.ars-chip-lost::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -1px;
    width: calc(100% + 2px);
    height: 2px;
    background: #d03030;
    transform: translateY(-50%) rotate(-38deg);
    transform-origin: center;
    border-radius: 1px;
}

/* Badge "↑" sur les pièces issues d'une promotion */
.ars-chip-promo-new::before {
    content: '↑';
    position: absolute;
    top: -6px;
    right: -4px;
    font-size: 9px;
    line-height: 1;
    color: #f0c040;
    font-weight: bold;
    z-index: 2;
    text-shadow: 0 0 3px #000;
}

/* Légère teinte dorée sur le fond des pièces promues */
.ars-chip-promo-new {
    background: rgba(240, 192, 64, 0.15);
    border-radius: 4px;
}

.ars-pts {
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    color: #aaa;
    min-width: 42px;
    text-align: right;
    white-space: nowrap;
}

.ars-divider {
    border: none;
    border-top: 1px solid rgba(224, 120, 32, 0.15);
    margin: 0.5rem 0;
}

.ars-score-row {
    text-align: center;
    font-size: 0.78rem;
    color: #888;
    margin-top: 0.4rem;
}

.ars-diff {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 0.9rem;
}
.ars-diff-win  { color: #4caf50; }
.ars-diff-lose { color: #e03030; }

/* ============================================================
   BADGE MODAL
   ============================================================ */
#badge-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#badge-modal-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: #0e0e22;
    border: 1px solid rgba(212, 165, 32, 0.4);
    border-radius: 10px;
    padding: 22px 20px 18px;
    max-width: 600px;
    width: 100%;
}

#badge-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: rgba(200, 200, 220, 0.55);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
#badge-modal-close:hover { color: #fff; }

#badge-preview-img {
    width: 100%;
    max-width: 560px;
    border-radius: 6px;
    display: block;
}

#badge-share-hint {
    font-size: 0.78rem;
    font-style: italic;
    color: rgba(180, 175, 160, 0.60);
    text-align: center;
    margin: 0;
}

#badge-rank-msg {
    font-size: 0.85rem;
    color: #d4a520;
    text-align: center;
    letter-spacing: 0.04em;
    min-height: 0;
}

#badge-modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

#badge-save-btn,
#badge-share-btn {
    padding: 9px 22px;
    border-radius: 5px;
    border: 1px solid rgba(212, 165, 32, 0.5);
    background: rgba(212, 165, 32, 0.12);
    color: #d4a520;
    font-size: 0.9rem;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 0.18s;
}
#badge-save-btn:hover,
#badge-share-btn:hover { background: rgba(212, 165, 32, 0.25); }

/* ============================================================
   LADDER SCREEN
   ============================================================ */
#ladder-screen {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(ellipse at 50% 20%, #1a1a3a 0%, #0a0a18 100%);
    color: #e8e0d0;
    padding-bottom: 40px;
    overflow-y: auto;
}

#ladder-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 20px 10px;
    position: relative;
}

#ladder-title {
    font-family: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
    font-size: clamp(1.4rem, 4vw, 2rem);
    color: #d4a520;
    margin: 0;
    text-shadow: 0 0 20px rgba(212, 165, 32, 0.4);
}

#ladder-back-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* Toggle catégorie (Meilleur score / Moins de coups) */
#ladder-type-toggle {
    display: flex;
    gap: 8px;
    padding: 0 16px 4px;
}

.ladder-toggle-btn {
    font-family: 'Orbitron', monospace;
    font-size: 0.76rem;
    letter-spacing: 0.06em;
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid rgba(212, 165, 32, 0.3);
    background: rgba(255,255,255,0.04);
    color: rgba(212, 165, 32, 0.5);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ladder-toggle-btn:hover {
    background: rgba(212, 165, 32, 0.1);
    color: rgba(212, 165, 32, 0.85);
    border-color: rgba(212, 165, 32, 0.5);
}

.ladder-toggle-btn.active {
    background: rgba(212, 165, 32, 0.18);
    border-color: rgba(212, 165, 32, 0.75);
    color: #d4a520;
}

/* Toggle difficulté */
#ladder-diff-toggle {
    display: flex;
    gap: 8px;
    padding: 0 16px 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.ladder-diff-btn {
    font-family: 'Orbitron', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    padding: 6px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255,255,255,0.04);
    color: rgba(200, 200, 220, 0.4);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ladder-diff-btn:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(200, 200, 220, 0.85);
    border-color: rgba(255, 255, 255, 0.35);
}

/* Facile — bleu */
.ladder-diff-btn[data-diff="easy"].active {
    background: rgba(80, 130, 220, 0.2);
    border-color: rgba(80, 130, 220, 0.7);
    color: #7ab0f5;
}

/* Normal — violet */
.ladder-diff-btn[data-diff="normal"].active {
    background: rgba(114, 51, 145, 0.25);
    border-color: rgba(114, 51, 145, 0.75);
    color: #c070f5;
}

/* Difficile — rouge */
.ladder-diff-btn[data-diff="hard"].active {
    background: rgba(135, 28, 75, 0.25);
    border-color: rgba(135, 28, 75, 0.75);
    color: #e06090;
}

/* Impossible — or */
.ladder-diff-btn[data-diff="impossible"].active {
    background: rgba(168, 125, 11, 0.25);
    border-color: rgba(168, 125, 11, 0.75);
    color: #d4a020;
}

#ladder-content {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    padding: 16px 16px 20px;
    width: 100%;
    max-width: 860px;
}

.ladder-boss-section {
    flex: 1 1 260px;
    max-width: 380px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(212, 165, 32, 0.25);
    border-radius: 10px;
    padding: 20px 18px 22px;
}

/* Deux colonnes : points | coups */
.ladder-categories {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.ladder-category {
    flex: 1 1 200px;
    min-width: 0;
}

.ladder-category-title {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(212, 165, 32, 0.75);
    margin-bottom: 10px;
    font-family: 'Orbitron', monospace;
}

.ladder-boss-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(212, 165, 32, 0.2);
}

.ladder-boss-img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 6px;
    opacity: 0.92;
}

.ladder-boss-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ladder-boss-level {
    font-size: 0.72rem;
    color: rgba(212, 165, 32, 0.65);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ladder-boss-name {
    font-family: 'Orbitron', monospace;
    font-size: 1.15rem;
    color: #e07820;
    letter-spacing: 0.1em;
}

.ladder-podium {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ladder-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
}

.ladder-entry.rank-1 {
    border-color: rgba(212, 165, 32, 0.5);
    background: rgba(212, 165, 32, 0.06);
}
.ladder-entry.rank-2 {
    border-color: rgba(180, 180, 195, 0.4);
    background: rgba(180, 180, 195, 0.04);
}
.ladder-entry.rank-3 {
    border-color: rgba(160, 105, 60, 0.4);
    background: rgba(160, 105, 60, 0.04);
}

.ladder-medal {
    font-size: 1.4rem;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.ladder-player-name {
    flex: 1;
    font-size: 0.95rem;
    color: #e0dcd0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ladder-score {
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    color: #d4a520;
    flex-shrink: 0;
}

.ladder-empty {
    color: rgba(180, 180, 200, 0.35);
    font-size: 0.82rem;
    text-align: center;
    padding: 8px 0;
    font-style: italic;
}

/* Wrapper : cache la colonne gauche du badge (148px + 10px de gap sur 560px total) */
.ladder-badge-wrap {
    overflow: hidden;
    border-radius: 5px;
    margin-top: 14px;
    border: 1px solid rgba(212, 165, 32, 0.25);
}

/* Image décalée à gauche pour ne montrer que la partie droite                   */
/* On coupe à 148px pour laisser ~10px de marge visuelle à gauche               */
/* Largeur visible = 412px (560-148) ; ratio = 560/412 ≈ 135.9%                 */
/* Décalage gauche = 148/412 ≈ 35.9%                                            */
.ladder-top1-badge {
    display: block;
    width: 135.9%;
    margin-left: -35.9%;
}

/* Bouton Ladder dans le menu — styles communs avec les autres boutons home */


/* ======================================================
   ÉCRAN DIFFICULTÉ
   ====================================================== */

#difficulty-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg);
    padding: 28px 32px;
    overflow-y: auto;
}

#difficulty-header {
    display: flex;
    position: relative;
    width: 100%;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 20px;
}

#difficulty-title {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1.5rem, 6vw, 3rem);
    font-weight: 700;
    color: #e07820;
    text-align: center;
    letter-spacing: 0.06em;
}

#difficulty-back-btn {
    position: absolute;
    right: 0;
}

.difficulty-subtitle {
    color: rgba(200, 200, 220, 0.55);
    font-size: 0.9rem;
    margin: 0 0 32px;
    letter-spacing: 0.05em;
}

#difficulty-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 560px;
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.difficulty-entry {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.difficulty-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(176, 138, 98, 0.35);
    border-radius: 10px;
    color: #e8e0d0;
    padding: 16px 24px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
    text-align: left;
}

.difficulty-btn:hover:not(:disabled) {
    border-color: #e07820;
    background: rgba(224, 120, 32, 0.08);
    box-shadow: 0 0 18px rgba(224, 120, 32, 0.2);
}

.difficulty-btn:disabled,
.difficulty-btn.difficulty-locked {
    cursor: not-allowed;
    opacity: 0.50;
}

.difficulty-name {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    font-weight: 700;
    color: #e07820;
    letter-spacing: 0.05em;
}

.difficulty-desc {
    font-size: clamp(0.7rem, 1.8vw, 0.85rem);
    color: rgba(200, 200, 220, 0.65);
    letter-spacing: 0.03em;
}

.difficulty-lock-panel {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(176, 138, 98, 0.2);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 10px 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.diff-lock-label {
    font-size: 0.78rem;
    color: rgba(200, 200, 220, 0.5);
    letter-spacing: 0.04em;
}

.diff-code-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.diff-code-row input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(176,138,98,0.35);
    border-radius: 6px;
    color: #e8e0d0;
    padding: 6px 12px;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    outline: none;
}

.diff-code-row input:focus {
    border-color: rgba(224, 120, 32, 0.6);
}

.diff-code-error {
    font-size: 0.75rem;
    color: #e05050;
}

.code-btn {
    background: #2a2a3e;
    border: 1.5px solid #555;
    color: #ccc;
    font-size: 1rem;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s;
}

.code-btn:hover {
    border-color: #e07820;
    color: #e07820;
}

/* ============================================================
   ÉCRAN SÉLECTION GÉNÉRATION ALPHAROGUE
   ============================================================ */

#alpharogue-picker {
    position: fixed;
    inset: 0;
    background: var(--bg, #0d0d1a);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem;
    z-index: 10;
}

#alpharogue-picker-back {
    position: absolute;
    top: 1.2rem;
    left: 1.2rem;
    background: transparent;
    border: none;
    color: #888;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s;
}
#alpharogue-picker-back:hover { color: #e07820; }

#alpharogue-picker-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--text, #e8e0d0);
    margin: 0;
    text-align: center;
}

#alpharogue-picker-subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: #888;
    font-size: 0.95rem;
    margin: 0;
    text-align: center;
}

#alpharogue-version-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.6rem;
    width: 100%;
    max-width: 400px;
}

/* ── Slider de génération ── */
.aro-slider-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.aro-slider-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
}

.aro-slider-label-end {
    font-family: 'Cinzel Decorative', serif;
    font-size: 0.85rem;
    color: #e07820;
    white-space: nowrap;
    min-width: 2rem;
    text-align: center;
}

#aro-gen-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #444;
    outline: none;
    cursor: pointer;
}
#aro-gen-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e07820;
    cursor: pointer;
}
#aro-gen-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e07820;
    cursor: pointer;
    border: none;
}

.aro-slider-gen-counter {
    font-size: 0.75rem;
    color: #555;
    margin: 0;
    letter-spacing: 0.05em;
}

/* ── Carte sélectionnée ── */
.alpharogue-version-card {
    background: #1a1a2e;
    border: 1.5px solid #333;
    border-radius: 10px;
    padding: 1.2rem 1.6rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: center;
    width: 100%;
}
.alpharogue-version-card:hover,
.aro-selected-card {
    border-color: #e07820;
    box-shadow: 0 0 20px rgba(224, 120, 32, 0.25);
}

.alpharogue-version-label {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.2rem;
    color: #e07820;
    display: block;
    margin-bottom: 0.5rem;
}

.alpharogue-version-date {
    font-size: 0.72rem;
    color: #555;
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 0.6rem;
}

.alpharogue-version-desc {
    font-size: 0.85rem;
    color: #888;
    line-height: 1.4;
    display: block;
    margin-bottom: 0.8rem;
}

.aro-play-hint {
    display: block;
    font-size: 0.85rem;
    color: #e07820;
    opacity: 0.7;
    letter-spacing: 0.1em;
    margin-top: 0.4rem;
}

/* Bandeau "faire jouer vs autre version" */
#aro-vs-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(176,138,98,0.2);
    border-radius: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

#aro-vs-label {
    font-size: 0.82rem;
    color: #aaa;
    letter-spacing: 0.04em;
}

#aro-vs-select {
    background: #1a1a2e;
    border: 1px solid rgba(176,138,98,0.35);
    border-radius: 6px;
    color: #e8e0d0;
    font-size: 0.85rem;
    padding: 5px 10px;
    outline: none;
    cursor: pointer;
}

#aro-vs-btn {
    background: #2a2a3e;
    border: 1.5px solid #555;
    color: #ccc;
    font-size: 0.85rem;
    padding: 5px 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s;
}

#aro-vs-btn:hover {
    border-color: #e07820;
    color: #e07820;
}

/* ============================================================
   ÉCRAN DES REMERCIEMENTS — générique cinématographique
   ============================================================ */

#credits-screen {
    position: fixed; inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #000;
    overflow: hidden;
    z-index: 10;
}

/* En-tête avec titre */
#credits-header {
    position: relative;
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 20px 32px;
    z-index: 20;
}

#credits-title {
    font-family: 'Cinzel Decorative', 'Palatino Linotype', serif;
    font-size: clamp(1.5rem, 6vw, 3rem);
    font-weight: 700;
    color: #e07820;
    text-align: center;
    letter-spacing: 0.06em;
}

/* Bouton Retour fixe en surimpression */
#credits-back-btn {
    position: absolute;
    right: 32px;
    z-index: 20;
}

/* Zone de défilement — masque ce qui dépasse */
#credits-roll-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

/* Le bandeau qui roule de bas en haut */
#credits-roll {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    text-align: center;
    animation: credits-scroll 55s linear forwards;
    animation-play-state: running;
}

@keyframes credits-scroll {
    0%   { transform: translateY(100vh); }
    100% { transform: translateY(-100%); }
}

.cr-spacer {
    height: 80px;
}

/* Chaque ligne : nom + rôle */
.cr-line {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
}

.cr-name {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(1.1rem, 3.5vw, 1.6rem);
    color: #e07820;
    letter-spacing: 0.1em;
    text-shadow: 0 0 18px rgba(224,120,32,0.5);
}

.cr-role {
    font-size: clamp(0.78rem, 2.2vw, 1rem);
    color: #9090a8;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

/* Bloc final poétique */
.cr-outro {
    margin-top: 20px;
    margin-bottom: 20px;
}

.cr-outro p {
    font-style: italic;
    font-size: clamp(0.85rem, 2.5vw, 1.05rem);
    color: #706880;
    line-height: 2.4;
    margin: 0;
}

/* Fondus haut/bas */
#credits-fade-top,
#credits-fade-bottom {
    position: absolute;
    left: 0; right: 0;
    height: 120px;
    pointer-events: none;
    z-index: 10;
}

#credits-fade-top {
    top: 0;
    background: linear-gradient(to bottom, #000 40%, transparent);
}

#credits-fade-bottom {
    bottom: 0;
    background: linear-gradient(to top, #000 40%, transparent);
}

/* La ligne de crédit sur l'accueil est cliquable */
#home-credit {
    cursor: pointer;
    transition: color 0.2s;
}
#home-credit:hover {
    color: #c0a070;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ============================================================
   ALPHA DRAFT MODE MODAL
   ============================================================ */
#alpha-draft-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#alpha-draft-modal-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: #0e0e22;
    border: 1px solid rgba(212, 165, 32, 0.4);
    border-radius: 10px;
    padding: 24px 20px 18px;
    max-width: 900px;
    width: 100%;
}

#alpha-draft-title {
    margin: 0;
    color: #d4a520;
    font-family: 'Orbitron', monospace;
    font-size: 0.95rem;
    text-align: center;
}

#alpha-draft-subtitle {
    margin: 0;
    color: rgba(200, 200, 220, 0.65);
    font-size: 0.82rem;
    text-align: center;
}

#alpha-draft-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    width: 100%;
}

/* Petit écran : 2 colonnes */
@media (max-width: 600px) {
    #alpha-draft-options {
        grid-template-columns: 1fr 1fr;
    }
}

.alpha-draft-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #1a1a35;
    border: 1px solid rgba(212, 165, 32, 0.3);
    border-radius: 10px;
    padding: 10px 10px 14px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    width: 100%;
}

.alpha-draft-img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    object-position: center top;
    border-radius: 6px;
    display: block;
}

.alpha-draft-btn:hover {
    background: #252545;
    border-color: #e07820;
    transform: translateY(-2px);
}

.alpha-draft-mode-name {
    color: rgba(220, 220, 240, 0.95);
    font-family: 'Orbitron', monospace;
    font-size: 0.78rem;
    font-weight: 600;
}

.alpha-draft-mode-desc {
    color: rgba(180, 180, 200, 0.6);
    font-size: 0.72rem;
    text-align: center;
    line-height: 1.3;
}

#alpha-draft-cancel {
    background: none;
    border: none;
    color: rgba(200, 200, 220, 0.45);
    cursor: pointer;
    font-size: 0.82rem;
    padding: 4px 12px;
    transition: color 0.2s;
}

#alpha-draft-cancel:hover {
    color: rgba(200, 200, 220, 0.8);
}

/* ── Picker ARoBot α — carte boss ── */
#alpharogue-card-wrap {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

#alpharogue-card-wrap .ai-opponent-card {
    width: 160px;
    cursor: pointer;
}

.ai-card-subtitle {
    font-size: 0.78rem;
    color: #e07820;
    margin-top: 4px;
    letter-spacing: 0.04em;
}

/* ============================================================
   RESPONSIVE GLOBAL — Corrections multi-formats
   Breakpoints :
     ≤ 768px — tablette portrait / grand smartphone paysage
     ≤ 480px — smartphone standard (iPhone 12, Galaxy S21…)
     ≤ 360px — petit smartphone (iPhone SE, Galaxy A12…)
   ============================================================ */

/* ── Tablette portrait ≤ 768px ─────────────────────────── */
@media (max-width: 768px) {

    /* Paddings latéraux généreux → réduits */
    #rules-screen,
    #settings-screen    { padding: 20px 20px; }
    #adventure-screen   { padding: 20px 20px; }
    #online-lobby-screen{ padding: 28px 20px; gap: 24px; }

    /* Règles : contenu un peu plus large */
    #rules-content,
    #rules-description-list { width: 92%; }

    /* Cartes boss : légèrement compactées */
    .ai-opponent-card { width: 170px; height: 221px; }

    /* Ladder : boutons de difficulté peuvent wrapper */
    #ladder-diff-row { flex-wrap: wrap; gap: 6px; }
}

/* ── Smartphone standard ≤ 480px ───────────────────────── */
@media (max-width: 480px) {

    /* ── Paddings globaux ── */
    #rules-screen,
    #settings-screen    { padding: 14px 12px; gap: 20px; }
    #adventure-screen   { padding: 14px 12px; }
    #online-lobby-screen{ padding: 18px 14px; gap: 18px;
                          justify-content: flex-start; }
    #difficulty-screen  { padding: 20px 14px; }

    /* ── Règles — contenu pleine largeur ── */
    #rules-content,
    #rules-description-list { width: 98%; }

    /* Icônes pièces plus petites dans les cartes */
    .rules-description-card-icon {
        flex: 0 0 80px;
        height: 80px;
        padding: 10px;
    }

    /* ── Écran nom du joueur — formulaire en colonne ── */
    #name-screen  { gap: 20px; padding: 0 16px; box-sizing: border-box; }
    #name-form    { flex-direction: column; align-items: stretch;
                    width: 100%; max-width: 340px; }
    #name-input   { width: 100%; max-width: 100%; }
    #name-confirm-btn { width: 100%; }

    /* ── Lobby en ligne — sections empilées ── */
    #lobby-sections   { flex-direction: column; gap: 20px; align-items: center; }
    .lobby-section    { min-width: unset; width: 100%; max-width: 300px; }
    #lobby-code-input { width: 100%; max-width: 200px; }

    /* ── Aventure — cartes responsives ── */
    #adventure-header { margin-bottom: 20px; }
    .adventure-opponents { gap: 14px; }
    .ai-opponent-card {
        width: clamp(120px, 42vw, 160px);
        height: auto;
        aspect-ratio: 200 / 260;
    }

    /* ── Fin de partie — panel scrollable + codes adaptés ── */
    #game-over-panel {
        max-height: calc(100vh - 260px);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(224,120,32,0.4) transparent;
    }
    #game-over-code,
    #game-over-code-dynamic,
    #game-over-code-normal-diff,
    #game-over-code-hard-diff,
    #game-over-code-impossible-diff,
    #game-over-code-final { padding: 8px 12px; }
    #game-over-actions { gap: 8px; }
    #replay-start-btn,
    #home-btn           { padding: 7px 14px; font-size: 0.82rem; }

    /* ── Paramètres ── */
    #slider-volume { width: 140px; }
    #piece-profile-list { gap: 14px; flex-wrap: wrap; justify-content: center; }
    .piece-profile-card button { padding: 10px 18px; font-size: 0.9rem; }

    /* ── Modal ARoBot ── */
    #alpha-draft-modal-inner { padding: 16px 12px 14px; }
}

/* ── Petit smartphone ≤ 360px ──────────────────────────── */
@media (max-width: 360px) {

    /* ── Règles — icônes empilées verticalement ── */
    .rules-description-card-body {
        flex-direction: column;
        align-items: center;
    }
    .rules-description-card-icon {
        flex: 0 0 60px;
        height: 60px;
        width: 60px;
        align-self: center;
        padding: 8px;
    }

    /* ── Paddings encore réduits ── */
    #rules-screen,
    #adventure-screen   { padding: 10px 8px; gap: 16px; }
    #settings-screen    { padding: 10px 8px; gap: 16px; }
    #online-lobby-screen{ padding: 12px 8px; }

    /* ── Cartes boss encore plus petites ── */
    .ai-opponent-card {
        width: clamp(110px, 44vw, 140px);
        height: auto;
        aspect-ratio: 200 / 260;
    }

    /* ── Formulaire nom ── */
    #name-input   { font-size: 1rem; padding: 8px 12px; }
    #name-confirm-btn { font-size: 0.9rem; padding: 8px 16px; }

    /* ── Fin de partie ── */
    #game-over-panel {
        max-height: calc(100vh - 240px);
        padding: 10px 12px;
    }
    .game-over-code-value { font-size: clamp(0.8rem, 3vw, 1rem); }
    #game-over-text { font-size: 0.9rem; }

    /* ── Lobby ── */
    .lobby-section { max-width: 260px; }

    /* ── Paramètres ── */
    #piece-profile-list { gap: 8px; }
    .piece-profile-card button { padding: 8px 12px; font-size: 0.82rem; }
}
