/* General Page Structure */
body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    color: #343a40;
    line-height: 1.6;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Game Section */
#game-section {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 2.5rem;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.go-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.board-size-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
}

.board-size-label {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
}

.btn-size {
    background: #e9ecef;
    color: #343a40;
    border: 1px solid #ced4da;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-size:hover {
    background: #dee2e6;
}

.btn-size.selected {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 10px 0;
}

.player-turn {
    font-size: 1.2rem;
    font-weight: 500;
    color: #343a40;
}

.scores {
    display: flex;
    gap: 1rem;
}

.black-score, .white-score {
    font-size: 1rem;
    font-weight: 500;
}


:root {
    --go-cell-size: 60px;
    --go-border: 15px;
    --go-line: 2px;
}

#go-board {
    display: grid;
    grid-template-columns: repeat(19, var(--go-cell-size));
    grid-template-rows: repeat(19, var(--go-cell-size));
    background-color: #d4a574; /* Wood color */
    border: var(--go-border) solid #63370e; /* Darker, thicker wood border */
    border-radius: 10px; /* Slightly rounded corners for the frame */
    padding: 0; /* No padding so lines touch border */
    box-shadow: 0 10px 25px rgba(0,0,0,0.3), 
                inset 0 0 10px rgba(0,0,0,0.2); /* Deeper shadow and inner shadow */
    position: relative;
    width: fit-content;
    max-width: 96vw;
    max-height: 82vh;
    box-sizing: border-box;
    overflow: hidden;
}

.go-intersection {
    width: var(--go-cell-size);
    height: var(--go-cell-size);
    position: relative;
    cursor: pointer;
    touch-action: manipulation;
}

.go-intersection::before, .go-intersection::after {
    content: '';
    position: absolute;
    background-color: #333; /* Line color */
    z-index: 0;
}

.go-intersection::before { /* Horizontal line */
    left: 0;
    right: 0;
    top: 50%;
    height: var(--go-line);
    transform: translateY(calc(-0.5 * var(--go-line)));
}

.go-intersection::after { /* Vertical line */
    top: 0;
    bottom: 0;
    left: 50%;
    width: var(--go-line);
    transform: translateX(calc(-0.5 * var(--go-line)));
}

/* Star points (Hoshi) */
.go-intersection.star-point::before {
    background: radial-gradient(circle, #333 4px, transparent 4px);
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transform: none;
    z-index: 0;
}

.go-stone {
    border-radius: 50%;
    position: absolute;
    z-index: 1;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(var(--go-cell-size) - 10px);
    height: calc(var(--go-cell-size) - 10px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.go-stone.black {
    background: radial-gradient(circle at 35% 35%, #666 1%, #000 70%);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    border: none;
}

.go-stone.white {
    background: radial-gradient(circle at 35% 35%, #fff 1%, #e6e6e6 60%, #ccc 100%);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    border: none;
}

.go-stone.white.last-move {
    box-shadow: none;
    animation: bluePulse 1.6s ease-in-out infinite;
}

@keyframes bluePulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
    50% { box-shadow: 0 0 18px 8px rgba(0, 123, 255, 0.75); }
    100% { box-shadow: 0 0 0 0 rgba(0, 123, 255, 0); }
}

.captured-info {
    display: flex;
    justify-content: space-between;
    width: 600px; /* Approximately match board width */
    margin: 10px 0;
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.go-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.primary-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

#pass, #new-game {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

#pass:hover, #new-game:hover {
    background-color: #0056b3;
}

#message {
    font-size: 1.1rem;
    font-weight: 500;
    min-height: 24px;
}

/* Internal Navigation / More Games */
.internal-nav {
    text-align: center;
    margin-bottom: 3rem;
}

.internal-nav h3 {
    font-size: 2.5rem;
    font-weight: 600;
    color: #003366;
    margin-top: 0;
    margin-bottom: 2rem;
}

.game-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.game-btn {
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e9ecef;
    color: #343a40;
    text-decoration: none;
}

.game-btn:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.game-btn img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.game-btn span {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Info Sections & Cards */
.info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.info-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 2.5rem;
}

.info-card.full-width {
    grid-column: 1 / -1;
}

.info-card h2 {
    font-size: 2rem;
    font-weight: 600;
    color: #003366;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.info-card p, .info-card li {
    color: #343a40;
}

.info-card ul, .info-card ol {
    padding-left: 20px;
}

@media (max-width: 1100px) {
    :root {
        --go-cell-size: 44px;
        --go-border: 13px;
        --go-line: 2px;
    }
}

/* Responsive Design */
@media (max-width: 992px) {
    .info-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    main {
        padding: 2rem 1rem;
    }
    #game-section, .info-card {
        padding: 2rem;
    }
    .internal-nav h3, .info-card h2 {
        font-size: 2rem;
    }
    :root {
        --go-cell-size: 26px;
        --go-border: 10px;
        --go-line: 1.6px;
    }
}

@media (max-width: 620px) {
    #game-section {
        padding: 1.5rem;
    }
    #go-board {
        max-width: 92vw;
        border-width: 12px;
    }
    .captured-info {
        width: 100%;
        flex-direction: column;
        align-items: center;
        gap: 0.4rem;
        text-align: center;
    }
    .primary-controls, .board-size-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    :root {
        --go-cell-size: 20px;
        --go-border: 10px;
        --go-line: 1.4px;
    }
    .board-size-controls {
        row-gap: 0.5rem;
    }
    .btn-size,
    #pass,
    #new-game {
        padding: 0.65rem 1.1rem;
    }
}

@media (orientation: portrait) and (max-width: 540px) {
    #game-section {
        padding: 1.25rem;
    }
    #go-board {
        max-width: 94vw;
    }
    :root {
        --go-cell-size: clamp(17px, 4.4vw, 22px);
        --go-border: 10px;
        --go-line: 1.4px;
    }
    .captured-info {
        width: 100%;
        flex-direction: column;
        gap: 0.4rem;
        text-align: center;
        align-items: center;
    }
    .primary-controls,
    .board-size-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (orientation: portrait) and (max-width: 430px) {
    #go-board {
        width: calc(min(100vw, 100vh) - 2 * var(--go-border));
        height: calc(min(100vw, 100vh) - 2 * var(--go-border));
        max-width: none;
        max-height: none;
        grid-template-columns: repeat(19, 1fr);
        grid-template-rows: repeat(19, 1fr);
    }
    .go-intersection {
        width: 100%;
        height: 100%;
    }
    .go-stone {
        width: calc(100% - 10px);
        height: calc(100% - 10px);
    }
    :root {
        --go-cell-size: 16px; /* Not used, but keep */
        --go-border: 8px;
        --go-line: 1.4px;
    }
    .captured-info {
        width: 100%;
        flex-direction: column;
        gap: 0.35rem;
        text-align: center;
        align-items: center;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    #go-board {
        width: calc(min(100vw, 100vh) - 2 * var(--go-border));
        height: calc(min(100vw, 100vh) - 2 * var(--go-border));
        max-width: none;
        max-height: none;
        grid-template-columns: repeat(19, 1fr);
        grid-template-rows: repeat(19, 1fr);
    }
    .go-intersection {
        width: 100%;
        height: 100%;
    }
    .go-stone {
        width: calc(100% - 10px);
        height: calc(100% - 10px);
    }
    :root {
        --go-cell-size: 15px; /* Not used */
        --go-border: 10px;
        --go-line: 1.2px;
    }
    .captured-info {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: center;
    }
    .primary-controls,
    .board-size-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}