/* ==========================================================================
   CSS Reset & Variables
   ========================================================================== */
:root {
    --color-bg-start: #FFE4E8; /* 부드러운 핑크빛 성운 시작 */
    --color-bg-end: #D4ECF9;   /* 파스텔 스카이 블루 끝 */
    --color-pink-primary: #FFB7C5; /* 주 벚꽃 핑크 */
    --color-pink-dark: #F59FA8;
    --color-blue-pastel: #AEC6CF;  /* 파스텔 스카이 블루 */
    --color-blue-dark: #8CA6AF;
    --color-white-glass: rgba(255, 255, 255, 0.75);
    --color-white-glass-border: rgba(255, 255, 255, 0.45);
    --color-text-main: #4A3A40;   /* 차분한 적갈색 텍스트 */
    --color-text-sub: #7A6970;
    --font-family: 'Gowun Dodum', 'Outfit', sans-serif;
    --shadow-soft: 0 8px 32px 0 rgba(255, 183, 197, 0.25);
    --shadow-neon: 0 0 15px rgba(255, 183, 197, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f7eded;
    font-family: var(--font-family);
    color: var(--color-text-main);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==========================================================================
   Game Container & Aspect Ratio (9:16)
   ========================================================================== */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 580px;
    max-height: 1000px;
    aspect-ratio: 9/16;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(74, 58, 64, 0.15);
    background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
}

/* 폰 화면 꽉 차게 조절 (태블릿 및 대화면 스마트기기 대응 확대) */
@media (max-width: 768px), (max-height: 1024px) {
    #game-container {
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
        max-height: 100%;
        width: 100vw;
        height: 100vh;
    }
}

/* ==========================================================================
   Background & Sakura Falling Effects
   ========================================================================== */
.background-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
    background-image: url('cherry_blossom_nebula.png');
    background-size: cover;
    background-position: center;
}

.lake-reflection {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background: linear-gradient(to top, rgba(174, 198, 207, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

#sakura-bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.sakura-leaf {
    position: absolute;
    background-color: var(--color-pink-primary);
    border-radius: 10px 0 10px 10px;
    opacity: 0.8;
    transform-origin: left top;
    animation: fall linear infinite;
    pointer-events: none;
}

@keyframes fall {
    0% {
        transform: translateY(-20px) rotate(0deg) scale(0.6);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(900px) translateX(200px) rotate(360deg) scale(1.2);
        opacity: 0;
    }
}

/* ==========================================================================
   Screens & Layouts
   ========================================================================== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: none;
    flex-direction: column;
    padding: 24px;
}

.screen.active {
    display: flex;
}

/* Lobby Screen */
#lobby-screen {
    justify-content: space-between;
    align-items: center;
    padding: 64px 32px 32px 32px;
}

.lobby-header {
    text-align: center;
    animation: float 4s ease-in-out infinite;
}

.lobby-sub {
    font-size: 14px;
    color: var(--color-text-sub);
    letter-spacing: 2px;
    margin-bottom: 8px;
    font-weight: 600;
}

.lobby-title {
    font-size: 42px;
    font-weight: 800;
    color: var(--color-text-main);
    text-shadow: 0 4px 12px rgba(255, 183, 197, 0.6);
    margin-bottom: 2px;
}

.lobby-title-eng {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--color-pink-dark);
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.lobby-menu {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 48px;
}

/* ==========================================================================
   Buttons UI
   ========================================================================== */
.btn {
    width: 100%;
    border: none;
    border-radius: 20px;
    padding: 16px 24px;
    font-family: var(--font-family);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-soft);
    background: var(--color-white-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--color-white-glass-border);
}

.btn:active {
    transform: scale(0.96);
    box-shadow: 0 4px 16px rgba(255, 183, 197, 0.15);
}

.btn-icon {
    font-size: 28px;
    margin-right: 16px;
    filter: drop-shadow(0 2px 6px rgba(74, 58, 64, 0.1));
}

.btn-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.btn-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text-main);
}

.btn-title-single {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text-main);
    text-align: center;
    width: 100%;
}

.btn-desc {
    font-size: 12px;
    color: var(--color-text-sub);
    margin-top: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 183, 197, 0.35) 100%);
    border: 1px solid rgba(255, 183, 197, 0.5);
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(174, 198, 207, 0.35) 100%);
    border: 1px solid rgba(174, 198, 207, 0.5);
}

.btn-info {
    justify-content: center;
    padding: 14px 24px;
}

.btn-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--color-white-glass-border);
    background: var(--color-white-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 58, 64, 0.08);
    transition: all 0.2s;
}

.btn-circle:active {
    transform: scale(0.9);
}

.lobby-footer {
    font-size: 11px;
    color: var(--color-text-sub);
    opacity: 0.6;
    letter-spacing: 1px;
}

/* ==========================================================================
   Game Screen UI Header
   ========================================================================== */
#game-screen {
    padding: 0;
}

#game-ui-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 16px 20px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 16px rgba(74, 58, 64, 0.05);
}

.ui-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 8px;
}

