/* 전체 레이아웃 */
* {
    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%);
    color: #333;
    overflow: hidden;
    height: 100vh;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 헤더 */
.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.header h1 {
    font-size: 24px;
    color: #4a5568;
    margin: 0;
}

/* 앱 설치 버튼 */
.install-btn {
    background: #4299e1;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.install-btn:hover {
    background: #3182ce;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.install-btn.hidden {
    display: none;
}

/* 메인 컨테이너 */
.main-container {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 20px;
    height: calc(100vh - 70px);
}

/* 왼쪽: 카메라 섹션 */
.camera-section {
    flex: 2;
    position: relative;
    background: #1a202c;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

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

#videoElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    transform: scaleX(-1); /* 좌우 반전 */
}

#canvasElement {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    transform: scaleX(-1); /* 좌우 반전 */
}

/* 수학 문제 오버레이 */
.problem-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    pointer-events: none;
    padding-top: 50px; /* 더 위쪽으로 올리기 */
}

.math-problem {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px 50px;
    border-radius: 20px;
    font-size: 48px;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 60px; /* 답안과 더 떨어뜨리기 */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: 3px solid #4299e1;
}

.answer-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px; /* 답안 옵션들 사이 간격 증가 */
    width: 450px; /* 전체 너비 증가 */
}

.answer-option {
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    color: #2d3748;
    border: 3px solid #4299e1; /* 기본 테두리도 통일된 색으로 */
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
}

.answer-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.answer-option.correct {
    border-color: #4299e1; /* 모든 테두리 동일한 색으로 통일 */
}

.answer-option.selected {
    background: #4299e1;
    color: white;
    border-color: #4299e1; /* 통일된 테두리 색 */
}

.answer-option.wrong {
    background: #f56565;
    color: white;
    border-color: #4299e1; /* 통일된 테두리 색 */
}

/* 오른쪽: 컨트롤 섹션 */
.control-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 100%;
    overflow-y: auto;
}

/* 난이도 패널 */
.difficulty-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.difficulty-panel h3 {
    margin-bottom: 15px;
    color: #2d3748;
    font-size: 18px;
}

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

.difficulty-btn {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    color: #4a5568;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    line-height: 1.3;
}

.difficulty-btn:hover {
    background: #f7fafc;
    border-color: #4299e1;
}

.difficulty-btn.active {
    background: #4299e1;
    color: white;
    border-color: #3182ce;
}

/* 게임 상태 */
.game-status {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.score-display {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
}

.score-item:last-child {
    border-bottom: none;
}

.label {
    font-size: 14px;
    color: #718096;
    font-weight: 500;
}

.value {
    font-size: 18px;
    font-weight: bold;
    color: #2d3748;
}

/* 게임 컨트롤 */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-btn {
    padding: 15px 20px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.start-btn {
    background: #48bb78;
    color: white;
}

.start-btn:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
}

.pause-btn {
    background: #ed8936;
    color: white;
}

.pause-btn:hover:not(:disabled) {
    background: #dd6b20;
    transform: translateY(-2px);
}

.reset-btn {
    background: #e53e3e;
    color: white;
}

.reset-btn:hover:not(:disabled) {
    background: #c53030;
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 도움말 패널 */
.help-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.help-panel h4 {
    margin-bottom: 12px;
    color: #2d3748;
    font-size: 16px;
}

.help-panel ul {
    list-style: none;
    color: #4a5568;
}

.help-panel li {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
}



/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2d3748;
    font-size: 24px;
}

.modal-content p {
    margin-bottom: 30px;
    color: #4a5568;
    font-size: 16px;
}

.modal-btn {
    padding: 12px 30px;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

/* 로딩 화면 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #4299e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 16px;
    margin: 0;
}

/* 반응형 디자인 - 패드 세로 모드 */
@media screen and (max-width: 1024px) and (orientation: portrait) {
    .main-container {
        flex-direction: column;
    }
    
    .camera-section {
        flex: 1;
        min-height: 60%;
    }
    
    .control-section {
        flex: none;
        height: auto;
        max-height: 40%;
    }
    
    .difficulty-buttons {
        flex-direction: row;
    }
    
    .difficulty-btn {
        flex: 1;
        font-size: 12px;
        padding: 10px 8px;
    }
}

/* 작은 화면 대응 */
@media screen and (max-width: 768px) {
    .header h1 {
        font-size: 20px;
    }
    
    .math-problem {
        font-size: 36px;
        padding: 20px 30px;
    }
    
    .answer-options {
        width: 300px;
    }
    
    .answer-option {
        font-size: 24px;
        padding: 15px;
    }
    
    .control-section {
        gap: 15px;
    }
    
    .difficulty-panel,
    .game-status,
    .help-panel {
        padding: 15px;
    }
} 