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

body {
    font-family: 'Noto Sans KR', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
}

.container {
    width: 100%;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
}

/* 모든 섹션 제목에 일관된 스타일 적용 */
h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5rem;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
}

h1 {
    margin-bottom: 20px;
    color: #333;
}

section {
    margin-bottom: 30px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

/* 헤더 섹션 */
.welcome-section {
    padding: 30px;
    background-color: #f0f8ff;
    text-align: center;
}

/* 로고 컨테이너 및 이미지 스타일 */
.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-logo {
    width: 210px; /* 140px * 1.5 */
    height: auto;
    transition: transform 0.3s ease;
    margin: 10px 0;
}

/* Styles for the logo on the login page */
.login-page-logo-container .site-logo {
    width: 177px !important; /* 118px * 1.5 */
}

/* Styles for the logo on the home page */
.home-page-logo-container .site-logo {
    width: 177px !important; /* 118px * 1.5 */
}

.site-logo:hover {
    transform: scale(1.05);
}

/* Top Header Links */
.top-header-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 5px 10px;
    font-size: 0.96rem;
    color: #555;
    background-color: transparent; /* 배경색 제거 */
    border-bottom: none;
}



.header-link {
    color: #555;
    text-decoration: none;
    padding: 3px 5px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.header-link:hover {
    color: #000;
}

.admin-link {
    margin: 0 auto; /* Center the admin link */
}

/* 슬로건 스타일 */
.slogan {
    margin-top: 10px;
}

.slogan h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #333;
    margin: 0;
    padding: 10px;
}

/* 배열 선택 스타일 */
.array-selection {
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

/* 배열 옵션 그리드 */
.array-grid {
    display: flex;
    gap: 20px;
}

.array-column {
    flex: 1;
}

.array-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.array-option {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.array-option input[type="radio"] {
    margin-right: 8px;
}

.array-option label {
    font-weight: 500;
    cursor: pointer;
}

/* 액션 버튼 스타일 */
.action-button {
    background-color: #9acd32;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    box-sizing: border-box;
}

.action-button:hover {
    background-color: #8bb92d;
}

/* 카드 배열 메시지 */
.empty-selection-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
    margin-top: 20px;
}

/* 카드 그리드에 일관된 스타일 적용 */
.cards-grid {
    display: grid;
    gap: 2px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    padding-bottom: 20px;
    height: auto; /* 높이 자동 조정 */
}

.selected-cards .cards-grid {
    grid-template-columns: repeat(6, 1fr); /* 배열 선택: 6열 */
}

.card-selection .cards-grid {
    grid-template-columns: repeat(9, 1fr); /* 카드 선택: 9열 */
}

.logo-container-grid {
    grid-column: 7 / span 3; /* 7번째 칸에서 시작하여 3칸 차지 */
    grid-row: 9 / span 1;  /* 9번째 줄에서 시작하여 1줄 차지 */
    display: flex;
    justify-content: center;
    align-items: center;
    border: none !important; /* 테두리 강제 제거 */
    box-shadow: none !important; /* 그림자 강제 제거 */
    background-color: transparent !important; /* 배경색 강제 제거 */
}

.logo-container-grid img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border: none;
    box-shadow: none;
}

/* 카드 아이템 기본 스타일 */
.card-item {
    text-align: center;
    margin-bottom: 0;
    opacity: 0; /* 애니메이션 시작을 위해 초기에 투명하게 설정 */
    transform: translateY(20px); /* 아래에서 위로 올라오는 효과 */
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    width: 100%; /* 카드 크기를 컨테이너에 맞춤 */
    margin: 0; /* 마진 제거 */
}

.card-item.visible {
    opacity: 1;
    transform: translateY(0);
}

/* 카드 이미지 스타일 */
.card-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    cursor: pointer;
}

.card-item img:hover {
    transform: scale(1.03);
}

/* 카드 번호 표시 */
.card-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 1.2rem;
    color: #000;
    text-shadow: 0px 0px 3px white, 0px 0px 6px white;
    z-index: 10;
}

/* 카드 위치 번호 스타일 */
.card-position {
    position: absolute;
    top: -2px;
    left: 2px;
    font-weight: bold;
    font-size: 0.85rem;
    color: #fff;
    text-shadow: none;
    z-index: 20;
    background-color: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-text-stroke: none;
}

/* 카드가 있을 때는 슬롯 번호 숨김 */
.card-slot.active.has-card::before {
    display: none;
}