.badge {
    background: var(--color-white-glass);
    border: 1px solid var(--color-white-glass-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 800;
    color: var(--color-pink-dark);
    box-shadow: 0 2px 8px rgba(255, 183, 197, 0.15);
}

.ui-score-container {
    background: rgba(74, 58, 64, 0.8);
    padding: 6px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ui-label {
    font-family: 'Outfit', sans-serif;
    font-size: 10px;
    font-weight: 800;
    color: var(--color-pink-primary);
    letter-spacing: 1px;
}

#ui-score-val {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

/* Progress / Timer Bar */
.progress-bar-container {
    width: 100%;
    height: 20px;
    background: var(--color-white-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--color-white-glass-border);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(74, 58, 64, 0.05);
}

#progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--color-pink-primary) 0%, var(--color-pink-dark) 100%);
    border-radius: 10px;
    transition: width 0.3s ease-out;
}

#progress-text {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--color-text-main);
}

/* ==========================================================================
   Canvas Area
   ========================================================================== */
#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none; /* 모바일 드래그 시 브라우저 스크롤 스와이프 방지 */
}

/* Fever Overlay Effect */
#fever-overlay {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px var(--color-pink-primary), 0 0 20px var(--color-pink-dark);
    z-index: 40;
    pointer-events: none;
    animation: feverGlow 1s ease-in-out infinite alternate;
}

@keyframes feverGlow {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Modal System (Glassmorphism popup)
   ========================================================================== */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(74, 58, 64, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 28px;
    width: 100%;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(74, 58, 64, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.6);
    overflow: hidden;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(74, 58, 64, 0.08);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 800;
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--color-text-sub);
    cursor: pointer;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

/* Encyclopedia Progress bar */
.encyclopedia-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 600;
}

.encyclopedia-bar {
    flex: 1;
    height: 10px;
    background: #EAE3E5;
    border-radius: 5px;
    overflow: hidden;
}

#encyclopedia-bar-fill {
    height: 100%;
    background: var(--color-pink-primary);
    border-radius: 5px;
}

/* Encyclopedia Cards Grid */
.encyclopedia-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.encyclopedia-card {
    background: #FFF;
    border: 1px solid rgba(74, 58, 64, 0.08);
    border-radius: 16px;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(74, 58, 64, 0.03);
}

.encyclopedia-card:active {
    transform: scale(0.95);
}

.encyclopedia-card.locked {
    background: #F0EBEC;
    cursor: default;
}

.card-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.encyclopedia-card.locked .card-icon {
    filter: grayscale(1) opacity(0.4);
}

.card-title {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    color: var(--color-text-main);
}

.encyclopedia-card.locked .card-title {
    color: var(--color-text-sub);
    opacity: 0.6;
}

/* ==========================================================================
   Detail Info Dialog (Micro Pop-up)
   ========================================================================== */
.detail-content {
    max-width: 320px;
    border-radius: 28px;
    overflow: hidden;
}

.detail-header-color {
    height: 8px;
    width: 100%;
}

.detail-body {
    padding: 32px 24px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.detail-icon-wrapper {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #FDF7F8;
    box-shadow: 0 6px 20px rgba(255, 183, 197, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    margin-bottom: 16px;
}

#detail-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--color-text-main);
    margin-bottom: 8px;
}

.detail-badge {
    background: #FFF;
    border: 1px solid rgba(74, 58, 64, 0.1);
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-sub);
    margin-bottom: 16px;
}

.detail-desc {
    font-size: 13px;
    line-height: 1.6;
    color: var(--color-text-sub);
}

.detail-footer {
    padding: 0 24px 24px 24px;
    width: 100%;
}

.btn-close-modal {
    width: 100%;
    justify-content: center;
    background: var(--color-pink-primary) !important;
    color: #fff !important;
    font-weight: 800;
    border: none !important;
    box-shadow: 0 6px 20px rgba(255, 183, 197, 0.4) !important;
}

.btn-close-modal:active {
    background: var(--color-pink-dark) !important;
}

/* 하트 부족 등으로 인한 비활성화 상태 */
.btn-close-modal:disabled, .btn-primary:disabled {
    background: #CCC !important;
    color: #888 !important;
    box-shadow: none !important;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==========================================================================
   Space Items Buttons UI (하단에 띄우기)
   ========================================================================== */
#game-items-container {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 60;
}

.btn-item {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 1px solid var(--color-white-glass-border);
    background: var(--color-white-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-item:active {
    transform: scale(0.9);
}

.btn-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.item-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.item-label {
    font-size: 9px;
    font-weight: 800;
    color: var(--color-text-main);
}

/* 결과 화면 네온 골드 텍스트 애니메이션 */
.neon-gold-text {
    animation: goldPulse 2s infinite alternate;
    display: inline-block;
}

@keyframes goldPulse {
    0% {
        text-shadow: 0 0 6px rgba(255, 215, 0, 0.5), 0 0 15px rgba(255, 215, 0, 0.2);
        transform: scale(0.98);
    }
    100% {
        text-shadow: 0 0 16px rgba(255, 215, 0, 0.9), 0 0 30px rgba(255, 215, 0, 0.5);
        transform: scale(1.02);
    }
}

/* Shuffle Overlay Effect */
#shuffle-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-family);
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    background: rgba(74, 58, 64, 0.88);
    padding: 14px 28px;
    border-radius: 20px;
    border: 1px solid rgba(255, 183, 197, 0.35);
    text-shadow: 0 0 10px var(--color-pink-primary);
    z-index: 45;
    pointer-events: none;
    box-shadow: var(--shadow-soft);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Toast Overlay Style */
#toast-overlay {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    background: rgba(74, 58, 64, 0.92);
    padding: 10px 22px;
    border-radius: 12px;
    border: 1px solid rgba(255, 183, 197, 0.35);
    z-index: 99;
    pointer-events: none;
    box-shadow: var(--shadow-soft);
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.2);
}
