/* 기본 스타일 */
body {
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    background-color: #f5f5f5;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

/* 언어 선택기 스타일 - 크기 조정 */
.language-selector {
    position: fixed;
    top: 10px; /* 15px에서 10px로 줄임 */
    right: 10px; /* 15px에서 10px로 줄임 */
    z-index: 1000;
}

.language-buttons {
    display: flex;
    background-color: #f0f0f0;
    border-radius: 16px; /* 20px에서 16px로 줄임 */
    padding: 2px; /* 3px에서 2px로 줄임 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.lang-btn {
    padding: 4px 8px; /* 6px 10px에서 4px 8px로 줄임 */
    border-radius: 14px; /* 17px에서 14px로 줄임 */
    border: none;
    background: transparent;
    font-size: 11px; /* 12px에서 11px로 줄임 */
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 28px; /* 32px에서 28px로 줄임 */
    text-align: center;
    color: #666;
}

.lang-btn.active {
    background-color: #fff;
    color: #5B9BFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 메인 컨테이너 */
.main-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 800px;
    margin: 32px auto 0 auto;
    flex-wrap: wrap;
    gap: 20px;
}

/* 룰렛 섹션 */
.roulette-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 200px;
}

/* 괘 형성 섹션 */
.hexagram-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 200px;
}

h1 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 16px;
}

.result-box {
    width: 100px;
    padding: 5px;
    margin-bottom: 10px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.result-display {
    font-size: 20px;
    font-weight: bold;
    padding: 5px;
    background-color: #e6f0ff;
    border-radius: 8px;
}

/* 룰렛 스타일 */
.roulette-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 10px;
}

.roulette {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #ccc;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pointer {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 10px solid #ff0000;
    z-index: 10;
}

.center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #333;
    z-index: 5;
}

