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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    padding: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

h3 {
    margin: 15px 0 10px;
    color: #444;
}

.editor-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.board-container {
    flex: 1;
    min-width: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.janggi-board {
    width: 100%;
    /* 고정 크기 제거 */
    max-width: 500px;
    /* 최대 크기 제한 */
    aspect-ratio: 9 / 10;
    /* 비율 유지 */
    background-image: url('../images/JanggiOrange.png');
    background-size: contain;
    background-repeat: no-repeat;
    position: relative;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(10, 1fr);
}

.janggi-cell {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.janggi-cell.highlight {
    background-color: rgba(255, 255, 0, 0.3);
}

.janggi-piece {
    width: 80%;
    height: 80%;
    position: absolute;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s;
}

.janggi-piece img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pieces-palette {
    flex: 1;
    min-width: 200px;
    /* 모바일에서 최소 크기 설정 */
    padding: 10px;
    /* 여백 줄이기 */
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

.palette-pieces {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.palette-piece {
    width: 50px;
    /* 크기 줄이기 */
    height: 50px;
    /* 크기 줄이기 */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #eee;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, background-color 0.2s;
}

.palette-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.palette-piece img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    /* 모바일에서 중앙 정렬 */
}

button {
    padding: 8px 10px;
    /* 버튼 크기 줄이기 */
    font-size: 12px;
    /* 폰트 크기 줄이기 */
}

button:hover {
    background-color: #3e8e41;
}

button#remove-piece {
    background-color: #f44336;
}

button#remove-piece:hover {
    background-color: #d32f2f;
}

.fen-container {
    margin-top: 20px;
    padding: 10px;
    /* 여백 줄이기 */
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

textarea {
    width: 100%;
    padding: 8px;
    /* 여백 줄이기 */
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    font-family: monospace;
    margin-bottom: 10px;
}

.fen-controls {
    display: flex;
    gap: 10px;
}

.janggi-piece.selected {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.7);
    z-index: 20;
}

.palette-piece.active {
    background-color: #ffe066;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.is-removing .janggi-piece:hover {
    opacity: 0.5;
    background-color: rgba(255, 0, 0, 0.2);
    border-radius: 50%;
}

/* 미디어 쿼리: 모바일 화면 대응 */
@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
        /* 세로 배치 */
        align-items: center;
    }

    .board-container {
        min-width: 100%;
        /* 화면 크기에 맞게 확장 */
    }

    .janggi-board {
        max-width: 100%;
        /* 화면 크기에 맞게 확장 */
    }

    .pieces-palette {
        min-width: 100%;
        /* 화면 크기에 맞게 확장 */
    }

    .controls {
        flex-direction: column;
        /* 버튼 세로 배치 */
        gap: 5px;
    }

    button {
        width: 100%;
        /* 버튼 너비 확장 */
    }

    textarea {
        font-size: 14px;
        /* 폰트 크기 조정 */
    }
}