/* ====================================
   1. 기본 레이아웃 및 전체 스타일
   ==================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f4f4f4; /* 밝은 배경 */
    margin: 0;
    padding: 20px;
}

header {
    margin-bottom: 20px;
    text-align: center;
}

h1 {
    color: #333;
}

.btn {
    text-decoration: none;
    padding: 8px 15px;
    background-color: #5cb85c;
    color: white;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #449d44;
}


/* ====================================
   2. 체스판과 칸 스타일
   ==================================== */
:root {
    --square-size: 80px;
}

#chessboard {
    display: grid;
    /* 8x8 그리드 레이아웃 생성 */
    grid-template-columns: repeat(8, var(--square-size));
    grid-template-rows: repeat(8, var(--square-size));
    border: 5px solid #2c3e50; /* 테두리 */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    width: calc(var(--square-size) * 8);
    max-width: 100%;
}

.square {
    width: var(--square-size);
    height: var(--square-size);
    display: flex; /* 말을 칸 중앙에 놓기 위해 flex 사용 */
    justify-content: center;
    align-items: center;
    position: relative;
    /* transition: background-color 0.1s; */
}

/* 칸 색상 정의 */
.square.light {
    background-color: #f0d9b5; /* 밝은 칸 (나무색 계열) */
}

.square.dark {
    background-color: #b58863; /* 어두운 칸 (진한 나무색 계열) */
}

/* 이동 가능한 칸, 선택된 칸 등 하이라이트 */
.square.selected {
    background-color: #a87932; /* 선택된 칸 색상 */
    opacity: 0.9;
}

.square.highlight {
    background-color: rgba(68, 178, 255, 0.5); /* 이동 가능한 칸 하이라이트 */
}


/* ====================================
   3. 유니코드 말 스타일
   ==================================== */
.piece {
    /* 유니코드 문자의 모양이 폰트에 따라 바뀌지 않도록 통일 */
    font-family: "Lucida Sans Unicode", "Arial Unicode MS", sans-serif; 
    /* 칸 중앙에 위치하도록 이미 flex가 되어있음 */
    font-size: calc(var(--square-size) * 0.75); /* 말의 크기 지정 (80px 칸에 맞춤) */
    text-align: center;
    cursor: pointer;
    user-select: none; /* 드래그 방지 */
    position: absolute; /* 칸 안에서 절대 위치 */
}

/* 흰색 말 스타일 */
.piece.white {
    color: #f0f0f0; /* 밝은 색상 */
    /* 말이 배경에 묻히지 않도록 검은색 테두리 추가 */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8), -1px -1px 2px rgba(0, 0, 0, 0.8); 
}

/* 검은색 말 스타일 */
.piece.black {
    color: #333333; /* 어두운 색상 */
    /* 말이 배경에 묻히지 않도록 흰색 테두리 추가 */
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8), -1px -1px 2px rgba(255, 255, 255, 0.8);
}


/* ====================================
   4. 기타 요소 (컨트롤 및 상태)
   ==================================== */
#controls {
    margin: 15px 0;
}

#controls button {
    padding: 10px 20px;
    margin: 0 5px;
    font-size: 16px;
    cursor: pointer;
}

#status {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}


/* ====================================
   5. 승진 선택 오버레이 스타일
   ==================================== */
#promo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#promo-options {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    gap: 15px;
}

.promo-piece {
    font-size: calc(var(--square-size) * 0.9); /* 크게 표시 */
    cursor: pointer;
    padding: 10px;
    border: 2px solid transparent;
    transition: border 0.2s;
}

.promo-piece:hover {
    border: 2px solid #3498db;
}

.hidden {
    display: none !important;
}

/* ====================================
   6. 반응형 조정 (모바일 대응)
   ==================================== */
@media (max-width: 900px) {
    :root {
        --square-size: 60px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 15px;
    }

    :root {
        --square-size: 48px;
    }

    #controls button {
        padding: 8px 14px;
        font-size: 14px;
    }
}

@media (max-width: 420px) {
    :root {
        --square-size: 40px;
    }

    #controls {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    #controls button {
        width: 100%;
    }
}

@media (max-width: 360px) {
    :root {
        --square-size: 34px;
    }
}