/* 카드 슬롯 번호 표시 */
.card-slot.active::before {
    content: attr(data-order);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 1.2rem;
    color: #000;
    text-shadow: 0px 0px 3px white, 0px 0px 6px white;
    z-index: 10;
}

/* 카드 슬롯이 덮였을 때 (카드가 놓였을 때) 배경 및 테두리 투명 처리 */
.card-slot.card-slot-covered {
    background-color: transparent !important;
    border-color: transparent !important;
}

/* 덮인 카드 슬롯의 ::before 요소 (숫자 표시) 숨기기 */
.card-slot.card-slot-covered::before {
    display: none !important;
}

/* 회색 큰 숫자 숨김 처리 */
.card-slot-number-placeholder {
    display: none;
}

/* 카드 앞면/뒷면 스타일 - ref 버전과 완전 동일하게 복원 */
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-front img, .card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.card-back {
    transform: rotateY(0deg);
}

.card-front {
    transform: rotateY(180deg);
}

.flipped .card-back {
    transform: rotateY(180deg);
}

.flipped .card-front {
    transform: rotateY(0deg);
}

/* 선택된 카드 섹션 - ref 버전과 완전 동일하게 복원 */
.selected-card {
    perspective: 1000px;
    margin: 0;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
}

/* 애니메이션 효과 - 순차적으로 나타나는 효과 */
@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 배열 섹션과 클릭 섹션의 구조 통일 */
.selected-cards, .card-selection {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* 카드 슬롯 크기 증가 - 카드 클릭 섹션의 카드와 일치 */
.card-slot {
    border: 1px dashed #ccc;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: #999;
    aspect-ratio: 7/13;
    width: 100%;
}

/* 카드 공통 크기 */
.card-item, .card-slot, .selected-card {
    position: relative;
    width: 100%;
    aspect-ratio: 7/13;
    box-sizing: border-box;
}

/* 배열 그리드 특별 설정 */
.card-position-grid {
    margin-top: 20px;
}

/* 카드 배열 슬롯 크기 조정 */
.card-slot.active {
    border: 1px solid #666;
    background-color: rgba(220, 220, 220, 0.7);
    position: relative;
}

.card-slot:not(.active) {
    border: none;
    background-color: transparent;
}

/* 배열에 카드가 놓일 때 스타일 */
.card-in-array {
    position: relative;
    width: 100%;
    height: 100%;
}

/* 반응형 로고 */
@media screen and (max-width: 767px) {
    .site-logo {
        width: 150px; /* 100px * 1.5 */
    }
    
    .slogan h1 {
        font-size: 1.3rem;
    }
    
    .welcome-section {
        padding: 20px;
    }
    
    .array-options {
        flex-direction: column;
    }
    
    .selected-cards {
        padding: 10px;
    }
    
    .card-slot.active::before {
        width: auto;
        height: auto;
    }
    
    section {
        padding: 10px;
    }
    
    /* 카드 배열과 카드 클릭 섹션의 번호 스타일 통일 */
    .card-number, .card-slot.active::before {
        font-size: 0.85rem;
        text-shadow: 0px 0px 2px white, 0px 0px 4px white;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-weight: bold;
        color: #000;
        z-index: 10;
    }
    
    .card-position {
        top: 1px;
        left: 1px;
        font-size: 0.55rem;
    }
}

/* 태블릿 크기에서의 로고 */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    .site-logo {
        width: 180px; /* 120px * 1.5 */
    }
    
    .slogan h1 {
        font-size: 1.6rem;
    }
    
    .card-slot.active::before {
        font-size: 1.1rem;
        text-shadow: 0px 0px 3px white, 0px 0px 5px white;
    }
}

