@import url('https://fonts.googleapis.com/css2?family=Jua&display=swap');

/* 기본 설정 */
body {
    font-family: 'Jua', sans-serif;
    touch-action: manipulation; /* 모바일 터치 지연 방지 */
    user-select: none; /* 텍스트 선택 방지 */
    -webkit-user-select: none;
    overflow: hidden; /* 스크롤 방지 */
    background: linear-gradient(to bottom, #7dd3fc, #38bdf8);
    transition: background 1s ease;
}

/* 배경 이미지 (JS에서 설정 시 적용) */
body.has-bg {
    background-image: var(--bg-image) !important;
    background-size: cover;
    background-position: center;
}

/* [추가] 아이폰 노치 대응 (상단 안전 영역 확보) */
.safe-area-top {
    padding-top: env(safe-area-inset-top);
}

.hidden-force { display: none !important; }

/* ---------------- 애니메이션 정의 ---------------- */

/* 피버 모드: 화면 흔들림 */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.fever-active #game-area {
    animation: shake 0.5s infinite;
}

/* 피버 모드: 붉은 화면 효과 */
.fever-active::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 50px rgba(255, 0, 0, 0.5);
    pointer-events: none;
    z-index: 15;
    animation: pulse-red 0.5s infinite alternate;
}

@keyframes pulse-red {
    from { box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.2); }
    to { box-shadow: inset 0 0 80px rgba(255, 80, 0, 0.6); }
}

/* 별 배경 (우주 단계) */
.stars {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #eee, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, #fff, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0;
    transition: opacity 2s ease;
    z-index: 0;
    pointer-events: none;
}

/* 클릭 시 튕김 효과 (Pop) */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); } 
    100% { transform: scale(1); }
}
.animate-pop {
    animation: pop 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 멘트 말풍선 등장 효과 */
@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.msg-pop {
    animation: bounceIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 대박 텍스트 효과 */
@keyframes jackpot {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; }
    50% { transform: scale(1.5) rotate(0deg); opacity: 1; }
    100% { transform: scale(1.2) rotate(0deg); opacity: 0; }
}
.jackpot-text {
    animation: jackpot 1s ease-out forwards;
}

/* 준비 화면 텍스트 줌인 */
.ready-animate {
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes zoomIn {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* 파티클 사라짐 효과 */
.particle {
    position: absolute;
    pointer-events: none;
    animation: fadeOut 0.8s forwards;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
}
@keyframes fadeOut {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-80px) scale(1.5); }
}

/* [추가] 랭킹(리더보드) 스타일 */
.leaderboard-box {
    margin-top: 0.5rem;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 1rem;
    padding: 0.8rem;
    border: 2px solid #fbbf24;
    max-height: 150px;
    overflow-y: auto;
}

.rank-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    color: #4b5563;
}

.rank-item:last-child {
    border-bottom: none;
}

.rank-badge {
    display: inline-block;
    width: 1.5rem;
    text-align: center;
    font-weight: bold;
    margin-right: 0.3rem;
}

/* 1, 2, 3위 강조 색상 */
.rank-1 .rank-badge { color: #f59e0b; font-size: 1.2em; text-shadow: 1px 1px 0 rgba(0,0,0,0.1); } /* 금 */
.rank-2 .rank-badge { color: #9ca3af; font-size: 1.1em; } /* 은 */
.rank-3 .rank-badge { color: #b45309; font-size: 1.1em; } /* 동 */

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.name-input {
    flex: 1;
    padding: 0.6rem;
    border: 2px solid #ddd;
    border-radius: 0.5rem;
    outline: none;
    font-family: inherit;
}

.name-input:focus {
    border-color: #f59e0b;
}

.save-btn {
    background-color: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: bold;
    white-space: nowrap;
}