/* 페이지 숨김/보이기 */
.screen {
    display: none;
    padding: 2rem 1rem; /* 기본 패딩 */
}
.screen.active {
    display: block;
}
#step-four-page { /* 4페이지 패딩 제거 */
    padding: 0 !important;
}

/* 공통 스타일 */
body {
    background-color: #e0f3ff;
    font-family: 'Arial', sans-serif, 'Malgun Gothic', '맑은 고딕', '돋움';
    color: #333;
}
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow-x: hidden;
    scroll-behavior: auto;
}
body:has(#step-one-page.screen.active) { /* 첫 페이지에서 스크롤 */
    overflow: auto !important;
}

/* 브금 on/off 버튼 */
.sound-toggle {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.1);
    color: white;
    font-size: 1rem;
    border: none;
    border-radius: 50%;
    padding: 0.5rem 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}
.sound-toggle:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

/* 청휘석 */
.pyroxene-used {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    z-index: 1000;
    font-weight: bold;
}

/* 1. 가챠 인트로 페이지 ///////////////////////////////// */

/* 로고 */
.logo-image {
    display: block;
    margin: 0.5rem auto 1.5rem;
    max-width: 300px;
    width: 80%;
}
@media (min-width: 1024px) { /* 데스크탑에서는 로고 키우기 */
    .logo-image {
        max-width: 540px;
        width: 100%;
    }
}

/* 아로나 이미지 컨테이너 */
.arona-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.2rem;
}
.arona-image {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(0, 128, 255, 0.4);
    object-fit: cover;
}

/* 말풍선 */
.speech-bubble {
    margin-top: 1rem;
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    border: 1px solid #ccc;
    font-size: 0.95rem;
    position: relative;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.speech-bubble::after { /* 말풍선 꼬리 */
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent white transparent;
}

/* 가챠 인트로 페이지 기본 */
.intro-container {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}
.intro-title {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
.intro-subtitle {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #666;
}
.gacha-button-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.gacha-button {
    font-size: 1.2rem;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}
.gacha-button:hover {
    background-color: #0056b3;
    transform: scale(1.02);
    transition: background-color 0.2s, transform 0.15s;
}

/* 2. 아로나 사인 페이지 ///////////////////////////////// */

/* 아로나 사인 페이지 기본 */
.sign-container {
    text-align: center;
    margin-top: 2rem;
}
.sign-instruction {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: bolder;
    color: #333;
}
.signCanvas {
    width: 300px;
    height: 300px;
    border: 2px solid #ccc;
    background-color: white;
    touch-action: none; /* 스마트폰에서 드래그 방지 */
    border-radius: 8px;
    cursor: crosshair;
    margin-bottom: 30px;
}
.signCanvas.signing {
    background-color: #ffe6f0 !important;
    transition: background-color 0.3s ease;
}
@media (min-width: 768px) {
    #signCanvas {
        width: 500px;
        height: 300px;
    }
}
@media (min-width: 1024px) {
    #signCanvas {
        width: 700px;
        height: 300px;
    }
}

/* 아로나 하단 이미지 */
.arona-full-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: cover;
    object-position: top;
    z-index: 1;
    position: relative;
}

/* 폭죽 연출 */
.fireworks {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 999;
}
.firework { /* 폭죽 알갱이 */
    position: absolute;
    bottom: 0;
    width: var(--fw-size, 12px);
    height: var(--fw-size, 12px);
    border-radius: 50%;
    opacity: 1;
    animation: explode 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards, firework-glow 0.9s linear forwards;
}
/* nth-child로 폭죽 알갱이 크기 다양화 */
.firework:nth-child(3n)   { --fw-size: 8px; }
.firework:nth-child(3n+1) { --fw-size: 10px; }
.firework:nth-child(3n+2) { --fw-size: 12px; }
@keyframes explode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--x), var(--y)) scale(1.5);
        opacity: 0;
    }
}
.hidden {
    display: none;
}

/* 3. 가챠 페이지 ///////////////////////////////// */

