@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 (haut de page) */
#home-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#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 au milieu de l'écran */
#home-buttons {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

#btn-rules {
    margin-bottom: 50px; /* ajuste la position du bouton par rapport aux autres (et au titre) */
    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 {
    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;
}

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

#btn-ai {
    color: #555566;
    cursor: default;
}

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

#btn-ai-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

#btn-ai-tooltip {
    font-size: 0.7rem;
    color: #555566;
    letter-spacing: 0.03em;
    font-style: italic;
}

/* 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: 'MagicSchool', cursive;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    color: var(--text);
    margin: 0 0 4px;
    text-align: left;
    line-height: 1.3;
}

.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;
}

/* ── 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: 260px;
    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: 100%;
}

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

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

.player-name {
    color: var(--text);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}

.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-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;
}

/* 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);
    background: #2a2a5a;
    color: var(--text-bright);
}

.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;
}

/* ============================================================
   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;
}

.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-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%);
    max-width: 220px;
    padding: 0 12px;
    pointer-events: none;
    user-select: none;
    display: none; /* masqué par défaut */
    /* left/right positionnés dynamiquement par JS */
}

/* 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-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;
}
