/* General Styling */
body {
    font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Prioritize Chinese font */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background-color: #f4f4f4;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    color: #333; /* Default text color */
}

.game-container {
    background-color: #ffffff;
    padding: 20px 30px 30px 30px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 700px;
    width: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 600; /* Slightly bolder */
}

/* Game Info & Controls */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 5px; /* Reduced horizontal padding slightly */
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

#status {
    font-size: 1.2em;
    font-weight: 500;
    color: #34495e;
    flex-grow: 1;
    text-align: left;
    min-height: 1.5em; /* Prevent layout shift */
}

#new-game-button {
    padding: 10px 20px; /* Adjusted padding slightly */
    font-size: 1em; /* Match default font size */
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}
#new-game-button:disabled {
    background-color: #bdc3c7; /* Gray out when disabled */
    cursor: not-allowed;
    box-shadow: none;
}
#new-game-button:not(:disabled):hover {
    background-color: #2980b9;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
#new-game-button:not(:disabled):active {
     background-color: #2573a7;
     box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}


.options {
    margin-top: 5px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px 20px; /* Row gap, Column gap */
    flex-wrap: wrap;
    width: 100%;
}

.options label {
    font-weight: 500;
    color: #555;
    margin-right: 5px;
}

.options select {
    padding: 6px 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: #fff;
    font-size: 0.95em;
    cursor: pointer;
}
.options select:disabled {
     background-color: #ecf0f1; /* Light gray when disabled */
     color: #95a5a6;
     cursor: not-allowed;
}

/* Thinking Indicator */
.thinking-indicator {
    margin-top: 10px;
    font-style: italic;
    color: #e74c3c; /* Make thinking indicator red */
    font-weight: 500;
    height: 1.2em; /* Reserve space */
    min-height: 1.2em; /* Ensure space is kept */
}


/* Board Styling */
.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
}

#board {
    display: grid;
    background-color: #e4b268;
    border: 3px solid #8b4513;
    box-shadow: 0 0 15px rgba(0,0,0,0.15) inset, 0 5px 10px rgba(0,0,0,0.1);
    position: relative;
    aspect-ratio: 1 / 1;
    max-width: 600px;
    width: 90vw;
}

.intersection {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

/* Grid Lines */
.intersection::before,
.intersection::after {
    content: '';
    position: absolute;
    background-color: #a0522d;
    z-index: 0;
}
.intersection::before { left: 0; right: 0; top: 50%; height: 1px; transform: translateY(-50%); }
.intersection::after { top: 0; bottom: 0; left: 50%; width: 1px; transform: translateX(-50%); }

/* Piece Styling */
.piece {
    position: absolute;
    width: 85%;
    height: 85%;
    border-radius: 50%;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3), inset 1px 1px 3px rgba(255, 255, 255, 0.1);
    z-index: 1;
    cursor: default;
    transform: translate(-50%, -50%);
    top: 50%;
    left: 50%;
    box-sizing: border-box;
}

/* Piece Placement Animation */
@keyframes placePieceAnim {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0.5; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.piece-appear {
    animation: placePieceAnim 0.2s ease-out forwards;
}


.black-piece {
    background: radial-gradient(circle at 35% 35%, #666, #111);
    border: 1px solid #000;
}

.white-piece {
    background: radial-gradient(circle at 65% 65%, #fff, #d0d0d0);
    border: 1px solid #b0b0b0;
}

/* Hover effect for valid moves */
.intersection:not(.occupied):not(.game-over *):hover { /* Check not game over */
     background-color: rgba(0, 0, 0, 0.05); /* Subtle highlight */
     cursor: pointer;
}
.intersection.occupied, .game-over .intersection {
    cursor: default; /* Or not-allowed */
}


/* Game Over State */
.game-over #board {
    /* opacity: 0.85; Slightly fade board */
    cursor: default; /* Change board cursor */
}
.game-over .intersection {
    cursor: default !important; /* Ensure cursor changes */
    pointer-events: none; /* Disable all pointer events */
}
.game-over .intersection:hover {
    background-color: transparent; /* Remove hover effect */
}


/* Winning Line Highlight */
.winning-piece {
     outline: 3px solid gold;
     outline-offset: 1px;
     box-shadow: 0 0 10px 3px gold, 2px 2px 5px rgba(0, 0, 0, 0.3), inset 1px 1px 3px rgba(255, 255, 255, 0.1);
     /* Ensure winning piece is visually distinct */
     z-index: 2; /* Make sure outline is fully visible */
}

/* Responsive adjustments */
@media (max-width: 750px) {
     #board { max-width: 95vw; }
     .game-container { padding: 15px; }
}

@media (max-width: 650px) {
    h1 { font-size: 1.5em; }
    .game-info { padding: 0; flex-direction: column; align-items: stretch; padding-bottom: 15px; gap: 10px; }
    #status { text-align: center; margin-bottom: 10px; }
    #new-game-button { width: 100%; padding: 10px 20px; }
    .options { flex-direction: column; align-items: stretch; gap: 12px; }
    .options label { margin-right: 0; margin-bottom: 3px; text-align: center; }
    .options select { width: 100%; box-sizing: border-box; }
    #board { max-width: 90vw; border-width: 2px; }
    .piece { width: 80%; height: 80%; }
}

@media (max-width: 400px) {
     h1 { font-size: 1.3em; }
     #status { font-size: 1em; }
     .piece { box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3); }
     .winning-piece { outline-width: 2px; }
}