/* === General Styles === */
body {
    background-color: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: 'Arial', sans-serif;
    color: #ccc;
    overflow-x: hidden;
    padding: 20px;
    box-sizing: border-box;
}

/* === Container === */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 1100px;
}

/* === Title === */
#game-title {
    color: #fff;
    font-size: 2.5em;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    user-select: none;
    text-align: center;
    padding: 0 10px;
}

/* === Turn Indicator === */
#turn-indicator {
    color: #00ff88;
    font-size: 1em;
    font-weight: bold;
    text-align: center;
    padding: 6px 12px;
    border: 2px solid #00ff88;
    border-radius: 25px;
    background-color: rgba(0, 255, 136, 0.1);
    transition: all 0.3s ease;
    user-select: none;
}

#turn-indicator.ai-thinking {
    color: #ffaa00;
    border-color: #ffaa00;
    background-color: rgba(255, 170, 0, 0.1);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* === Board Container === */
#board-container {
    width: 100%;
    max-width: 80vmin;
    aspect-ratio: 1 / 1;
    background-color: #2a2a2a;
    border: 3px solid #444;
    border-radius: 8px;
    padding: 5px;
    box-sizing: border-box;
}

/* === Board Grid === */
#board {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(16, 1fr);
    width: 100%;
    height: 100%;
    border: 2px solid #ccc;
    box-sizing: border-box;
}

/* === Cell Styles === */
.cell {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    background-color: #f0d9b5;
    outline: none;
    user-select: none;
    transition: outline 0.1s ease, box-shadow 0.2s ease;
}

.cell.dark {
    background-color: #b58863;
}

.cell:focus {
    outline: 2px solid #00ff88 !important;
    box-shadow: 0 0 6px 3px rgba(0, 255, 136, 0.5);
    z-index: 2;
}

.piece {
    border: none;
    display: block;
    background: transparent;
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    z-index: 5;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
}

.cell:hover .piece {
    filter: brightness(1.1);
    transition: filter 0.2s ease, transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.piece.capturing {
    animation: captureAnimation 0.3s ease-out forwards;
    z-index: 10;
}

@keyframes captureAnimation {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(5deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0) rotate(15deg);
        opacity: 0;
    }
}

.piece.moving {
    z-index: 15;
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* === Move Indicator === */
.legal-move::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15%;
    height: 15%;
    background-color: rgba(100, 255, 126, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* === Column Labels === */
#col-labels {
    display: grid;
    grid-template-columns: 1fr repeat(16, 1fr);
    width: 100%;
    max-width: 90vmin;
    margin: 0 auto 5px auto;
    font-size: 10px;
}

#col-labels span {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ccc;
}

/* === Row Labels === */
#grid-with-rows {
    display: grid;
    grid-template-rows: repeat(16, 1fr);
    width: 100%;
    max-width: 90vmin;
}

.board-row {
    display: grid;
    grid-template-columns: 1fr repeat(16, 1fr);
}

.row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 10px;
}

/* === Game Options === */
#game-options-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.button-group {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

#undo-btn, #surrender-btn {
    padding: 8px 16px;
    border: 2px solid #555;
    border-radius: 25px;
    background-color: #3a3a3a;
    color: #ccc;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

#undo-btn:hover {
    background-color: #4a4a4a;
    border-color: #00ff88;
    color: #00ff88;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 255, 136, 0.2);
}

#surrender-btn:hover {
    background-color: #4a4a4a;
    border-color: #ff4444;
    color: #ff4444;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 68, 68, 0.2);
}

#undo-btn:active, #surrender-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* === Rulebook Scroll === */
#rulebook-scroll {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    max-height: 85vh;
    border: 3px solid #8b4513;
    border-radius: 15px;
    box-shadow:
        inset 0 0 20px rgba(139, 69, 19, 0.3),
        0 10px 25px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(139, 69, 19, 0.2);
    overflow-y: auto;
    z-index: 500;
    font-family: 'Georgia', serif;
}

#scroll-content {
    padding: 25px 20px;
    color: #e4d1ca;
    line-height: 1.4;
}

#scroll-content h2 {
    text-align: center;
    color: #d17534;
    font-size: 1.4em;
    margin: 0 0 20px 0;
    text-shadow: 2px 2px 4px rgba(139, 69, 19, 0.3);
    border-bottom: 2px solid #8b4513;
    padding-bottom: 10px;
}

#scroll-content h3 {
    color: #ebb37a;
    font-size: 1.1em;
    margin: 15px 0 8px 0;
    font-weight: bold;
}

.scroll-section {
    margin-bottom: 12px;
    padding: 5px 0;
}

.scroll-section p {
    margin: 8px 0;
    font-size: 14px;
    text-align: justify;
}

.terrain-rule {
    background: rgba(139, 69, 19, 0.08);
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 3px solid #8b4513;
    border-radius: 5px;
    font-size: 13px;
}

.scroll-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #8b4513;
    font-size: 13px;
    color: #c78848;
}

.scroll-footer em {
    display: block;
    margin-bottom: 8px;
    font-style: italic;
}

/* === Scrollbar Styling === */
#rulebook-scroll::-webkit-scrollbar {
    width: 8px;
}

#rulebook-scroll::-webkit-scrollbar-track {
    background: rgba(139, 69, 19, 0.2);
    border-radius: 4px;
}

#rulebook-scroll::-webkit-scrollbar-thumb {
    background: #8b4513;
    border-radius: 4px;
}

#rulebook-scroll::-webkit-scrollbar-thumb:hover {
    background: #654321;
}

/* === Game Footer === */
#game-footer {
    position: fixed;
    bottom: 10px;
    right: 15px;
    font-size: 12px;
    color: #666;
    font-family: 'Arial', sans-serif;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

#game-footer:hover {
    opacity: 1;
}
/* ===== Mobile Rulebook Section ===== */
#mobile-rulebook {
    display: none;
    width: 100%;
    border: 2px solid #8b4513;
    border-radius: 10px;
    padding: 16px;
    margin-top: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    font-family: 'Georgia', serif;
}

#mobile-scroll-content h2 {
    text-align: center;
    color: #8b4513;
    font-size: 1.3em;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

#mobile-scroll-content h3 {
    color: #6b4226;
    font-size: 1.1em;
    margin: 15px 0 8px 0;
    font-weight: bold;
}

.terrain-rule {
    background: rgba(139, 69, 19, 0.06);
    margin: 6px 0;
    padding: 10px;
    border-left: 4px solid #8b4513;
    border-radius: 5px;
    font-size: 14px;
    line-height: 1.4;
}

.scroll-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #c78848;
    font-style: italic;
}

/* ===== Responsive Logic ===== */
@media (max-width: 768px) {
    #rulebook-scroll {
        display: none !important;
    }

    #mobile-rulebook {
        display: block;
    }
}

@media (min-width: 769px) {
    #mobile-rulebook {
        display: none;
    }
}

@media (max-width: 600px) {
    #board-container {
        max-width: 98vw;
        padding: 2px;
        border-width: 2px;
    }
    #board {
        max-width: 98vw;
        max-height: 98vw;
        width: 98vw;
        height: 98vw;
        border-width: 1px;
    }
    #col-labels, #grid-with-rows {
        max-width: 98vw;
        font-size: 8px;
    }
    .row-label {
        font-size: 8px;
    }
    .cell {
        min-width: 0;
        min-height: 0;
    }
}
