/* ========== VARIABLES ========== */
:root {
    --bg: #1a1410;
    --panel: #231c15;
    --text: #d4c5b2;
    --gold: #c9a24e;
    --red: #8b3a3a;
    --blue: #4a6d8c;
    --cell-bg: #2a2118;
    --cell-hover: #3a2f24;
    --cell-revealed: #3d3226;
    --border: #4a3f32;
    --btn-bg: #352b1f;
    --btn-hover: #4a3a2a;
    --white-moine: #e8dcc8;
    --black-moine: #2a1f18;
    --cell-blanc-bg: #3d3528;
    --cell-noir-bg: #1f1a14;
}

/* ========== RESET & BASE ========== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg);
    background-image: radial-gradient(ellipse at center, #2a2018 0%, #1a1410 70%);
    color: var(--text);
    font-family: 'Georgia', 'Times New Roman', serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* ========== LAYOUT ========== */
.game-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 1100px;
}

.main-panel {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 280px;
    max-width: 320px;
}

/* ========== PLATEAU ========== */
.board-title {
    font-size: 1.8em;
    color: var(--gold);
    margin-bottom: 15px;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.board {
    display: grid;
    grid-template-columns: repeat(6, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 4px;
    margin-bottom: 20px;
}

/* ========== CELLULES ========== */
.cell {
    width: 60px;
    height: 60px;
    background: var(--cell-bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    position: relative;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.cell:hover {
    background: var(--cell-hover);
    border-color: var(--gold);
    transform: translateY(-2px);
}

.cell.revealed {
    background: var(--cell-revealed);
    border-color: #5a4e3e;
    cursor: pointer;
}

.cell.revealed:hover {
    background: #463a2c;
    border-color: var(--gold);
}

.cell.occupee-blanc {
    background: var(--cell-blanc-bg) !important;
    border-color: #8a7a5e !important;
    box-shadow: inset 0 0 20px rgba(232, 220, 200, 0.15), 0 0 0 1px rgba(232, 220, 200, 0.3) !important;
}

.cell.occupee-noir {
    background: var(--cell-noir-bg) !important;
    border-color: #5a4a3a !important;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(100, 80, 60, 0.3) !important;
}

.cell.occupee-blanc.occupee-noir {
    background: #2a2520 !important;
    border-color: var(--gold) !important;
}

.cell.selected {
    border-color: #fff !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.6) !important;
    transform: scale(1.08);
    z-index: 2;
}

/* ========== SURBRILLANCES ========== */
.cell.move-target {
    border-color: #8ab4d8 !important;
    box-shadow: 0 0 16px rgba(138, 180, 216, 0.4) !important;
    animation: pulse-blue 1.5s infinite;
}

.cell.gratter-target {
    border-color: #c98a4e !important;
    box-shadow: 0 0 16px rgba(201, 138, 78, 0.4) !important;
    animation: pulse-orange 1.5s infinite;
}

.cell.effacer-target {
    border-color: #8b4a4a !important;
    box-shadow: 0 0 16px rgba(139, 74, 74, 0.4) !important;
    animation: pulse-red 1s infinite;
}

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 8px rgba(138, 180, 216, 0.3); }
    50%      { box-shadow: 0 0 20px rgba(138, 180, 216, 0.6); }
}

@keyframes pulse-orange {
    0%, 100% { box-shadow: 0 0 8px rgba(201, 138, 78, 0.3); }
    50%      { box-shadow: 0 0 20px rgba(201, 138, 78, 0.6); }
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 8px rgba(139, 74, 74, 0.3); }
    50%      { box-shadow: 0 0 20px rgba(139, 74, 74, 0.6); }
}

/* ========== MOINES ========== */
.moine-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    z-index: 3;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.7));
    pointer-events: none;
}

.cell.occupee-blanc.revealed > span:not(.coords-label):not(.moine-img),
.cell.occupee-noir.revealed > span:not(.coords-label):not(.moine-img) {
    opacity: 0.4;
    font-size: 1.1em !important;
    margin-top: -8px;
}

