/* CSS 변수를 통한 테마 관리 */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-bg: #ecf0f1;
    --dark-bg: #2c3e50;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    position: relative;
}

/* 화면 전환 */
.screen {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 메인 화면 */
.main-content {
    text-align: center;
    background: white;
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: var(--shadow-hover);
    max-width: 500px;
    margin: 0 auto;
}

.game-title {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
    letter-spacing: 1px;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.difficulty-setting {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.difficulty-setting label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

#difficulty-select {
    padding: 12px 20px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

#difficulty-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.start-button {
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.start-button:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* 게임 화면 */
.game-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    position: relative;
}

.back-button {
    position: absolute;
    left: 0;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--primary-color);
    font-weight: 600;
}

.back-button:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.game-header h2 {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-hover);
}

.score-section {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 30px;
    align-items: center;
}

.player-score, .ai-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--light-bg);
    border-radius: 15px;
}

.score-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.score-disc {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    box-shadow: var(--shadow);
}

.score-disc.black {
    background: #2c3e50;
}

.score-disc.white {
    background: #ecf0f1;
}

.score-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
}

/* 게임판 */
.game-board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 2px;
    background: var(--primary-color);
    padding: 10px;
    border-radius: 15px;
    box-shadow: var(--shadow-hover);
    width: 400px;
    height: 400px;
}

.cell {
    background: var(--success-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.cell:hover {
    background: #2ecc71;
    transform: scale(0.95);
}

.cell.valid-move {
    background: #f1c40f;
    box-shadow: inset 0 0 10px rgba(241, 196, 15, 0.5);
}

.cell.valid-move:hover {
    background: #f39c12;
}

.disc {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.disc.black {
    background: #2c3e50;
}

.disc.white {
    background: #ecf0f1;
}

.disc.flipping {
    animation: flip 0.6s ease-in-out;
}

@keyframes flip {
    0%, 100% { transform: rotateY(0deg); }
    50% { transform: rotateY(180deg) scale(1.1); }
}

.game-status {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    text-align: center;
    padding: 15px 25px;
    background: var(--light-bg);
    border-radius: 25px;
    border: 2px solid var(--border-color);
}

/* 게임 종료 팝업 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    animation: modalFadeIn 0.3s ease-out;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 25px;
    padding: 40px 35px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 90%;
    text-align: center;
    transform: scale(0.8);
    animation: modalSlideIn 0.3s ease-out forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { 
        transform: scale(0.8) translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.game-over-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

.game-over-header h2 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.result-emoji {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: bounce 1s ease-in-out infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0px); }
    to { transform: translateY(-10px); }
}

.final-scores {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 25px 0;
    padding: 25px 20px;
    background: linear-gradient(135deg, var(--light-bg) 0%, #d5dbdb 100%);
    border-radius: 20px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.final-score span:first-of-type {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.final-score-value {
    font-size: 2.2rem !important;
    font-weight: 800 !important;
    color: var(--primary-color) !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-vs {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-secondary);
    margin: 0 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.game-over-message {
    margin: 25px 0;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    border-left: 5px solid var(--accent-color);
}

.game-over-message p {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
    line-height: 1.4;
    white-space: pre-line; /* 줄바꿈 문자를 실제 줄바꿈으로 표시 */
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.modal-button {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 120px;
}

.modal-button.primary {
    background: linear-gradient(135deg, var(--success-color) 0%, #229954 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.modal-button.primary:hover {
    background: linear-gradient(135deg, #229954 0%, #1e8449 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.modal-button.secondary {
    background: linear-gradient(135deg, var(--text-secondary) 0%, #6c7b7d 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(127, 140, 141, 0.3);
}

.modal-button.secondary:hover {
    background: linear-gradient(135deg, #6c7b7d 0%, #5d6d6e 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(127, 140, 141, 0.4);
}

/* 승리/패배별 테마 */
.modal.victory .result-emoji {
    color: #f1c40f;
}

.modal.defeat .result-emoji {
    color: #e74c3c;
}

.modal.tie .result-emoji {
    color: #3498db;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        padding: 40px 20px;
        margin: 20px;
    }
    
    .game-title {
        font-size: 3rem;
    }
    
    .score-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .game-board {
        width: 320px;
        height: 320px;
    }
    
    .game-content {
        padding: 20px;
    }
    
    .back-button {
        position: static;
        margin-bottom: 10px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .game-board {
        width: 280px;
        height: 280px;
    }
    
    .main-content {
        margin: 10px;
        padding: 30px 15px;
    }
    
    .game-over-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .final-scores {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .modal-content {
        width: 95%;
        padding: 30px 20px;
        margin: 10px;
    }
    
    .game-over-header h2 {
        font-size: 1.8rem;
    }
    
    .result-emoji {
        font-size: 2.5rem;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-button {
        width: 100%;
        padding: 12px 20px;
    }
}

/* 접근성 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 포커스 스타일 */
button:focus,
select:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.cell:focus {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}