/* 버튼 스타일 - 모바일 터치 최적화 */
button {
    padding: 12px 20px; /* 기존 8px 16px에서 확대 */
    font-size: 14px;
    background-color: #5B9BFF;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    -webkit-tap-highlight-color: rgba(91, 155, 255, 0.3); /* 터치 하이라이트 색상 설정 */
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.3);
    
    /* 모바일 터치 최적화 추가 */
    min-height: 44px; /* iOS 권장 최소 터치 타겟 크기 */
    min-width: 44px;
    position: relative;
    z-index: 100; /* 다른 요소 위에 오도록 */
    touch-action: manipulation; /* 터치 지연 제거 */
    user-select: none; /* 텍스트 선택 방지 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

button:hover {
    background-color: #4285f4;
}

button:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

/* AI 버튼 특별 스타일 */
.ai-button {
    background: linear-gradient(135deg, #5B9BFF, #4285f4);
    padding: 8px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(66, 133, 244, 0.3);
}

.ai-button:hover {
    background: linear-gradient(135deg, #4285f4, #3367d6);
    box-shadow: 0 6px 12px rgba(66, 133, 244, 0.4);
}

/* 로그 영역 */
.result-log {
    margin-top: 10px;
    width: 100%;
    padding: 8px;
    background-color: #fff;
    border-radius: 8px;
    font-size: 12px;
    max-height: 100px;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* 괘 스타일 */
.hexagram-container {
    width: 100%;
    max-width: 180px;
    margin-bottom: 10px;
    padding: 15px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.hexagram-title {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #464646;
}

.hexagram-lines {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.hexagram-line {
    width: 100%;
    height: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px dashed #ddd;
    border-radius: 4px;
    position: relative;
    transition: all 0.3s;
}

.hexagram-line.highlighted {
    background-color: #fffacd;
    border: 2px solid #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.yang-line {
    width: 80%;
    height: 4px;
    background-color: #333;
}

.yin-line {
    width: 80%;
    height: 4px;
    display: flex;
    justify-content: space-between;
}

.yin-line-part {
    width: 40%;
    height: 4px;
    background-color: #333;
}

.hexagram-status {
    text-align: center;
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    font-weight: bold;
}

.hexagram-number {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    margin-top: 5px;
    color: #4285f4;
}

/* 효 위치 표시 */
.line-position {
    position: absolute;
    left: -20px;
    font-size: 10px;
    color: #888;
}

/* 모달 스타일 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start; /* 이미 올바르게 설정되어 있음 */
    backdrop-filter: blur(3px);
    overflow-y: auto; /* 이 한 줄만 추가! */
    padding: 20px 0; /* 위아래 여백 추가 */
}

.modal {
    background-color: white;
    padding: 24px;
    border-radius: 16px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    margin-top: 32px;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 18px;
    color: #464646;
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-content {
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* 질문 모달 스타일 */
.question-item {
    padding: 12px;
    margin-bottom: 10px;
    border: 1.5px solid #e0e7ef;
    border-radius: 8px;
    cursor: pointer;
    background: #f7faff;
    color: #333;
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(91, 155, 255, 0.04);
}

.question-item:hover {
    background-color: #e6f0ff;
    color: #2563eb;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px rgba(91, 155, 255, 0.10);
}

.question-item.selected {
    background-color: #dbeafe;
    border-color: #4285f4;
    color: #2563eb;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.13);
}

/* 정보 확인 모달 스타일 */
.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.info-label {
    font-weight: bold;
    color: #555;
}

.language-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 15px;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 주역점 해석 모달 스타일 */
.interpretation-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.interpretation-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #464646;
}

.interpretation-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    line-height: 1.5;
}

.interpretation-content {
    margin-bottom: 20px;
}

.interpretation-section {
    margin-bottom: 16px;
}

.interpretation-section-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #5B9BFF;
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.keyword-tag {
    background: linear-gradient(135deg, #5B9BFF, #4285f4);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    color: white;
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.3);
    transition: all 0.2s;
}

.keyword-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(66, 133, 244, 0.4);
}

/* AI 해석 모달 스타일 */
.ai-interpretation-modal {
    border-radius: 16px;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 24px;
}

.ai-modal-header {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.ai-icon {
    width: 36px;
    height: 36px;
    margin-right: 12px;
    background-color: #5B9BFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-title {
    font-size: 20px;
    font-weight: 600;
    color: #464646;
}

.ai-content {
    font-size: 16px;
    line-height: 1.6;
    color: #464646;
    margin-bottom: 24px;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
}

/* 모바일 대응 */
@media (max-width: 600px) {
    .main-container {
        flex-direction: row;
        gap: 10px;
        padding: 10px;
        max-width: none;
        width: 100vw;
        flex-wrap: nowrap;
        box-sizing: border-box;
    }

    .roulette-section, .hexagram-section {
        width: 50%;
        max-width: none;
        min-width: 0;
    }

    .language-buttons {
        padding: 2px;
    }

    .lang-btn {
        padding: 4px 8px;
        font-size: 11px;
        min-width: 28px;
    }

    .modal {
        width: 95%;
        max-width: none;
        margin-top: 16px;
    }

    .modal-title {
        font-size: 16px;
    }

    .ai-content {
        font-size: 14px;
        padding: 10px;
    }

    button {
        padding: 14px 24px; /* 모바일에서 더 큰 패딩 */
        font-size: 16px; /* 모바일에서 더 큰 글꼴 */
        min-height: 48px; /* 모바일 권장 터치 타겟 크기 */
        margin: 8px 4px; /* 버튼 간 간격 추가 */
    }
    
    /* 룰렛 돌리기 버튼 특별 스타일 (ID로 선택) */
    #spinButton {
        width: 100%; /* 전체 너비 사용 */
        max-width: 200px; /* 최대 너비 제한 */
        padding: 16px 20px; /* 더 큰 패딩 */
        font-size: 16px;
        font-weight: 600; /* 글꼴 굵게 */
        box-shadow: 0 4px 8px rgba(91, 155, 255, 0.4); /* 더 큰 그림자 */
        z-index: 200; /* 높은 z-index */
    }
    
    /* 터치 시 시각적 피드백 강화 */
    button:active {
        transform: scale(0.98); /* 터치 시 살짝 축소 */
        box-shadow: 0 2px 4px rgba(91, 155, 255, 0.6);
    }

    .language-selector {
        top: 8px;
        right: 8px;
    }
    
    .language-buttons {
        padding: 1px; /* 더 작게 */
        border-radius: 12px;
    }

    .lang-btn {
        padding: 3px 6px; /* 더 작은 패딩 */
        font-size: 10px; /* 더 작은 글꼴 */
        min-width: 24px; /* 더 작은 최소 너비 */
        border-radius: 11px;
    }

}

/* 로딩 효과 */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    z-index: 2000;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 20%;
}

.spinner-container {
    margin-bottom: 24px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(91, 155, 255, 0.2);
    border-top: 4px solid #5B9BFF;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
    margin: 0 auto;
}

.loading-text {
    font-size: 18px;
    color: #464646;
    text-align: center;
    margin-bottom: 10px;
}

.loading-subtext {
    font-size: 14px;
    color: #888;
    text-align: center;
    margin-bottom: 40px;
}

/* 광고 공간 준비 */
.ad-container {
    margin-top: 50px;
    width: 300px;
    height: 250px;
    border: 1px dashed #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 12px;
}

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

/* 정보 모달 레이아웃 - 컴팩트 버전 */
.info-modal {
    width: 75%; /* 기존 90%에서 75%로 축소 */
    max-width: 450px; /* 기존 600px에서 450px로 축소 */
}

.info-modal-content {
    padding: 8px 0; /* 패딩 감소 */
}

.info-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 15px; /* 간격 감소 */
}

/* 왼쪽: 괘 이미지 컨테이너 */
.hexagram-image-container {
    flex: 0.8; /* 비율 약간 감소 */
    padding: 8px; /* 패딩 감소 */
    background-color: #f8f9fa;
    border-radius: 10px; /* 라운딩 감소 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); /* 그림자 효과 감소 */
}

.hexagram-image {
    width: 100%;
    max-width: 150px; /* 최대 너비 감소 */
}

/* 괘 이미지 내부 요소 크기 조정 */
.modal-hexagram-lines {
    gap: 6px; /* 간격 감소 */
    margin: 8px auto;
    width: 85%;
    max-width: 140px;
}

.modal-hexagram-lines .hexagram-line {
    height: 12px; /* 높이 감소 */
}

.modal-hexagram-name {
    font-size: 12px; /* 글꼴 크기 감소 */
    margin-top: 6px;
}

/* 오른쪽: 괘 정보 */
.hexagram-info {
    flex: 1.2; /* 비율 약간 증가 */
}

/* 정보 그리드 컴팩트화 */
.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px; /* 간격 감소 */
    font-size: 14px; /* 글꼴 크기 감소 */
}

