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

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

/* 언어 선택기 스타일 */
.language-selector {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
}

.language-buttons {
    display: flex;
    background-color: #f0f0f0;
    border-radius: 20px;
    padding: 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.lang-btn {
    padding: 6px 10px;
    border-radius: 17px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 32px;
    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: 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: 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: transparent;
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.3);
}

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: center;
    backdrop-filter: blur(3px);
}

.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);
}

.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: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.question-item:hover {
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.question-item.selected {
    background-color: #e6f0ff;
    border-color: #5B9BFF;
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.2);
}

/* 정보 확인 모달 스타일 */
.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: 8px;
        padding: 8px;
        max-width: 100%;  /* 100vw → 100%로 변경 */
        width: 100%;      /* 100vw → 100%로 변경 */
        flex-wrap: nowrap;
        box-sizing: border-box;
        overflow: hidden; /* 추가: 넘치는 콘텐츠 숨김 */
    }
    
    /* 룰렛/괘 섹션 크기 조정 */
    .roulette-section, .hexagram-section {
        min-height: 320px;
        max-width: none;
        flex: 1;          /* 추가: 동일한 크기로 분할 */
        min-width: 0;     /* 추가: flex 축소 허용 */
    }

    .language-buttons {
        padding: 2px;
    }

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

    .modal {
        width: 95%;
        max-width: none;
    }

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

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

/* 로딩 효과 */
.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%; /* 모바일에서는 좀 더 넓게 */
    }
}

/* 모달 내 괘 이미지 스타일 */
.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;
}

button {
    padding: 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: transparent;
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.3);
    
    /* 모바일 터치 개선 */
    position: relative;
    touch-action: manipulation; /* 추가: 터치 최적화 */
    user-select: none;          /* 추가: 텍스트 선택 방지 */
    -webkit-user-select: none;  /* 추가: Safari 텍스트 선택 방지 */
}

/*  모바일에서 버튼 크기 대폭 확대 */
@media (max-width: 600px) {
    /* 스핀 버튼 특별 처리 */
    #spinButton {
        padding: 12px 20px !important;  /* 더 큰 터치 영역 */
        font-size: 16px !important;     /* 더 큰 글꼴 */
        min-height: 44px !important;    /* iOS 권장 최소 터치 크기 */
        min-width: 120px !important;    /* 충분한 너비 */
        border-radius: 10px;
        font-weight: 600;
        
        /* 터치 영역 확장을 위한 의사 요소 */
        position: relative;
        z-index: 1;
    }
    
    /* 터치 영역을 더 크게 만들기 위한 의사 요소 */
    #spinButton::before {
        content: '';
        position: absolute;
        top: -8px;      /* 상하좌우 8px씩 터치 영역 확장 */
        left: -8px;
        right: -8px;
        bottom: -8px;
        z-index: -1;
        background: transparent;
        border-radius: 12px;
    }
    
    /* 일반 버튼들도 크기 확대 */
    button {
        min-height: 40px;
        min-width: 80px;
        padding: 10px 16px;
        font-size: 15px;
    }
    
    /* 컨트롤 버튼 크기 확대 */
    .control-btn {
        padding: 12px 16px !important;
        font-size: 15px !important;
        min-height: 44px;
        border-radius: 10px;
    }
}

/*  터치 피드백 개선 */
button:active,
button:focus {
    transform: scale(0.98);     /* 터치 시 살짝 축소 효과 */
    transition: transform 0.1s ease;
}

@media (max-width: 600px) {
    button:active,
    button:focus {
        transform: scale(0.95);  /* 모바일에서 더 명확한 피드백 */
        background-color: #4285f4;
    }
    
    #spinButton:active {
        background-color: #3367d6 !important;
        box-shadow: 0 4px 8px rgba(51, 103, 214, 0.4);
    }
}

/*  룰렛 컨테이너 터치 간섭 방지 */
.roulette-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
    margin-top: 0;
    
    /* 터치 간섭 방지 */
    pointer-events: none;  /* 룰렛 자체는 터치 비활성화 */
}

.roulette-container * {
    pointer-events: none;  /* 모든 하위 요소 터치 비활성화 */
}

/*  결과 박스 터치 간섭 방지 */
.result-box {
    width: 100px;
    padding: 5px;
    margin-bottom: 24px;
    margin-top: 0;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    text-align: center;
    
    /* 터치 간섭 방지 */
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/*  전체적인 터치 최적화 */
@media (max-width: 600px) {
    /* 터치 스크롤 개선 */
    body {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }
    
    /* 터치 딜레이 제거 */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        -webkit-touch-callout: none;
    }
    
    /* 선택 가능한 요소만 터치 허용 */
    button, a, input, textarea, select {
        -webkit-tap-highlight-color: rgba(91, 155, 255, 0.2);
        -webkit-touch-callout: default;
    }
}