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

body {
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #8B4513 0%, #D2691E 50%, #F4A460 100%);
    min-height: 100vh;
    color: #333;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #654321;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Panneau de contrôle */
.control-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    height: fit-content;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.game-info, .score-panel, .game-controls, .game-settings, 
.game-actions, .move-history, .rules-summary {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.rules-summary {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.game-info h3, .score-panel h3, .game-settings h3, 
.move-history h3, .rules-summary h3 {
    color: #654321;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: bold;
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #D2691E;
}

.status-item .label {
    font-weight: bold;
    color: #6c757d;
}

/* Score */
.players-score {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.player-score {
    padding: 15px;
    border-radius: 10px;
    border: 2px solid;
}

.player-score.black {
    background: #f8f9fa;
    border-color: #333;
}

.player-score.white {
    background: #ffffff;
    border-color: #ddd;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.player-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.score-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.score-line {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.score-line.total {
    border-top: 2px solid #ccc;
    padding-top: 8px;
    margin-top: 5px;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Pierres */
.stone {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
}

.stone.black-stone {
    background: radial-gradient(circle at 30% 30%, #555, #000);
    border-color: #333;
}

.stone.white-stone {
    background: radial-gradient(circle at 30% 30%, #fff, #ddd);
    border-color: #999;
}

/* Boutons */
.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn.primary {
    background: #D2691E;
    color: white;
}

.btn.primary:hover {
    background: #B8860B;
    transform: translateY(-2px);
}

.btn.secondary {
    background: #6c757d;
    color: white;
}

.btn.secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn.small {
    padding: 5px 8px;
    font-size: 0.8rem;
}

.btn:disabled {
    background: #dee2e6;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.game-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.game-actions {
    display: grid;
    gap: 10px;
}

/* Paramètres */
.settings-group {
    margin-bottom: 15px;
}

.settings-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #654321;
}

.settings-group select,
.settings-group input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.settings-group input[type="checkbox"] {
    margin-right: 8px;
}

/* Historique */
.history-list {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
}

.history-item {
    padding: 5px 8px;
    margin-bottom: 5px;
    background: white;
    border-radius: 4px;
    border-left: 4px solid;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: #e9ecef;
}

.history-item.black {
    border-left-color: #333;
}

.history-item.white {
    border-left-color: #999;
}

.history-item.current {
    background: #fff3cd;
    border-left-color: #ffc107;
}

.history-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

/* Règles */
.rules-summary ul {
    list-style: none;
    padding: 0;
}

.rules-summary li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.rules-summary li:last-child {
    border-bottom: none;
}

/* Plateau de jeu */
.board-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 600px;
}

.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.coordinates-top {
    display: grid;
    gap: 0;
    margin-bottom: 5px;
    margin-left: 30px;
}

.board-with-coords {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 5px;
    width: 100%;
    max-width: 600px;
}

.coordinates-left {
    display: grid;
    gap: 0;
}

.coord {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #654321;
    font-size: 0.9rem;
    min-height: 25px;
}

.go-board {
    width: 600px;
    height: 600px;
    position: relative;
    background: linear-gradient(45deg, #DEB887 0%, #F5DEB3 100%);
    border: 3px solid #8B4513;
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
}

.board-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.board-line {
    position: absolute;
    background: #8B4513;
}

.board-line.horizontal {
    height: 1px;
}

.board-line.vertical {
    width: 1px;
}

.board-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    z-index: 2;
}

.intersection {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.intersection:hover::before {
    content: '';
    position: absolute;
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    pointer-events: none;
    z-index: 1;
}

.intersection.has-stone:hover::before {
    display: none;
}

.intersection .stone {
    position: relative;
    z-index: 3;
    border-radius: 50%;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Points de handicap (hoshi) */
.intersection.star-point::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #8B4513;
    border-radius: 50%;
    z-index: 1;
}

.intersection.has-stone.star-point::after {
    display: none;
}

/* Territoire marqué */
.intersection.black-territory {
    background: rgba(0, 0, 0, 0.2);
}

.intersection.white-territory {
    background: rgba(255, 255, 255, 0.4);
}

.intersection.dead-stone .stone {
    opacity: 0.5;
    filter: grayscale(50%);
}

/* Informations du plateau */
.board-info {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 1.1rem;
}

.last-move-info {
    font-style: italic;
    color: #6c757d;
}

/* Messages */
.message-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
}

.message {
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    max-width: 400px;
    text-align: center;
}

.message.show {
    opacity: 1;
    transform: scale(1);
}

.message.success { background: #28a745; color: white; }
.message.error { background: #dc3545; color: white; }
.message.info { background: #17a2b8; color: white; }
.message.warning { background: #ffc107; color: #333; }

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalAppear 0.3s ease;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    color: #654321;
    margin-bottom: 20px;
    font-size: 2rem;
}

.final-score, .territory-score {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.score-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.player-final-score {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid;
}

.player-final-score.winner {
    background: #d4edda;
    border-color: #28a745;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .control-panel {
        position: static;
        order: 2;
        max-height: none;
        overflow-y: visible;
    }
    
    .board-container {
        order: 1;
    }
}

@media (max-width: 900px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .game-container {
        padding: 0 10px;
    }
    
    .status-grid {
        grid-template-columns: 1fr;
    }
    
    .game-controls {
        grid-template-columns: 1fr;
    }
    
    .players-score {
        gap: 10px;
    }
    
    .board-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .coord {
        font-size: 0.7rem;
        min-height: 20px;
    }
    
    .intersection .stone {
        max-width: 25px;
        max-height: 25px;
    }
    
    .modal-actions {
        grid-template-columns: 1fr;
    }
    
    .score-comparison {
        grid-template-columns: 1fr;
    }
}

/* Animations */
.stone.placing {
    animation: placeStone 0.3s ease;
}

@keyframes placeStone {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.stone.capturing {
    animation: captureStone 0.5s ease-out forwards;
}

@keyframes captureStone {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Mode sombre (optionnel) */
@media (prefers-color-scheme: dark) {
    .control-panel,
    .board-container {
        background: rgba(30, 30, 30, 0.95);
        color: #e9ecef;
    }
    
    .game-info h3, .score-panel h3, .game-settings h3,
    .move-history h3, .rules-summary h3 {
        color: #D2691E;
    }
    
    .status-item, .history-list {
        background: #404040;
        border-left-color: #D2691E;
    }
    
    .board-info {
        background: #404040;
        color: #e9ecef;
    }
}