/* 가챠 페이지 기본 */
.gacha-result-container {
    max-width: 100%;
    margin: 0;
    padding: 0.5rem;
    height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    align-items: center;
    justify-items: center;
}
.gacha-card {
    width: 42vw;
    height: 13vh;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: rotateY(0deg);
    transition: transform 0.3s ease;
    position: relative;
    z-index: 2;
}
@media (min-width: 768px) and (max-width: 1023px) { /* 태블릿용 카드 뭉치 */
    .card-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 12px;
        padding: 1.2rem;
    }
    .gacha-card {
        width: 100%;
        aspect-ratio: 3 / 4;
        height: auto;
    }
}
@media (min-width: 1024px) { /* 데스크탑용 카드 뭉치 */
    .card-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 16px;
        padding: 1.5rem;
        display: grid;
        justify-content: center;
    }
    .gacha-card {
        width: 100%;
        max-width: 240px;
        aspect-ratio: 3 / 4;
        height: auto;
        margin: 0 auto;
    }
}

/* 화면 터치 가이드 */
.touch-guide {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 8px #222, 0 0 16px #4ea1ff;
    z-index: 1001;
    pointer-events: none;
    animation: touch-guide-glow 1.2s ease-in-out infinite;
}
@media (min-width: 768px) {
    .touch-guide {
        font-size: 2.0rem;
    }
}
@media (min-width: 1024px) {
    .touch-guide {
        font-size: 4.0rem;
    }
}

/* 화면 터치 문구 애니메이션 */
@keyframes touch-guide-glow {
    0% {
        transform: translate(-50%, -50%) scale(1);
        text-shadow: 0 2px 8px #222, 0 0 16px #4ea1ff;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.13);
        text-shadow: 0 4px 16px #222, 0 0 32px #4ea1ff;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        text-shadow: 0 2px 8px #222, 0 0 16px #4ea1ff;
    }
}

/* 배경 추가 */
#step-three-page {
    background: none;
    background-color: #e0f3ff;
}
@media (min-width: 768px) { /* 태블릿용 배경 */
    #step-three-page {
        background: url("images/common/background-tablet.jpg") no-repeat center center fixed;
        background-size: cover;
        min-height: 100vh;
        overflow: hidden;
        position: relative;
    }
    #step-three-page::before {
        content: "";
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.25); /* 어두운 반투명 레이어 */
        z-index: 1;
        pointer-events: none;
    }
}
@media (min-width: 1024px) { /* 데스크탑용 배경 */
    #step-three-page {
        background: url("images/common/background-pc.jpg") no-repeat center center fixed;
        background-size: cover;
        min-height: 100vh;
        overflow: hidden;
        position: relative;
    }
    #step-three-page::before {
        content: "";
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.25); /* 어두운 반투명 레이어 */
        z-index: 1;
        pointer-events: none;
    }
}

/* 등급별 색상 */
.rarity-3 { background: hotpink; }
.rarity-2 { background: gold; }
.rarity-1 { background: dodgerblue; }
.rarity-1:nth-child(3n) { background: royalblue; } /* 1성 카드 랜덤 색깔 */

/* 카드 애니메이션 */
@keyframes pop-in-spin {
    0% {
        transform: translateZ(400px) scale(1.8) rotateY(0deg);
        opacity: 0;
    }
    100% {
        transform: translateZ(0) scale(1) rotateY(360deg); /* 카드 회전량 */
        opacity: 1;
    }
}
.gacha-card.animate-in {
    animation: pop-in-spin 0.8s ease-out forwards;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    perspective: 1000px;
}
@media (min-width: 1024px) {
    .gacha-card:hover {
        z-index: 5;
        box-shadow: 0 20px 48px 0 rgba(0, 0, 0, 0.38), 0 2px 16px 0 rgba(0, 128, 255, 0.18);
        transition: transform 0.18s cubic-bezier(0.4,1.4,0.6,1), box-shadow 0.18s;
    }
}

/* 3성 카드 전용 애니메이션 */
@keyframes glow {
    0% {
        box-shadow:
            0 0 0px rgba(255, 105, 180, 0),
            0 0 0px rgba(255, 105, 180, 0);
    }
    50% {
        box-shadow:
            0 0 20px 10px rgba(255, 105, 180, 0.9),
            0 0 20px 10px rgba(255, 255, 255, 0.7);
    }
    100% {
        box-shadow:
            0 0 0px rgba(255, 105, 180, 0),
            0 0 0px rgba(255, 105, 180, 0);
    }
}
.gacha-card.glow {
    animation: glow 1.2s ease-in-out infinite;
    border-radius: 12px;
    border: 2px solid rgba(255, 105, 180, 0.8);
    z-index: 10;
    position: relative;
}

