* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.container {
    display: flex;
    max-width: 1400px;
    margin: 2rem auto;
    gap: 2rem;
    padding: 0 1rem;
}

.sidebar {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lesson-panel, .instruction-panel, .controls, .problems-panel, .progress-panel {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.lesson-panel h3, .instruction-panel h3, .progress-panel h3, .problems-panel h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
}

.lesson-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lesson-btn {
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
}

.lesson-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.lesson-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.lesson-btn.completed {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.lesson-btn.special {
    background: linear-gradient(135deg, #fd7e14 0%, #e83e8c 100%) !important;
    color: white !important;
    font-weight: 600;
}

.control-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.control-btn:active {
    transform: translateY(0);
}

/* 사활문제 설정 */
.problems-panel {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border: 2px solid #e9ecef;
}

.difficulty-selector, .problem-count-selector, .problem-type-selector {
    margin-bottom: 1rem;
}

.difficulty-selector label, .problem-count-selector label, .problem-type-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #495057;
}

.difficulty-selector select, .problem-count-selector select {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.3s ease;
}

.difficulty-selector select:focus, .problem-count-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.type-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.type-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.type-checkboxes label:hover {
    background-color: #f8f9fa;
}

.type-checkboxes input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

/* 진행 상황 */
.problem-progress, .overall-progress {
    text-align: center;
    margin-bottom: 1rem;
}

.progress-info {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #667eea;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    transition: width 0.5s ease;
    width: 0%;
}

.score-info, .lesson-completion {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

.overall-progress h4 {
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 1rem;
}

/* 보드 컨테이너 */
.board-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.board-wrapper {
    position: relative;
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.problem-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    text-align: center;
}

.problem-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
}

.problem-instruction {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.problem-timer {
    font-size: 0.9rem;
    opacity: 0.9;
}

.go-board-svg {
    width: 570px;
    height: 570px;
    border-radius: 10px;
    cursor: crosshair;
    border: 2px solid #8b4513;
}

/* 교차점 스타일 */
.intersection-point {
    fill: transparent;
    stroke: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.intersection-point:hover {
    fill: rgba(0, 0, 0, 0.1);
}

/* 바둑돌 스타일 */
.stone {
    cursor: pointer;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
    transition: all 0.3s ease;
}

.stone.black {
    fill: url(#blackGradient);
}

.stone.white {
    fill: url(#whiteGradient);
    stroke: #ccc;
    stroke-width: 1;
}

.stone.hint {
    opacity: 0.5;
    animation: pulse 2s infinite;
}

.stone.correct-move {
    stroke: #28a745;
    stroke-width: 3;
    animation: correctPulse 1s ease-in-out;
}

.stone.wrong-move {
    stroke: #dc3545;
    stroke-width: 3;
    animation: wrongShake 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

@keyframes correctPulse {
    0% { stroke-width: 3; }
    50% { stroke-width: 6; }
    100% { stroke-width: 3; }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* 좌표 라벨 */
.coordinate-labels {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.coord-top, .coord-left {
    position: absolute;
    display: flex;
    font-size: 0.9rem;
    color: #666;
    font-weight: bold;
}

.coord-top {
    top: -30px;
    left: 45px;
    right: 45px;
    justify-content: space-between;
}

.coord-left {
    left: -30px;
    top: 45px;
    bottom: 45px;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

/* 성취도 패널 */
.achievement-panel {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.achievement-panel h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.2rem;
}

.achievements {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.achievement {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.achievement.unlocked {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    transform: scale(1.02);
}

.achievement.locked {
    background: #f8f9fa;
    color: #999;
}

.achievement .icon {
    font-size: 1.5rem;
    width: 2rem;
    text-align: center;
}

.achievement .text .title {
    font-weight: 600;
    font-size: 0.95rem;
}

.achievement .text .desc {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* 모달 */
.result-modal, .help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    margin: 1rem;
}

.result-modal h3.correct {
    color: #28a745;
}

.result-modal h3.incorrect {
    color: #dc3545;
}

.result-stats {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: left;
}

.help-content {
    text-align: left;
    margin: 1rem 0;
}

.help-content h4 {
    color: #667eea;
    margin: 1rem 0 0.5rem 0;
}

.help-content p {
    margin-bottom: 0.5rem;
}

/* 플로팅 도움말 버튼 */
.floating-help {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 100;
}

.floating-help:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* 반응형 디자인 */
@media (max-width: 1200px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        flex: none;
        order: 2;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
    
    .board-wrapper {
        padding: 1rem;
    }
    
    .go-board-svg {
        width: 350px;
        height: 350px;
    }
    
    .coord-top {
        left: 27px;
        right: 27px;
    }
    
    .coord-left {
        left: -20px;
        top: 27px;
        bottom: 27px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .floating-help {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .go-board-svg {
        width: 280px;
        height: 280px;
    }
    
    .board-wrapper {
        padding: 0.5rem;
    }
    
    .modal-content {
        padding: 1rem;
        margin: 0.5rem;
    }
}

/* 다크모드 지원 */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        color: #ecf0f1;
    }
    
    .lesson-panel, .instruction-panel, .controls, .problems-panel, .progress-panel, .achievement-panel, .board-wrapper {
        background: #34495e;
        color: #ecf0f1;
    }
    
    .modal-content {
        background: #34495e;
        color: #ecf0f1;
    }
}
