/* RevUpBrain 재미 효과 스타일 (js/fun.js와 함께 사용) */

/* --- 짧은 애니메이션 --- */
@keyframes fun-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.18); }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes fun-shake {
    0%, 100% { transform: translateX(0); }
    15%, 55% { transform: translateX(-8px) rotate(-2deg); }
    35%, 75% { transform: translateX(8px) rotate(2deg); }
}

@keyframes fun-wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-6deg); }
    75% { transform: rotate(6deg); }
}

@keyframes fun-bounce-in {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

.fun-pop { animation: fun-pop 0.45s ease; }
.fun-shake { animation: fun-shake 0.5s ease; }
.fun-wiggle { animation: fun-wiggle 0.4s ease; }
.fun-bounce-in { animation: fun-bounce-in 0.5s ease both; }

/* --- 색종이 캔버스 --- */
.fun-confetti {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9998;
}

/* --- 튀어 나가는 별 --- */
@keyframes fun-star {
    0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity: 0; }
}

.fun-star {
    position: fixed;
    z-index: 9999;
    font-size: 22px;
    pointer-events: none;
    animation: fun-star 0.8s ease-out forwards;
}

/* --- 칭찬 배너 --- */
@keyframes fun-cheer {
    0% { transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.1) rotate(2deg); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1) rotate(0); }
    80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -80%) scale(0.9); opacity: 0; }
}

.fun-cheer {
    position: fixed;
    left: 50%;
    top: 40%;
    z-index: 9999;
    padding: 14px 34px;
    border-radius: 999px;
    background: #fff;
    border: 5px solid #ffd84d;
    box-shadow: 0 10px 0 #f5a400, 0 20px 40px rgba(0, 0, 0, 0.2);
    font-family: 'Fredoka', 'Segoe UI', sans-serif;
    font-size: clamp(1.6rem, 6vw, 3rem);
    font-weight: 700;
    color: #2f3357;
    white-space: nowrap;
    pointer-events: none;
    animation: fun-cheer 2.2s ease forwards;
}

/* --- 놀이 방법 안내 창 --- */
@keyframes fun-fade { from { opacity: 0; } to { opacity: 1; } }

.fun-howto {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(47, 51, 87, 0.45);
    animation: fun-fade 0.2s ease;
}

.fun-howto-card {
    width: min(520px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 24px 26px 26px;
    border-radius: 28px;
    background: #fff;
    border-top: 10px solid #ffd84d;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    font-family: 'Fredoka', 'Segoe UI', sans-serif;
    color: #2f3357;
    text-align: left;
    animation: fun-bounce-in 0.45s ease both;
}

.fun-howto-top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.fun-howto-mascot {
    width: 76px;
    height: 76px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #d9f7e6;
    animation: fun-wiggle 1.6s ease-in-out infinite;
}

.fun-howto-bubble {
    position: relative;
    padding: 10px 14px;
    border-radius: 16px;
    background: #d9f7e6;
    font-size: 1rem;
    line-height: 1.4;
}

.fun-howto-bubble::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right: 10px solid #d9f7e6;
    border-left: 0;
}

.fun-howto-card h2 {
    margin: 0 0 6px;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.2;
    color: #2f3357;
}

.fun-howto-goal {
    margin: 0 0 14px;
    padding: 8px 14px;
    border-radius: 14px;
    background: #fff1cc;
    font-size: 1.05rem;
    line-height: 1.4;
}

.fun-howto-steps {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    counter-reset: fun-step;
}

.fun-howto-steps li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.05rem;
    line-height: 1.4;
}

.fun-howto-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #dcebff;
    font-size: 1.5rem;
}

.fun-howto-go {
    display: block;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 999px;
    background: #2fbf71;
    color: #fff;
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 0 #1b8a4d;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fun-howto-go:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #1b8a4d; }
.fun-howto-go:active { transform: translateY(4px); box-shadow: 0 2px 0 #1b8a4d; }
.fun-howto-go:focus-visible { outline: 4px solid #2f3357; outline-offset: 3px; }

/* --- 메뉴 옆 도구 버튼 --- */
.rub-header .rub-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rub-header .rub-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 2px solid #ffd84d;
    border-radius: 999px;
    background: #fff8e1;
    color: #2f3357;
    font-family: 'Fredoka', 'Segoe UI', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: background 0.2s ease;
}

.rub-header .rub-tool-btn:hover { background: #ffd84d; }

/* 모은 별 개수 */
.rub-header .rub-star-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: #2f3357;
    color: #fff;
    font-family: 'Fredoka', 'Segoe UI', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}
.rub-header .rub-tool-btn:focus-visible { outline: 4px solid #2f3357; outline-offset: 2px; }
.rub-header .rub-tool-btn[hidden] { display: none; }

/* 데스크톱: 메뉴와 도구 버튼을 오른쪽에 나란히 */
.rub-header .rub-nav { margin-left: auto; }

@media (max-width: 860px) {
    .rub-header .rub-nav { margin-left: 0; }
    /* 휴대폰: 로고 줄 오른쪽에 도구 버튼, 메뉴는 아래 줄 */
    .rub-header .rub-logo { order: 1; }
    .rub-header .rub-tools { order: 2; margin-left: auto; }
    .rub-header .rub-nav { order: 3; }
    .rub-header .rub-tool-btn span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .fun-howto-mascot, .fun-cheer, .fun-howto-card { animation: none; }
    .fun-cheer { transform: translate(-50%, -50%); }
}