/* 카드 사라지는 좌우/상하로 애니메이션 */
.gacha-card.disappear-left {
    animation: disappear-left 0.4s ease forwards;
}
.gacha-card.disappear-right {
    animation: disappear-right 0.4s ease forwards;
}
@keyframes disappear-left {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(-120vw); opacity: 0; }
}
@keyframes disappear-right {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(120vw); opacity: 0; }
}
@media (min-width: 768px) {
    .gacha-card.disappear-up {
        animation: disappear-up 0.4s ease forwards;
    }
    .gacha-card.disappear-down {
        animation: disappear-down 0.4s ease forwards;
    }
    @keyframes disappear-up {
        0% { transform: translateY(0); opacity: 1; }
        100% { transform: translateY(-120vh); opacity: 0; }
    }
    @keyframes disappear-down {
        0% { transform: translateY(0); opacity: 1; }
        100% { transform: translateY(120vh); opacity: 0; }
    }
}

/* 4. 캐릭터 소개 페이지 ///////////////////////////////// */

/* 3성 캐릭터 카드 별 떨어지기 */
.star-container {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
    display: flex;
    gap: 24px;
    justify-content: center;
    align-items: center;
}
.star {
    font-size: 120px;
    color: gold;
    opacity: 0;
    animation: star-drop 1s ease-out forwards;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}
.star:nth-child(1) { animation-delay: 0s; }
.star:nth-child(2) { animation-delay: 0.2s; }
.star:nth-child(3) { animation-delay: 0.4s; }
@keyframes star-drop {
    0% {
        transform: translateY(-100px) scale(1.5);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(100px) scale(1);
        opacity: 0;
    }
}

/* 캐릭터 소개 페이지 기본 */
.character-card-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.character-card {
    width: 70vw;
    max-width: 280px;
    border-radius: 16px;
    object-fit: cover;
    opacity: 0;
    transform: translateY(60px);
    transition: all 0.6s ease;
}
.character-card.enter {
    animation: slide-in-right 0.6s cubic-bezier(0.15, 0.85, 0.4, 1.2) forwards;
}
@media (min-width: 768px) { /* 태블릿과 데스크탑에서는 사진 아래로 떨어짐 */
    .character-card.enter {
        animation: slide-in-down 0.6s cubic-bezier(0.15, 0.85, 0.4, 1.2) forwards;
    }
}
.character-info {
    margin-top: 1rem;
    text-align: center;
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.6s ease;
}
.character-info.enter {
    animation: fade-in 0.6s ease forwards;
}
.character-name {
    font-size: 2.0rem;
    font-weight: bold;
}
.character-school {
    font-size: 1.2rem;
    color: #888;
    margin: 0.4rem 0;
}
.character-stars {
    font-size: 2.5rem;
}

/* 학원 마크 배경 */
#school-mark-background {
    position: absolute;
    top: 70%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    opacity: 0.1;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    z-index: 1;
}
#character-image,
#character-info {
    position: relative;
    z-index: 2;
}

/* 캐릭터 이미지 애니메이션 */
@keyframes slide-in-right {
    0% {
        transform: translateX(120vw) scale(0.95);
        opacity: 0;
    }
    80% {
        transform: translateX(0vw) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}
@keyframes slide-in-down {
    0% {
        transform: translateY(-120vh) scale(0.95);
        opacity: 0;
    }
    80% {
        transform: translateY(0vh) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 5. 결과 정리 및 다시 뽑기 페이지 ///////////////////////////////// */


/* 결과 정리 페이지 기본 */
.result-summary {
    text-align: center;
    margin-top: 2rem;
}
#result-table-container {
    max-width: 500px;
    margin: 1rem auto 2rem;
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}
.result-table th,
.result-table td {
    padding: 0.6rem;
    border-bottom: 1px solid #ddd;
}
.result-table th {
    background-color: #f0f0f0;
    font-weight: bold;
}

/* 표에 들어가는 캐릭터 이미지 아이콘 */
.char-icon {
    width: 20px;
    height: 20px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: middle;
}
/* 3성 하이라이트 배경 */
.highlight-row {
    background-color: #ffe6f0;
}

/* 버튼 */
.result-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    margin: 2rem auto;
    max-width: 320px;
}
.result-button {
    font-size: 1.2rem;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    width: 100%;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}
.result-button:hover {
    background-color: #0056b3;
    transform: scale(1.02);
    transition: background-color 0.2s, transform 0.15s;
}
