header h1 { margin: .5rem;font-size: 1.8rem;}
footer p {margin: .5rem;font-size: .8rem;}

/* 전체 화면 배경 */
body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

* {
    word-break: keep-all;
    text-wrap: balance;
}

.main-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.instruction {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2em;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.instruction p {
    margin: 0;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    border-radius: 5px;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#instructionText {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.card-scroll-container {
    width: 100%;
    height: 400px;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 20px 0;
    cursor: grab;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 스크롤바 스타일링 - 투명하게 */
.card-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.card-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.card-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.card-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Firefox 스크롤바 스타일링 */
.card-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1);
}

/* 시작하기 버튼 오버레이 */
.start-button-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 3px solid white;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.start-button-overlay:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.start-button-overlay:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.start-button-overlay.hidden {
    display: none;
}

/* 다시 시작하기 버튼 컨테이너 */
.reset-buttons-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200; /* 카드보다 위에 표시 */
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
}

.reset-buttons-container.hidden {
    display: none;
}

/* 다시 시작하기 버튼 오버레이 */
.reset-button-overlay {
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: 3px solid white;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.reset-button-overlay:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
}

.reset-button-overlay:active {
    transform: scale(0.95);
}

/* 종료 버튼 오버레이 */
.exit-button-overlay {
    padding: 24px 48px;
    font-size: 2em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.exit-button-overlay:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.exit-button-overlay:active {
    transform: scale(0.95);
}

.card-scroll-container:active {
    cursor: grabbing;
}

.card-deck {
    display: flex;
    height: 100%;
    align-items: center;
    padding: 0 50px;
    gap: 10px;
}

.tarot-card {
    min-width: 150px;
    width: 150px;
    height: 250px;
    background: linear-gradient(145deg, #f0f0f0, #ffffff);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    margin-right: -50px;
    z-index: 1;
    /* GPU 가속 활성화 */
    transform: translateZ(0);
    will-change: transform, opacity;
}

/* 카드 섞기 애니메이션 - GPU 가속 최적화 */
.tarot-card.shuffling {
    animation: shuffleCard 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    pointer-events: none; /* 애니메이션 중 클릭 방지 */
    will-change: transform, opacity;
    /* GPU 가속 강제 활성화 */
    transform: translate3d(0, 0, 0);
}

@keyframes shuffleCard {
    0% {
        transform: translate3d(var(--shuffle-x, 0px), var(--shuffle-y, 0px), 0) 
                   rotateZ(var(--shuffle-rotate, 0deg)) 
                   scale(var(--shuffle-scale, 0.8));
        opacity: 0.5;
    }
    50% {
        transform: translate3d(calc(var(--shuffle-x, 0px) * 0.3), calc(var(--shuffle-y, 0px) * 0.3), 0) 
                   rotateZ(calc(var(--shuffle-rotate, 0deg) * 0.3)) 
                   scale(calc(var(--shuffle-scale, 0.8) + 0.2));
        opacity: 0.8;
    }
    100% {
        transform: translate3d(0, 0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
        pointer-events: auto; /* 애니메이션 완료 후 클릭 가능 */
        will-change: auto; /* 애니메이션 완료 후 will-change 제거 */
    }
}

.tarot-card:hover {
    transform: translate3d(0, -20px, 0) scale(1.1);
    z-index: 10;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.tarot-card.selected {
    transform: translate3d(0, -30px, 0) scale(1.15);
    z-index: 20;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 3px solid #ffd700;
}

.tarot-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.tarot-card .card-front {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    backface-visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    /* GPU 가속 */
    transform: translateZ(0);
    will-change: transform;
}

.tarot-card .card-back {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    background-image: url('./images/card-back.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    backface-visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(0deg) translateZ(0);
    overflow: hidden;
    /* GPU 가속 */
    will-change: transform;
}

.card-back-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    display: none; /* CSS background-image 사용하므로 숨김 */
}

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

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

.card-number {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 0.9em;
    color: #666;
    font-weight: bold;
}

.card-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    text-align: center;
    padding: 10px;
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
}

.card-back-pattern {
    width: 80%;
    height: 80%;
    background: repeating-linear-gradient(
        45deg,
        #34495e,
        #34495e 10px,
        #2c3e50 10px,
        #2c3e50 20px
    );
    border-radius: 10px;
}

.selected-cards-container {
    margin-top: 30px;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    min-height: 200px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.selected-cards-container h3 {
    text-align: center;
    margin-bottom: 20px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.selected-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.selected-card-item {
    width: 120px;
    height: 180px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    position: relative;
}

.selected-card-item .card-name {
    font-size: 0.9em;
    text-align: center;
    color: #333;
}

.selected-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

#startButton, #resetButton, #exitGameButton {
    padding: 24px 48px;
    font-size: 2em;
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#startButton:hover, #resetButton:hover, #exitGameButton:hover {
    background-color: #5568d3;
}

#exitGameButton {
    display: none;
}

/* 팝업 스타일 */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.popup-overlay.active {
    display: flex;
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease forwards;
}

.popup-overlay.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        background-color: rgba(0, 0, 0, 0);
    }
    to {
        opacity: 1;
        background-color: rgba(0, 0, 0, 0.7);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        background-color: rgba(0, 0, 0, 0.7);
    }
    to {
        opacity: 0;
        background-color: rgba(0, 0, 0, 0);
    }
}

.popup-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.popup-overlay.active .popup-content {
    opacity: 1;
    transform: scale(1) translateY(0);
    animation: popupFadeIn 0.3s ease forwards;
}

.popup-overlay.fade-out .popup-content {
    animation: popupFadeOut 0.3s ease forwards;
}

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

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

.popup-content h2 {
    text-align: center;
    color: #667eea;
    margin-bottom: 20px;
}

/* 팝업 내 선택된 카드 이미지 */
.selected-cards-in-popup {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 10px 0;
}

.popup-card-item {
    width: 100px;
    height: 150px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.popup-card-item:hover {
    transform: translateY(-5px) scale(1.05);
}

.popup-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.popup-card-name {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    color: #333;
    font-size: 0.9em;
    text-align: center;
    padding: 10px;
}

.fortune-result {
    font-size: 1.1em;
    line-height: 1.8;
    color: #333;
    margin-bottom: 20px;
}

.fortune-result .card-reading {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.fortune-result .card-reading h4 {
    margin-top: 0;
    color: #667eea;
}
.fortune-result .card-reading pre {
    font-size: 1.2rem;
}

#closePopup {
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#closePopup:hover {
    background-color: #5568d3;
}

@media screen and (orientation: portrait) {
    .card-scroll-container {
        height: 300px;
    }
    
    .tarot-card {
        min-width: 120px;
        width: 120px;
        height: 200px;
    }
}

@media screen and (orientation: landscape) {
    .container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        max-width: 100%;
    }
    
    .card-scroll-container {
        width: 100%;
        height: 350px;
    }
}