/* ========== SYMBOLES ========== */
.sym-citadelle { color: #c9a24e; }
.sym-fleuve    { color: #5b9bd5; }
.sym-pont      { color: #8b9a6b; }
.sym-oracle    { color: #b89ac9; }

.coords-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.45em;
    color: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    z-index: 1;
}

/* ========== PANNEAUX INFO ========== */
.info-box {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.info-box h3 {
    color: var(--gold);
    font-size: 1em;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.player-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg);
    margin-bottom: 10px;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.player-indicator.active {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(201, 162, 78, 0.25);
}

.player-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-blanc {
    background: var(--white-moine);
    border: 2px solid #aaa;
}

.dot-noir {
    background: var(--black-moine);
    border: 2px solid #666;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.9em;
}

.score-label {
    color: #a09080;
}

.score-value {
    font-weight: bold;
    color: var(--gold);
}

.status-text {
    font-size: 0.7em;
    color: #6a5e4e;
    margin-top: 8px;
    text-align: center;
}

.placeholder {
    color: #5a4e3e;
    font-style: italic;
}

/* ========== BOUTONS ========== */
.buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

button {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.85em;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--btn-bg);
    color: var(--text);
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

button:hover {
    background: var(--btn-hover);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 10px rgba(201, 162, 78, 0.2);
}

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

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

button.btn-primary {
    background: #4a3520;
    border-color: var(--gold);
    color: var(--gold);
    font-weight: bold;
}

button.btn-danger {
    border-color: #8b4a4a;
    color: #c97a7a;
}

button.btn-danger:hover {
    border-color: #c97a7a;
    color: #e8a0a0;
}

button.btn-prophecy {
    background: #3a2a3a;
    border-color: #7a6a8a;
    color: #c9b0d9;
}

button.btn-prophecy:hover {
    border-color: #b89ac9;
    color: #d9c8e8;
    box-shadow: 0 0 14px rgba(180, 150, 200, 0.25);
}

button.btn-regles {
    background: #2a2a1f;
    border-color: #8a8a6a;
    color: #c9c9a0;
}

button.btn-regles:hover {
    border-color: #c9c9a0;
    color: #e8e8c8;
    box-shadow: 0 0 14px rgba(200, 200, 160, 0.25);
}

/* ========== LOG ========== */
.log-box {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.8em;
    line-height: 1.5;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.log-box h3 {
    color: var(--gold);
    font-size: 0.9em;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #a09080;
}

.log-entry.important {
    color: var(--gold);
}

/* ========== MODALES ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal {
    background: var(--panel);
    border: 2px solid var(--gold);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    max-width: 500px;
    width: 90%;
    position: relative;
}

.modal h2 {
    color: var(--gold);
    font-size: 1.5em;
    letter-spacing: 2px;
    margin-bottom: 15px;
}

.modal p {
    color: var(--text);
}

.modal button {
    margin: 15px 5px 0;
    font-size: 1em;
    padding: 12px 24px;
}

/* Croix de fermeture */
.modal-close-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 0.8em;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    line-height: 1;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    z-index: 5;
}

.modal-close-btn:hover {
    background: #e74c3c;
    transform: scale(1.15);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

/* Modale Règles */
.modal-regles {
    max-width: 650px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
    padding: 25px 30px;
}

.modal-regles h2 {
    text-align: center;
    margin-bottom: 20px;
    padding-right: 30px;
}

.modal-regles .regles-content h3 {
    color: var(--gold);
    font-size: 1em;
    letter-spacing: 1px;
    margin-top: 18px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(201, 162, 78, 0.2);
    padding-bottom: 5px;
}

.modal-regles .regles-content p {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: 0.9em;
}

.modal-regles .regles-content ul,
.modal-regles .regles-content ol {
    margin-left: 20px;
    margin-bottom: 10px;
    line-height: 1.6;
    font-size: 0.9em;
}

.modal-regles .regles-content li {
    margin-bottom: 5px;
}

.modal-regles .regles-content ul ul,
.modal-regles .regles-content ol ul {
    margin-top: 5px;
    margin-bottom: 5px;
}

.modal-regles .regles-content strong {
    color: var(--gold);
}

/* Scrollbar pour la modale règles */
.modal-regles::-webkit-scrollbar {
    width: 6px;
}

.modal-regles::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 3px;
}

.modal-regles::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ========== PROPHÉTIE ========== */
#prophecy-bar {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.cell.prophecy-target {
    border-color: #b89ac9 !important;
    box-shadow: 0 0 14px rgba(184, 154, 201, 0.5) !important;
    animation: pulse-purple 1.5s infinite;
    cursor: pointer;
}

.cell.prophecy-selected {
    border-color: #fff !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.7) !important;
    background: #3a2a3a !important;
    transform: scale(1.05);
    z-index: 2;
}

@keyframes pulse-purple {
    0%, 100% { box-shadow: 0 0 10px rgba(184, 154, 201, 0.4); }
    50%      { box-shadow: 0 0 22px rgba(184, 154, 201, 0.7); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 800px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    .board {
        grid-template-columns: repeat(6, 45px);
        grid-template-rows: repeat(6, 45px);
        gap: 3px;
    }

    .cell {
        width: 45px;
        height: 45px;
        font-size: 1.2em;
    }

    .moine-img {
        width: 28px;
        height: 28px;
    }

    .side-panel {
        min-width: auto;
        width: 100%;
        max-width: 400px;
    }

    .modal-regles {
        max-width: 95%;
        max-height: 75vh;
        padding: 15px;
    }

    .modal-close-btn {
        top: 6px;
        right: 8px;
        width: 20px;
        height: 20px;
        font-size: 0.7em;
    }
}