/* 덱 선택 섹션 */
.decks {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.deck {
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.deck-title {
    margin-bottom: 15px;
    font-weight: 500;
}

.deck-examples {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.deck-examples img {
    width: 80px;
    border-radius: 4px;
    transition: transform 0.3s;
}

.deck-examples img:hover {
    transform: scale(1.05);
}

/* 카드 선택 섹션 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
    padding-right: 10px;
}

#initialClick, #newShuffle {
    cursor: pointer;
    transition: transform 0.3s;
}

#initialClick:hover, #newShuffle:hover {
    transform: scale(1.05);
}

.card-selection {
    margin-bottom: 60px;
}

/* 유틸리티 클래스 - 공유 버튼은 예외 처리 */
.hidden {
    display: none;
}

/* 공유 버튼은 hidden 클래스가 있어도 표시되도록 함 */
.action-button.hidden {
    display: inline-flex !important;
}

/* 미디어 쿼리 - 모바일 */
@media screen and (max-width: 767px) {
    section {
        padding: 10px;
    }
    
    .selected-cards-list {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }
    
    /* 카드 배열과 카드 클릭 섹션의 번호 스타일 통일 */
    .card-number, .card-slot.active::before {
        font-size: 0.85rem;
        text-shadow: 0px 0px 2px white, 0px 0px 4px white;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-weight: bold;
        color: #000;
        z-index: 10;
        background-color: transparent;
        width: auto;
        height: auto;
        display: block;
        border-radius: 0;
    }
    
    .card-position {
        top: 1px;
        left: 1px;
        font-size: 0.55rem;
        width: auto;
        height: auto;
    }
    
    .card-item {
        margin-bottom: 0;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .section-header h2 {
        margin-bottom: 10px;
        font-size: 1.5rem;
    }
    
    .card-selection .section-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .card-selection .section-header h2 {
        margin-bottom: 0;
    }
    
    .action-button.hidden {
        display: inline-flex !important;
        margin-top: 5px;
        width: auto;
    }
    
    .action-button.blinking {
        animation: blink 2s infinite ease-in-out;
        display: inline-flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .selected-cards .section-header {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .card-item img, .card-front img, .card-back img {
        border-radius: 5px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    .card-front, .card-back {
        border-radius: 5px;
    }
}

/* 미디어 쿼리 - 태블릿 */
@media screen and (min-width: 768px) {
    .decks {
        flex-direction: row;
    }
    
    .deck {
        flex: 1;
    }
    
    .card-position-grid {
        width: 100%;
    }
    
    .selected-card {
        width: 100%;
    }
    
    .section-header {
        font-size: 0.9rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .container {
        padding: 15px;
    }
    
    .share-button {
        padding: 10px 20px;
        font-size: 1rem;
    }
    
    .card-position {
        width: 24px;
        height: 24px;
        font-size: 0.85rem;
    }
    
    .card-selection {
        margin-bottom: 80px;
    }
    
    .selected-cards-list {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }
}

/* 미디어 쿼리 - 데스크탑 */
@media screen and (min-width: 1024px) {
    .card-position-grid {
        width: 100%;
    }
    
    .selected-cards-list {
        grid-template-columns: repeat(5, 1fr);
        gap: 12px;
    }
    
    .selected-card {
        width: 100%;
        margin: 0;
    }
    
    .section-header {
        font-size: 0.9rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .container {
        padding: 20px;
    }
    
    .card-selection {
        margin-bottom: 100px;
    }
    
    .share-button {
        padding: 12px 24px;
        font-size: 1.1rem;
    }
    
    .card-position {
        width: 28px;
        height: 28px;
        font-size: 0.95rem;
    }
}

/* 큰 화면 */
@media screen and (min-width: 1400px) {
    .selected-cards-list {
        grid-template-columns: repeat(5, 1fr);
        gap: 15px;
    }
}

/* 초기 카드 클릭 이미지 중앙 정렬 */
.initial-click-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 깜빡임 효과가 적용된 버튼 - 모든 환경에서 동일하게 작동 */
.action-button.blinking, .share-button.blinking {
    animation: blink 2s infinite ease-in-out; /* 2초마다 천천히 깜빡임 */
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    opacity: 1 !important;
    visibility: visible !important;
}

/* 커스텀 알림창 스타일 */
.custom-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 1000;
    max-width: 90%;
    width: 300px;
    text-align: center;
}

.custom-alert-message {
    margin-bottom: 20px;
    font-size: 1rem;
    white-space: pre-line; /* 줄바꿈 허용 */
}

.custom-alert-button {
    background-color: #9acd32;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 5px;
    min-width: 80px; /* 버튼 최소 너비 설정 */
}

/* 버튼 컨테이너 스타일 */
.custom-alert-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.custom-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 999;
}

/* 종이 비행기 아이콘 스타일 */
.paper-plane-icon {
    font-style: normal;
    margin-left: 5px;
    display: inline-block;
    transform: rotate(-20deg); /* 비행기가 위로 날아오르는 각도 */
    font-size: 1.1em;
}

/* 편지 봉투 아이콘 스타일 */
.envelope-icon {
    font-style: normal;
    margin-left: 6px;
    display: inline-block;
    transform: rotate(10deg) translateY(-5px); /* 위치를 더 위로 올림 */
    font-size: 2.3em; /* 아이콘 크기를 더 크게 증가 */
    transition: transform 0.3s ease; /* 부드러운 변환 효과 */
}

.action-button:hover .envelope-icon {
    transform: rotate(15deg) translateY(-8px) translateX(2px); /* 마우스 오버시 더 위로 날아가는 느낌 */
}

/* 관리자 페이지에서 보기 시 요소 숨김 */
.admin-view .card-selection,
.admin-view #shareButton {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* 버튼 위치 조정 */
.selected-cards .section-header #shareButton {
    position: relative;
    top: -10px; /* 버튼을 위로 올림 */
}

/* 로딩 스피너 스타일 */
.loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #9acd32;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* 오류 메시지 스타일 */
.error-message {
    color: #e74c3c;
    text-align: center;
    padding: 20px;
    background-color: #f9eaea;
    border-radius: 4px;
    margin: 20px auto;
    max-width: 80%;
}

/* Social Media Icons */
.social-media-icons {
    text-align: center;
    max-width: 400px; /* Match login form width */
    margin: 10px auto; /* 푸터와의 간격 50% 축소 */
}

.social-media-icons img {
    width: 32px;
    height: 32px;
    margin: 0 10px; /* Increased margin for better spacing */
    transition: transform 0.2s ease;
}

.social-media-icons img:hover {
    transform: scale(1.1); /* Slight zoom effect on hover */
}

/* Modal Styles */
.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6); /* Darker overlay for better focus */
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-dialog {
    display: none; /* Hidden by default */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background-color: white;
    padding: 25px; /* Increased padding */
    border-radius: 10px; /* Softer border radius */
    box-shadow: 0 5px 20px rgba(0,0,0,0.25); /* Enhanced shadow */
    z-index: 1001;
    width: 90%;
    max-width: 450px; /* Max width for larger screens */
    text-align: center; /* Center align text content */
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.modal-message {
    font-size: 1rem; /* Slightly larger font */
    color: #333;
    margin-bottom: 20px;
    line-height: 1.6; /* Improved readability */
    text-align: left; /* Align message text to the left */
}

.modal-options {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center; /* Center checkbox and label */
}

.modal-options input[type="checkbox"] {
    margin-right: 8px;
    width: 16px; /* Explicit size */
    height: 16px; /* Explicit size */
}

.modal-options label {
    font-size: 0.95rem; /* Consistent font size */
    color: #555;
}

.modal-button {
    background-color: #9acd32; /* Consistent with site's primary button */
    color: white;
    border: none;
    padding: 10px 20px; /* Standard padding */
    border-radius: 6px; /* Consistent border radius */
    font-size: 1rem;
    font-weight: 500; /* Match other primary buttons */
    cursor: pointer;
    transition: background-color 0.3s;
    width: auto; /* Auto width based on content */
    min-width: 100px; /* Minimum width */
}

.modal-button:hover {
    background-color: #8bb92d; /* Darker shade on hover */
}

/* Styles for when modal is shown */
.modal-overlay.active,
.modal-dialog.active {
    display: block; /* Use block to show, or flex if needed for centering */
    opacity: 1;
}
.modal-dialog.active {
    transform: translate(-50%, -50%) scale(1);
}

/* Home page specific styles for logout button and info text */
.home-actions-info {
    text-align: center;
    margin-top: 20px; /* Increased margin for better separation */
    padding-bottom: 10px; /* Added padding at the bottom */
}

.home-actions-info .action-button { /* Targets buttons within this container */
    margin: 0 5px 10px 5px; /* Horizontal margin for buttons, and bottom margin */
    text-decoration: none; /* Ensure links styled as buttons don't have underlines */
}

/* No specific style for home-logout-button or admin-link-button needed if action-button is sufficient */

.info-text {
    font-size: 0.8rem; /* Further reduced font size */
    color: #555;
    margin-top: 10px; /* Space above the info text */
    /* white-space: nowrap; /* Not typically needed for short centered text */
}

/* 질문 입력 섹션 스타일 */
.ask-section {
    margin-bottom: 30px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ask-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    font-family: 'Noto Sans KR', sans-serif;
}

.ask-info {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
}

/* 공유된 질문 섹션 스타일 */
.shared-ask-section {
    margin-bottom: 30px;
    padding: 15px;
    background-color: #f0f8ff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.shared-ask-section h2 {
    margin-bottom: 10px;
}

.shared-ask-section p {
    font-size: 1rem;
    color: #333;
    white-space: pre-wrap;
}