/* 모바일 대응 */
@media (max-width: 480px) {
    .info-container {
        flex-direction: column;
    }
    
    .hexagram-image-container {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .hexagram-info {
        width: 100%;
    }
    
    .info-modal {
        width: 90%; /* 모바일에서는 좀 더 넓게 */
    }

    .language-selector {
        top: 5px;
        right: 5px;
    }
    
    .language-buttons {
        padding: 1px;
        border-radius: 10px;
    }
    
    .lang-btn {
        padding: 2px 5px; /* 최소 패딩 */
        font-size: 9px; /* 최소 글꼴 크기 */
        min-width: 22px; /* 최소 너비 */
        border-radius: 9px;
    }

}

/* 모달 내 괘 이미지 스타일 */
.modal-hexagram-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px auto;
    width: 90%;
    max-width: 180px;
}

.modal-hexagram-lines .hexagram-line {
    height: 15px;
    border: 1px dashed #ddd;
    border-radius: 2px;
}

.modal-hexagram-name {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    margin-top: 10px;
    color: #4285f4;
}

/* 모달 내 괘 이미지 컨테이너 */
.hexagram-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background-color: white;
    border-radius: 12px;
}

/* 매우 작은 화면 (480px 이하)에서 추가 최적화 */
@media (max-width: 480px) {
    button {
        padding: 16px 28px;
        font-size: 17px; /* 가독성을 위해 더 큰 글꼴 */
        min-height: 52px; /* 더 큰 터치 영역 */
    }
    
    #spinButton {
        padding: 18px 24px;
        font-size: 18px;
        min-height: 56px;
        border-radius: 12px; /* 더 둥근 모서리 */
    }
}

/* 포인터 이벤트 확실히 설정 */
button, #spinButton {
    pointer-events: auto !important;
}

/* 부모 요소가 터치를 가로채지 않도록 */
.roulette-section {
    pointer-events: auto;
}

.roulette-section * {
    pointer-events: auto;
}

/* 버튼 일반 스타일은 유지하되, 언어 버튼만 예외 처리 */
.lang-btn {
    /* 일반 button 스타일의 영향을 받지 않도록 명시적으로 설정 */
    min-height: auto !important; /* 일반 버튼의 min-height 무시 */
    margin: 0 !important; /* 일반 버튼의 margin 무시 */
    box-shadow: none !important; /* 기본 상태에서는 그림자 없음 */
}

.lang-btn.active {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important; /* 활성 상태에서만 그림자 */
}